mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Scripts/SmartAI: Some clean-up work:
- NULL -> nullptr
- Rename "AssistPlayerInCombat(who)" to "AssistPlayerInCombatAgainst(who)" to reflect what the method actually does
- Code style
No functionality was changed.
(cherry picked from commit 152b3ad5b9)
# Conflicts:
# src/server/game/AI/SmartScripts/SmartAI.cpp
# src/server/game/AI/SmartScripts/SmartScript.cpp
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -109,7 +109,7 @@ struct TC_GAME_API 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();
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -69,7 +69,7 @@ class TC_GAME_API 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;
|
||||
|
||||
@@ -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, bool /*isUse*/)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class TC_GAME_API 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 TC_GAME_API 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 TC_GAME_API SmartAI : public CreatureAI
|
||||
bool mCanCombatMove;
|
||||
bool mForcedPaused;
|
||||
uint32 mInvincibilityHpLevel;
|
||||
bool AssistPlayerInCombat(Unit* who);
|
||||
bool AssistPlayerInCombatAgainst(Unit* who);
|
||||
|
||||
uint32 mDespawnTime;
|
||||
uint32 mDespawnState;
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
|
||||
SmartScript::SmartScript()
|
||||
{
|
||||
go = NULL;
|
||||
me = NULL;
|
||||
trigger = NULL;
|
||||
go = nullptr;
|
||||
me = nullptr;
|
||||
trigger = nullptr;
|
||||
mEventPhase = 0;
|
||||
mPathId = 0;
|
||||
mTargetStorage = new ObjectListMap();
|
||||
@@ -117,8 +117,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
Creature* talker = me;
|
||||
Player* targetPlayer = NULL;
|
||||
Unit* talkTarget = NULL;
|
||||
Player* targetPlayer = nullptr;
|
||||
Unit* talkTarget = nullptr;
|
||||
|
||||
if (targets)
|
||||
{
|
||||
@@ -328,7 +328,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
if (Quest const* q = sObjectMgr->GetQuestTemplate(e.action.quest.quest))
|
||||
{
|
||||
(*itr)->ToPlayer()->AddQuestAndCheckCompletion(q, NULL);
|
||||
(*itr)->ToPlayer()->AddQuestAndCheckCompletion(q, nullptr);
|
||||
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_ADD_QUEST: Player %s add quest %u",
|
||||
(*itr)->GetGUID().ToString().c_str(), e.action.quest.quest);
|
||||
}
|
||||
@@ -1502,7 +1502,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (!IsSmart())
|
||||
break;
|
||||
|
||||
WorldObject* target = NULL;
|
||||
WorldObject* target = nullptr;
|
||||
|
||||
if (e.GetTargetType() == SMART_TARGET_CREATURE_RANGE || e.GetTargetType() == SMART_TARGET_CREATURE_GUID ||
|
||||
e.GetTargetType() == SMART_TARGET_CREATURE_DISTANCE || e.GetTargetType() == SMART_TARGET_GAMEOBJECT_RANGE ||
|
||||
@@ -1636,7 +1636,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_TRIGGER_TIMED_EVENT:
|
||||
ProcessEventsFor((SMART_EVENT)SMART_EVENT_TIMED_EVENT_TRIGGERED, NULL, e.action.timeEvent.id);
|
||||
ProcessEventsFor((SMART_EVENT)SMART_EVENT_TIMED_EVENT_TRIGGERED, nullptr, e.action.timeEvent.id);
|
||||
break;
|
||||
case SMART_ACTION_REMOVE_TIMED_EVENT:
|
||||
mRemIDs.push_back(e.action.timeEvent.id);
|
||||
@@ -1655,7 +1655,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
meOrigGUID = me->GetGUID();
|
||||
if (!goOrigGUID && go)
|
||||
goOrigGUID = go->GetGUID();
|
||||
go = NULL;
|
||||
go = nullptr;
|
||||
me = (*itr)->ToCreature();
|
||||
break;
|
||||
}
|
||||
@@ -1666,7 +1666,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (!goOrigGUID && go)
|
||||
goOrigGUID = go->GetGUID();
|
||||
go = (*itr)->ToGameObject();
|
||||
me = NULL;
|
||||
me = nullptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2300,7 +2300,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
waypoints[4] = e.action.closestWaypointFromList.wp5;
|
||||
waypoints[5] = e.action.closestWaypointFromList.wp6;
|
||||
float distanceToClosest = std::numeric_limits<float>::max();
|
||||
WayPoint* closestWp = NULL;
|
||||
WayPoint* closestWp = nullptr;
|
||||
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (targets)
|
||||
@@ -2520,9 +2520,9 @@ SmartScriptHolder SmartScript::CreateEvent(SMART_EVENT e, uint32 event_flags, ui
|
||||
return script;
|
||||
}
|
||||
|
||||
ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*= NULL*/)
|
||||
ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*= nullptr*/)
|
||||
{
|
||||
Unit* scriptTrigger = NULL;
|
||||
Unit* scriptTrigger = nullptr;
|
||||
if (invoker)
|
||||
scriptTrigger = invoker;
|
||||
else if (Unit* tempLastInvoker = GetLastInvoker())
|
||||
@@ -2577,7 +2577,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*
|
||||
{
|
||||
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())
|
||||
if (Player* member = groupRef->GetSource())
|
||||
l->push_back(member);
|
||||
}
|
||||
@@ -2792,7 +2792,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*
|
||||
if (l->empty())
|
||||
{
|
||||
delete l;
|
||||
l = NULL;
|
||||
l = nullptr;
|
||||
}
|
||||
|
||||
return l;
|
||||
@@ -3204,7 +3204,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
{
|
||||
if (e.event.gameEvent.gameEventId != var0)
|
||||
return;
|
||||
ProcessAction(e, NULL, var0);
|
||||
ProcessAction(e, nullptr, var0);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_GO_STATE_CHANGED:
|
||||
@@ -3218,7 +3218,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
{
|
||||
if (e.event.eventInform.eventId != var0)
|
||||
return;
|
||||
ProcessAction(e, NULL, var0);
|
||||
ProcessAction(e, nullptr, var0);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_ACTION_DONE:
|
||||
@@ -3233,7 +3233,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
if (!me || !me->IsInCombat())
|
||||
return;
|
||||
|
||||
ObjectList* _targets = NULL;
|
||||
ObjectList* _targets = nullptr;
|
||||
|
||||
switch (e.GetTargetType())
|
||||
{
|
||||
@@ -3253,7 +3253,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
if (!_targets)
|
||||
return;
|
||||
|
||||
Unit* target = NULL;
|
||||
Unit* target = nullptr;
|
||||
|
||||
for (ObjectList::const_iterator itr = _targets->begin(); itr != _targets->end(); ++itr)
|
||||
{
|
||||
@@ -3384,7 +3384,7 @@ void SmartScript::UpdateTimer(SmartScriptHolder& e, uint32 const diff)
|
||||
if (e.GetEventType() == SMART_EVENT_UPDATE_IC && (!me || !me->IsInCombat()))
|
||||
return;
|
||||
|
||||
if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->IsInCombat())) //can be used with me=NULL (go script)
|
||||
if (e.GetEventType() == SMART_EVENT_UPDATE_OOC && (me && me->IsInCombat())) //can be used with me=nullptr (go script)
|
||||
return;
|
||||
|
||||
if (e.timer < diff)
|
||||
@@ -3521,7 +3521,7 @@ void SmartScript::OnUpdate(uint32 const diff)
|
||||
mTalkerEntry = 0;
|
||||
mTextTimer = 0;
|
||||
mUseTextTimer = false;
|
||||
ProcessEventsFor(SMART_EVENT_TEXT_OVER, NULL, textID, entry);
|
||||
ProcessEventsFor(SMART_EVENT_TEXT_OVER, nullptr, textID, entry);
|
||||
} else mTextTimer -= diff;
|
||||
}
|
||||
}
|
||||
@@ -3570,19 +3570,19 @@ void SmartScript::GetScript()
|
||||
e = sSmartScriptMgr->GetScript(-((int32)me->GetSpawnId()), mScriptType);
|
||||
if (e.empty())
|
||||
e = sSmartScriptMgr->GetScript((int32)me->GetEntry(), mScriptType);
|
||||
FillScript(e, me, NULL);
|
||||
FillScript(e, me, nullptr);
|
||||
}
|
||||
else if (go)
|
||||
{
|
||||
e = sSmartScriptMgr->GetScript(-((int32)go->GetSpawnId()), mScriptType);
|
||||
if (e.empty())
|
||||
e = sSmartScriptMgr->GetScript((int32)go->GetEntry(), mScriptType);
|
||||
FillScript(e, go, NULL);
|
||||
FillScript(e, go, nullptr);
|
||||
}
|
||||
else if (trigger)
|
||||
{
|
||||
e = sSmartScriptMgr->GetScript((int32)trigger->ID, mScriptType);
|
||||
FillScript(e, NULL, trigger);
|
||||
FillScript(e, nullptr, trigger);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3635,48 +3635,18 @@ 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)
|
||||
{
|
||||
if (!me)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
CellCoord p(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
|
||||
Cell cell(p);
|
||||
cell.SetNoCreate();
|
||||
|
||||
Unit* unit = NULL;
|
||||
Unit* unit = nullptr;
|
||||
|
||||
Trinity::MostHPMissingInRange u_check(me, range, MinHPDiff);
|
||||
Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, unit, u_check);
|
||||
@@ -3724,9 +3694,9 @@ void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& list, float ra
|
||||
Unit* SmartScript::DoFindClosestFriendlyInRange(float range, bool playerOnly)
|
||||
{
|
||||
if (!me)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
Unit* unit = NULL;
|
||||
Unit* unit = nullptr;
|
||||
Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(me, me, range, playerOnly);
|
||||
Trinity::UnitLastSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(me, unit, u_check);
|
||||
me->VisitNearbyObject(range, searcher);
|
||||
|
||||
@@ -34,19 +34,19 @@ class TC_GAME_API SmartScript
|
||||
SmartScript();
|
||||
~SmartScript();
|
||||
|
||||
void OnInitialize(WorldObject* obj, AreaTriggerEntry const* at = NULL);
|
||||
void OnInitialize(WorldObject* obj, AreaTriggerEntry const* at = nullptr);
|
||||
void GetScript();
|
||||
void FillScript(SmartAIEventList e, WorldObject* obj, AreaTriggerEntry const* at);
|
||||
|
||||
void ProcessEventsFor(SMART_EVENT e, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = NULL, GameObject* gob = NULL);
|
||||
void ProcessEvent(SmartScriptHolder& e, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = NULL, GameObject* gob = NULL);
|
||||
void ProcessEventsFor(SMART_EVENT e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr);
|
||||
void ProcessEvent(SmartScriptHolder& e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr);
|
||||
bool CheckTimer(SmartScriptHolder const& e) const;
|
||||
void RecalcTimer(SmartScriptHolder& e, uint32 min, uint32 max);
|
||||
void UpdateTimer(SmartScriptHolder& e, uint32 const diff);
|
||||
void InitTimer(SmartScriptHolder& e);
|
||||
void ProcessAction(SmartScriptHolder& e, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = NULL, GameObject* gob = NULL);
|
||||
void ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = NULL, GameObject* gob = NULL);
|
||||
ObjectList* GetTargets(SmartScriptHolder const& e, Unit* invoker = NULL);
|
||||
void ProcessAction(SmartScriptHolder& e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr);
|
||||
void ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr);
|
||||
ObjectList* GetTargets(SmartScriptHolder const& e, Unit* invoker = nullptr);
|
||||
ObjectList* GetWorldObjectsInDist(float dist);
|
||||
void InstallTemplate(SmartScriptHolder const& e);
|
||||
SmartScriptHolder CreateEvent(SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 phaseMask = 0);
|
||||
@@ -55,7 +55,7 @@ class TC_GAME_API SmartScript
|
||||
uint32 GetPathId() const { return mPathId; }
|
||||
WorldObject* GetBaseObject()
|
||||
{
|
||||
WorldObject* obj = NULL;
|
||||
WorldObject* obj = nullptr;
|
||||
if (me)
|
||||
obj = me;
|
||||
else if (go)
|
||||
@@ -108,7 +108,7 @@ class TC_GAME_API SmartScript
|
||||
(*mTargetStorage)[id] = new ObjectGuidList(targets, GetBaseObject());
|
||||
}
|
||||
|
||||
bool IsSmart(Creature* c = NULL)
|
||||
bool IsSmart(Creature* c = nullptr)
|
||||
{
|
||||
bool smart = true;
|
||||
if (c && c->GetAIName() != "SmartAI")
|
||||
@@ -123,7 +123,7 @@ class TC_GAME_API SmartScript
|
||||
return smart;
|
||||
}
|
||||
|
||||
bool IsSmartGO(GameObject* g = NULL)
|
||||
bool IsSmartGO(GameObject* g = nullptr)
|
||||
{
|
||||
bool smart = true;
|
||||
if (g && g->GetAIName() != "SmartGameObjectAI")
|
||||
@@ -142,7 +142,7 @@ class TC_GAME_API 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)
|
||||
@@ -214,14 +214,14 @@ class TC_GAME_API SmartScript
|
||||
if (Creature* m = ObjectAccessor::GetCreature(*lookupRoot, meOrigGUID))
|
||||
{
|
||||
me = m;
|
||||
go = NULL;
|
||||
go = nullptr;
|
||||
}
|
||||
}
|
||||
if (!goOrigGUID.IsEmpty())
|
||||
{
|
||||
if (GameObject* o = ObjectAccessor::GetGameObject(*lookupRoot, goOrigGUID))
|
||||
{
|
||||
me = NULL;
|
||||
me = nullptr;
|
||||
go = o;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user