mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 15:40:45 +01:00
Core/SmartScripts: Improve SMART_EVENT_DISTANCE_CREATURE so it can be used with SMART_TARGET_ACTION_INVOKER
Closes #16752
(cherry picked from commit a05a871d7c)
This commit is contained in:
@@ -3271,29 +3271,28 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
if (!me)
|
||||
return;
|
||||
|
||||
WorldObject* creature = NULL;
|
||||
Creature* creature = nullptr;
|
||||
|
||||
if (e.event.distance.guid != 0)
|
||||
{
|
||||
creature = FindCreatureNear(me, e.event.distance.guid);
|
||||
|
||||
if (!creature)
|
||||
return;
|
||||
|
||||
if (!me->IsInRange(creature, 0, (float)e.event.distance.dist))
|
||||
if (!me->IsInRange(creature, 0, static_cast<float>(e.event.distance.dist)))
|
||||
return;
|
||||
}
|
||||
else if (e.event.distance.entry != 0)
|
||||
{
|
||||
std::list<Creature*> list;
|
||||
me->GetCreatureListWithEntryInGrid(list, e.event.distance.entry, (float)e.event.distance.dist);
|
||||
me->GetCreatureListWithEntryInGrid(list, e.event.distance.entry, static_cast<float>(e.event.distance.dist));
|
||||
|
||||
if (!list.empty())
|
||||
creature = list.front();
|
||||
}
|
||||
|
||||
if (creature)
|
||||
ProcessTimedAction(e, e.event.distance.repeat, e.event.distance.repeat);
|
||||
ProcessTimedAction(e, e.event.distance.repeat, e.event.distance.repeat, creature);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -3302,29 +3301,28 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
if (!me)
|
||||
return;
|
||||
|
||||
WorldObject* gameobject = NULL;
|
||||
GameObject* gameobject = nullptr;
|
||||
|
||||
if (e.event.distance.guid != 0)
|
||||
{
|
||||
gameobject = FindGameObjectNear(me, e.event.distance.guid);
|
||||
|
||||
if (!gameobject)
|
||||
return;
|
||||
|
||||
if (!me->IsInRange(gameobject, 0, (float)e.event.distance.dist))
|
||||
if (!me->IsInRange(gameobject, 0, static_cast<float>(e.event.distance.dist)))
|
||||
return;
|
||||
}
|
||||
else if (e.event.distance.entry != 0)
|
||||
{
|
||||
std::list<GameObject*> list;
|
||||
me->GetGameObjectListWithEntryInGrid(list, e.event.distance.entry, (float)e.event.distance.dist);
|
||||
me->GetGameObjectListWithEntryInGrid(list, e.event.distance.entry, static_cast<float>(e.event.distance.dist));
|
||||
|
||||
if (!list.empty())
|
||||
gameobject = list.front();
|
||||
}
|
||||
|
||||
if (gameobject)
|
||||
ProcessTimedAction(e, e.event.distance.repeat, e.event.distance.repeat);
|
||||
ProcessTimedAction(e, e.event.distance.repeat, e.event.distance.repeat, nullptr, 0, 0, false, nullptr, gameobject);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user