*implement new creatureAI called: AOEAI

-it takes the spell1 from creature_template and casts on him self if aura not found, it can not attack or move
-creature becomes unattackable and invisible
NOTE: flag 128 should not be set in flags_extra field in creature_template, otherwise spells will be only visible to GMs

--HG--
branch : trunk
This commit is contained in:
Rat
2009-11-03 13:10:11 +01:00
parent ffb28c06a7
commit 609b8246f5
3 changed files with 46 additions and 0 deletions
+34
View File
@@ -54,6 +54,11 @@ int TurretAI::Permissible(const Creature *creature)
return PERMIT_BASE_NO; return PERMIT_BASE_NO;
} }
int AOEAI::Permissible(const Creature *creature)
{
return PERMIT_BASE_NO;
}
void CombatAI::InitializeAI() void CombatAI::InitializeAI()
{ {
for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i)
@@ -246,3 +251,32 @@ void TurretAI::UpdateAI(const uint32 diff)
//if(HostilReference *ref = me->getThreatManager().getCurrentVictim()) //if(HostilReference *ref = me->getThreatManager().getCurrentVictim())
//ref->removeReference(); //ref->removeReference();
} }
//////////////
//AOEAI
//////////////
AOEAI::AOEAI(Creature *c) : CreatureAI(c)
{
ASSERT(me->m_spells[0]);
me->SetVisibility(VISIBILITY_ON);//visible to see all spell anims
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);//can't be targeted
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_1);//can't be damaged
me->SetDisplayId(11686);//invisible model,around a size of a player
}
bool AOEAI::CanAIAttack(const Unit *who) const
{
return false;
}
void AOEAI::AttackStart(Unit *who)
{
}
void AOEAI::UpdateAI(const uint32 diff)
{
if(!me->HasAura(me->m_spells[0]))
me->CastSpell(me, me->m_spells[0],false);
}
+11
View File
@@ -90,4 +90,15 @@ struct TRINITY_DLL_SPEC TurretAI : public CreatureAI
float m_minRange; float m_minRange;
}; };
struct TRINITY_DLL_SPEC AOEAI : public CreatureAI
{
public:
explicit AOEAI(Creature *c);
bool CanAIAttack(const Unit *who) const;
void AttackStart(Unit *who);
void UpdateAI(const uint32 diff);
static int Permissible(const Creature *);
};
#endif #endif
+1
View File
@@ -49,6 +49,7 @@ namespace AIRegistry
(new CreatureAIFactory<ArchorAI>("ArchorAI"))->RegisterSelf(); (new CreatureAIFactory<ArchorAI>("ArchorAI"))->RegisterSelf();
(new CreatureAIFactory<TurretAI>("TurretAI"))->RegisterSelf(); (new CreatureAIFactory<TurretAI>("TurretAI"))->RegisterSelf();
(new CreatureAIFactory<CreatureEventAI>("EventAI"))->RegisterSelf(); (new CreatureAIFactory<CreatureEventAI>("EventAI"))->RegisterSelf();
(new CreatureAIFactory<AOEAI>("AOEAI"))->RegisterSelf();
(new MovementGeneratorFactory<RandomMovementGenerator<Creature> >(RANDOM_MOTION_TYPE))->RegisterSelf(); (new MovementGeneratorFactory<RandomMovementGenerator<Creature> >(RANDOM_MOTION_TYPE))->RegisterSelf();
(new MovementGeneratorFactory<WaypointMovementGenerator<Creature> >(WAYPOINT_MOTION_TYPE))->RegisterSelf(); (new MovementGeneratorFactory<WaypointMovementGenerator<Creature> >(WAYPOINT_MOTION_TYPE))->RegisterSelf();