Core/SmartAI: fixed EVENT_RANGE handling, and limited it to only creature scripts

--HG--
branch : trunk
This commit is contained in:
Rat
2010-11-03 17:25:46 +01:00
parent 58bc1194d2
commit 4747c5f820
2 changed files with 7 additions and 13 deletions
@@ -1477,19 +1477,13 @@ void SmartScript::ProcessEvent(SmartScriptHolder &e, Unit* unit, uint32 var0, ui
}
case SMART_EVENT_RANGE:
{
if (!GetBaseObject()) return;
ObjectList* targets = GetTargets(e, unit);
if (!targets) return;
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); itr++)
if (!me || !me->isInCombat() || !me->getVictim())
return;
if (me->IsInRange(me->getVictim(),(float)e.event.minMaxRepeat.min,(float)e.event.minMaxRepeat.max))
{
if (!IsUnit((*itr)))
continue;
if (GetBaseObject()->IsInMap((*itr)))
if (GetBaseObject()->IsInRange((*itr),(float)e.event.minMaxRepeat.min,(float)e.event.minMaxRepeat.max))
{
ProcessAction(e, (*itr)->ToUnit());
RecalcTimer(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
}
ProcessAction(e, me->getVictim());
RecalcTimer(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
}
break;
}