aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CoreAI/CombatAI.cpp92
-rw-r--r--src/server/game/AI/CoreAI/CombatAI.h25
-rw-r--r--src/server/game/AI/CoreAI/PetAI.cpp32
-rw-r--r--src/server/game/AI/CoreAI/PetAI.h14
-rw-r--r--src/server/game/AI/CoreAI/TotemAI.cpp8
-rw-r--r--src/server/game/AI/CoreAI/TotemAI.h2
-rw-r--r--src/server/game/AI/CoreAI/UnitAI.cpp20
-rw-r--r--src/server/game/AI/CoreAI/UnitAI.h28
-rw-r--r--src/server/game/AI/CreatureAI.cpp10
-rw-r--r--src/server/game/AI/CreatureAI.h10
-rw-r--r--src/server/game/AI/CreatureAISelector.h1
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp34
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.h28
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp30
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h14
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedGossip.cpp48
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp172
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.h59
18 files changed, 329 insertions, 298 deletions
diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp
index b4720802236..98da20b3420 100644
--- a/src/server/game/AI/CoreAI/CombatAI.cpp
+++ b/src/server/game/AI/CoreAI/CombatAI.cpp
@@ -57,19 +57,19 @@ void CombatAI::InitializeAI()
{
for (uint32 i = 0; i < MAX_CREATURE_SPELLS; ++i)
if (me->m_spells[i] && sSpellMgr->GetSpellInfo(me->m_spells[i], me->GetMap()->GetDifficultyID()))
- spells.push_back(me->m_spells[i]);
+ Spells.push_back(me->m_spells[i]);
CreatureAI::InitializeAI();
}
void CombatAI::Reset()
{
- events.Reset();
+ Events.Reset();
}
void CombatAI::JustDied(Unit* killer)
{
- for (SpellVct::iterator i = spells.begin(); i != spells.end(); ++i)
+ for (SpellVector::iterator i = Spells.begin(); i != Spells.end(); ++i)
if (AISpellInfoType const* info = GetAISpellInfo(*i, me->GetMap()->GetDifficultyID()))
if (info->condition == AICOND_DIE)
me->CastSpell(killer, *i, true);
@@ -77,14 +77,14 @@ void CombatAI::JustDied(Unit* killer)
void CombatAI::JustEngagedWith(Unit* who)
{
- for (SpellVct::iterator i = spells.begin(); i != spells.end(); ++i)
+ for (SpellVector::iterator i = Spells.begin(); i != Spells.end(); ++i)
{
if (AISpellInfoType const* info = GetAISpellInfo(*i, me->GetMap()->GetDifficultyID()))
{
if (info->condition == AICOND_AGGRO)
me->CastSpell(who, *i, false);
else if (info->condition == AICOND_COMBAT)
- events.ScheduleEvent(*i, info->cooldown + rand32() % info->cooldown);
+ Events.ScheduleEvent(*i, info->cooldown + rand32() % info->cooldown);
}
}
}
@@ -94,16 +94,16 @@ void CombatAI::UpdateAI(uint32 diff)
if (!UpdateVictim())
return;
- events.Update(diff);
+ Events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
- if (uint32 spellId = events.ExecuteEvent())
+ if (uint32 spellId = Events.ExecuteEvent())
{
DoCast(spellId);
if (AISpellInfoType const* info = GetAISpellInfo(spellId, me->GetMap()->GetDifficultyID()))
- events.ScheduleEvent(spellId, info->cooldown + rand32() % info->cooldown);
+ Events.ScheduleEvent(spellId, info->cooldown + rand32() % info->cooldown);
}
else
DoMeleeAttackIfReady();
@@ -111,7 +111,7 @@ void CombatAI::UpdateAI(uint32 diff)
void CombatAI::SpellInterrupted(uint32 spellId, uint32 unTimeMs)
{
- events.RescheduleEvent(spellId, unTimeMs);
+ Events.RescheduleEvent(spellId, unTimeMs);
}
/////////////////
@@ -122,24 +122,24 @@ void CasterAI::InitializeAI()
{
CombatAI::InitializeAI();
- m_attackDist = 30.0f;
- for (SpellVct::iterator itr = spells.begin(); itr != spells.end(); ++itr)
+ _attackDistance = 30.0f;
+ for (SpellVector::iterator itr = Spells.begin(); itr != Spells.end(); ++itr)
if (AISpellInfoType const* info = GetAISpellInfo(*itr, me->GetMap()->GetDifficultyID()))
- if (info->condition == AICOND_COMBAT && m_attackDist > info->maxRange)
- m_attackDist = info->maxRange;
+ if (info->condition == AICOND_COMBAT && _attackDistance > info->maxRange)
+ _attackDistance = info->maxRange;
- if (m_attackDist == 30.0f)
- m_attackDist = MELEE_RANGE;
+ if (_attackDistance == 30.0f)
+ _attackDistance = MELEE_RANGE;
}
void CasterAI::JustEngagedWith(Unit* who)
{
- if (spells.empty())
+ if (Spells.empty())
return;
- uint32 spell = rand32() % spells.size();
+ uint32 spell = rand32() % Spells.size();
uint32 count = 0;
- for (SpellVct::iterator itr = spells.begin(); itr != spells.end(); ++itr, ++count)
+ for (SpellVector::iterator itr = Spells.begin(); itr != Spells.end(); ++itr, ++count)
{
if (AISpellInfoType const* info = GetAISpellInfo(*itr, me->GetMap()->GetDifficultyID()))
{
@@ -150,10 +150,10 @@ void CasterAI::JustEngagedWith(Unit* who)
uint32 cooldown = info->realCooldown;
if (count == spell)
{
- DoCast(spells[spell]);
+ DoCast(Spells[spell]);
cooldown += me->GetCurrentSpellCastTime(*itr);
}
- events.ScheduleEvent(*itr, cooldown);
+ Events.ScheduleEvent(*itr, cooldown);
}
}
}
@@ -164,7 +164,7 @@ void CasterAI::UpdateAI(uint32 diff)
if (!UpdateVictim())
return;
- events.Update(diff);
+ Events.Update(diff);
if (me->GetVictim() && me->EnsureVictim()->HasBreakableByDamageCrowdControlAura(me))
{
@@ -175,12 +175,12 @@ void CasterAI::UpdateAI(uint32 diff)
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
- if (uint32 spellId = events.ExecuteEvent())
+ if (uint32 spellId = Events.ExecuteEvent())
{
DoCast(spellId);
uint32 casttime = me->GetCurrentSpellCastTime(spellId);
if (AISpellInfoType const* info = GetAISpellInfo(spellId, me->GetMap()->GetDifficultyID()))
- events.ScheduleEvent(spellId, (casttime ? casttime : 500) + info->realCooldown);
+ Events.ScheduleEvent(spellId, (casttime ? casttime : 500) + info->realCooldown);
}
}
@@ -194,10 +194,10 @@ ArcherAI::ArcherAI(Creature* c, uint32 scriptId) : CreatureAI(c, scriptId)
TC_LOG_ERROR("misc", "ArcherAI set for creature (entry = %u) with spell1=0. AI will do nothing", me->GetEntry());
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(me->m_spells[0], me->GetMap()->GetDifficultyID());
- m_minRange = spellInfo ? spellInfo->GetMinRange(false) : 0;
+ _minimumRange = spellInfo ? spellInfo->GetMinRange(false) : 0;
- if (!m_minRange)
- m_minRange = MELEE_RANGE;
+ if (!_minimumRange)
+ _minimumRange = MELEE_RANGE;
me->m_CombatDistance = spellInfo ? spellInfo->GetMaxRange(false) : 0;
me->m_SightDistance = me->m_CombatDistance;
}
@@ -207,7 +207,7 @@ void ArcherAI::AttackStart(Unit* who)
if (!who)
return;
- if (me->IsWithinCombatRange(who, m_minRange))
+ if (me->IsWithinCombatRange(who, _minimumRange))
{
if (me->Attack(who, true) && !who->IsFlying())
me->GetMotionMaster()->MoveChase(who);
@@ -227,7 +227,7 @@ void ArcherAI::UpdateAI(uint32 /*diff*/)
if (!UpdateVictim())
return;
- if (!me->IsWithinCombatRange(me->GetVictim(), m_minRange))
+ if (!me->IsWithinCombatRange(me->GetVictim(), _minimumRange))
DoSpellAttackIfReady(me->m_spells[0]);
else
DoMeleeAttackIfReady();
@@ -243,7 +243,7 @@ TurretAI::TurretAI(Creature* c, uint32 scriptId) : CreatureAI(c, scriptId)
TC_LOG_ERROR("misc", "TurretAI set for creature (entry = %u) with spell1=0. AI will do nothing", me->GetEntry());
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(me->m_spells[0], me->GetMap()->GetDifficultyID());
- m_minRange = spellInfo ? spellInfo->GetMinRange(false) : 0;
+ _minimumRange = spellInfo ? spellInfo->GetMinRange(false) : 0;
me->m_CombatDistance = spellInfo ? spellInfo->GetMaxRange(false) : 0;
me->m_SightDistance = me->m_CombatDistance;
}
@@ -252,7 +252,7 @@ bool TurretAI::CanAIAttack(Unit const* who) const
{
/// @todo use one function to replace it
if (!me->IsWithinCombatRange(who, me->m_CombatDistance)
- || (m_minRange && me->IsWithinCombatRange(who, m_minRange)))
+ || (_minimumRange && me->IsWithinCombatRange(who, _minimumRange)))
return false;
return true;
}
@@ -275,11 +275,11 @@ void TurretAI::UpdateAI(uint32 /*diff*/)
// VehicleAI
//////////////
-VehicleAI::VehicleAI(Creature* creature, uint32 scriptId) : CreatureAI(creature, scriptId), m_HasConditions(false), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME)
+VehicleAI::VehicleAI(Creature* creature, uint32 scriptId) : CreatureAI(creature, scriptId), _hasConditions(false), _conditionsTimer(VEHICLE_CONDITION_CHECK_TIME)
{
LoadConditions();
- m_DoDismiss = false;
- m_DismissTimer = VEHICLE_DISMISS_TIME;
+ _dismiss = false;
+ _dismissTimer = VEHICLE_DISMISS_TIME;
}
// NOTE: VehicleAI::UpdateAI runs even while the vehicle is mounted
@@ -287,42 +287,42 @@ void VehicleAI::UpdateAI(uint32 diff)
{
CheckConditions(diff);
- if (m_DoDismiss)
+ if (_dismiss)
{
- if (m_DismissTimer < diff)
+ if (_dismissTimer < diff)
{
- m_DoDismiss = false;
+ _dismiss = false;
me->DespawnOrUnsummon();
}
else
- m_DismissTimer -= diff;
+ _dismissTimer -= diff;
}
}
void VehicleAI::OnCharmed(bool /*isNew*/)
{
bool const charmed = me->IsCharmed();
- if (!me->GetVehicleKit()->IsVehicleInUse() && !charmed && m_HasConditions) // was used and has conditions
+ if (!me->GetVehicleKit()->IsVehicleInUse() && !charmed && _hasConditions) // was used and has conditions
{
- m_DoDismiss = true; // needs reset
+ _dismiss = true; // needs reset
}
else if (charmed)
- m_DoDismiss = false; // in use again
+ _dismiss = false; // in use again
- m_DismissTimer = VEHICLE_DISMISS_TIME; // reset timer
+ _dismissTimer = VEHICLE_DISMISS_TIME; // reset timer
}
void VehicleAI::LoadConditions()
{
- m_HasConditions = sConditionMgr->HasConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, me->GetEntry());
+ _hasConditions = sConditionMgr->HasConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, me->GetEntry());
}
void VehicleAI::CheckConditions(uint32 diff)
{
- if (!m_HasConditions)
+ if (!_hasConditions)
return;
- if (m_ConditionsTimer <= diff)
+ if (_conditionsTimer <= diff)
{
if (Vehicle * vehicleKit = me->GetVehicleKit())
{
@@ -340,10 +340,10 @@ void VehicleAI::CheckConditions(uint32 diff)
}
}
- m_ConditionsTimer = VEHICLE_CONDITION_CHECK_TIME;
+ _conditionsTimer = VEHICLE_CONDITION_CHECK_TIME;
}
else
- m_ConditionsTimer -= diff;
+ _conditionsTimer -= diff;
}
int32 VehicleAI::Permissible(Creature const* creature)
diff --git a/src/server/game/AI/CoreAI/CombatAI.h b/src/server/game/AI/CoreAI/CombatAI.h
index cfec8f91e41..227d06eb82b 100644
--- a/src/server/game/AI/CoreAI/CombatAI.h
+++ b/src/server/game/AI/CoreAI/CombatAI.h
@@ -31,7 +31,7 @@ class TC_GAME_API AggressorAI : public CreatureAI
static int32 Permissible(Creature const* creature);
};
-typedef std::vector<uint32> SpellVct;
+typedef std::vector<uint32> SpellVector;
class TC_GAME_API CombatAI : public CreatureAI
{
@@ -48,20 +48,20 @@ class TC_GAME_API CombatAI : public CreatureAI
static int32 Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; }
protected:
- EventMap events;
- SpellVct spells;
+ EventMap Events;
+ SpellVector Spells;
};
class TC_GAME_API CasterAI : public CombatAI
{
public:
- explicit CasterAI(Creature* c, uint32 scriptId = {}) : CombatAI(c, scriptId) { m_attackDist = MELEE_RANGE; }
+ explicit CasterAI(Creature* c, uint32 scriptId = {}) : CombatAI(c, scriptId) { _attackDistance = MELEE_RANGE; }
void InitializeAI() override;
- void AttackStart(Unit* victim) override { AttackStartCaster(victim, m_attackDist); }
+ void AttackStart(Unit* victim) override { AttackStartCaster(victim, _attackDistance); }
void UpdateAI(uint32 diff) override;
void JustEngagedWith(Unit* /*who*/) override;
private:
- float m_attackDist;
+ float _attackDistance;
};
struct TC_GAME_API ArcherAI : public CreatureAI
@@ -74,7 +74,7 @@ struct TC_GAME_API ArcherAI : public CreatureAI
static int32 Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; }
protected:
- float m_minRange;
+ float _minimumRange;
};
struct TC_GAME_API TurretAI : public CreatureAI
@@ -88,7 +88,7 @@ struct TC_GAME_API TurretAI : public CreatureAI
static int32 Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; }
protected:
- float m_minRange;
+ float _minimumRange;
};
#define VEHICLE_CONDITION_CHECK_TIME 1000
@@ -109,10 +109,11 @@ struct TC_GAME_API VehicleAI : public CreatureAI
private:
void LoadConditions();
void CheckConditions(uint32 diff);
- bool m_HasConditions;
- uint32 m_ConditionsTimer;
- bool m_DoDismiss;
- uint32 m_DismissTimer;
+
+ bool _hasConditions;
+ uint32 _conditionsTimer;
+ bool _dismiss;
+ uint32 _dismissTimer;
};
#endif
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp
index 1c01ddf55d3..ea8d4c1c464 100644
--- a/src/server/game/AI/CoreAI/PetAI.cpp
+++ b/src/server/game/AI/CoreAI/PetAI.cpp
@@ -44,14 +44,14 @@ int32 PetAI::Permissible(Creature const* creature)
return PERMIT_BASE_NO;
}
-PetAI::PetAI(Creature* c, uint32 scriptId) : CreatureAI(c, scriptId), i_tracker(TIME_INTERVAL_LOOK)
+PetAI::PetAI(Creature* c, uint32 scriptId) : CreatureAI(c, scriptId), _tracker(TIME_INTERVAL_LOOK)
{
if (!me->GetCharmInfo())
throw InvalidAIException("Creature doesn't have a valid charm info");
UpdateAllies();
}
-bool PetAI::_needToStop()
+bool PetAI::NeedToStop()
{
// This is needed for charmed creatures, as once their target was reset other effects can trigger threat
if (me->IsCharmed() && me->GetVictim() == me->GetCharmer())
@@ -65,7 +65,7 @@ bool PetAI::_needToStop()
return !me->IsValidAttackTarget(me->GetVictim());
}
-void PetAI::_stopAttack()
+void PetAI::StopAttack()
{
if (!me->IsAlive())
{
@@ -89,11 +89,11 @@ void PetAI::UpdateAI(uint32 diff)
Unit* owner = me->GetCharmerOrOwner();
- if (m_updateAlliesTimer <= diff)
+ if (_updateAlliesTimer <= diff)
// UpdateAllies self set update timer
UpdateAllies();
else
- m_updateAlliesTimer -= diff;
+ _updateAlliesTimer -= diff;
if (me->GetVictim() && me->EnsureVictim()->IsAlive())
{
@@ -105,10 +105,10 @@ void PetAI::UpdateAI(uint32 diff)
return;
}
- if (_needToStop())
+ if (NeedToStop())
{
TC_LOG_DEBUG("misc", "Pet AI stopped attacking [%s]", me->GetGUID().ToString().c_str());
- _stopAttack();
+ StopAttack();
return;
}
@@ -200,7 +200,7 @@ void PetAI::UpdateAI(uint32 diff)
// No enemy, check friendly
if (!spellUsed)
{
- for (GuidSet::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar)
+ for (GuidSet::const_iterator tar = _allySet.begin(); tar != _allySet.end(); ++tar)
{
Unit* ally = ObjectAccessor::GetUnit(*me, *tar);
@@ -262,7 +262,7 @@ void PetAI::UpdateAI(uint32 diff)
void PetAI::UpdateAllies()
{
- m_updateAlliesTimer = 10 * IN_MILLISECONDS; // update friendly targets every 10 seconds, lesser checks increase performance
+ _updateAlliesTimer = 10 * IN_MILLISECONDS; // update friendly targets every 10 seconds, lesser checks increase performance
Unit* owner = me->GetCharmerOrOwner();
if (!owner)
@@ -273,15 +273,15 @@ void PetAI::UpdateAllies()
group = player->GetGroup();
//only pet and owner/not in group->ok
- if (m_AllySet.size() == 2 && !group)
+ if (_allySet.size() == 2 && !group)
return;
//owner is in group; group members filled in already (no raid -> subgroupcount = whole count)
- if (group && !group->isRaidGroup() && m_AllySet.size() == (group->GetMembersCount() + 2))
+ if (group && !group->isRaidGroup() && _allySet.size() == (group->GetMembersCount() + 2))
return;
- m_AllySet.clear();
- m_AllySet.insert(me->GetGUID());
+ _allySet.clear();
+ _allySet.insert(me->GetGUID());
if (group) //add group
{
for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
@@ -293,11 +293,11 @@ void PetAI::UpdateAllies()
if (Target->GetGUID() == owner->GetGUID())
continue;
- m_AllySet.insert(Target->GetGUID());
+ _allySet.insert(Target->GetGUID());
}
}
else //remove group
- m_AllySet.insert(owner->GetGUID());
+ _allySet.insert(owner->GetGUID());
}
void PetAI::KilledUnit(Unit* victim)
@@ -309,7 +309,7 @@ void PetAI::KilledUnit(Unit* victim)
// Clear target just in case. May help problem where health / focus / mana
// regen gets stuck. Also resets attack command.
- // Can't use _stopAttack() because that activates movement handlers and ignores
+ // Can't use StopAttack() because that activates movement handlers and ignores
// next target selection
me->AttackStop();
me->InterruptNonMeleeSpells(false);
diff --git a/src/server/game/AI/CoreAI/PetAI.h b/src/server/game/AI/CoreAI/PetAI.h
index 091b06378ee..ddf97354b2b 100644
--- a/src/server/game/AI/CoreAI/PetAI.h
+++ b/src/server/game/AI/CoreAI/PetAI.h
@@ -52,19 +52,17 @@ class TC_GAME_API PetAI : public CreatureAI
void EnterEvadeMode(EvadeReason /*why*/) override { } // For fleeing, pets don't use this type of Evade mechanic
private:
- bool _needToStop(void);
- void _stopAttack(void);
-
+ bool NeedToStop();
+ void StopAttack();
void UpdateAllies();
-
- TimeTracker i_tracker;
- GuidSet m_AllySet;
- uint32 m_updateAlliesTimer;
-
Unit* SelectNextTarget(bool allowAutoSelect) const;
void HandleReturnMovement();
void DoAttack(Unit* target, bool chase);
bool CanAttack(Unit* target);
void ClearCharmInfoFlags();
+
+ TimeTracker _tracker;
+ GuidSet _allySet;
+ uint32 _updateAlliesTimer;
};
#endif
diff --git a/src/server/game/AI/CoreAI/TotemAI.cpp b/src/server/game/AI/CoreAI/TotemAI.cpp
index 7f36ae8e5bf..8047c3cca39 100644
--- a/src/server/game/AI/CoreAI/TotemAI.cpp
+++ b/src/server/game/AI/CoreAI/TotemAI.cpp
@@ -32,7 +32,7 @@ int32 TotemAI::Permissible(Creature const* creature)
return PERMIT_BASE_NO;
}
-TotemAI::TotemAI(Creature* c, uint32 scriptId) : CreatureAI(c, scriptId), i_victimGuid()
+TotemAI::TotemAI(Creature* c, uint32 scriptId) : CreatureAI(c, scriptId), _victimGUID()
{
ASSERT(c->IsTotem());
}
@@ -63,7 +63,7 @@ void TotemAI::UpdateAI(uint32 /*diff*/)
// SpellModOp::Range not applied in this place just because not existence range mods for attacking totems
// pointer to appropriate target if found any
- Unit* victim = !i_victimGuid.IsEmpty() ? ObjectAccessor::GetUnit(*me, i_victimGuid) : nullptr;
+ Unit* victim = !_victimGUID.IsEmpty() ? ObjectAccessor::GetUnit(*me, _victimGUID) : nullptr;
// Search victim if no, not attackable, or out of range, or friendly (possible in case duel end)
if (!victim ||
@@ -80,13 +80,13 @@ void TotemAI::UpdateAI(uint32 /*diff*/)
if (victim)
{
// remember
- i_victimGuid = victim->GetGUID();
+ _victimGUID = victim->GetGUID();
// attack
me->CastSpell(victim, me->ToTotem()->GetSpell());
}
else
- i_victimGuid.Clear();
+ _victimGUID.Clear();
}
void TotemAI::AttackStart(Unit* /*victim*/)
diff --git a/src/server/game/AI/CoreAI/TotemAI.h b/src/server/game/AI/CoreAI/TotemAI.h
index e4efea9dc7e..13c024ccbe4 100644
--- a/src/server/game/AI/CoreAI/TotemAI.h
+++ b/src/server/game/AI/CoreAI/TotemAI.h
@@ -38,6 +38,6 @@ class TC_GAME_API TotemAI : public CreatureAI
static int32 Permissible(Creature const* creature);
private:
- ObjectGuid i_victimGuid;
+ ObjectGuid _victimGUID;
};
#endif
diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp
index b2e48e807c6..df37aa94f03 100644
--- a/src/server/game/AI/CoreAI/UnitAI.cpp
+++ b/src/server/game/AI/CoreAI/UnitAI.cpp
@@ -318,40 +318,40 @@ std::string UnitAI::GetDebugInfo() const
}
DefaultTargetSelector::DefaultTargetSelector(Unit const* unit, float dist, bool playerOnly, bool withTank, int32 aura)
- : me(unit), m_dist(dist), m_playerOnly(playerOnly), except(!withTank ? me->GetThreatManager().GetCurrentVictim() : nullptr), m_aura(aura)
+ : _me(unit), _dist(dist), _playerOnly(playerOnly), _exception(!withTank ? _me->GetThreatManager().GetCurrentVictim() : nullptr), _aura(aura)
{
}
bool DefaultTargetSelector::operator()(Unit const* target) const
{
- if (!me)
+ if (!_me)
return false;
if (!target)
return false;
- if (except && target == except)
+ if (_exception && target == _exception)
return false;
- if (m_playerOnly && (target->GetTypeId() != TYPEID_PLAYER))
+ if (_playerOnly && (target->GetTypeId() != TYPEID_PLAYER))
return false;
- if (m_dist > 0.0f && !me->IsWithinCombatRange(target, m_dist))
+ if (_dist > 0.0f && !_me->IsWithinCombatRange(target, _dist))
return false;
- if (m_dist < 0.0f && me->IsWithinCombatRange(target, -m_dist))
+ if (_dist < 0.0f && _me->IsWithinCombatRange(target, -_dist))
return false;
- if (m_aura)
+ if (_aura)
{
- if (m_aura > 0)
+ if (_aura > 0)
{
- if (!target->HasAura(m_aura))
+ if (!target->HasAura(_aura))
return false;
}
else
{
- if (target->HasAura(-m_aura))
+ if (target->HasAura(-_aura))
return false;
}
}
diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h
index c129966a1ec..7aa770cfcb9 100644
--- a/src/server/game/AI/CoreAI/UnitAI.h
+++ b/src/server/game/AI/CoreAI/UnitAI.h
@@ -59,19 +59,21 @@ enum SelectAggroTarget
// default predicate function to select target based on distance, player and/or aura criteria
struct TC_GAME_API DefaultTargetSelector
{
- Unit const* me;
- float m_dist;
- bool m_playerOnly;
- Unit const* except;
- int32 m_aura;
-
- // unit: the reference unit
- // dist: if 0: ignored, if > 0: maximum distance to the reference unit, if < 0: minimum distance to the reference unit
- // playerOnly: self explaining
- // withMainTank: allow current tank to be selected
- // aura: if 0: ignored, if > 0: the target shall have the aura, if < 0, the target shall NOT have the aura
- DefaultTargetSelector(Unit const* unit, float dist, bool playerOnly, bool withMainTank, int32 aura);
- bool operator()(Unit const* target) const;
+ public:
+ // unit: the reference unit
+ // dist: if 0: ignored, if > 0: maximum distance to the reference unit, if < 0: minimum distance to the reference unit
+ // playerOnly: self explaining
+ // withMainTank: allow current tank to be selected
+ // aura: if 0: ignored, if > 0: the target shall have the aura, if < 0, the target shall NOT have the aura
+ DefaultTargetSelector(Unit const* unit, float dist, bool playerOnly, bool withMainTank, int32 aura);
+ bool operator()(Unit const* target) const;
+
+ private:
+ Unit const* _me;
+ float _dist;
+ bool _playerOnly;
+ Unit const* _exception;
+ int32 _aura;
};
// Target selector for spell casts checking range, auras and attributes
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
index 57aa2a6fb88..359fb0fa206 100644
--- a/src/server/game/AI/CreatureAI.cpp
+++ b/src/server/game/AI/CreatureAI.cpp
@@ -55,7 +55,7 @@ AISpellInfoType* GetAISpellInfo(uint32 spellId, Difficulty difficulty)
CreatureAI::CreatureAI(Creature* creature, uint32 scriptId)
: UnitAI(creature), me(creature), _boundary(nullptr),
- _negateBoundary(false), _scriptId(scriptId ? scriptId : creature->GetScriptId()), m_MoveInLineOfSight_locked(false)
+ _negateBoundary(false), _scriptId(scriptId ? scriptId : creature->GetScriptId()), _moveInLOSLocked(false)
{
ASSERT(_scriptId, "A CreatureAI was initialized with an invalid scriptId!");
}
@@ -103,11 +103,11 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= nullptr*/)
// MoveInLineOfSight can be called inside another MoveInLineOfSight and cause stack overflow
void CreatureAI::MoveInLineOfSight_Safe(Unit* who)
{
- if (m_MoveInLineOfSight_locked == true)
+ if (_moveInLOSLocked == true)
return;
- m_MoveInLineOfSight_locked = true;
+ _moveInLOSLocked = true;
MoveInLineOfSight(who);
- m_MoveInLineOfSight_locked = false;
+ _moveInLOSLocked = false;
}
void CreatureAI::MoveInLineOfSight(Unit* who)
@@ -119,7 +119,7 @@ void CreatureAI::MoveInLineOfSight(Unit* who)
me->EngageWithTarget(who);
}
-void CreatureAI::_OnOwnerCombatInteraction(Unit* target)
+void CreatureAI::OnOwnerCombatInteraction(Unit* target)
{
if (!target || !me->IsAlive())
return;
diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h
index 520a1542dfe..5b0ab08c4db 100644
--- a/src/server/game/AI/CreatureAI.h
+++ b/src/server/game/AI/CreatureAI.h
@@ -148,10 +148,10 @@ class TC_GAME_API CreatureAI : public UnitAI
virtual void ReceiveEmote(Player* /*player*/, uint32 /*emoteId*/) { }
// Called when owner takes damage
- virtual void OwnerAttackedBy(Unit* attacker) { _OnOwnerCombatInteraction(attacker); }
+ virtual void OwnerAttackedBy(Unit* attacker) { OnOwnerCombatInteraction(attacker); }
// Called when owner attacks something
- virtual void OwnerAttacked(Unit* target) { _OnOwnerCombatInteraction(target); }
+ virtual void OwnerAttacked(Unit* target) { OnOwnerCombatInteraction(target); }
/// == Triggered Actions Requested ==================
@@ -233,10 +233,10 @@ class TC_GAME_API CreatureAI : public UnitAI
bool _negateBoundary;
private:
- uint32 const _scriptId;
+ void OnOwnerCombatInteraction(Unit* target);
- bool m_MoveInLineOfSight_locked;
- void _OnOwnerCombatInteraction(Unit* target);
+ uint32 const _scriptId;
+ bool _moveInLOSLocked;
};
enum Permitions : int32
diff --git a/src/server/game/AI/CreatureAISelector.h b/src/server/game/AI/CreatureAISelector.h
index d8447f6f350..7e2c1acd683 100644
--- a/src/server/game/AI/CreatureAISelector.h
+++ b/src/server/game/AI/CreatureAISelector.h
@@ -38,4 +38,5 @@ namespace FactorySelector
TC_GAME_API uint32 GetSelectedAIId(GameObject const* go);
TC_GAME_API uint32 GetSelectedAIId(AreaTrigger const* at);
}
+
#endif
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index 69681e171aa..32ba4bdf5a1 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -33,19 +33,19 @@
void SummonList::Summon(Creature const* summon)
{
- storage_.push_back(summon->GetGUID());
+ _storage.push_back(summon->GetGUID());
}
void SummonList::Despawn(Creature const* summon)
{
- storage_.remove(summon->GetGUID());
+ _storage.remove(summon->GetGUID());
}
void SummonList::DoZoneInCombat(uint32 entry)
{
- for (StorageType::iterator i = storage_.begin(); i != storage_.end();)
+ for (StorageType::iterator i = _storage.begin(); i != _storage.end();)
{
- Creature* summon = ObjectAccessor::GetCreature(*me, *i);
+ Creature* summon = ObjectAccessor::GetCreature(*_me, *i);
++i;
if (summon && summon->IsAIEnabled()
&& (!entry || summon->GetEntry() == entry))
@@ -57,14 +57,14 @@ void SummonList::DoZoneInCombat(uint32 entry)
void SummonList::DespawnEntry(uint32 entry)
{
- for (StorageType::iterator i = storage_.begin(); i != storage_.end();)
+ for (StorageType::iterator i = _storage.begin(); i != _storage.end();)
{
- Creature* summon = ObjectAccessor::GetCreature(*me, *i);
+ Creature* summon = ObjectAccessor::GetCreature(*_me, *i);
if (!summon)
- i = storage_.erase(i);
+ i = _storage.erase(i);
else if (summon->GetEntry() == entry)
{
- i = storage_.erase(i);
+ i = _storage.erase(i);
summon->DespawnOrUnsummon();
}
else
@@ -74,10 +74,10 @@ void SummonList::DespawnEntry(uint32 entry)
void SummonList::DespawnAll()
{
- while (!storage_.empty())
+ while (!_storage.empty())
{
- Creature* summon = ObjectAccessor::GetCreature(*me, storage_.front());
- storage_.pop_front();
+ Creature* summon = ObjectAccessor::GetCreature(*_me, _storage.front());
+ _storage.pop_front();
if (summon)
summon->DespawnOrUnsummon();
}
@@ -85,20 +85,20 @@ void SummonList::DespawnAll()
void SummonList::RemoveNotExisting()
{
- for (StorageType::iterator i = storage_.begin(); i != storage_.end();)
+ for (StorageType::iterator i = _storage.begin(); i != _storage.end();)
{
- if (ObjectAccessor::GetCreature(*me, *i))
+ if (ObjectAccessor::GetCreature(*_me, *i))
++i;
else
- i = storage_.erase(i);
+ i = _storage.erase(i);
}
}
bool SummonList::HasEntry(uint32 entry) const
{
- for (StorageType::const_iterator i = storage_.begin(); i != storage_.end(); ++i)
+ for (StorageType::const_iterator i = _storage.begin(); i != _storage.end(); ++i)
{
- Creature* summon = ObjectAccessor::GetCreature(*me, *i);
+ Creature* summon = ObjectAccessor::GetCreature(*_me, *i);
if (summon && summon->GetEntry() == entry)
return true;
}
@@ -110,7 +110,7 @@ void SummonList::DoActionImpl(int32 action, StorageType const& summons)
{
for (auto const& guid : summons)
{
- Creature* summon = ObjectAccessor::GetCreature(*me, guid);
+ Creature* summon = ObjectAccessor::GetCreature(*_me, guid);
if (summon && summon->IsAIEnabled())
summon->AI()->DoAction(action);
}
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h
index bc7d558e87e..f6f9f23a322 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h
@@ -36,52 +36,50 @@ public:
typedef StorageType::size_type size_type;
typedef StorageType::value_type value_type;
- explicit SummonList(Creature* creature)
- : me(creature)
- { }
+ explicit SummonList(Creature* creature) : _me(creature) { }
// And here we see a problem of original inheritance approach. People started
// to exploit presence of std::list members, so I have to provide wrappers
iterator begin()
{
- return storage_.begin();
+ return _storage.begin();
}
const_iterator begin() const
{
- return storage_.begin();
+ return _storage.begin();
}
iterator end()
{
- return storage_.end();
+ return _storage.end();
}
const_iterator end() const
{
- return storage_.end();
+ return _storage.end();
}
iterator erase(iterator i)
{
- return storage_.erase(i);
+ return _storage.erase(i);
}
bool empty() const
{
- return storage_.empty();
+ return _storage.empty();
}
size_type size() const
{
- return storage_.size();
+ return _storage.size();
}
// Clear the underlying storage. This does NOT despawn the creatures - use DespawnAll for that!
void clear()
{
- storage_.clear();
+ _storage.clear();
}
void Summon(Creature const* summon);
@@ -92,14 +90,14 @@ public:
template <typename T>
void DespawnIf(T const& predicate)
{
- storage_.remove_if(predicate);
+ _storage.remove_if(predicate);
}
template <class Predicate>
void DoAction(int32 info, Predicate&& predicate, uint16 max = 0)
{
// We need to use a copy of SummonList here, otherwise original SummonList would be modified
- StorageType listCopy = storage_;
+ StorageType listCopy = _storage;
Trinity::Containers::RandomResize<StorageType, Predicate>(listCopy, std::forward<Predicate>(predicate), max);
DoActionImpl(info, listCopy);
}
@@ -111,8 +109,8 @@ public:
private:
void DoActionImpl(int32 action, StorageType const& summons);
- Creature* me;
- StorageType storage_;
+ Creature* _me;
+ StorageType _storage;
};
class TC_GAME_API EntryCheckPredicate
diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
index 30cec2a814d..156daa0aed9 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
@@ -39,9 +39,9 @@ enum Points
};
FollowerAI::FollowerAI(Creature* creature) : ScriptedAI(creature),
- m_uiUpdateFollowTimer(2500),
- m_uiFollowState(STATE_FOLLOW_NONE),
- m_pQuestForFollow(nullptr)
+ _updateFollowTimer(2500),
+ _followState(STATE_FOLLOW_NONE),
+ _questForFollow(nullptr)
{ }
void FollowerAI::AttackStart(Unit* who)
@@ -126,7 +126,7 @@ void FollowerAI::MoveInLineOfSight(Unit* who)
void FollowerAI::JustDied(Unit* /*killer*/)
{
- if (!HasFollowState(STATE_FOLLOW_INPROGRESS) || !m_uiLeaderGUID || !m_pQuestForFollow)
+ if (!HasFollowState(STATE_FOLLOW_INPROGRESS) || !_leaderGUID || !_questForFollow)
return;
/// @todo need a better check for quests with time limit.
@@ -137,16 +137,16 @@ void FollowerAI::JustDied(Unit* /*killer*/)
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
if (Player* member = groupRef->GetSource())
if (member->IsInMap(player))
- member->FailQuest(m_pQuestForFollow->GetQuestId());
+ member->FailQuest(_questForFollow->GetQuestId());
}
else
- player->FailQuest(m_pQuestForFollow->GetQuestId());
+ player->FailQuest(_questForFollow->GetQuestId());
}
}
void FollowerAI::JustAppeared()
{
- m_uiFollowState = STATE_FOLLOW_NONE;
+ _followState = STATE_FOLLOW_NONE;
if (!IsCombatMovementAllowed())
SetCombatMovement(true);
@@ -188,7 +188,7 @@ void FollowerAI::UpdateAI(uint32 uiDiff)
{
if (HasFollowState(STATE_FOLLOW_INPROGRESS) && !me->GetVictim())
{
- if (m_uiUpdateFollowTimer <= uiDiff)
+ if (_updateFollowTimer <= uiDiff)
{
if (HasFollowState(STATE_FOLLOW_COMPLETE) && !HasFollowState(STATE_FOLLOW_POSTEVENT))
{
@@ -236,10 +236,10 @@ void FollowerAI::UpdateAI(uint32 uiDiff)
return;
}
- m_uiUpdateFollowTimer = 1000;
+ _updateFollowTimer = 1000;
}
else
- m_uiUpdateFollowTimer -= uiDiff;
+ _updateFollowTimer -= uiDiff;
}
UpdateFollowerAI(uiDiff);
@@ -285,12 +285,12 @@ void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, Quest co
}
//set variables
- m_uiLeaderGUID = player->GetGUID();
+ _leaderGUID = player->GetGUID();
if (factionForFollower)
me->SetFaction(factionForFollower);
- m_pQuestForFollow = quest;
+ _questForFollow = quest;
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
{
@@ -306,12 +306,12 @@ void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, Quest co
me->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
- TC_LOG_DEBUG("scripts", "FollowerAI start follow %s (%s)", player->GetName().c_str(), m_uiLeaderGUID.ToString().c_str());
+ TC_LOG_DEBUG("scripts", "FollowerAI start follow %s (%s)", player->GetName().c_str(), _leaderGUID.ToString().c_str());
}
Player* FollowerAI::GetLeaderForFollower()
{
- if (Player* player = ObjectAccessor::GetPlayer(*me, m_uiLeaderGUID))
+ if (Player* player = ObjectAccessor::GetPlayer(*me, _leaderGUID))
{
if (player->IsAlive())
return player;
@@ -325,7 +325,7 @@ Player* FollowerAI::GetLeaderForFollower()
if (member && me->IsWithinDistInMap(member, MAX_PLAYER_DISTANCE) && member->IsAlive())
{
TC_LOG_DEBUG("scripts", "FollowerAI GetLeader changed and returned new leader.");
- m_uiLeaderGUID = member->GetGUID();
+ _leaderGUID = member->GetGUID();
return member;
}
}
diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h
index 39c5da0e8ae..f0f8fbb26a1 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h
+++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h
@@ -60,22 +60,22 @@ class TC_GAME_API FollowerAI : public ScriptedAI
void SetFollowPaused(bool bPaused); //if special event require follow mode to hold/resume during the follow
void SetFollowComplete(bool bWithEndEvent = false);
- bool HasFollowState(uint32 uiFollowState) { return (m_uiFollowState & uiFollowState) != 0; }
+ bool HasFollowState(uint32 uiFollowState) { return (_followState & uiFollowState) != 0; }
protected:
Player* GetLeaderForFollower();
private:
- void AddFollowState(uint32 uiFollowState) { m_uiFollowState |= uiFollowState; }
- void RemoveFollowState(uint32 uiFollowState) { m_uiFollowState &= ~uiFollowState; }
+ void AddFollowState(uint32 uiFollowState) { _followState |= uiFollowState; }
+ void RemoveFollowState(uint32 uiFollowState) { _followState &= ~uiFollowState; }
bool AssistPlayerInCombatAgainst(Unit* who);
- ObjectGuid m_uiLeaderGUID;
- uint32 m_uiUpdateFollowTimer;
- uint32 m_uiFollowState;
+ ObjectGuid _leaderGUID;
+ uint32 _updateFollowTimer;
+ uint32 _followState;
- Quest const* m_pQuestForFollow; //normally we have a quest
+ Quest const* _questForFollow;
};
#endif
diff --git a/src/server/game/AI/ScriptedAI/ScriptedGossip.cpp b/src/server/game/AI/ScriptedAI/ScriptedGossip.cpp
index 4790eee5649..c9b4fe249b4 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedGossip.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedGossip.cpp
@@ -19,14 +19,46 @@
#include "Creature.h"
#include "Player.h"
-uint32 GetGossipActionFor(Player* player, uint32 gossipListId) { return player->PlayerTalkClass->GetGossipOptionAction(gossipListId); }
-void ClearGossipMenuFor(Player* player) { player->PlayerTalkClass->ClearMenus(); }
+uint32 GetGossipActionFor(Player* player, uint32 gossipListId)
+{
+ return player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
+}
+
+void ClearGossipMenuFor(Player* player)
+{
+ player->PlayerTalkClass->ClearMenus();
+}
+
// Using provided text, not from DB
-void AddGossipItemFor(Player* player, GossipOptionIcon icon, std::string const& text, uint32 sender, uint32 action) { player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, "", 0); }
+void AddGossipItemFor(Player* player, GossipOptionIcon icon, std::string const& text, uint32 sender, uint32 action)
+{
+ player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, "", 0);
+}
+
// Using provided texts, not from DB
-void AddGossipItemFor(Player* player, GossipOptionIcon icon, std::string const& text, uint32 sender, uint32 action, std::string const& popupText, uint32 popupMoney, bool coded) { player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, popupText, popupMoney, coded); }
+void AddGossipItemFor(Player* player, GossipOptionIcon icon, std::string const& text, uint32 sender, uint32 action, std::string const& popupText, uint32 popupMoney, bool coded)
+{
+ player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, popupText, popupMoney, coded);
+}
+
// Uses gossip item info from DB
-void AddGossipItemFor(Player* player, uint32 gossipMenuID, uint32 gossipMenuItemID, uint32 sender, uint32 action) { player->PlayerTalkClass->GetGossipMenu().AddMenuItem(gossipMenuID, gossipMenuItemID, sender, action); }
-void SendGossipMenuFor(Player* player, uint32 npcTextID, ObjectGuid const& guid) { player->PlayerTalkClass->SendGossipMenu(npcTextID, guid); }
-void SendGossipMenuFor(Player* player, uint32 npcTextID, Creature const* creature) { if (creature) SendGossipMenuFor(player, npcTextID, creature->GetGUID()); }
-void CloseGossipMenuFor(Player* player) { player->PlayerTalkClass->SendCloseGossip(); }
+void AddGossipItemFor(Player* player, uint32 gossipMenuID, uint32 gossipMenuItemID, uint32 sender, uint32 action)
+{
+ player->PlayerTalkClass->GetGossipMenu().AddMenuItem(gossipMenuID, gossipMenuItemID, sender, action);
+}
+
+void SendGossipMenuFor(Player* player, uint32 npcTextID, ObjectGuid const& guid)
+{
+ player->PlayerTalkClass->SendGossipMenu(npcTextID, guid);
+}
+
+void SendGossipMenuFor(Player* player, uint32 npcTextID, Creature const* creature)
+{
+ if (creature)
+ SendGossipMenuFor(player, npcTextID, creature->GetGUID());
+}
+
+void CloseGossipMenuFor(Player* player)
+{
+ player->PlayerTalkClass->SendCloseGossip();
+}
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index 868d773dce0..4218ca172ae 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -30,17 +30,17 @@
#include "ScriptMgr.h"
#include "Vehicle.h"
-SmartAI::SmartAI(Creature* creature, uint32 scriptId) : CreatureAI(creature, scriptId), mIsCharmed(false), mFollowCreditType(0), mFollowArrivedTimer(0), mFollowCredit(0), mFollowArrivedEntry(0), mFollowDist(0.f), mFollowAngle(0.f),
+SmartAI::SmartAI(Creature* creature, uint32 scriptId) : CreatureAI(creature, scriptId), _charmed(false), _followCreditType(0), _followArrivedTimer(0), _followCredit(0), _followArrivedEntry(0), _followDistance(0.f), _followAngle(0.f),
_escortState(SMART_ESCORT_NONE), _escortNPCFlags(0), _escortInvokerCheckTimer(1000), _currentWaypointNode(0), _waypointReached(false), _waypointPauseTimer(0), _waypointPauseForced(false), _repeatWaypointPath(false),
- _OOCReached(false), _waypointPathEnded(false), mRun(true), mEvadeDisabled(false), mCanAutoAttack(true), mCanCombatMove(true), mInvincibilityHpLevel(0), mDespawnTime(0), mDespawnState(0), mConditionsTimer(0),
- _gossipReturn(false), mEscortQuestID(0)
+ _OOCReached(false), _waypointPathEnded(false), _run(true), _evadeDisabled(false), _canAutoAttack(true), _canCombatMove(true), _invincibilityHPLevel(0), _despawnTime(0), _despawnState(0), _vehicleConditionsTimer(0),
+ _gossipReturn(false), _escortQuestId(0)
{
- mHasConditions = sConditionMgr->HasConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, creature->GetEntry());
+ _vehicleConditions = sConditionMgr->HasConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, creature->GetEntry());
}
bool SmartAI::IsAIControlled() const
{
- return !mIsCharmed;
+ return !_charmed;
}
void SmartAI::StartPath(bool run/* = false*/, uint32 pathId/* = 0*/, bool repeat/* = false*/, Unit* invoker/* = nullptr*/, uint32 nodeId/* = 1*/)
@@ -102,7 +102,7 @@ bool SmartAI::LoadPath(uint32 entry)
{
Trinity::NormalizeMapCoord(waypoint.x);
Trinity::NormalizeMapCoord(waypoint.y);
- waypoint.moveType = mRun ? WAYPOINT_MOVE_TYPE_RUN : WAYPOINT_MOVE_TYPE_WALK;
+ waypoint.moveType = _run ? WAYPOINT_MOVE_TYPE_RUN : WAYPOINT_MOVE_TYPE_WALK;
}
GetScript()->SetPathId(entry);
@@ -133,7 +133,7 @@ void SmartAI::PausePath(uint32 delay, bool forced)
if (forced)
{
_waypointPauseForced = forced;
- SetRun(mRun);
+ SetRun(_run);
me->PauseMovement();
me->SetHomePosition(me->GetPosition());
}
@@ -152,7 +152,7 @@ void SmartAI::StopPath(uint32 DespawnTime, uint32 quest, bool fail)
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
waypointInfo = me->GetCurrentWaypointInfo();
- if (mDespawnState != 2)
+ if (_despawnState != 2)
SetDespawnTime(DespawnTime);
me->GetMotionMaster()->MoveIdle();
@@ -164,16 +164,16 @@ void SmartAI::StopPath(uint32 DespawnTime, uint32 quest, bool fail)
{
if (waypointInfo.first)
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_ENDED, nullptr, waypointInfo.first, waypointInfo.second);
- if (mDespawnState == 1)
+ if (_despawnState == 1)
StartDespawn();
}
return;
}
if (quest)
- mEscortQuestID = quest;
+ _escortQuestId = quest;
- if (mDespawnState != 2)
+ if (_despawnState != 2)
SetDespawnTime(DespawnTime);
me->GetMotionMaster()->MoveIdle();
@@ -196,16 +196,16 @@ void SmartAI::EndPath(bool fail)
}
ObjectVector const* targets = GetScript()->GetStoredTargetVector(SMART_ESCORT_TARGETS, *me);
- if (targets && mEscortQuestID)
+ if (targets && _escortQuestId)
{
if (targets->size() == 1 && GetScript()->IsPlayer((*targets->begin())))
{
Player* player = targets->front()->ToPlayer();
if (!fail && player->IsAtGroupRewardDistance(me) && !player->HasCorpse())
- player->GroupEventHappens(mEscortQuestID, me);
+ player->GroupEventHappens(_escortQuestId, me);
if (fail)
- player->FailQuest(mEscortQuestID);
+ player->FailQuest(_escortQuestId);
if (Group* group = player->GetGroup())
{
@@ -216,9 +216,9 @@ void SmartAI::EndPath(bool fail)
continue;
if (!fail && groupGuy->IsAtGroupRewardDistance(me) && !groupGuy->HasCorpse())
- groupGuy->AreaExploredOrEventHappens(mEscortQuestID);
+ groupGuy->AreaExploredOrEventHappens(_escortQuestId);
else if (fail)
- groupGuy->FailQuest(mEscortQuestID);
+ groupGuy->FailQuest(_escortQuestId);
}
}
}
@@ -230,9 +230,9 @@ void SmartAI::EndPath(bool fail)
{
Player* player = target->ToPlayer();
if (!fail && player->IsAtGroupRewardDistance(me) && !player->HasCorpse())
- player->AreaExploredOrEventHappens(mEscortQuestID);
+ player->AreaExploredOrEventHappens(_escortQuestId);
else if (fail)
- player->FailQuest(mEscortQuestID);
+ player->FailQuest(_escortQuestId);
}
}
}
@@ -248,12 +248,12 @@ void SmartAI::EndPath(bool fail)
if (_repeatWaypointPath)
{
if (IsAIControlled())
- StartPath(mRun, GetScript()->GetPathId(), _repeatWaypointPath);
+ StartPath(_run, GetScript()->GetPathId(), _repeatWaypointPath);
}
else if (pathid == GetScript()->GetPathId()) // if it's not the same pathid, our script wants to start another path; don't override it
GetScript()->SetPathId(0);
- if (mDespawnState == 1)
+ if (_despawnState == 1)
StartDespawn();
}
@@ -267,7 +267,7 @@ void SmartAI::ResumePath()
_waypointReached = false;
_waypointPauseTimer = 0;
- SetRun(mRun);
+ SetRun(_run);
me->ResumeMovement();
}
@@ -296,7 +296,7 @@ void SmartAI::UpdateAI(uint32 diff)
if (!UpdateVictim())
return;
- if (mCanAutoAttack)
+ if (_canAutoAttack)
DoMeleeAttackIfReady();
}
@@ -380,7 +380,7 @@ void SmartAI::WaypointReached(uint32 nodeId, uint32 pathId)
if (_currentWaypointNode == _path.nodes.size())
_waypointPathEnded = true;
else
- SetRun(mRun);
+ SetRun(_run);
}
}
@@ -410,7 +410,7 @@ void SmartAI::MovementInform(uint32 type, uint32 id)
void SmartAI::EnterEvadeMode(EvadeReason /*why*/)
{
- if (mEvadeDisabled)
+ if (_evadeDisabled)
{
GetScript()->ProcessEventsFor(SMART_EVENT_EVADE);
return;
@@ -429,7 +429,7 @@ void SmartAI::EnterEvadeMode(EvadeReason /*why*/)
GetScript()->ProcessEventsFor(SMART_EVENT_EVADE); // must be after _EnterEvadeMode (spells, auras, ...)
- SetRun(mRun);
+ SetRun(_run);
if (Unit* owner = me->GetCharmerOrOwner())
{
@@ -441,9 +441,9 @@ void SmartAI::EnterEvadeMode(EvadeReason /*why*/)
AddEscortState(SMART_ESCORT_RETURNING);
ReturnToLastOOCPos();
}
- else if (Unit* target = !mFollowGuid.IsEmpty() ? ObjectAccessor::GetUnit(*me, mFollowGuid) : nullptr)
+ else if (Unit* target = !_followGUID.IsEmpty() ? ObjectAccessor::GetUnit(*me, _followGUID) : nullptr)
{
- me->GetMotionMaster()->MoveFollow(target, mFollowDist, mFollowAngle);
+ me->GetMotionMaster()->MoveFollow(target, _followDistance, _followAngle);
// evade is not cleared in MoveFollow, so we can't keep it
me->ClearUnitState(UNIT_STATE_EVADE);
}
@@ -517,8 +517,8 @@ void SmartAI::InitializeAI()
{
GetScript()->OnInitialize(me);
- mDespawnTime = 0;
- mDespawnState = 0;
+ _despawnTime = 0;
+ _despawnState = 0;
_escortState = SMART_ESCORT_NONE;
me->SetVisible(true);
@@ -529,13 +529,13 @@ void SmartAI::InitializeAI()
GetScript()->OnReset();
}
- mFollowGuid.Clear(); // do not reset follower on Reset(), we need it after combat evade
- mFollowDist = 0;
- mFollowAngle = 0;
- mFollowCredit = 0;
- mFollowArrivedTimer = 1000;
- mFollowArrivedEntry = 0;
- mFollowCreditType = 0;
+ _followGUID.Clear(); // do not reset follower on Reset(), we need it after combat evade
+ _followDistance = 0;
+ _followAngle = 0;
+ _followCredit = 0;
+ _followArrivedTimer = 1000;
+ _followArrivedEntry = 0;
+ _followCreditType = 0;
}
void SmartAI::JustReachedHome()
@@ -590,18 +590,18 @@ void SmartAI::AttackStart(Unit* who)
if (!IsAIControlled())
{
if (who)
- me->Attack(who, mCanAutoAttack);
+ me->Attack(who, _canAutoAttack);
return;
}
- if (who && me->Attack(who, mCanAutoAttack))
+ if (who && me->Attack(who, _canAutoAttack))
{
me->GetMotionMaster()->Clear(MOTION_PRIORITY_NORMAL);
me->PauseMovement();
- if (mCanCombatMove)
+ if (_canCombatMove)
{
- SetRun(mRun);
+ SetRun(_run);
me->GetMotionMaster()->MoveChase(who);
}
}
@@ -624,8 +624,8 @@ void SmartAI::DamageTaken(Unit* doneBy, uint32& damage)
if (!IsAIControlled()) // don't allow players to use unkillable units
return;
- if (mInvincibilityHpLevel && (damage >= me->GetHealth() - mInvincibilityHpLevel))
- damage = me->GetHealth() - mInvincibilityHpLevel; // damage should not be nullified, because of player damage req.
+ if (_invincibilityHPLevel && (damage >= me->GetHealth() - _invincibilityHPLevel))
+ damage = me->GetHealth() - _invincibilityHPLevel; // damage should not be nullified, because of player damage req.
}
void SmartAI::HealReceived(Unit* doneBy, uint32& addhealth)
@@ -672,14 +672,14 @@ void SmartAI::OnCharmed(bool /*isNew*/)
EndPath(true);
}
- mIsCharmed = charmed;
+ _charmed = charmed;
if (!charmed && !me->IsInEvadeMode())
{
if (_repeatWaypointPath)
- StartPath(mRun, GetScript()->GetPathId(), true);
+ StartPath(_run, GetScript()->GetPathId(), true);
else
- me->SetWalk(!mRun);
+ me->SetWalk(!_run);
if (!me->LastCharmerGUID.IsEmpty())
{
@@ -718,7 +718,7 @@ ObjectGuid SmartAI::GetGUID(int32 /*id*/) const
void SmartAI::SetRun(bool run)
{
me->SetWalk(!run);
- mRun = run;
+ _run = run;
for (auto& node : _path.nodes)
node.moveType = run ? WAYPOINT_MOVE_TYPE_RUN : WAYPOINT_MOVE_TYPE_WALK;
}
@@ -740,7 +740,7 @@ void SmartAI::SetSwim(bool swim)
void SmartAI::SetEvadeDisabled(bool disable)
{
- mEvadeDisabled = disable;
+ _evadeDisabled = disable;
}
bool SmartAI::GossipHello(Player* player)
@@ -774,10 +774,10 @@ void SmartAI::QuestReward(Player* player, Quest const* quest, LootItemType /*typ
void SmartAI::SetCombatMove(bool on)
{
- if (mCanCombatMove == on)
+ if (_canCombatMove == on)
return;
- mCanCombatMove = on;
+ _canCombatMove = on;
if (!IsAIControlled())
return;
@@ -791,7 +791,7 @@ void SmartAI::SetCombatMove(bool on)
return movement->Mode == MOTION_MODE_DEFAULT && movement->Priority == MOTION_PRIORITY_NORMAL;
}))
{
- SetRun(mRun);
+ SetRun(_run);
me->GetMotionMaster()->MoveChase(me->GetVictim());
}
}
@@ -811,38 +811,38 @@ void SmartAI::SetFollow(Unit* target, float dist, float angle, uint32 credit, ui
return;
}
- mFollowGuid = target->GetGUID();
- mFollowDist = dist;
- mFollowAngle = angle;
- mFollowArrivedTimer = 1000;
- mFollowCredit = credit;
- mFollowArrivedEntry = end;
- mFollowCreditType = creditType;
- SetRun(mRun);
- me->GetMotionMaster()->MoveFollow(target, mFollowDist, mFollowAngle);
+ _followGUID = target->GetGUID();
+ _followDistance = dist;
+ _followAngle = angle;
+ _followArrivedTimer = 1000;
+ _followCredit = credit;
+ _followArrivedEntry = end;
+ _followCreditType = creditType;
+ SetRun(_run);
+ me->GetMotionMaster()->MoveFollow(target, _followDistance, _followAngle);
}
void SmartAI::StopFollow(bool complete)
{
- mFollowGuid.Clear();
- mFollowDist = 0;
- mFollowAngle = 0;
- mFollowCredit = 0;
- mFollowArrivedTimer = 1000;
- mFollowArrivedEntry = 0;
- mFollowCreditType = 0;
+ _followGUID.Clear();
+ _followDistance = 0;
+ _followAngle = 0;
+ _followCredit = 0;
+ _followArrivedTimer = 1000;
+ _followArrivedEntry = 0;
+ _followCreditType = 0;
me->GetMotionMaster()->MoveIdle();
if (!complete)
return;
- Player* player = ObjectAccessor::GetPlayer(*me, mFollowGuid);
+ Player* player = ObjectAccessor::GetPlayer(*me, _followGUID);
if (player)
{
- if (!mFollowCreditType)
- player->RewardPlayerAndGroupAtEvent(mFollowCredit, me);
+ if (!_followCreditType)
+ player->RewardPlayerAndGroupAtEvent(_followCredit, me);
else
- player->GroupEventHappens(mFollowCredit, me);
+ player->GroupEventHappens(_followCredit, me);
}
SetDespawnTime(5000);
@@ -870,10 +870,10 @@ void SmartAI::OnSpellClick(Unit* clicker, bool spellClickHandled)
void SmartAI::CheckConditions(uint32 diff)
{
- if (!mHasConditions)
+ if (!_vehicleConditions)
return;
- if (mConditionsTimer <= diff)
+ if (_vehicleConditionsTimer <= diff)
{
if (Vehicle * vehicleKit = me->GetVehicleKit())
{
@@ -891,10 +891,10 @@ void SmartAI::CheckConditions(uint32 diff)
}
}
- mConditionsTimer = 1000;
+ _vehicleConditionsTimer = 1000;
}
else
- mConditionsTimer -= diff;
+ _vehicleConditionsTimer -= diff;
}
void SmartAI::UpdatePath(uint32 diff)
@@ -906,7 +906,7 @@ void SmartAI::UpdatePath(uint32 diff)
{
if (!IsEscortInvokerInRange())
{
- StopPath(0, mEscortQuestID, true);
+ StopPath(0, _escortQuestId, true);
// allow to properly hook out of range despawn action, which in most cases should perform the same operation as dying
GetScript()->ProcessEventsFor(SMART_EVENT_DEATH, me);
@@ -950,41 +950,41 @@ void SmartAI::UpdatePath(uint32 diff)
void SmartAI::UpdateFollow(uint32 diff)
{
- if (mFollowGuid.IsEmpty())
+ if (!_followGUID.IsEmpty())
{
- if (mFollowArrivedTimer < diff)
+ if (_followArrivedTimer < diff)
{
- if (me->FindNearestCreature(mFollowArrivedEntry, INTERACTION_DISTANCE, true))
+ if (me->FindNearestCreature(_followArrivedEntry, INTERACTION_DISTANCE, true))
{
StopFollow(true);
return;
}
- mFollowArrivedTimer = 1000;
+ _followArrivedTimer = 1000;
}
else
- mFollowArrivedTimer -= diff;
+ _followArrivedTimer -= diff;
}
}
void SmartAI::UpdateDespawn(uint32 diff)
{
- if (mDespawnState <= 1 || mDespawnState > 3)
+ if (_despawnState <= 1 || _despawnState > 3)
return;
- if (mDespawnTime < diff)
+ if (_despawnTime < diff)
{
- if (mDespawnState == 2)
+ if (_despawnState == 2)
{
me->SetVisible(false);
- mDespawnTime = 5000;
- mDespawnState++;
+ _despawnTime = 5000;
+ _despawnState++;
}
else
me->DespawnOrUnsummon();
}
else
- mDespawnTime -= diff;
+ _despawnTime -= diff;
}
void SmartGameObjectAI::UpdateAI(uint32 diff)
diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h
index 801981a676a..26658533b2a 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.h
+++ b/src/server/game/AI/SmartScripts/SmartAI.h
@@ -62,9 +62,9 @@ class TC_GAME_API SmartAI : public CreatureAI
bool HasEscortState(uint32 uiEscortState) const { return (_escortState & uiEscortState) != 0; }
void AddEscortState(uint32 uiEscortState) { _escortState |= uiEscortState; }
void RemoveEscortState(uint32 uiEscortState) { _escortState &= ~uiEscortState; }
- void SetAutoAttack(bool on) { mCanAutoAttack = on; }
+ void SetAutoAttack(bool on) { _canAutoAttack = on; }
void SetCombatMove(bool on);
- bool CanCombatMove() { return mCanCombatMove; }
+ bool CanCombatMove() { return _canCombatMove; }
void SetFollow(Unit* target, float dist = 0.0f, float angle = 0.0f, uint32 credit = 0, uint32 end = 0, uint32 creditType = 0);
void StopFollow(bool complete);
bool IsEscortInvokerInRange();
@@ -75,7 +75,7 @@ class TC_GAME_API SmartAI : public CreatureAI
void WaypointPathEnded(uint32 nodeId, uint32 pathId) override;
void SetTimedActionList(SmartScriptHolder& e, uint32 entry, Unit* invoker);
- SmartScript* GetScript() { return &mScript; }
+ SmartScript* GetScript() { return &_script; }
// Called at reaching home after evade, InitializeAI(), EnterEvadeMode() for resetting variables
void JustReachedHome() override;
@@ -170,7 +170,7 @@ class TC_GAME_API SmartAI : public CreatureAI
void SetEvadeDisabled(bool disable = true);
- void SetInvincibilityHpLevel(uint32 level) { mInvincibilityHpLevel = level; }
+ void SetInvincibilityHpLevel(uint32 level) { _invincibilityHPLevel = level; }
bool GossipHello(Player* player) override;
bool GossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override;
@@ -181,10 +181,10 @@ class TC_GAME_API SmartAI : public CreatureAI
void SetDespawnTime (uint32 t)
{
- mDespawnTime = t;
- mDespawnState = t ? 1 : 0;
+ _despawnTime = t;
+ _despawnState = t ? 1 : 0;
}
- void StartDespawn() { mDespawnState = 2; }
+ void StartDespawn() { _despawnState = 2; }
void OnSpellClick(Unit* clicker, bool spellClickHandled) override;
@@ -192,7 +192,7 @@ class TC_GAME_API SmartAI : public CreatureAI
void SetGossipReturn(bool val) { _gossipReturn = val; }
- void SetEscortQuest(uint32 questID) { mEscortQuestID = questID; }
+ void SetEscortQuest(uint32 questID) { _escortQuestId = questID; }
private:
bool AssistPlayerInCombatAgainst(Unit* who);
@@ -202,16 +202,15 @@ class TC_GAME_API SmartAI : public CreatureAI
void UpdateFollow(uint32 diff);
void UpdateDespawn(uint32 diff);
- SmartScript mScript;
-
- bool mIsCharmed;
- uint32 mFollowCreditType;
- uint32 mFollowArrivedTimer;
- uint32 mFollowCredit;
- uint32 mFollowArrivedEntry;
- ObjectGuid mFollowGuid;
- float mFollowDist;
- float mFollowAngle;
+ SmartScript _script;
+ bool _charmed;
+ uint32 _followCreditType;
+ uint32 _followArrivedTimer;
+ uint32 _followCredit;
+ uint32 _followArrivedEntry;
+ ObjectGuid _followGUID;
+ float _followDistance;
+ float _followAngle;
uint32 _escortState;
uint32 _escortNPCFlags;
@@ -225,23 +224,23 @@ class TC_GAME_API SmartAI : public CreatureAI
bool _OOCReached;
bool _waypointPathEnded;
- bool mRun;
- bool mEvadeDisabled;
- bool mCanAutoAttack;
- bool mCanCombatMove;
- uint32 mInvincibilityHpLevel;
+ bool _run;
+ bool _evadeDisabled;
+ bool _canAutoAttack;
+ bool _canCombatMove;
+ uint32 _invincibilityHPLevel;
- uint32 mDespawnTime;
- uint32 mDespawnState;
+ uint32 _despawnTime;
+ uint32 _despawnState;
// Vehicle conditions
- bool mHasConditions;
- uint32 mConditionsTimer;
+ bool _vehicleConditions;
+ uint32 _vehicleConditionsTimer;
// Gossip
bool _gossipReturn;
- uint32 mEscortQuestID;
+ uint32 _escortQuestId;
};
class TC_GAME_API SmartGameObjectAI : public GameObjectAI
@@ -253,7 +252,7 @@ class TC_GAME_API SmartGameObjectAI : public GameObjectAI
void UpdateAI(uint32 diff) override;
void InitializeAI() override;
void Reset() override;
- SmartScript* GetScript() { return &mScript; }
+ SmartScript* GetScript() { return &_script; }
static int32 Permissible(GameObject const* /*go*/) { return PERMIT_BASE_NO; }
bool GossipHello(Player* player) override;
@@ -274,7 +273,7 @@ class TC_GAME_API SmartGameObjectAI : public GameObjectAI
void SetGossipReturn(bool val) { _gossipReturn = val; }
private:
- SmartScript mScript;
+ SmartScript _script;
// Gossip
bool _gossipReturn;