Byrth / Lua-Byrth

Lua Addons and Scripts
3 stars 2 forks source link

GearSwap - Trust NPC Targetting Error #378

Closed lorand-ffxi closed 8 years ago

lorand-ffxi commented 9 years ago

When trying to cast a spell on a Trust NPC by name rather than with the it as the current target, sometimes GearSwap would prevent the spell from being cast. The issue is persistent on a given Trust NPC once it starts. It appears as though the wrong instance of the Trust NPC would be picked up as the spell target.

Command used for testing: /ma "Cure IV" Tenzen With GearSwap unloaded, I was able to successfully cast magic on Trust NPCs. I was able to duplicate the result of having a spell be prevented from casting while using a completely fresh Character_JOB.lua file with nothing in it.

Code that I added to that file that fixes the problem:

function init()
    trusts = S{}
    for _,spell in pairs(gearswap.res.spells) do
        if (spell.type == 'Trust') then
            trusts:add(spell.en)
        end
    end
end

init()

function pretarget(spell)
    if trusts:contains(spell.target.name) then
        local pt_targ = get_party_member(spell.target.name)
        if (pt_targ ~= nil) then
            change_target(tostring(pt_targ.mob.id))
        end
    end
end

function get_party_member(name)
    for _,member in pairs(windower.ffxi.get_party()) do
        if (type(member)=='table') and (member.name == name) then
            return member
        end
    end
    return nil
end
Byrth commented 8 years ago

I still have no idea what could have caused this and can't replicate it. Going to try again tomorrow when I can log back in.

Byrth commented 8 years ago

Going to close this for now. I can't make it happen.