Lua GetNextTarget

From ArcEmu-Wiki
Jump to: navigation, search

 :GetNextTarget()

Description

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.

Usage

function GetTargetForSpell(Unit)
    local target = Unit:GetRandomPlayer(0)
    Unit:SetNextTarget(target)
    Unit:RegisterEvent("CastNextSpell", 3000, 0)
end
 
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.]]
end
Personal tools