diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index 1b8b472b80..3a4bd913e3 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -66,7 +66,7 @@ void npc_escortAI::AttackStart(Unit* who) } //see followerAI -bool npc_escortAI::AssistPlayerInCombat(Unit* who) +bool npc_escortAI::AssistPlayerInCombatAgainst(Unit* who) { if (!who || !who->GetVictim()) return false; @@ -107,7 +107,7 @@ void npc_escortAI::MoveInLineOfSight(Unit* who) { if (me->HasReactState(REACT_AGGRESSIVE) && !me->HasUnitState(UNIT_STATE_STUNNED) && who->isTargetableForAttack() && who->isInAccessiblePlaceFor(me)) { - if (HasEscortState(STATE_ESCORT_ESCORTING) && AssistPlayerInCombat(who)) + if (HasEscortState(STATE_ESCORT_ESCORTING) && AssistPlayerInCombatAgainst(who)) return; if (!me->CanFly() && me->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h index 673f3e671a..2b5f8c909d 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h @@ -109,7 +109,7 @@ struct npc_escortAI : public ScriptedAI Player* GetPlayerForEscort() { return ObjectAccessor::GetPlayer(*me, m_uiPlayerGUID); } private: - bool AssistPlayerInCombat(Unit* who); + bool AssistPlayerInCombatAgainst(Unit* who); bool IsPlayerOrGroupInRange(); void FillPointMovementListForCreature(); diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp index bd07e688fb..24de7344f9 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp @@ -63,7 +63,7 @@ void FollowerAI::AttackStart(Unit* who) //This part provides assistance to a player that are attacked by who, even if out of normal aggro range //It will cause me to attack who that are attacking _any_ player (which has been confirmed may happen also on offi) //The flag (type_flag) is unconfirmed, but used here for further research and is a good candidate. -bool FollowerAI::AssistPlayerInCombat(Unit* who) +bool FollowerAI::AssistPlayerInCombatAgainst(Unit* who) { if (!who || !who->GetVictim()) return false; @@ -104,7 +104,7 @@ void FollowerAI::MoveInLineOfSight(Unit* who) { if (me->HasReactState(REACT_AGGRESSIVE) && !me->HasUnitState(UNIT_STATE_STUNNED) && who->isTargetableForAttack() && who->isInAccessiblePlaceFor(me)) { - if (HasFollowState(STATE_FOLLOW_INPROGRESS) && AssistPlayerInCombat(who)) + if (HasFollowState(STATE_FOLLOW_INPROGRESS) && AssistPlayerInCombatAgainst(who)) return; if (!me->CanFly() && me->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h index d1c976b45c..6d7aada205 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h @@ -69,7 +69,7 @@ class FollowerAI : public ScriptedAI void AddFollowState(uint32 uiFollowState) { m_uiFollowState |= uiFollowState; } void RemoveFollowState(uint32 uiFollowState) { m_uiFollowState &= ~uiFollowState; } - bool AssistPlayerInCombat(Unit* who); + bool AssistPlayerInCombatAgainst(Unit* who); ObjectGuid m_uiLeaderGUID; uint32 m_uiUpdateFollowTimer; diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index e21f59fe58..4a577f5a53 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -30,12 +30,12 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c) { // copy script to local (protection for table reload) - mWayPoints = NULL; + mWayPoints = nullptr; mEscortState = SMART_ESCORT_NONE; mCurrentWPID = 0;//first wp id is 1 !! mWPReached = false; mWPPauseTimer = 0; - mLastWP = NULL; + mLastWP = nullptr; mCanRepeatPath = false; @@ -90,7 +90,7 @@ void SmartAI::UpdateDespawn(const uint32 diff) WayPoint* SmartAI::GetNextWayPoint() { if (!mWayPoints || mWayPoints->empty()) - return NULL; + return nullptr; mCurrentWPID++; WPPath::const_iterator itr = mWayPoints->find(mCurrentWPID); @@ -103,7 +103,7 @@ WayPoint* SmartAI::GetNextWayPoint() } return (*itr).second; } - return NULL; + return nullptr; } void SmartAI::StartPath(bool run, uint32 path, bool repeat, Unit* /*invoker*/) @@ -130,7 +130,7 @@ void SmartAI::StartPath(bool run, uint32 path, bool repeat, Unit* /*invoker*/) { mLastOOCPos = me->GetPosition(); me->GetMotionMaster()->MovePoint(wp->id, wp->x, wp->y, wp->z); - GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_START, NULL, wp->id, GetScript()->GetPathId()); + GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_START, nullptr, wp->id, GetScript()->GetPathId()); } } @@ -167,7 +167,7 @@ void SmartAI::PausePath(uint32 delay, bool forced) me->StopMoving();//force stop me->GetMotionMaster()->MoveIdle();//force stop } - GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_PAUSED, NULL, mLastWP->id, GetScript()->GetPathId()); + GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_PAUSED, nullptr, mLastWP->id, GetScript()->GetPathId()); } void SmartAI::StopPath(uint32 DespawnTime, uint32 quest, bool fail) @@ -183,19 +183,19 @@ void SmartAI::StopPath(uint32 DespawnTime, uint32 quest, bool fail) mLastOOCPos = me->GetPosition(); me->StopMoving();//force stop me->GetMotionMaster()->MoveIdle(); - GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_STOPPED, NULL, mLastWP->id, GetScript()->GetPathId()); + GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_STOPPED, nullptr, mLastWP->id, GetScript()->GetPathId()); EndPath(fail); } void SmartAI::EndPath(bool fail) { - GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_ENDED, NULL, mLastWP->id, GetScript()->GetPathId()); + GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_ENDED, nullptr, mLastWP->id, GetScript()->GetPathId()); RemoveEscortState(SMART_ESCORT_ESCORTING | SMART_ESCORT_PAUSED | SMART_ESCORT_RETURNING); - mWayPoints = NULL; + mWayPoints = nullptr; mCurrentWPID = 0; mWPPauseTimer = 0; - mLastWP = NULL; + mLastWP = nullptr; if (mCanRepeatPath) StartPath(mRun, GetScript()->GetPathId(), true); @@ -216,7 +216,7 @@ void SmartAI::EndPath(bool fail) if (Group* group = player->GetGroup()) { - for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next()) + for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next()) { Player* groupGuy = groupRef->GetSource(); @@ -226,7 +226,8 @@ void SmartAI::EndPath(bool fail) groupGuy->FailQuest(mEscortQuestID); } } - }else + } + else { for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); ++iter) { @@ -278,7 +279,7 @@ void SmartAI::UpdatePath(const uint32 diff) { if (!me->IsInCombat() && !HasEscortState(SMART_ESCORT_RETURNING) && (mWPReached || mLastWPIDReached == SMART_ESCORT_LAST_OOC_POINT || mForcedPaused)) { - GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_RESUMED, NULL, mLastWP->id, GetScript()->GetPathId()); + GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_RESUMED, nullptr, mLastWP->id, GetScript()->GetPathId()); RemoveEscortState(SMART_ESCORT_PAUSED); if (mForcedPaused)// if paused between 2 wps resend movement { @@ -365,7 +366,7 @@ bool SmartAI::IsEscortInvokerInRange() if (Group* group = player->GetGroup()) { - for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next()) + for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next()) { Player* groupGuy = groupRef->GetSource(); @@ -373,7 +374,8 @@ bool SmartAI::IsEscortInvokerInRange() return true; } } - }else + } + else { for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); ++iter) { @@ -391,7 +393,7 @@ bool SmartAI::IsEscortInvokerInRange() void SmartAI::MovepointReached(uint32 id) { if (id != SMART_ESCORT_LAST_OOC_POINT && mLastWPIDReached != id) - GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_REACHED, NULL, id); + GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_REACHED, nullptr, id); mLastWPIDReached = id; mWPReached = true; @@ -402,7 +404,7 @@ void SmartAI::MovementInform(uint32 MovementType, uint32 Data) if ((MovementType == POINT_MOTION_TYPE && Data == SMART_ESCORT_LAST_OOC_POINT) || MovementType == FOLLOW_MOTION_TYPE) me->ClearUnitState(UNIT_STATE_EVADE); - GetScript()->ProcessEventsFor(SMART_EVENT_MOVEMENTINFORM, NULL, MovementType, Data); + GetScript()->ProcessEventsFor(SMART_EVENT_MOVEMENTINFORM, nullptr, MovementType, Data); if (MovementType != POINT_MOTION_TYPE || !HasEscortState(SMART_ESCORT_ESCORTING)) return; MovepointReached(Data); @@ -448,7 +450,7 @@ void SmartAI::MoveInLineOfSight(Unit* who) GetScript()->OnMoveInLineOfSight(who); - if (AssistPlayerInCombat(who)) + if (AssistPlayerInCombatAgainst(who)) return; CreatureAI::MoveInLineOfSight(who); @@ -459,7 +461,7 @@ bool SmartAI::CanAIAttack(const Unit* /*who*/) const return !(me->HasReactState(REACT_PASSIVE)); } -bool SmartAI::AssistPlayerInCombat(Unit* who) +bool SmartAI::AssistPlayerInCombatAgainst(Unit* who) { if (me->HasReactState(REACT_PASSIVE)) return false; @@ -627,7 +629,7 @@ void SmartAI::UpdateAIWhileCharmed(const uint32 /*diff*/) { } void SmartAI::CorpseRemoved(uint32& respawnDelay) { - GetScript()->ProcessEventsFor(SMART_EVENT_CORPSE_REMOVED, NULL, respawnDelay); + GetScript()->ProcessEventsFor(SMART_EVENT_CORPSE_REMOVED, nullptr, respawnDelay); } void SmartAI::PassengerBoarded(Unit* who, int8 seatId, bool apply) @@ -646,7 +648,7 @@ void SmartAI::InitializeAI() void SmartAI::OnCharmed(bool apply) { - GetScript()->ProcessEventsFor(SMART_EVENT_CHARMED, NULL, 0, 0, apply); + GetScript()->ProcessEventsFor(SMART_EVENT_CHARMED, nullptr, 0, 0, apply); if (!apply && !me->IsInEvadeMode()) if (Unit* charmer = me->GetCharmer()) @@ -655,7 +657,7 @@ void SmartAI::OnCharmed(bool apply) void SmartAI::DoAction(int32 param) { - GetScript()->ProcessEventsFor(SMART_EVENT_ACTION_DONE, NULL, param); + GetScript()->ProcessEventsFor(SMART_EVENT_ACTION_DONE, nullptr, param); } uint32 SmartAI::GetData(uint32 /*id*/) const @@ -665,7 +667,7 @@ uint32 SmartAI::GetData(uint32 /*id*/) const void SmartAI::SetData(uint32 id, uint32 value) { - GetScript()->ProcessEventsFor(SMART_EVENT_DATA_SET, NULL, id, value); + GetScript()->ProcessEventsFor(SMART_EVENT_DATA_SET, nullptr, id, value); } void SmartAI::SetGUID(ObjectGuid /*guid*/, int32 /*id*/) { } @@ -799,7 +801,7 @@ void SmartAI::SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker) void SmartAI::sOnGameEvent(bool start, uint16 eventId) { - GetScript()->ProcessEventsFor(start ? SMART_EVENT_GAME_EVENT_START : SMART_EVENT_GAME_EVENT_END, NULL, eventId); + GetScript()->ProcessEventsFor(start ? SMART_EVENT_GAME_EVENT_START : SMART_EVENT_GAME_EVENT_END, nullptr, eventId); } void SmartAI::OnSpellClick(Unit* clicker, bool& result) @@ -838,14 +840,14 @@ void SmartGameObjectAI::Reset() bool SmartGameObjectAI::GossipHello(Player* player) { TC_LOG_DEBUG("scripts.ai", "SmartGameObjectAI::GossipHello"); - GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_HELLO, player, 0, 0, false, NULL, go); + GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_HELLO, player, 0, 0, false, nullptr, go); return false; } // Called when a player selects a gossip item in the gameobject's gossip menu. bool SmartGameObjectAI::GossipSelect(Player* player, uint32 sender, uint32 action) { - GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_SELECT, player, sender, action, false, NULL, go); + GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_SELECT, player, sender, action, false, nullptr, go); return false; } @@ -858,26 +860,26 @@ bool SmartGameObjectAI::GossipSelectCode(Player* /*player*/, uint32 /*sender*/, // Called when a player accepts a quest from the gameobject. bool SmartGameObjectAI::QuestAccept(Player* player, Quest const* quest) { - GetScript()->ProcessEventsFor(SMART_EVENT_ACCEPTED_QUEST, player, quest->GetQuestId(), 0, false, NULL, go); + GetScript()->ProcessEventsFor(SMART_EVENT_ACCEPTED_QUEST, player, quest->GetQuestId(), 0, false, nullptr, go); return false; } // Called when a player selects a quest reward. bool SmartGameObjectAI::QuestReward(Player* player, Quest const* quest, uint32 opt) { - GetScript()->ProcessEventsFor(SMART_EVENT_REWARD_QUEST, player, quest->GetQuestId(), opt, false, NULL, go); + GetScript()->ProcessEventsFor(SMART_EVENT_REWARD_QUEST, player, quest->GetQuestId(), opt, false, nullptr, go); return false; } // Called when the gameobject is destroyed (destructible buildings only). void SmartGameObjectAI::Destroyed(Player* player, uint32 eventId) { - GetScript()->ProcessEventsFor(SMART_EVENT_DEATH, player, eventId, 0, false, NULL, go); + GetScript()->ProcessEventsFor(SMART_EVENT_DEATH, player, eventId, 0, false, nullptr, go); } void SmartGameObjectAI::SetData(uint32 id, uint32 value) { - GetScript()->ProcessEventsFor(SMART_EVENT_DATA_SET, NULL, id, value); + GetScript()->ProcessEventsFor(SMART_EVENT_DATA_SET, nullptr, id, value); } void SmartGameObjectAI::SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker) @@ -889,7 +891,7 @@ void SmartGameObjectAI::SetScript9(SmartScriptHolder& e, uint32 entry, Unit* inv void SmartGameObjectAI::OnGameEvent(bool start, uint16 eventId) { - GetScript()->ProcessEventsFor(start ? SMART_EVENT_GAME_EVENT_START : SMART_EVENT_GAME_EVENT_END, NULL, eventId); + GetScript()->ProcessEventsFor(start ? SMART_EVENT_GAME_EVENT_START : SMART_EVENT_GAME_EVENT_END, nullptr, eventId); } void SmartGameObjectAI::OnStateChanged(uint32 state, Unit* unit) @@ -899,7 +901,7 @@ void SmartGameObjectAI::OnStateChanged(uint32 state, Unit* unit) void SmartGameObjectAI::EventInform(uint32 eventId) { - GetScript()->ProcessEventsFor(SMART_EVENT_GO_EVENT_INFORM, NULL, eventId); + GetScript()->ProcessEventsFor(SMART_EVENT_GO_EVENT_INFORM, nullptr, eventId); } class SmartTrigger : public AreaTriggerScript @@ -915,7 +917,7 @@ class SmartTrigger : public AreaTriggerScript TC_LOG_DEBUG("scripts.ai", "AreaTrigger %u is using SmartTrigger script", trigger->id); SmartScript script; - script.OnInitialize(NULL, trigger); + script.OnInitialize(nullptr, trigger); script.ProcessEventsFor(SMART_EVENT_AREATRIGGER_ONTRIGGER, player, trigger->id); return true; } diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index 02c057247f..ee8330e64b 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -49,7 +49,7 @@ class SmartAI : public CreatureAI explicit SmartAI(Creature* c); // Start moving to the desired MovePoint - void StartPath(bool run = false, uint32 path = 0, bool repeat = false, Unit* invoker = NULL); + void StartPath(bool run = false, uint32 path = 0, bool repeat = false, Unit* invoker = nullptr); bool LoadPath(uint32 entry); void PausePath(uint32 delay, bool forced = false); void StopPath(uint32 DespawnTime = 0, uint32 quest = 0, bool fail = false); @@ -75,7 +75,7 @@ class SmartAI : public CreatureAI // Called at reaching home after evade, InitializeAI(), EnterEvadeMode() for resetting variables void JustReachedHome() override; - // Called for reaction at enter to combat if not in combat yet (enemy can be NULL) + // Called for reaction at enter to combat if not in combat yet (enemy can be nullptr) void EnterCombat(Unit* enemy) override; // Called for reaction at stopping attack at no attackers or targets @@ -221,7 +221,7 @@ class SmartAI : public CreatureAI bool mCanCombatMove; bool mForcedPaused; uint32 mInvincibilityHpLevel; - bool AssistPlayerInCombat(Unit* who); + bool AssistPlayerInCombatAgainst(Unit* who); uint32 mDespawnTime; uint32 mDespawnState; diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 394fd9614b..0a27186d9c 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -3613,36 +3613,6 @@ void SmartScript::OnMoveInLineOfSight(Unit* who) ProcessEventsFor(me->IsInCombat() ? SMART_EVENT_IC_LOS : SMART_EVENT_OOC_LOS, who); } - -/* -void SmartScript::UpdateAIWhileCharmed(const uint32 diff) { } - -void SmartScript::DoAction(const int32 param) { } - -uint32 SmartScript::GetData(uint32 id) -{ - return 0; -} - -void SmartScript::SetData(uint32 id, uint32 value) { } - -void SmartScript::SetGUID(uint64 guid, int32 id) { } - -uint64 SmartScript::GetGUID(int32 id) -{ - return 0; -} - -void SmartScript::MovepointStart(uint32 id) { } - -void SmartScript::SetRun(bool run) { } - -void SmartScript::SetMovePathEndAction(SMART_ACTION action) { } - -uint32 SmartScript::DoChat(int8 id, uint64 whisperGuid) -{ - return 0; -}*/ // SmartScript end Unit* SmartScript::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h index 4cbf439e48..0d51238963 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -142,7 +142,7 @@ class SmartScript ObjectListMap::iterator itr = mTargetStorage->find(id); if (itr != mTargetStorage->end()) return (*itr).second->GetObjectList(); - return NULL; + return nullptr; } void StoreCounter(uint32 id, uint32 value, uint32 reset)