aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/ScriptedAI
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2011-03-19 10:54:16 +0100
committerShauren <shauren.trinity@gmail.com>2011-03-19 10:54:16 +0100
commit1a4a618d81067969d7eec3725988a8bf0f845881 (patch)
tree195d616efde474fc13a65e0ef50f2b2e402eaf70 /src/server/game/AI/ScriptedAI
parent6eb5014182a63640e3e3d2a4460aecde83f4d63f (diff)
Core/Scripts: Code style cleanup in ScriptedAI and BossAI
Diffstat (limited to 'src/server/game/AI/ScriptedAI')
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp168
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.h185
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp4
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp4
4 files changed, 185 insertions, 176 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index cf2a491d33f..d72f19f4f29 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -111,11 +111,11 @@ bool SummonList::HasEntry(uint32 entry)
ScriptedAI::ScriptedAI(Creature* pCreature) : CreatureAI(pCreature),
me(pCreature),
IsFleeing(false),
- m_bCombatMovement(true),
- m_uiEvadeCheckCooldown(2500)
+ _isCombatMovementAllowed(true),
+ _evadeCheckCooldown(2500)
{
- m_heroicMode = me->GetMap()->IsHeroic();
- m_difficulty = Difficulty(me->GetMap()->GetSpawnMode());
+ _isHeroic = me->GetMap()->IsHeroic();
+ _difficulty = Difficulty(me->GetMap()->GetSpawnMode());
}
void ScriptedAI::AttackStartNoMove(Unit* pWho)
@@ -187,15 +187,15 @@ void ScriptedAI::DoPlaySoundToSet(WorldObject* pSource, uint32 uiSoundId)
pSource->PlayDirectSound(uiSoundId);
}
-Creature* ScriptedAI::DoSpawnCreature(uint32 uiId, float fX, float fY, float fZ, float fAngle, uint32 uiType, uint32 uiDespawntime)
+Creature* ScriptedAI::DoSpawnCreature(uint32 entry, float offsetX, float offsetY, float offsetZ, float angle, uint32 type, uint32 despawntime)
{
- return me->SummonCreature(uiId, me->GetPositionX()+fX, me->GetPositionY()+fY, me->GetPositionZ()+fZ, fAngle, (TempSummonType)uiType, uiDespawntime);
+ return me->SummonCreature(entry, me->GetPositionX() + offsetX, me->GetPositionY() + offsetY, me->GetPositionZ() + offsetZ, angle, TempSummonType(type), despawntime);
}
-SpellEntry const* ScriptedAI::SelectSpell(Unit* pTarget, uint32 uiSchool, uint32 uiMechanic, SelectTargetType selectTargets, uint32 uiPowerCostMin, uint32 uiPowerCostMax, float fRangeMin, float fRangeMax, SelectEffect selectEffects)
+SpellEntry const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 mechanic, SelectTargetType targets, uint32 powerCostMin, uint32 powerCostMax, float rangeMin, float rangeMax, SelectEffect effects)
{
//No target so we can't cast
- if (!pTarget)
+ if (!target)
return false;
//Silenced so we can't cast
@@ -204,101 +204,101 @@ SpellEntry const* ScriptedAI::SelectSpell(Unit* pTarget, uint32 uiSchool, uint32
//Using the extended script system we first create a list of viable spells
SpellEntry const* apSpell[CREATURE_MAX_SPELLS];
- memset(apSpell, 0, sizeof(SpellEntry*)*CREATURE_MAX_SPELLS);
+ memset(apSpell, 0, CREATURE_MAX_SPELLS * sizeof(SpellEntry*));
- uint32 uiSpellCount = 0;
+ uint32 spellCount = 0;
- SpellEntry const* pTempSpell;
- SpellRangeEntry const* pTempRange;
+ SpellEntry const* tempSpell = NULL;
+ SpellRangeEntry const* tempRange = NULL;
//Check if each spell is viable(set it to null if not)
for (uint32 i = 0; i < CREATURE_MAX_SPELLS; i++)
{
- pTempSpell = GetSpellStore()->LookupEntry(me->m_spells[i]);
+ tempSpell = sSpellStore.LookupEntry(me->m_spells[i]);
//This spell doesn't exist
- if (!pTempSpell)
+ if (!tempSpell)
continue;
// Targets and Effects checked first as most used restrictions
//Check the spell targets if specified
- if (selectTargets && !(SpellSummary[me->m_spells[i]].Targets & (1 << (selectTargets-1))))
+ if (targets && !(SpellSummary[me->m_spells[i]].Targets & (1 << (targets-1))))
continue;
//Check the type of spell if we are looking for a specific spell type
- if (selectEffects && !(SpellSummary[me->m_spells[i]].Effects & (1 << (selectEffects-1))))
+ if (effects && !(SpellSummary[me->m_spells[i]].Effects & (1 << (effects-1))))
continue;
//Check for school if specified
- if (uiSchool && (pTempSpell->SchoolMask & uiSchool) == 0)
+ if (school && (tempSpell->SchoolMask & school) == 0)
continue;
//Check for spell mechanic if specified
- if (uiMechanic && pTempSpell->Mechanic != uiMechanic)
+ if (mechanic && tempSpell->Mechanic != mechanic)
continue;
//Make sure that the spell uses the requested amount of power
- if (uiPowerCostMin && pTempSpell->manaCost < uiPowerCostMin)
+ if (powerCostMin && tempSpell->manaCost < powerCostMin)
continue;
- if (uiPowerCostMax && pTempSpell->manaCost > uiPowerCostMax)
+ if (powerCostMax && tempSpell->manaCost > powerCostMax)
continue;
//Continue if we don't have the mana to actually cast this spell
- if (pTempSpell->manaCost > me->GetPower((Powers)pTempSpell->powerType))
+ if (tempSpell->manaCost > me->GetPower(Powers(tempSpell->powerType)))
continue;
//Get the Range
- pTempRange = GetSpellRangeStore()->LookupEntry(pTempSpell->rangeIndex);
+ tempRange = GetSpellRangeStore()->LookupEntry(tempSpell->rangeIndex);
//Spell has invalid range store so we can't use it
- if (!pTempRange)
+ if (!tempRange)
continue;
//Check if the spell meets our range requirements
- if (fRangeMin && me->GetSpellMinRangeForTarget(pTarget, pTempRange) < fRangeMin)
+ if (rangeMin && me->GetSpellMinRangeForTarget(target, tempRange) < rangeMin)
continue;
- if (fRangeMax && me->GetSpellMaxRangeForTarget(pTarget, pTempRange) > fRangeMax)
+ if (rangeMax && me->GetSpellMaxRangeForTarget(target, tempRange) > rangeMax)
continue;
//Check if our target is in range
- if (me->IsWithinDistInMap(pTarget, (float)me->GetSpellMinRangeForTarget(pTarget, pTempRange)) || !me->IsWithinDistInMap(pTarget, (float)me->GetSpellMaxRangeForTarget(pTarget, pTempRange)))
+ if (me->IsWithinDistInMap(target, float(me->GetSpellMinRangeForTarget(target, tempRange))) || !me->IsWithinDistInMap(target, float(me->GetSpellMaxRangeForTarget(target, tempRange))))
continue;
//All good so lets add it to the spell list
- apSpell[uiSpellCount] = pTempSpell;
- ++uiSpellCount;
+ apSpell[spellCount] = tempSpell;
+ ++spellCount;
}
//We got our usable spells so now lets randomly pick one
- if (!uiSpellCount)
+ if (!spellCount)
return NULL;
- return apSpell[rand()%uiSpellCount];
+ return apSpell[urand(0, spellCount - 1)];
}
-bool ScriptedAI::CanCast(Unit* pTarget, SpellEntry const* pSpell, bool bTriggered)
+bool ScriptedAI::CanCast(Unit* target, SpellEntry const* spell, bool triggered /*= false*/)
{
//No target so we can't cast
- if (!pTarget || !pSpell)
+ if (!target || !spell)
return false;
//Silenced so we can't cast
- if (!bTriggered && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
+ if (!triggered && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
return false;
//Check for power
- if (!bTriggered && me->GetPower((Powers)pSpell->powerType) < pSpell->manaCost)
+ if (!triggered && me->GetPower(Powers(spell->powerType)) < spell->manaCost)
return false;
- SpellRangeEntry const* pTempRange = GetSpellRangeStore()->LookupEntry(pSpell->rangeIndex);
+ SpellRangeEntry const* tempRange = GetSpellRangeStore()->LookupEntry(spell->rangeIndex);
//Spell has invalid range store so we can't use it
- if (!pTempRange)
+ if (!tempRange)
return false;
//Unit is out of range of this spell
- if (me->IsInRange(pTarget, (float)me->GetSpellMinRangeForTarget(pTarget, pTempRange), (float)me->GetSpellMaxRangeForTarget(pTarget, pTempRange)))
+ if (me->IsInRange(target, float(me->GetSpellMinRangeForTarget(target, tempRange)), float(me->GetSpellMaxRangeForTarget(target, tempRange))))
return false;
return true;
@@ -417,29 +417,29 @@ Player* ScriptedAI::GetPlayerAtMinimumRange(float fMinimumRange)
return pPlayer;
}
-void ScriptedAI::SetEquipmentSlots(bool bLoadDefault, int32 uiMainHand, int32 uiOffHand, int32 uiRanged)
+void ScriptedAI::SetEquipmentSlots(bool loadDefault, int32 mainHand /*= EQUIP_NO_CHANGE*/, int32 offHand /*= EQUIP_NO_CHANGE*/, int32 ranged /*= EQUIP_NO_CHANGE*/)
{
- if (bLoadDefault)
+ if (loadDefault)
{
- if (CreatureInfo const* pInfo = GetCreatureTemplateStore(me->GetEntry()))
- me->LoadEquipment(pInfo->equipmentId,true);
+ if (CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(me->GetEntry()))
+ me->LoadEquipment(creatureInfo->equipmentId, true);
return;
}
- if (uiMainHand >= 0)
- me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(uiMainHand));
+ if (mainHand >= 0)
+ me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(mainHand));
- if (uiOffHand >= 0)
- me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, uint32(uiOffHand));
+ if (offHand >= 0)
+ me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, uint32(offHand));
- if (uiRanged >= 0)
- me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, uint32(uiRanged));
+ if (ranged >= 0)
+ me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, uint32(ranged));
}
-void ScriptedAI::SetCombatMovement(bool bCombatMove)
+void ScriptedAI::SetCombatMovement(bool allowMovement)
{
- m_bCombatMovement = bCombatMove;
+ _isCombatMovementAllowed = allowMovement;
}
enum eNPCs
@@ -452,13 +452,13 @@ enum eNPCs
// Hacklike storage used for misc creatures that are expected to evade of outside of a certain area.
// It is assumed the information is found elswehere and can be handled by the core. So far no luck finding such information/way to extract it.
-bool ScriptedAI::EnterEvadeIfOutOfCombatArea(const uint32 uiDiff)
+bool ScriptedAI::EnterEvadeIfOutOfCombatArea(uint32 const diff)
{
- if (m_uiEvadeCheckCooldown <= uiDiff)
- m_uiEvadeCheckCooldown = 2500;
+ if (_evadeCheckCooldown <= diff)
+ _evadeCheckCooldown = 2500;
else
{
- m_uiEvadeCheckCooldown -= uiDiff;
+ _evadeCheckCooldown -= diff;
return false;
}
@@ -496,20 +496,18 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(const uint32 uiDiff)
return true;
}
-void Scripted_NoMovementAI::AttackStart(Unit* pWho)
+void Scripted_NoMovementAI::AttackStart(Unit* target)
{
- if (!pWho)
+ if (!target)
return;
- if (me->Attack(pWho, true))
- {
- DoStartNoMovement(pWho);
- }
+ if (me->Attack(target, true))
+ DoStartNoMovement(target);
}
-BossAI::BossAI(Creature *c, uint32 id) : ScriptedAI(c)
-, bossId(id), summons(me), instance(c->GetInstanceScript())
-, boundary(instance ? instance->GetBossBoundary(id) : NULL)
+BossAI::BossAI(Creature* creature, uint32 bossId) : ScriptedAI(creature)
+, _bossId(bossId), summons(creature), instance(creature->GetInstanceScript())
+, _boundary(instance ? instance->GetBossBoundary(bossId) : NULL)
{
}
@@ -522,7 +520,7 @@ void BossAI::_Reset()
events.Reset();
summons.DespawnAll();
if (instance)
- instance->SetBossState(bossId, NOT_STARTED);
+ instance->SetBossState(_bossId, NOT_STARTED);
}
void BossAI::_JustDied()
@@ -531,7 +529,7 @@ void BossAI::_JustDied()
summons.DespawnAll();
if (instance)
{
- instance->SetBossState(bossId, DONE);
+ instance->SetBossState(_bossId, DONE);
instance->SaveToDB();
}
}
@@ -543,12 +541,12 @@ void BossAI::_EnterCombat()
if (instance)
{
// bosses do not respawn, check only on enter combat
- if (!instance->CheckRequiredBosses(bossId))
+ if (!instance->CheckRequiredBosses(_bossId))
{
EnterEvadeMode();
return;
}
- instance->SetBossState(bossId, IN_PROGRESS);
+ instance->SetBossState(_bossId, IN_PROGRESS);
}
}
@@ -556,18 +554,19 @@ void BossAI::TeleportCheaters()
{
float x, y, z;
me->GetPosition(x, y, z);
- std::list<HostileReference*> &m_threatlist = me->getThreatManager().getThreatList();
- for (std::list<HostileReference*>::iterator itr = m_threatlist.begin(); itr != m_threatlist.end(); ++itr)
- if ((*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER && !CheckBoundary((*itr)->getTarget()))
- (*itr)->getTarget()->NearTeleportTo(x, y, z, 0);
+ std::list<HostileReference*>& threatList = me->getThreatManager().getThreatList();
+ for (std::list<HostileReference*>::iterator itr = threatList.begin(); itr != threatList.end(); ++itr)
+ if (Unit* target = (*itr)->getTarget())
+ if (target->GetTypeId() == TYPEID_PLAYER && !CheckBoundary(target))
+ target->NearTeleportTo(x, y, z, 0);
}
-bool BossAI::CheckBoundary(Unit *who)
+bool BossAI::CheckBoundary(Unit* who)
{
- if (!boundary || !who)
+ if (!GetBoundary() || !who)
return true;
- for (BossBoundaryMap::const_iterator itr = boundary->begin(); itr != boundary->end(); ++itr)
+ for (BossBoundaryMap::const_iterator itr = GetBoundary()->begin(); itr != GetBoundary()->end(); ++itr)
{
switch (itr->first)
{
@@ -611,32 +610,35 @@ bool BossAI::CheckBoundary(Unit *who)
return true;
}
-void BossAI::JustSummoned(Creature *summon)
+void BossAI::JustSummoned(Creature* summon)
{
summons.Summon(summon);
if (me->isInCombat())
DoZoneInCombat(summon);
}
-void BossAI::SummonedCreatureDespawn(Creature *summon)
+void BossAI::SummonedCreatureDespawn(Creature* summon)
{
summons.Despawn(summon);
}
// SD2 grid searchers.
-Creature *GetClosestCreatureWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange, bool bAlive)
+Creature* GetClosestCreatureWithEntry(WorldObject* source, uint32 entry, float maxSearchRange, bool alive /*= true*/)
{
- return pSource->FindNearestCreature(uiEntry, fMaxSearchRange, bAlive);
+ return source->FindNearestCreature(entry, maxSearchRange, alive);
}
-GameObject *GetClosestGameObjectWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange)
+
+GameObject* GetClosestGameObjectWithEntry(WorldObject* source, uint32 entry, float maxSearchRange)
{
- return pSource->FindNearestGameObject(uiEntry, fMaxSearchRange);
+ return source->FindNearestGameObject(entry, maxSearchRange);
}
-void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange)
+
+void GetCreatureListWithEntryInGrid(std::list<Creature*>& list, WorldObject* source, uint32 entry, float maxSearchRange)
{
- return pSource->GetCreatureListWithEntryInGrid(lList, uiEntry, fMaxSearchRange);
+ source->GetCreatureListWithEntryInGrid(list, entry, maxSearchRange);
}
-void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange)
+
+void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& list, WorldObject* source, uint32 entry, float maxSearchRange)
{
- return pSource->GetGameObjectListWithEntryInGrid(lList, uiEntry, fMaxSearchRange);
+ source->GetGameObjectListWithEntryInGrid(list, entry, maxSearchRange);
}
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h
index b933bb31a17..85eac24a657 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h
@@ -30,8 +30,8 @@ class SummonList : public std::list<uint64>
{
public:
explicit SummonList(Creature* creature) : me(creature) {}
- void Summon(Creature *summon) { push_back(summon->GetGUID()); }
- void Despawn(Creature *summon) { remove(summon->GetGUID()); }
+ void Summon(Creature* summon) { push_back(summon->GetGUID()); }
+ void Despawn(Creature* summon) { remove(summon->GetGUID()); }
void DespawnEntry(uint32 entry);
void DespawnAll();
void DoAction(uint32 entry, int32 info);
@@ -39,46 +39,46 @@ class SummonList : public std::list<uint64>
void RemoveNotExisting();
bool HasEntry(uint32 entry);
private:
- Creature *me;
+ Creature* me;
};
struct ScriptedAI : public CreatureAI
{
- explicit ScriptedAI(Creature* pCreature);
+ explicit ScriptedAI(Creature* creature);
virtual ~ScriptedAI() {}
// *************
//CreatureAI Functions
// *************
- void AttackStartNoMove(Unit *pTarget);
+ void AttackStartNoMove(Unit* target);
// Called at any Damage from any attacker (before damage apply)
- void DamageTaken(Unit* /*pDone_by*/, uint32& /*uiDamage*/) {}
+ void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) {}
//Called at World update tick
void UpdateAI(const uint32);
//Called at creature death
- void JustDied(Unit* /*who*/){}
+ void JustDied(Unit* /*killer*/) {}
//Called at creature killing another unit
- void KilledUnit(Unit* /*who*/){}
+ void KilledUnit(Unit* /*victim*/) {}
// Called when the creature summon successfully other creature
- void JustSummoned(Creature*) {}
+ void JustSummoned(Creature* /*summon*/) {}
// Called when a summoned creature is despawned
- void SummonedCreatureDespawn(Creature*) {}
+ void SummonedCreatureDespawn(Creature* /*summon*/) {}
// Called when hit by a spell
- void SpellHit(Unit* /*caster*/, const SpellEntry * /*spell*/) {}
+ void SpellHit(Unit* /*caster*/, SpellEntry const* /*spell*/) {}
// Called when spell hits a target
- void SpellHitTarget(Unit * /*pTarget*/, const SpellEntry * /*spell*/) {}
+ void SpellHitTarget(Unit * /*target*/, SpellEntry const* /*spell*/) {}
//Called at waypoint reached or PointMovement end
- void MovementInform(uint32 /*type*/, uint32 /*id*/){}
+ void MovementInform(uint32 /*type*/, uint32 /*id*/) {}
// Called when AI is temporarily replaced or put back when possess is applied or removed
void OnPossess(bool /*apply*/) {}
@@ -101,98 +101,98 @@ struct ScriptedAI : public CreatureAI
void Reset() {}
//Called at creature aggro either by MoveInLOS or Attack Start
- void EnterCombat(Unit* /*who*/) {}
+ void EnterCombat(Unit* /*victim*/) {}
// *************
//AI Helper Functions
// *************
//Start movement toward victim
- void DoStartMovement(Unit* pVictim, float fDistance = 0, float fAngle = 0);
+ void DoStartMovement(Unit* target, float distance = 0.0f, float angle = 0.0f);
//Start no movement on victim
- void DoStartNoMovement(Unit* pVictim);
+ void DoStartNoMovement(Unit* target);
//Stop attack of current victim
void DoStopAttack();
//Cast spell by spell info
- void DoCastSpell(Unit* pTarget, SpellEntry const* pSpellInfo, bool bTriggered = false);
+ void DoCastSpell(Unit* target, SpellEntry const* spellInfo, bool triggered = false);
//Plays a sound to all nearby players
- void DoPlaySoundToSet(WorldObject* pSource, uint32 sound);
+ void DoPlaySoundToSet(WorldObject* source, uint32 soundId);
//Drops all threat to 0%. Does not remove players from the threat list
void DoResetThreat();
- float DoGetThreat(Unit* u);
- void DoModifyThreatPercent(Unit* pUnit, int32 pct);
+ float DoGetThreat(Unit* unit);
+ void DoModifyThreatPercent(Unit* unit, int32 pct);
- void DoTeleportTo(float fX, float fY, float fZ, uint32 uiTime = 0);
- void DoTeleportTo(const float pos[4]);
+ void DoTeleportTo(float x, float y, float z, uint32 time = 0);
+ void DoTeleportTo(float const pos[4]);
- void DoAction(const int32 /*param*/) {}
+ void DoAction(int32 const /*param*/) {}
//Teleports a player without dropping threat (only teleports to same map)
- void DoTeleportPlayer(Unit* pUnit, float fX, float fY, float fZ, float fO);
- void DoTeleportAll(float fX, float fY, float fZ, float fO);
+ void DoTeleportPlayer(Unit* unit, float x, float y, float z, float o);
+ void DoTeleportAll(float x, float y, float z, float o);
//Returns friendly unit with the most amount of hp missing from max hp
- Unit* DoSelectLowestHpFriendly(float fRange, uint32 uiMinHPDiff = 1);
+ Unit* DoSelectLowestHpFriendly(float range, uint32 minHPDiff = 1);
//Returns a list of friendly CC'd units within range
- std::list<Creature*> DoFindFriendlyCC(float fRange);
+ std::list<Creature*> DoFindFriendlyCC(float range);
//Returns a list of all friendly units missing a specific buff within range
- std::list<Creature*> DoFindFriendlyMissingBuff(float fRange, uint32 uiSpellId);
+ std::list<Creature*> DoFindFriendlyMissingBuff(float range, uint32 spellId);
//Return a player with at least minimumRange from me
- Player* GetPlayerAtMinimumRange(float fMinimumRange);
+ Player* GetPlayerAtMinimumRange(float minRange);
//Spawns a creature relative to me
- Creature* DoSpawnCreature(uint32 uiId, float fX, float fY, float fZ, float fAngle, uint32 uiType, uint32 uiDespawntime);
+ Creature* DoSpawnCreature(uint32 entry, float offsetX, float offsetY, float offsetZ, float angle, uint32 type, uint32 despawntime);
bool HealthBelowPct(uint32 pct) const { return me->HealthBelowPct(pct); }
bool HealthAbovePct(uint32 pct) const { return me->HealthAbovePct(pct); }
//Returns spells that meet the specified criteria from the creatures spell list
- SpellEntry const* SelectSpell(Unit* Target, uint32 School, uint32 Mechanic, SelectTargetType Targets, uint32 PowerCostMin, uint32 PowerCostMax, float RangeMin, float RangeMax, SelectEffect Effect);
+ SpellEntry const* SelectSpell(Unit* target, uint32 school, uint32 mechanic, SelectTargetType targets, uint32 powerCostMin, uint32 powerCostMax, float rangeMin, float rangeMax, SelectEffect effect);
//Checks if you can cast the specified spell
- bool CanCast(Unit* pTarget, SpellEntry const* pSpell, bool bTriggered = false);
+ bool CanCast(Unit* target, SpellEntry const* spell, bool triggered = false);
- void SetEquipmentSlots(bool bLoadDefault, int32 uiMainHand = EQUIP_NO_CHANGE, int32 uiOffHand = EQUIP_NO_CHANGE, int32 uiRanged = EQUIP_NO_CHANGE);
+ void SetEquipmentSlots(bool loadDefault, int32 mainHand = EQUIP_NO_CHANGE, int32 offHand = EQUIP_NO_CHANGE, int32 ranged = EQUIP_NO_CHANGE);
//Generally used to control if MoveChase() is to be used or not in AttackStart(). Some creatures does not chase victims
- void SetCombatMovement(bool CombatMove);
- bool IsCombatMovement() { return m_bCombatMovement; }
+ void SetCombatMovement(bool allowMovement);
+ bool IsCombatMovementAllowed() { return _isCombatMovementAllowed; }
- bool EnterEvadeIfOutOfCombatArea(const uint32 uiDiff);
+ bool EnterEvadeIfOutOfCombatArea(uint32 const diff);
// return true for heroic mode. i.e.
// - for dungeon in mode 10-heroic,
// - for raid in mode 10-Heroic
// - for raid in mode 25-heroic
// DO NOT USE to check raid in mode 25-normal.
- bool IsHeroic() { return m_heroicMode; }
+ bool IsHeroic() { return _isHeroic; }
// return the dungeon or raid difficulty
- Difficulty getDifficulty() { return m_difficulty; }
+ Difficulty GetDifficulty() { return _difficulty; }
// return true for 25 man or 25 man heroic mode
- bool Is25ManRaid() { return m_difficulty & 1; }
+ bool Is25ManRaid() { return _difficulty & 1; }
template<class T> inline
const T& DUNGEON_MODE(const T& normal5, const T& heroic10)
{
- switch(m_difficulty)
+ switch (_difficulty)
{
- case DUNGEON_DIFFICULTY_NORMAL:
- return normal5;
- case DUNGEON_DIFFICULTY_HEROIC:
- return heroic10;
- default:
- break;
+ case DUNGEON_DIFFICULTY_NORMAL:
+ return normal5;
+ case DUNGEON_DIFFICULTY_HEROIC:
+ return heroic10;
+ default:
+ break;
}
return heroic10;
@@ -201,14 +201,14 @@ struct ScriptedAI : public CreatureAI
template<class T> inline
const T& RAID_MODE(const T& normal10, const T& normal25)
{
- switch(m_difficulty)
+ switch (_difficulty)
{
- case RAID_DIFFICULTY_10MAN_NORMAL:
- return normal10;
- case RAID_DIFFICULTY_25MAN_NORMAL:
- return normal25;
- default:
- break;
+ case RAID_DIFFICULTY_10MAN_NORMAL:
+ return normal10;
+ case RAID_DIFFICULTY_25MAN_NORMAL:
+ return normal25;
+ default:
+ break;
}
return normal25;
@@ -217,27 +217,28 @@ struct ScriptedAI : public CreatureAI
template<class T> inline
const T& RAID_MODE(const T& normal10, const T& normal25, const T& heroic10, const T& heroic25)
{
- switch(m_difficulty)
+ switch (_difficulty)
{
- case RAID_DIFFICULTY_10MAN_NORMAL:
- return normal10;
- case RAID_DIFFICULTY_25MAN_NORMAL:
- return normal25;
- case RAID_DIFFICULTY_10MAN_HEROIC:
- return heroic10;
- case RAID_DIFFICULTY_25MAN_HEROIC:
- return heroic25;
+ case RAID_DIFFICULTY_10MAN_NORMAL:
+ return normal10;
+ case RAID_DIFFICULTY_25MAN_NORMAL:
+ return normal25;
+ case RAID_DIFFICULTY_10MAN_HEROIC:
+ return heroic10;
+ case RAID_DIFFICULTY_25MAN_HEROIC:
+ return heroic25;
+ default:
+ break;
}
return heroic25;
}
private:
- bool m_bCombatMovement;
- uint32 m_uiEvadeCheckCooldown;
-
- bool m_heroicMode;
- Difficulty m_difficulty;
+ Difficulty _difficulty;
+ uint32 _evadeCheckCooldown;
+ bool _isCombatMovementAllowed;
+ bool _isHeroic;
};
struct Scripted_NoMovementAI : public ScriptedAI
@@ -246,29 +247,27 @@ struct Scripted_NoMovementAI : public ScriptedAI
virtual ~Scripted_NoMovementAI() {}
//Called at each attack of me by any victim
- void AttackStart(Unit* who);
+ void AttackStart(Unit* target);
};
-struct BossAI : public ScriptedAI
+class BossAI : public ScriptedAI
{
- BossAI(Creature *c, uint32 id);
- virtual ~BossAI() {}
+ public:
+ BossAI(Creature* creature, uint32 bossId);
+ virtual ~BossAI() {}
- const uint32 bossId;
- EventMap events;
- SummonList summons;
- InstanceScript * const instance;
- const BossBoundaryMap * const boundary;
+ InstanceScript* const instance;
+ BossBoundaryMap const* GetBoundary() const { return _boundary; }
- void JustSummoned(Creature *summon);
- void SummonedCreatureDespawn(Creature *summon);
+ void JustSummoned(Creature* summon);
+ void SummonedCreatureDespawn(Creature* summon);
- void UpdateAI(const uint32 diff) = 0;
+ void UpdateAI(uint32 const diff) = 0;
- void Reset() { _Reset(); }
- void EnterCombat(Unit * /*who*/) { _EnterCombat(); }
- void JustDied(Unit * /*killer*/) { _JustDied(); }
- void JustReachedHome() { _JustReachedHome(); }
+ void Reset() { _Reset(); }
+ void EnterCombat(Unit* /*who*/) { _EnterCombat(); }
+ void JustDied(Unit* /*killer*/) { _JustDied(); }
+ void JustReachedHome() { _JustReachedHome(); }
protected:
void _Reset();
@@ -280,18 +279,26 @@ struct BossAI : public ScriptedAI
{
if (CheckBoundary(me))
return true;
+
EnterEvadeMode();
return false;
}
- bool CheckBoundary(Unit *who);
+
+ bool CheckBoundary(Unit* who);
void TeleportCheaters();
+
+ EventMap events;
+ SummonList summons;
+
+ private:
+ BossBoundaryMap const* const _boundary;
+ const uint32 _bossId;
};
// SD2 grid searchers.
-Creature *GetClosestCreatureWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange, bool bAlive = true);
-GameObject *GetClosestGameObjectWithEntry(WorldObject *pSource, uint32 uiEntry, float fMaxSearchRange);
-void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange);
-void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, WorldObject* pSource, uint32 uiEntry, float fMaxSearchRange);
+Creature *GetClosestCreatureWithEntry(WorldObject* source, uint32 entry, float maxSearchRange, bool alive = true);
+GameObject* GetClosestGameObjectWithEntry(WorldObject* source, uint32 entry, float maxSearchRange);
+void GetCreatureListWithEntryInGrid(std::list<Creature*>& list, WorldObject* source, uint32 entry, float maxSearchRange);
+void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& list, WorldObject* source, uint32 entry, float maxSearchRange);
#endif
-
diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
index 1e4e86b9d48..2c39bdc86d3 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
@@ -45,7 +45,7 @@ void npc_escortAI::AttackStart(Unit* pWho)
if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE)
me->GetMotionMaster()->MovementExpired();
- if (IsCombatMovement())
+ if (IsCombatMovementAllowed())
me->GetMotionMaster()->MoveChase(pWho);
}
}
@@ -148,7 +148,7 @@ void npc_escortAI::JustRespawned()
{
m_uiEscortState = STATE_ESCORT_NONE;
- if (!IsCombatMovement())
+ if (!IsCombatMovementAllowed())
SetCombatMovement(true);
//add a small delay before going to first waypoint, normal in near all cases
diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
index 8b2eef48d56..036d43229ff 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
@@ -41,7 +41,7 @@ void FollowerAI::AttackStart(Unit* pWho)
if (me->HasUnitState(UNIT_STAT_FOLLOW))
me->ClearUnitState(UNIT_STAT_FOLLOW);
- if (IsCombatMovement())
+ if (IsCombatMovementAllowed())
me->GetMotionMaster()->MoveChase(pWho);
}
}
@@ -147,7 +147,7 @@ void FollowerAI::JustRespawned()
{
m_uiFollowState = STATE_FOLLOW_NONE;
- if (!IsCombatMovement())
+ if (!IsCombatMovementAllowed())
SetCombatMovement(true);
if (me->getFaction() != me->GetCreatureInfo()->faction_A)