*Script for quest "An End To All Things..."

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-17 22:34:18 -05:00
parent 7c2db4f2a9
commit 6701d3d24f
7 changed files with 89 additions and 4 deletions
@@ -100,6 +100,54 @@ CreatureAI* GetAI_npc_valkyr_battle_maiden(Creature* pCreature)
return new npc_valkyr_battle_maidenAI (pCreature);
}
struct TRINITY_DLL_DECL mob_anti_airAI : public ScriptedAI
{
mob_anti_airAI(Creature *c) : ScriptedAI(c)
{
assert(me->m_spells[0]);
range = DoGetSpellMaxRange(me->m_spells[0]);
}
float range;
void MoveInLineOfSight(Unit *who)
{
if(!me->getVictim() && me->canAttack(who)
&& me->IsWithinCombatRange(who, range)
&& me->IsWithinLOSInMap(who))
AttackStart(who);
}
void AttackStart(Unit *who)
{
if(who->IsFlying() || !me->IsWithinMeleeRange(who))
{
if(me->Attack(who, false))
me->GetMotionMaster()->MoveIdle();
}
else if(me->Attack(who, true))
me->GetMotionMaster()->MoveChase(who);
}
void UpdateAI(const uint32 diff)
{
if(!UpdateVictim())
return;
if(me->getVictim()->IsFlying() || !me->IsWithinMeleeRange(me->getVictim()))
{
if(!DoSpellAttackIfReady(me->m_spells[0]))
EnterEvadeMode();
}
else
DoMeleeAttackIfReady();
}
};
CreatureAI* GetAI_mob_anti_air(Creature* pCreature)
{
return new mob_anti_airAI (pCreature);
}
void AddSC_the_scarlet_enclave()
{
@@ -109,4 +157,9 @@ void AddSC_the_scarlet_enclave()
newscript->Name="npc_valkyr_battle_maiden";
newscript->GetAI = &GetAI_npc_valkyr_battle_maiden;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name="mob_anti_air";
newscript->GetAI = &GetAI_mob_anti_air;
newscript->RegisterSelf();
}
+12 -3
View File
@@ -8152,10 +8152,19 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
if (m_attacking == victim)
{
// switch to melee attack from ranged/magic
if( meleeAttack && !hasUnitState(UNIT_STAT_MELEE_ATTACKING) )
if(meleeAttack)
{
addUnitState(UNIT_STAT_MELEE_ATTACKING);
SendMeleeAttackStart(victim);
if(!hasUnitState(UNIT_STAT_MELEE_ATTACKING))
{
addUnitState(UNIT_STAT_MELEE_ATTACKING);
SendMeleeAttackStart(victim);
return true;
}
}
else if(hasUnitState(UNIT_STAT_MELEE_ATTACKING))
{
clearUnitState(UNIT_STAT_MELEE_ATTACKING);
SendMeleeAttackStop(victim);
return true;
}
return false;
+5
View File
@@ -223,6 +223,11 @@ void UnitAI::SelectTargetList(std::list<Unit*> &targetList, uint32 num, SelectAg
}
}
float UnitAI::DoGetSpellMaxRange(uint32 spellId, bool positive)
{
return GetSpellMaxRange(spellId, positive);
}
void UnitAI::DoCast(uint32 spellId)
{
Unit *target = NULL;
+2
View File
@@ -69,6 +69,8 @@ class TRINITY_DLL_SPEC UnitAI
void DoCast(Unit* victim, uint32 spellId, bool triggered = false);
void DoCastAOE(uint32 spellId, bool triggered = false);
float DoGetSpellMaxRange(uint32 spellId, bool positive = false);
void DoMeleeAttackIfReady();
bool DoSpellAttackIfReady(uint32 spell);