Lua GetNextTarget

From ArcEmu-Wiki
Jump to: navigation, search



It returns the target set by :SetNextTarget(target), where 'target' is a unit. Its usage is similar to setting a target to a variable [:SetNextTarget(target)] , and then retrieving that variable [:GetNextTarget]. The advantage to this is if you wanted to select a target that would persist after the function. How long it would persist is unknown. It might be overwritten every AI Update. More testing is needed.


function GetTargetForSpell(Unit)
    local target = Unit:GetRandomPlayer(0)
    Unit:RegisterEvent("CastNextSpell", 3000, 0)
function CastSpell(Unit)
   Unit:CastSpell(12345, Unit:GetNextTarget()) --[[would use the same target from the GetTargetForSpell function,
                                   as long as that function wasn't run again.]]
Personal tools