aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2018-02-13 18:42:28 +0100
committerShauren <shauren.trinity@gmail.com>2021-06-20 21:42:35 +0200
commitbd158f6c29581e08633c3971a130b0720f90b630 (patch)
tree0c30a6ddc4fce6f38281fb3fb9763f79175a990c
parent1f26122528ad31a9dedbfcf5c1029cf750dfd1d4 (diff)
oops, now it builds (and a bonus refactor that annoyed me)
(cherry picked from commit 2cd5992f37fe386786ddd906cd4dd691125ad2b6)
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp32
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.h9
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp26
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.h3
4 files changed, 30 insertions, 40 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index d0c64c1f9c4..364013eaea3 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -515,6 +515,8 @@ bool SmartAI::AssistPlayerInCombatAgainst(Unit* who)
void SmartAI::InitializeAI()
{
+ GetScript()->OnInitialize(me);
+
mDespawnTime = 0;
mRespawnTime = 0;
mDespawnState = 0;
@@ -522,11 +524,11 @@ void SmartAI::InitializeAI()
me->SetVisible(true);
- if (me->GetFaction() != me->GetCreatureTemplate()->faction)
- me->RestoreFaction();
-
- GetScript()->OnReset();
- GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN);
+ if (!me->isDead())
+ {
+ GetScript()->ProcessEventsFor(SMART_EVENT_RESPAWN);
+ GetScript()->OnReset();
+ }
mFollowGuid.Clear(); // do not reset follower on Reset(), we need it after combat evade
mFollowDist = 0;
@@ -659,14 +661,6 @@ void SmartAI::PassengerBoarded(Unit* who, int8 seatId, bool apply)
GetScript()->ProcessEventsFor(apply ? SMART_EVENT_PASSENGER_BOARDED : SMART_EVENT_PASSENGER_REMOVED, who, uint32(seatId), 0, apply);
}
-void SmartAI::InitializeAI()
-{
- GetScript()->OnInitialize(me);
-
- if (!me->isDead())
- GetScript()->OnReset();
-}
-
void SmartAI::OnCharmed(bool apply)
{
if (apply) // do this before we change charmed state, as charmed state might prevent these things from processing
@@ -837,9 +831,9 @@ void SmartAI::StopFollow(bool complete)
GetScript()->ProcessEventsFor(SMART_EVENT_FOLLOW_COMPLETED, player);
}
-void SmartAI::SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker)
+void SmartAI::SetTimedActionList(SmartScriptHolder& e, uint32 entry, Unit* invoker)
{
- GetScript()->SetScript9(e, entry, invoker);
+ GetScript()->SetTimedActionList(e, entry, invoker);
}
void SmartAI::OnGameEvent(bool start, uint16 eventId)
@@ -1042,9 +1036,9 @@ void SmartGameObjectAI::SetData(uint32 id, uint32 value)
GetScript()->ProcessEventsFor(SMART_EVENT_DATA_SET, nullptr, id, value);
}
-void SmartGameObjectAI::SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker)
+void SmartGameObjectAI::SetTimedActionList(SmartScriptHolder& e, uint32 entry, Unit* invoker)
{
- GetScript()->SetScript9(e, entry, invoker);
+ GetScript()->SetTimedActionList(e, entry, invoker);
}
void SmartGameObjectAI::OnGameEvent(bool start, uint16 eventId)
@@ -1101,9 +1095,9 @@ void SmartAreaTriggerAI::OnUnitEnter(Unit* unit)
GetScript()->ProcessEventsFor(SMART_EVENT_AREATRIGGER_ONTRIGGER, unit);
}
-void SmartAreaTriggerAI::SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker)
+void SmartAreaTriggerAI::SetTimedActionList(SmartScriptHolder& e, uint32 entry, Unit* invoker)
{
- GetScript()->SetScript9(e, entry, invoker);
+ GetScript()->SetTimedActionList(e, entry, invoker);
}
class SmartAreaTriggerEntityScript : public AreaTriggerEntityScript
diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h
index 9a032ad481f..54266d065cd 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.h
+++ b/src/server/game/AI/SmartScripts/SmartAI.h
@@ -74,12 +74,9 @@ class TC_GAME_API SmartAI : public CreatureAI
void WaypointReached(uint32 nodeId, uint32 pathId) override;
void WaypointPathEnded(uint32 nodeId, uint32 pathId) override;
- void SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker);
+ void SetTimedActionList(SmartScriptHolder& e, uint32 entry, Unit* invoker);
SmartScript* GetScript() { return &mScript; }
- // Called when creature is spawned or respawned
- void JustAppeared() override;
-
// Called at reaching home after evade, InitializeAI(), EnterEvadeMode() for resetting variables
void JustReachedHome() override;
@@ -269,7 +266,7 @@ class TC_GAME_API SmartGameObjectAI : public GameObjectAI
void QuestReward(Player* player, Quest const* quest, LootItemType type, uint32 opt) override;
void Destroyed(Player* player, uint32 eventId) override;
void SetData(uint32 id, uint32 value) override;
- void SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker);
+ void SetTimedActionList(SmartScriptHolder& e, uint32 entry, Unit* invoker);
void OnGameEvent(bool start, uint16 eventId) override;
void OnLootStateChanged(uint32 state, Unit* unit) override;
void EventInform(uint32 eventId) override;
@@ -294,7 +291,7 @@ public:
void OnUnitEnter(Unit* unit) override;
SmartScript* GetScript() { return &mScript; }
- void SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker);
+ void SetTimedActionList(SmartScriptHolder& e, uint32 entry, Unit* invoker);
private:
SmartScript mScript;
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 275f4aa4e2e..1dd8649b6f8 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -1623,16 +1623,16 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (Creature* creature = target->ToCreature())
{
if (IsSmart(creature))
- ENSURE_AI(SmartAI, creature->AI())->SetScript9(e, e.action.timedActionList.id, GetLastInvoker());
+ ENSURE_AI(SmartAI, creature->AI())->SetTimedActionList(e, e.action.timedActionList.id, GetLastInvoker());
}
else if (GameObject* goTarget = target->ToGameObject())
{
if (IsSmartGO(goTarget))
- ENSURE_AI(SmartGameObjectAI, goTarget->AI())->SetScript9(e, e.action.timedActionList.id, GetLastInvoker());
+ ENSURE_AI(SmartGameObjectAI, goTarget->AI())->SetTimedActionList(e, e.action.timedActionList.id, GetLastInvoker());
}
else if (AreaTrigger* areaTriggerTarget = target->ToAreaTrigger())
if (SmartAreaTriggerAI* atSAI = CAST_AI(SmartAreaTriggerAI, areaTriggerTarget->AI()))
- atSAI->SetScript9(e, e.action.timedActionList.id, GetLastInvoker());
+ atSAI->SetTimedActionList(e, e.action.timedActionList.id, GetLastInvoker());
}
break;
}
@@ -1713,16 +1713,16 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (Creature* creature = target->ToCreature())
{
if (IsSmart(creature))
- ENSURE_AI(SmartAI, creature->AI())->SetScript9(e, id, GetLastInvoker());
+ ENSURE_AI(SmartAI, creature->AI())->SetTimedActionList(e, id, GetLastInvoker());
}
else if (GameObject* goTarget = target->ToGameObject())
{
if (IsSmartGO(goTarget))
- ENSURE_AI(SmartGameObjectAI, goTarget->AI())->SetScript9(e, id, GetLastInvoker());
+ ENSURE_AI(SmartGameObjectAI, goTarget->AI())->SetTimedActionList(e, id, GetLastInvoker());
}
else if (AreaTrigger* areaTriggerTarget = target->ToAreaTrigger())
if (SmartAreaTriggerAI* atSAI = CAST_AI(SmartAreaTriggerAI, areaTriggerTarget->AI()))
- atSAI->SetScript9(e, id, GetLastInvoker());
+ atSAI->SetTimedActionList(e, id, GetLastInvoker());
}
break;
}
@@ -1740,16 +1740,16 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (Creature* creature = target->ToCreature())
{
if (IsSmart(creature))
- ENSURE_AI(SmartAI, creature->AI())->SetScript9(e, id, GetLastInvoker());
+ ENSURE_AI(SmartAI, creature->AI())->SetTimedActionList(e, id, GetLastInvoker());
}
else if (GameObject* goTarget = target->ToGameObject())
{
if (IsSmartGO(goTarget))
- ENSURE_AI(SmartGameObjectAI, goTarget->AI())->SetScript9(e, id, GetLastInvoker());
+ ENSURE_AI(SmartGameObjectAI, goTarget->AI())->SetTimedActionList(e, id, GetLastInvoker());
}
else if (AreaTrigger* areaTriggerTarget = target->ToAreaTrigger())
if (SmartAreaTriggerAI* atSAI = CAST_AI(SmartAreaTriggerAI, areaTriggerTarget->AI()))
- atSAI->SetScript9(e, id, GetLastInvoker());
+ atSAI->SetTimedActionList(e, id, GetLastInvoker());
}
break;
}
@@ -3558,10 +3558,10 @@ void SmartScript::UpdateTimer(SmartScriptHolder& e, uint32 const diff)
{
if (e.GetScriptType() == SMART_SCRIPT_TYPE_TIMED_ACTIONLIST)
{
- Unit* invoker9 = nullptr;
+ Unit* invoker = nullptr;
if (me && !mTimedActionListInvoker.IsEmpty())
- invoker9 = ObjectAccessor::GetUnit(*me, mTimedActionListInvoker);
- ProcessEvent(e, invoker9);
+ invoker = ObjectAccessor::GetUnit(*me, mTimedActionListInvoker);
+ ProcessEvent(e, invoker);
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)
{
@@ -3941,7 +3941,7 @@ Unit* SmartScript::DoFindClosestFriendlyInRange(float range, bool playerOnly) co
return unit;
}
-void SmartScript::SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker)
+void SmartScript::SetTimedActionList(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
diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h
index b79532f4c14..49c51e1e450 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.h
+++ b/src/server/game/AI/SmartScripts/SmartScript.h
@@ -100,8 +100,7 @@ class TC_GAME_API SmartScript
void OnReset();
void ResetBaseObject();
- //TIMED_ACTIONLIST (script type 9 aka script9)
- void SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker);
+ void SetTimedActionList(SmartScriptHolder& e, uint32 entry, Unit* invoker);
Unit* GetLastInvoker(Unit* invoker = nullptr) const;
ObjectGuid mLastInvoker;
typedef std::unordered_map<uint32, uint32> CounterMap;