mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 11:43:18 -04:00
Scripts/SmartAI: Forward invoker to invoked action list actions. Also JustAppeared -> InitializeAI.
(cherry picked from commit 6fb0bc1038)
This commit is contained in:
@@ -212,7 +212,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (!roll_chance_i(e.event.event_chance))
|
||||
return;
|
||||
}
|
||||
e.runOnce = true;//used for repeat check
|
||||
e.runOnce = true; //used for repeat check
|
||||
|
||||
if (unit)
|
||||
mLastInvoker = unit->GetGUID();
|
||||
@@ -3556,9 +3556,12 @@ void SmartScript::UpdateTimer(SmartScriptHolder& e, uint32 const diff)
|
||||
case SMART_EVENT_DISTANCE_CREATURE:
|
||||
case SMART_EVENT_DISTANCE_GAMEOBJECT:
|
||||
{
|
||||
ProcessEvent(e);
|
||||
if (e.GetScriptType() == SMART_SCRIPT_TYPE_TIMED_ACTIONLIST)
|
||||
{
|
||||
Unit* invoker9 = nullptr;
|
||||
if (me && !mTimedActionListInvoker.IsEmpty())
|
||||
invoker9 = ObjectAccessor::GetUnit(*me, mTimedActionListInvoker);
|
||||
ProcessEvent(e, invoker9);
|
||||
e.enableTimed = false;//disable event if it is in an ActionList and was processed once
|
||||
for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
|
||||
{
|
||||
@@ -3570,6 +3573,8 @@ void SmartScript::UpdateTimer(SmartScriptHolder& e, uint32 const diff)
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
ProcessEvent(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3936,7 +3941,7 @@ Unit* SmartScript::DoFindClosestFriendlyInRange(float range, bool playerOnly) co
|
||||
return unit;
|
||||
}
|
||||
|
||||
void SmartScript::SetScript9(SmartScriptHolder& e, uint32 entry)
|
||||
void SmartScript::SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker)
|
||||
{
|
||||
//do NOT clear mTimedActionList if it's being iterated because it will invalidate the iterator and delete
|
||||
// any SmartScriptHolder contained like the "e" parameter passed to this function
|
||||
@@ -3950,6 +3955,7 @@ void SmartScript::SetScript9(SmartScriptHolder& e, uint32 entry)
|
||||
mTimedActionList = sSmartScriptMgr->GetScript(entry, SMART_SCRIPT_TYPE_TIMED_ACTIONLIST);
|
||||
if (mTimedActionList.empty())
|
||||
return;
|
||||
mTimedActionListInvoker = invoker ? invoker->GetGUID() : ObjectGuid::Empty;
|
||||
for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
|
||||
{
|
||||
i->enableTimed = i == mTimedActionList.begin();//enable processing only for the first action
|
||||
|
||||
Reference in New Issue
Block a user