Core/Scripts: Code style cleanup in AI base classes, removed duplicate DoAction method
This commit is contained in:
@@ -102,12 +102,12 @@ class UnitAI
|
||||
protected:
|
||||
Unit * const me;
|
||||
public:
|
||||
explicit UnitAI(Unit *u) : me(u) {}
|
||||
explicit UnitAI(Unit* unit) : me(unit) {}
|
||||
virtual ~UnitAI() {}
|
||||
|
||||
virtual bool CanAIAttack(const Unit * /*who*/) const { return true; }
|
||||
virtual void AttackStart(Unit *);
|
||||
virtual void UpdateAI(const uint32 diff) = 0;
|
||||
virtual bool CanAIAttack(Unit const* /*target*/) const { return true; }
|
||||
virtual void AttackStart(Unit* /*target*/);
|
||||
virtual void UpdateAI(uint32 const diff) = 0;
|
||||
|
||||
virtual void InitializeAI() { if (!me->isDead()) Reset(); }
|
||||
|
||||
@@ -117,10 +117,10 @@ class UnitAI
|
||||
virtual void OnCharmed(bool apply) = 0;
|
||||
|
||||
// Pass parameters between AI
|
||||
virtual void DoAction(const int32 /*param*/ = 0) {}
|
||||
virtual void DoAction(int32 const /*param*/) {}
|
||||
virtual uint32 GetData(uint32 /*id = 0*/) { return 0; }
|
||||
virtual void SetData(uint32 /*id*/, uint32 /*value*/) {}
|
||||
virtual void SetGUID(const uint64 &/*guid*/, int32 /*id*/ = 0) {}
|
||||
virtual void SetGUID(uint64 const&/*guid*/, int32 /*id*/ = 0) {}
|
||||
virtual uint64 GetGUID(int32 /*id*/ = 0) { return 0; }
|
||||
|
||||
Unit* SelectTarget(SelectAggroTarget targetType, uint32 position = 0, float dist = 0.0f, bool playerOnly = false, int32 aura = 0);
|
||||
@@ -173,6 +173,7 @@ class UnitAI
|
||||
}
|
||||
|
||||
void SelectTargetList(std::list<Unit*> &targetList, uint32 num, SelectAggroTarget targetType, float dist = 0.0f, bool playerOnly = false, int32 aura = 0);
|
||||
|
||||
// Select the targets satifying the predicate.
|
||||
// predicate shall extend std::unary_function<Unit *, bool>
|
||||
template <class PREDICATE> void SelectTargetList(std::list<Unit*> &targetList, PREDICATE predicate, uint32 maxTargets, SelectAggroTarget targetType)
|
||||
@@ -214,7 +215,7 @@ class UnitAI
|
||||
// Called when the unit heals
|
||||
virtual void HealDone(Unit* /*done_to*/, uint32& /*addhealth*/) {}
|
||||
|
||||
void AttackStartCaster(Unit *victim, float dist);
|
||||
void AttackStartCaster(Unit* victim, float dist);
|
||||
|
||||
void DoAddAuraToAllHostilePlayers(uint32 spellid);
|
||||
void DoCast(uint32 spellId);
|
||||
@@ -233,7 +234,7 @@ class UnitAI
|
||||
|
||||
virtual void sGossipHello(Player* /*player*/) {}
|
||||
virtual void sGossipSelect(Player* /*player*/, uint32 /*sender*/, uint32 /*action*/) {}
|
||||
virtual void sGossipSelectCode(Player* /*player*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) {}
|
||||
virtual void sGossipSelectCode(Player* /*player*/, uint32 /*sender*/, uint32 /*action*/, char const* /*code*/) {}
|
||||
virtual void sQuestAccept(Player* /*player*/, Quest const* /*quest*/) {}
|
||||
virtual void sQuestSelect(Player* /*player*/, Quest const* /*quest*/) {}
|
||||
virtual void sQuestComplete(Player* /*player*/, Quest const* /*quest*/) {}
|
||||
@@ -254,8 +255,8 @@ class PlayerAI : public UnitAI
|
||||
class SimpleCharmedAI : public PlayerAI
|
||||
{
|
||||
public:
|
||||
void UpdateAI(const uint32 diff);
|
||||
SimpleCharmedAI(Player *p): PlayerAI(p) {}
|
||||
void UpdateAI(uint32 const diff);
|
||||
SimpleCharmedAI(Player* player): PlayerAI(player) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -40,7 +40,7 @@ void CreatureAI::Talk(uint8 id, uint64 WhisperGuid)
|
||||
sCreatureTextMgr->SendChat(me, id, WhisperGuid);
|
||||
}
|
||||
|
||||
void CreatureAI::DoZoneInCombat(Creature* creature)
|
||||
void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/)
|
||||
{
|
||||
if (!creature)
|
||||
creature = me;
|
||||
|
||||
@@ -66,12 +66,12 @@ enum SCEquip
|
||||
class CreatureAI : public UnitAI
|
||||
{
|
||||
protected:
|
||||
Creature * const me;
|
||||
Creature* const me;
|
||||
|
||||
bool UpdateVictim();
|
||||
bool UpdateVictimWithGaze();
|
||||
|
||||
void SetGazeOn(Unit *target);
|
||||
void SetGazeOn(Unit* target);
|
||||
|
||||
Creature *DoSummon(uint32 uiEntry, const Position &pos, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
|
||||
Creature *DoSummon(uint32 uiEntry, WorldObject *obj, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
|
||||
@@ -79,14 +79,14 @@ class CreatureAI : public UnitAI
|
||||
|
||||
public:
|
||||
void Talk(uint8 id, uint64 WhisperGuid = 0);
|
||||
explicit CreatureAI(Creature *c) : UnitAI((Unit*)c), me(c), m_MoveInLineOfSight_locked(false) {}
|
||||
explicit CreatureAI(Creature* creature) : UnitAI(creature), me(creature), m_MoveInLineOfSight_locked(false) {}
|
||||
|
||||
virtual ~CreatureAI() {}
|
||||
|
||||
/// == Reactions At =================================
|
||||
|
||||
// Called if IsVisible(Unit *who) is true at each *who move, reaction at visibility zone enter
|
||||
void MoveInLineOfSight_Safe(Unit *who);
|
||||
void MoveInLineOfSight_Safe(Unit* who);
|
||||
|
||||
// Called in Creature::Update when deathstate = DEAD. Inherited classes may maniuplate the ability to respawn based on scripted events.
|
||||
virtual bool CanRespawn() { return true; }
|
||||
@@ -95,29 +95,29 @@ class CreatureAI : public UnitAI
|
||||
virtual void EnterEvadeMode();
|
||||
|
||||
// Called for reaction at enter to combat if not in combat yet (enemy can be NULL)
|
||||
virtual void EnterCombat(Unit* /*enemy*/) {}
|
||||
virtual void EnterCombat(Unit* /*victim*/) {}
|
||||
|
||||
// Called when the creature is killed
|
||||
virtual void JustDied(Unit *) {}
|
||||
virtual void JustDied(Unit* /*killer*/) {}
|
||||
|
||||
// Called when the creature kills a unit
|
||||
virtual void KilledUnit(Unit *) {}
|
||||
virtual void KilledUnit(Unit* /*victim*/) {}
|
||||
|
||||
// Called when the creature summon successfully other creature
|
||||
virtual void JustSummoned(Creature*) {}
|
||||
virtual void IsSummonedBy(Unit * /*summoner*/) {}
|
||||
virtual void JustSummoned(Creature* /*summon*/) {}
|
||||
virtual void IsSummonedBy(Unit* /*summoner*/) {}
|
||||
|
||||
virtual void SummonedCreatureDespawn(Creature* /*unit*/) {}
|
||||
virtual void SummonedCreatureDies(Creature* /*unit*/, Unit* /*killer*/) {}
|
||||
virtual void SummonedCreatureDespawn(Creature* /*summon*/) {}
|
||||
virtual void SummonedCreatureDies(Creature* /*summon*/, Unit* /*killer*/) {}
|
||||
|
||||
// Called when hit by a spell
|
||||
virtual void SpellHit(Unit*, const SpellEntry*) {}
|
||||
virtual void SpellHit(Unit* /*caster*/, SpellEntry const* /*spell*/) {}
|
||||
|
||||
// Called when spell hits a target
|
||||
virtual void SpellHitTarget(Unit* /*target*/, const SpellEntry*) {}
|
||||
virtual void SpellHitTarget(Unit* /*target*/, SpellEntry const* /*spell*/) {}
|
||||
|
||||
// Called to get trigger target for aura effect
|
||||
virtual Unit * GetAuraEffectTriggerTarget(uint32 /*spellId*/, uint8 /*effIndex*/) {return NULL;}
|
||||
virtual Unit* GetAuraEffectTriggerTarget(uint32 /*spellId*/, uint8 /*effIndex*/) { return NULL; }
|
||||
|
||||
// Called when the creature is target of hostile action: swing, hostile spell landed, fear/etc)
|
||||
//virtual void AttackedBy(Unit* attacker);
|
||||
@@ -127,7 +127,7 @@ class CreatureAI : public UnitAI
|
||||
virtual void JustRespawned() { Reset(); }
|
||||
|
||||
// Called at waypoint reached or point movement finished
|
||||
virtual void MovementInform(uint32 /*MovementType*/, uint32 /*Data*/) {}
|
||||
virtual void MovementInform(uint32 /*type*/, uint32 /*id*/) {}
|
||||
|
||||
void OnCharmed(bool apply);
|
||||
|
||||
@@ -136,10 +136,10 @@ class CreatureAI : public UnitAI
|
||||
// Called at reaching home after evade
|
||||
virtual void JustReachedHome() {}
|
||||
|
||||
void DoZoneInCombat(Creature* pUnit = NULL);
|
||||
void DoZoneInCombat(Creature* creature = NULL);
|
||||
|
||||
// Called at text emote receive from player
|
||||
virtual void ReceiveEmote(Player* /*pPlayer*/, uint32 /*text_emote*/) {}
|
||||
virtual void ReceiveEmote(Player* /*player*/, uint32 /*emoteId*/) {}
|
||||
|
||||
/// == Triggered Actions Requested ==================
|
||||
|
||||
@@ -156,7 +156,7 @@ class CreatureAI : public UnitAI
|
||||
//virtual bool IsVisible(Unit *) const { return false; }
|
||||
|
||||
// called when the corpse of this creature gets removed
|
||||
virtual void CorpseRemoved(uint32 & /*respawnDelay*/) {}
|
||||
virtual void CorpseRemoved(uint32& /*respawnDelay*/) {}
|
||||
|
||||
// Called when victim entered water and creature can not enter water
|
||||
//virtual bool canReachByRangeAttack(Unit*) { return false; }
|
||||
@@ -166,11 +166,11 @@ class CreatureAI : public UnitAI
|
||||
// Pointer to controlled by AI creature
|
||||
//Creature* const me;
|
||||
|
||||
virtual void PassengerBoarded(Unit * /*who*/, int8 /*seatId*/, bool /*apply*/) {}
|
||||
virtual void PassengerBoarded(Unit* /*passenger*/, int8 /*seatId*/, bool /*apply*/) {}
|
||||
|
||||
virtual bool CanSeeAlways(WorldObject const* /*obj*/) { return false; }
|
||||
protected:
|
||||
virtual void MoveInLineOfSight(Unit *);
|
||||
virtual void MoveInLineOfSight(Unit* /*who*/);
|
||||
|
||||
bool _EnterEvadeMode();
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ void ScriptedAI::AttackStartNoMove(Unit* pWho)
|
||||
DoStartNoMovement(pWho);
|
||||
}
|
||||
|
||||
void ScriptedAI::UpdateAI(const uint32 /*uiDiff*/)
|
||||
void ScriptedAI::UpdateAI(uint32 const /*diff*/)
|
||||
{
|
||||
//Check if we have a current target
|
||||
if (!UpdateVictim())
|
||||
|
||||
@@ -57,7 +57,7 @@ struct ScriptedAI : public CreatureAI
|
||||
void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/) {}
|
||||
|
||||
//Called at World update tick
|
||||
void UpdateAI(const uint32);
|
||||
virtual void UpdateAI(uint32 const diff);
|
||||
|
||||
//Called at creature death
|
||||
void JustDied(Unit* /*killer*/) {}
|
||||
@@ -131,8 +131,6 @@ struct ScriptedAI : public CreatureAI
|
||||
void DoTeleportTo(float x, float y, float z, uint32 time = 0);
|
||||
void DoTeleportTo(float const pos[4]);
|
||||
|
||||
void DoAction(int32 const /*param*/) {}
|
||||
|
||||
//Teleports a player without dropping threat (only teleports to same map)
|
||||
void DoTeleportPlayer(Unit* unit, float x, float y, float z, float o);
|
||||
void DoTeleportAll(float x, float y, float z, float o);
|
||||
|
||||
@@ -1045,7 +1045,7 @@ public:
|
||||
else
|
||||
{
|
||||
if (Creature *car = Unit::GetCreature(*me, carGUID))
|
||||
car->AI()->DoAction();
|
||||
car->AI()->DoAction(0);
|
||||
IntroPhase = 0;
|
||||
}
|
||||
} else IntroTimer-=diff;
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
{
|
||||
pPlayer->CLOSE_GOSSIP_MENU();
|
||||
CAST_AI(npc_sergeant_bly::npc_sergeant_blyAI,pCreature->AI())->PlayerGUID = pPlayer->GetGUID();
|
||||
pCreature->AI()->DoAction();
|
||||
pCreature->AI()->DoAction(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
case 1:
|
||||
//weegli doesn't fight - he goes & blows up the door
|
||||
if (Creature* pWeegli = pInstance->instance->GetCreature(pInstance->GetData64(ENTRY_WEEGLI)))
|
||||
pWeegli->AI()->DoAction();
|
||||
pWeegli->AI()->DoAction(0);
|
||||
DoScriptText(SAY_1,me);
|
||||
Text_Timer = 5000;
|
||||
break;
|
||||
@@ -268,7 +268,7 @@ public:
|
||||
{
|
||||
pPlayer->CLOSE_GOSSIP_MENU();
|
||||
//here we make him run to door, set the charge and run away off to nowhere
|
||||
pCreature->AI()->DoAction();
|
||||
pCreature->AI()->DoAction(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user