diff options
| author | Treeston <treeston.mmoc@gmail.com> | 2018-02-13 18:42:28 +0100 | 
|---|---|---|
| committer | Treeston <treeston.mmoc@gmail.com> | 2018-02-13 18:42:28 +0100 | 
| commit | 2cd5992f37fe386786ddd906cd4dd691125ad2b6 (patch) | |
| tree | b35dcfcd534e58dacb4f97fc16386d8eb25cb5a7 /src/server/game/AI/SmartScripts | |
| parent | 6fb0bc10387b73836cea9a3c0eaaafcf58794b7d (diff) | |
oops, now it builds (and a bonus refactor that annoyed me)
Diffstat (limited to 'src/server/game/AI/SmartScripts')
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartAI.cpp | 28 | ||||
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartAI.h | 7 | ||||
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 20 | ||||
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.h | 3 | 
4 files changed, 24 insertions, 34 deletions
| diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 82915d61e85..5797e761b0e 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -513,17 +513,19 @@ bool SmartAI::AssistPlayerInCombatAgainst(Unit* who)  void SmartAI::InitializeAI()  { +    GetScript()->OnInitialize(me); +      mDespawnTime = 0;      mDespawnState = 0;      _escortState = SMART_ESCORT_NONE;      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; @@ -656,14 +658,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 @@ -834,9 +828,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) @@ -1039,9 +1033,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) diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index aabf33111d4..25fc1981f2d 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -73,12 +73,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; @@ -265,7 +262,7 @@ class TC_GAME_API SmartGameObjectAI : public GameObjectAI          void QuestReward(Player* player, Quest const* quest, 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; diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index d3b47e89600..6de2dea4d71 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1593,12 +1593,12 @@ 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());                  }              }              break; @@ -1680,12 +1680,12 @@ 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());                  }              }              break; @@ -1704,12 +1704,12 @@ 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());                  }              }              break; @@ -3366,10 +3366,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) -                        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)                      { @@ -3675,7 +3675,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 3c9cb468f2d..ae79239fc99 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -84,8 +84,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; | 
