All pastes #366929 Raw Edit

Something

public text v1 · immutable
#366929 ·published 2007-02-22 00:20 UTC
rendered paste body
function CheckAggro()
{
declare Index int local 1
declare NearestGUID string local "NOTARGET"
declare NearestDistance float local 100
declare AggroList guidlist local

; We have aggroed something so lets check what it is
AggroList:Search[-units,-aggro,-alive,-nearest,-range 0-40]

; make sure we have got some units nearby (we should!)
debug("CheckAggro:Possible Aggros:${AggroList.Count}")

;If we found some Aggro units
if ${AggroList.Count}>0
{
; The closest aggro mob might not be your so we will search them all checking if they
; have you or your pet targeted
do
{
debug("CheckAggro:Checking aggro on ${Unit[${AggroList.GUID[${Index}]}].Name} ${AggroList.GUID[${Index}]}")
if (${Unit[${AggroList.GUID[${Index}]}].Target.GUID.Equal[${Me.GUID}]}||${Unit[${AggroList.GUID[${Index}]}].Target.GUID.Equal[${Me.Pet.GUID}]})&&!${Unit[${AggroList.GUID[${Index}]}].Mine}
{
TargetGUID:Set[${AggroList.GUID[${Index}]}]
call UpdateHudStatus "${Object[${TargetGUID}].Name} Aggrod"
return
}
}
while ${Index:Inc}<=${AggroList.Count}
}
else 
{
;Just in case we have got aggro but the search isnt picking it up lets check if we have a target
; and its targeting us.
debug("CheckAggro:${Unit[${Target.GUID}].AttackingUnit.GUID.Equal[${Me.GUID}]}")
if ${Unit[${Target.GUID}](exists)}&&${Unit[${Target.GUID}].AttackingUnit.GUID.Equal[${Me.GUID}]}
{
TargetGUID:Set[${Target.GUID}]
call UpdateHudStatus "${Object[${TargetGUID}].Name} has us targeted so ill go with it"
return
}
else
{
debug("False Aggro delaying checks")
FalseAggro:Set[TRUE]
FalseAggroTimer:Set[${Script.RunningTime}+3000]
}
}


}