*Rename some ai functions.
--HG-- branch : trunk
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
#include "sc_creature.h"
|
||||
#include "sc_gossip.h"
|
||||
#include "sc_instance.h"
|
||||
#include "AggressorAI.h"
|
||||
#include "NullCreatureAI.h"
|
||||
#include "CombatAI.h"
|
||||
#include "PassiveAI.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
|
||||
@@ -336,9 +336,9 @@ int32 m_auiRandomSay[] =
|
||||
SAY_DUEL_A, SAY_DUEL_B, SAY_DUEL_C, SAY_DUEL_D, SAY_DUEL_E, SAY_DUEL_F, SAY_DUEL_G, SAY_DUEL_H, SAY_DUEL_I
|
||||
};
|
||||
|
||||
struct TRINITY_DLL_DECL npc_death_knight_initiateAI : public SpellAI
|
||||
struct TRINITY_DLL_DECL npc_death_knight_initiateAI : public CombatAI
|
||||
{
|
||||
npc_death_knight_initiateAI(Creature* pCreature) : SpellAI(pCreature)
|
||||
npc_death_knight_initiateAI(Creature* pCreature) : CombatAI(pCreature)
|
||||
{
|
||||
m_bIsDuelInProgress = false;
|
||||
}
|
||||
@@ -352,7 +352,7 @@ struct TRINITY_DLL_DECL npc_death_knight_initiateAI : public SpellAI
|
||||
{
|
||||
lose = false;
|
||||
me->RestoreFaction();
|
||||
SpellAI::Reset();
|
||||
CombatAI::Reset();
|
||||
|
||||
m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_15);
|
||||
|
||||
@@ -432,7 +432,7 @@ struct TRINITY_DLL_DECL npc_death_knight_initiateAI : public SpellAI
|
||||
|
||||
// TODO: spells
|
||||
|
||||
SpellAI::UpdateAI(uiDiff);
|
||||
CombatAI::UpdateAI(uiDiff);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -249,9 +249,9 @@ struct TRINITY_DLL_DECL boss_gothikAI : public BossAI
|
||||
}
|
||||
};
|
||||
|
||||
struct TRINITY_DLL_DECL mob_gothik_minionAI : public SpellAI
|
||||
struct TRINITY_DLL_DECL mob_gothik_minionAI : public CombatAI
|
||||
{
|
||||
mob_gothik_minionAI(Creature *c) : SpellAI(c)
|
||||
mob_gothik_minionAI(Creature *c) : CombatAI(c)
|
||||
{
|
||||
liveSide = me->GetPositionY() < POS_Y_GATE;
|
||||
}
|
||||
@@ -277,7 +277,7 @@ struct TRINITY_DLL_DECL mob_gothik_minionAI : public SpellAI
|
||||
if (me->isSummon())
|
||||
{
|
||||
if (Unit *owner = CAST_SUM(me)->GetSummoner())
|
||||
SpellAI::JustDied(owner);
|
||||
CombatAI::JustDied(owner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ struct TRINITY_DLL_DECL mob_gothik_minionAI : public SpellAI
|
||||
{
|
||||
if (!gateClose)
|
||||
{
|
||||
SpellAI::EnterEvadeMode();
|
||||
CombatAI::EnterEvadeMode();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ struct TRINITY_DLL_DECL mob_gothik_minionAI : public SpellAI
|
||||
return;
|
||||
}
|
||||
|
||||
SpellAI::UpdateAI(diff);
|
||||
CombatAI::UpdateAI(diff);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1673,13 +1673,13 @@ CreatureAI* GetAI_mob_mojo(Creature* pCreature)
|
||||
return new mob_mojoAI (pCreature);
|
||||
}
|
||||
|
||||
struct TRINITY_DLL_DECL npc_mirror_image : SpellCasterAI
|
||||
struct TRINITY_DLL_DECL npc_mirror_image : CasterAI
|
||||
{
|
||||
npc_mirror_image(Creature *c) : SpellCasterAI(c) {}
|
||||
npc_mirror_image(Creature *c) : CasterAI(c) {}
|
||||
|
||||
void InitializeAI()
|
||||
{
|
||||
SpellCasterAI::InitializeAI();
|
||||
CasterAI::InitializeAI();
|
||||
Unit * owner = me->GetOwner();
|
||||
if (!owner)
|
||||
return;
|
||||
@@ -1713,15 +1713,15 @@ CreatureAI* GetAI_npc_mirror_image(Creature* pCreature)
|
||||
return new npc_mirror_image (pCreature);
|
||||
}
|
||||
|
||||
struct TRINITY_DLL_DECL npc_ebon_gargoyleAI : SpellCasterAI
|
||||
struct TRINITY_DLL_DECL npc_ebon_gargoyleAI : CasterAI
|
||||
{
|
||||
npc_ebon_gargoyleAI(Creature *c) : SpellCasterAI(c) {}
|
||||
npc_ebon_gargoyleAI(Creature *c) : CasterAI(c) {}
|
||||
|
||||
int despawnTimer;
|
||||
|
||||
void InitializeAI()
|
||||
{
|
||||
SpellCasterAI::InitializeAI();
|
||||
CasterAI::InitializeAI();
|
||||
Unit * owner = me->GetOwner();
|
||||
if (!owner)
|
||||
return;
|
||||
@@ -1789,7 +1789,7 @@ struct TRINITY_DLL_DECL npc_ebon_gargoyleAI : SpellCasterAI
|
||||
}
|
||||
return;
|
||||
}
|
||||
SpellCasterAI::UpdateAI(diff);
|
||||
CasterAI::UpdateAI(diff);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "AggressorAI.h"
|
||||
#include "CombatAI.h"
|
||||
#include "SpellMgr.h"
|
||||
|
||||
int AggressorAI::Permissible(const Creature *creature)
|
||||
@@ -38,12 +38,12 @@ void AggressorAI::UpdateAI(const uint32 /*diff*/)
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
|
||||
int SpellAI::Permissible(const Creature *creature)
|
||||
int CombatAI::Permissible(const Creature *creature)
|
||||
{
|
||||
return PERMIT_BASE_NO;
|
||||
}
|
||||
|
||||
void SpellAI::InitializeAI()
|
||||
void CombatAI::InitializeAI()
|
||||
{
|
||||
for(uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
|
||||
if(me->m_spells[i] && GetSpellStore()->LookupEntry(me->m_spells[i]))
|
||||
@@ -52,19 +52,19 @@ void SpellAI::InitializeAI()
|
||||
CreatureAI::InitializeAI();
|
||||
}
|
||||
|
||||
void SpellAI::Reset()
|
||||
void CombatAI::Reset()
|
||||
{
|
||||
events.Reset();
|
||||
}
|
||||
|
||||
void SpellAI::JustDied(Unit *killer)
|
||||
void CombatAI::JustDied(Unit *killer)
|
||||
{
|
||||
for(SpellVct::iterator i = spells.begin(); i != spells.end(); ++i)
|
||||
if(AISpellInfo[*i].condition == AICOND_DIE)
|
||||
me->CastSpell(killer, *i, true);
|
||||
}
|
||||
|
||||
void SpellAI::EnterCombat(Unit *who)
|
||||
void CombatAI::EnterCombat(Unit *who)
|
||||
{
|
||||
for(SpellVct::iterator i = spells.begin(); i != spells.end(); ++i)
|
||||
{
|
||||
@@ -75,7 +75,7 @@ void SpellAI::EnterCombat(Unit *who)
|
||||
}
|
||||
}
|
||||
|
||||
void SpellAI::UpdateAI(const uint32 diff)
|
||||
void CombatAI::UpdateAI(const uint32 diff)
|
||||
{
|
||||
if(!UpdateVictim())
|
||||
return;
|
||||
@@ -94,25 +94,29 @@ void SpellAI::UpdateAI(const uint32 diff)
|
||||
DoMeleeAttackIfReady();
|
||||
}
|
||||
|
||||
void SpellCasterAI::InitializeAI()
|
||||
|
||||
/////////////////
|
||||
//CasterAI
|
||||
/////////////////
|
||||
|
||||
void CasterAI::InitializeAI()
|
||||
{
|
||||
SpellAI::InitializeAI();
|
||||
CombatAI::InitializeAI();
|
||||
|
||||
float m_attackDist = 30.0f;
|
||||
for(SpellVct::iterator itr = spells.begin(); itr != spells.end(); ++itr)
|
||||
{
|
||||
if (AISpellInfo[*itr].condition == AICOND_COMBAT && m_attackDist > GetAISpellInfo(*itr)->maxRange)
|
||||
m_attackDist = GetAISpellInfo(*itr)->maxRange;
|
||||
}
|
||||
if (m_attackDist == 30.0f)
|
||||
m_attackDist = MELEE_RANGE;
|
||||
}
|
||||
|
||||
void SpellCasterAI::EnterCombat(Unit *who)
|
||||
void CasterAI::EnterCombat(Unit *who)
|
||||
{
|
||||
if (spells.empty())
|
||||
return;
|
||||
|
||||
uint32 spell = rand() % spells.size();
|
||||
uint32 spell = rand()%spells.size();
|
||||
uint32 count = 0;
|
||||
for(SpellVct::iterator itr = spells.begin(); itr != spells.end(); ++itr, ++count)
|
||||
{
|
||||
@@ -131,7 +135,7 @@ void SpellCasterAI::EnterCombat(Unit *who)
|
||||
}
|
||||
}
|
||||
|
||||
void SpellCasterAI::UpdateAI(const uint32 diff)
|
||||
void CasterAI::UpdateAI(const uint32 diff)
|
||||
{
|
||||
if(!UpdateVictim())
|
||||
return;
|
||||
@@ -148,3 +152,60 @@ void SpellCasterAI::UpdateAI(const uint32 diff)
|
||||
events.ScheduleEvent(spellId, (casttime ? casttime : 500) + GetAISpellInfo(spellId)->realCooldown);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////
|
||||
//ArchorAI
|
||||
//////////////
|
||||
|
||||
ArchorAI::ArchorAI(Creature *c) : CreatureAI(c), m_canMelee(true)
|
||||
{
|
||||
assert(me->m_spells[0]);
|
||||
m_minRange = GetSpellMinRange(me->m_spells[0], false);
|
||||
m_maxRange = GetSpellMaxRange(me->m_spells[0], false);
|
||||
if(!m_minRange)
|
||||
m_minRange = MELEE_RANGE;
|
||||
}
|
||||
|
||||
void ArchorAI::MoveInLineOfSight(Unit *who)
|
||||
{
|
||||
if(!me->getVictim() && me->canAttack(who)
|
||||
&& me->IsWithinCombatRange(who, m_maxRange)
|
||||
&& me->IsWithinLOSInMap(who))
|
||||
AttackStart(who);
|
||||
}
|
||||
|
||||
void ArchorAI::AttackStart(Unit *who)
|
||||
{
|
||||
if(who->IsFlying() || !me->IsWithinCombatRange(who, m_minRange))
|
||||
{
|
||||
if(me->Attack(who, false))
|
||||
me->GetMotionMaster()->MoveIdle();
|
||||
}
|
||||
else if(m_canMelee)
|
||||
{
|
||||
if(me->Attack(who, true))
|
||||
me->GetMotionMaster()->MoveChase(who);
|
||||
}
|
||||
}
|
||||
|
||||
void ArchorAI::UpdateAI(const uint32 diff)
|
||||
{
|
||||
if(!UpdateVictim())
|
||||
return;
|
||||
|
||||
if(me->getVictim()->IsFlying() || !me->IsWithinCombatRange(me->getVictim(), m_minRange))
|
||||
{
|
||||
if(!DoSpellAttackIfReady(me->m_spells[0]))
|
||||
{
|
||||
if(HostilReference *ref = me->getThreatManager().getCurrentVictim())
|
||||
ref->removeReference();
|
||||
else // i do not know when this could happen
|
||||
EnterEvadeMode();
|
||||
}
|
||||
}
|
||||
else if(m_canMelee)
|
||||
DoMeleeAttackIfReady();
|
||||
else if(HostilReference *ref = me->getThreatManager().getCurrentVictim())
|
||||
ref->removeReference();
|
||||
}
|
||||
@@ -18,8 +18,8 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef TRINITY_AGGRESSORAI_H
|
||||
#define TRINITY_AGGRESSORAI_H
|
||||
#ifndef TRINITY_COMBATAI_H
|
||||
#define TRINITY_COMBATAI_H
|
||||
|
||||
#include "CreatureAI.h"
|
||||
#include "CreatureAIImpl.h"
|
||||
@@ -37,10 +37,10 @@ class TRINITY_DLL_DECL AggressorAI : public CreatureAI
|
||||
|
||||
typedef std::vector<uint32> SpellVct;
|
||||
|
||||
class TRINITY_DLL_SPEC SpellAI : public CreatureAI
|
||||
class TRINITY_DLL_SPEC CombatAI : public CreatureAI
|
||||
{
|
||||
public:
|
||||
explicit SpellAI(Creature *c) : CreatureAI(c) {}
|
||||
explicit CombatAI(Creature *c) : CreatureAI(c) {}
|
||||
|
||||
void InitializeAI();
|
||||
void Reset();
|
||||
@@ -53,16 +53,28 @@ class TRINITY_DLL_SPEC SpellAI : public CreatureAI
|
||||
SpellVct spells;
|
||||
};
|
||||
|
||||
class TRINITY_DLL_SPEC SpellCasterAI : public SpellAI
|
||||
class TRINITY_DLL_SPEC CasterAI : public CombatAI
|
||||
{
|
||||
public:
|
||||
explicit SpellCasterAI(Creature *c) : SpellAI(c) {m_attackDist = MELEE_RANGE;}
|
||||
explicit CasterAI(Creature *c) : CombatAI(c) { m_attackDist = MELEE_RANGE; }
|
||||
void InitializeAI();
|
||||
void AttackStart(Unit * victim){SpellAI::AttackStartCaster(victim, m_attackDist);}
|
||||
void AttackStart(Unit * victim) { AttackStartCaster(victim, m_attackDist); }
|
||||
void UpdateAI(const uint32 diff);
|
||||
void EnterCombat(Unit *who);
|
||||
private:
|
||||
float m_attackDist;
|
||||
};
|
||||
|
||||
struct TRINITY_DLL_SPEC ArchorAI : public CreatureAI
|
||||
{
|
||||
public:
|
||||
explicit ArchorAI(Creature *c);
|
||||
void MoveInLineOfSight(Unit *who);
|
||||
void AttackStart(Unit *who);
|
||||
void UpdateAI(const uint32 diff);
|
||||
protected:
|
||||
float m_maxRange, m_minRange;
|
||||
bool m_canMelee;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -18,9 +18,9 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "NullCreatureAI.h"
|
||||
#include "PassiveAI.h"
|
||||
#include "ReactorAI.h"
|
||||
#include "AggressorAI.h"
|
||||
#include "CombatAI.h"
|
||||
#include "GuardAI.h"
|
||||
#include "PetAI.h"
|
||||
#include "TotemAI.h"
|
||||
@@ -45,7 +45,7 @@ namespace AIRegistry
|
||||
(new CreatureAIFactory<GuardAI>("GuardAI"))->RegisterSelf();
|
||||
(new CreatureAIFactory<PetAI>("PetAI"))->RegisterSelf();
|
||||
(new CreatureAIFactory<TotemAI>("TotemAI"))->RegisterSelf();
|
||||
(new CreatureAIFactory<SpellAI>("SpellAI"))->RegisterSelf();
|
||||
(new CreatureAIFactory<CombatAI>("CombatAI"))->RegisterSelf();
|
||||
(new CreatureAIFactory<CreatureEventAI>("EventAI"))->RegisterSelf();
|
||||
|
||||
(new MovementGeneratorFactory<RandomMovementGenerator<Creature> >(RANDOM_MOTION_TYPE))->RegisterSelf();
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "Creature.h"
|
||||
#include "CreatureAISelector.h"
|
||||
#include "NullCreatureAI.h"
|
||||
#include "PassiveAI.h"
|
||||
#include "Policies/SingletonImp.h"
|
||||
#include "MovementGenerator.h"
|
||||
#include "ScriptCalls.h"
|
||||
@@ -81,7 +81,7 @@ namespace FactorySelector
|
||||
{
|
||||
if(creature->m_spells[i])
|
||||
{
|
||||
ai_factory = ai_registry.GetRegistryItem("SpellAI");
|
||||
ai_factory = ai_registry.GetRegistryItem("CombatAI");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "NullCreatureAI.h"
|
||||
#include "PassiveAI.h"
|
||||
#include "Creature.h"
|
||||
#include "TemporarySummon.h"
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef TRINITY_NULLCREATUREAI_H
|
||||
#define TRINITY_NULLCREATUREAI_H
|
||||
#ifndef TRINITY_PASSIVEAI_H
|
||||
#define TRINITY_PASSIVEAI_H
|
||||
|
||||
#include "CreatureAI.h"
|
||||
#include "CreatureAIImpl.h"
|
||||
//#include "CreatureAIImpl.h"
|
||||
|
||||
class TRINITY_DLL_SPEC PassiveAI : public CreatureAI
|
||||
{
|
||||
@@ -160,18 +160,28 @@ inline float GetSpellRadius(SpellEntry const *spellInfo, uint32 effectIdx, bool
|
||||
? GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(spellInfo->EffectRadiusIndex[effectIdx]))
|
||||
: GetSpellRadiusForHostile(sSpellRadiusStore.LookupEntry(spellInfo->EffectRadiusIndex[effectIdx]));
|
||||
}
|
||||
|
||||
inline float GetSpellMaxRange(SpellEntry const *spellInfo, bool positive)
|
||||
{
|
||||
return positive
|
||||
? GetSpellMaxRangeForFriend(sSpellRangeStore.LookupEntry(spellInfo->rangeIndex))
|
||||
: GetSpellMaxRangeForHostile(sSpellRangeStore.LookupEntry(spellInfo->rangeIndex));
|
||||
}
|
||||
|
||||
inline float GetSpellMinRange(SpellEntry const *spellInfo, bool positive)
|
||||
{
|
||||
return positive
|
||||
? GetSpellMinRangeForFriend(sSpellRangeStore.LookupEntry(spellInfo->rangeIndex))
|
||||
: GetSpellMinRangeForHostile(sSpellRangeStore.LookupEntry(spellInfo->rangeIndex));
|
||||
}
|
||||
|
||||
inline float GetSpellMinRange(uint32 id, bool positive)
|
||||
{
|
||||
SpellEntry const *spellInfo = GetSpellStore()->LookupEntry(id);
|
||||
if(!spellInfo) return 0;
|
||||
return GetSpellMinRange(spellInfo, positive);
|
||||
}
|
||||
|
||||
inline float GetSpellMaxRange(uint32 id, bool positive)
|
||||
{
|
||||
SpellEntry const *spellInfo = GetSpellStore()->LookupEntry(id);
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
#include "Path.h"
|
||||
#include "CreatureGroups.h"
|
||||
#include "PetAI.h"
|
||||
#include "NullCreatureAI.h"
|
||||
#include "PassiveAI.h"
|
||||
#include "Traveller.h"
|
||||
#include "TemporarySummon.h"
|
||||
#include "Vehicle.h"
|
||||
|
||||
@@ -1514,11 +1514,11 @@
|
||||
Name="AI"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\src\game\AggressorAI.cpp"
|
||||
RelativePath="..\..\src\game\CombatAI.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\game\AggressorAI.h"
|
||||
RelativePath="..\..\src\game\CombatAI.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@@ -1578,11 +1578,11 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\game\NullCreatureAI.cpp"
|
||||
RelativePath="..\..\src\game\PassiveAI.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\game\NullCreatureAI.h"
|
||||
RelativePath="..\..\src\game\PassiveAI.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
||||
@@ -1507,11 +1507,11 @@
|
||||
Name="AI"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\src\game\AggressorAI.cpp"
|
||||
RelativePath="..\..\src\game\CombatAI.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\game\AggressorAI.h"
|
||||
RelativePath="..\..\src\game\CombatAI.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@@ -1571,11 +1571,11 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\game\NullCreatureAI.cpp"
|
||||
RelativePath="..\..\src\game\PassiveAI.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\game\NullCreatureAI.h"
|
||||
RelativePath="..\..\src\game\PassiveAI.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
||||
Reference in New Issue
Block a user