Make some cleanup.

My thank goes to Az@zel for the code analysis.

--HG--
branch : trunk
This commit is contained in:
Anubisss
2010-12-16 18:08:23 +01:00
parent bb7bd9ef45
commit 6d9029c12e
14 changed files with 56 additions and 95 deletions
@@ -184,7 +184,7 @@ public:
void Reset()
{
summons.DespawnAll();
DespawnAllImp();
}
void JustSummoned(Creature* summon)
@@ -125,8 +125,10 @@ public:
DrainLifeTimer = 3000 + rand()%4000;
DrainManaTimer = DrainLifeTimer + 5000;
FelExplosionTimer = 2100;
DrainCrystalTimer = 10000 + rand()%5000;
DrainCrystalTimer = 20000 + rand()%5000;
if (IsHeroic())
DrainCrystalTimer = 10000 + rand()%5000;
else
DrainCrystalTimer = 20000 + rand()%5000;
EmpowerTimer = 10000;
IsDraining = false;
@@ -104,17 +104,17 @@ public:
ai->Reset();
ai->EnterEvadeMode();
ai->Spell[0].SpellId = SPELL_BLIZZARD;
ai->Spell[0].Cooldown = 15000 + rand()%20000;
ai->Spell[0].TargetType = TARGETTYPE_RANDOM;
ai->Spells[0].SpellId = SPELL_BLIZZARD;
ai->Spells[0].Cooldown = 15000 + rand()%20000;
ai->Spells[0].TargetType = TARGETTYPE_RANDOM;
ai->Spell[1].SpellId = SPELL_PYROBLAST;
ai->Spell[1].Cooldown = 5500 + rand()%4000;
ai->Spell[1].TargetType = TARGETTYPE_RANDOM;
ai->Spells[1].SpellId = SPELL_PYROBLAST;
ai->Spells[1].Cooldown = 5500 + rand()%4000;
ai->Spells[1].TargetType = TARGETTYPE_RANDOM;
ai->Spell[2].SpellId = SPELL_SUMMON_ELEMENTALS;
ai->Spell[2].Cooldown = 15000 + rand()%30000;
ai->Spell[2].TargetType = TARGETTYPE_SELF;
ai->Spells[2].SpellId = SPELL_SUMMON_ELEMENTALS;
ai->Spells[2].Cooldown = 15000 + rand()%30000;
ai->Spells[2].TargetType = TARGETTYPE_SELF;
return ai;
}
@@ -188,13 +188,13 @@ public:
ai->Reset();
ai->EnterEvadeMode();
ai->Spell[0].SpellId = SPELL_CHAIN_LIGHTNING;
ai->Spell[0].Cooldown = 3000 + rand()%5000;
ai->Spell[0].TargetType = TARGETTYPE_VICTIM;
ai->Spells[0].SpellId = SPELL_CHAIN_LIGHTNING;
ai->Spells[0].Cooldown = 3000 + rand()%5000;
ai->Spells[0].TargetType = TARGETTYPE_VICTIM;
ai->Spell[1].SpellId = SPELL_SUMMON_DIRE_WOLF;
ai->Spell[1].Cooldown = 6000 + rand()%35000;
ai->Spell[1].TargetType = TARGETTYPE_RANDOM;
ai->Spells[1].SpellId = SPELL_SUMMON_DIRE_WOLF;
ai->Spells[1].Cooldown = 6000 + rand()%35000;
ai->Spells[1].TargetType = TARGETTYPE_RANDOM;
return ai;
}
@@ -389,7 +389,7 @@ void hyjalAI::Reset()
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
//Initialize spells
memset(Spell, 0, sizeof(Spell));
memset(Spells, 0, sizeof(Spell) * HYJAL_AI_MAX_SPELLS);
//Reset Instance Data for trash count
if (pInstance)
@@ -425,9 +425,9 @@ void hyjalAI::EnterEvadeMode()
void hyjalAI::EnterCombat(Unit * /*who*/)
{
if (IsDummy)return;
for (uint8 i = 0; i < 3; ++i)
if (Spell[i].Cooldown)
SpellTimer[i] = Spell[i].Cooldown;
for (uint8 i = 0; i < HYJAL_AI_MAX_SPELLS; ++i)
if (Spells[i].Cooldown)
SpellTimer[i] = Spells[i].Cooldown;
Talk(ATTACKED);
}
@@ -881,9 +881,9 @@ void hyjalAI::UpdateAI(const uint32 diff)
if (!UpdateVictim())
return;
for (uint8 i = 0; i < 3; ++i)
for (uint8 i = 0; i < HYJAL_AI_MAX_SPELLS; ++i)
{
if (Spell[i].SpellId)
if (Spells[i].SpellId)
{
if (SpellTimer[i] <= diff)
{
@@ -892,7 +892,7 @@ void hyjalAI::UpdateAI(const uint32 diff)
Unit *pTarget = NULL;
switch(Spell[i].TargetType)
switch(Spells[i].TargetType)
{
case TARGETTYPE_SELF: pTarget = me; break;
case TARGETTYPE_RANDOM: pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0); break;
@@ -901,8 +901,8 @@ void hyjalAI::UpdateAI(const uint32 diff)
if (pTarget && pTarget->isAlive())
{
DoCast(pTarget, Spell[i].SpellId);
SpellTimer[i] = Spell[i].Cooldown;
DoCast(pTarget, Spells[i].SpellId);
SpellTimer[i] = Spells[i].Cooldown;
}
} else SpellTimer[i] -= diff;
}
@@ -22,6 +22,8 @@
#include "hyjal.h"
#include "ScriptedEscortAI.h"
#define HYJAL_AI_MAX_SPELLS 3
// Trash Mobs summoned in waves
#define NECROMANCER 17899//done
#define ABOMINATION 17898//done
@@ -252,7 +254,7 @@ struct hyjalAI : public npc_escortAI
uint32 SpellId;
uint32 Cooldown;
uint32 TargetType;
}Spell[3];
} Spells[HYJAL_AI_MAX_SPELLS];
private:
uint32 SpellTimer[3];
@@ -79,8 +79,8 @@ public:
case 0: RandX = 0.0f - Rand; break;
case 1: RandX = 0.0f + Rand; break;
}
Rand = 0;
Rand = 10 + (rand()%10);
Rand = 10 + (rand()%10);
switch (rand()%2)
{
case 0: RandY = 0.0f - Rand; break;
@@ -1194,7 +1194,7 @@ public:
m_uiShadowBreathTimer -= uiDiff;
// Don't attack current target if he's not visible for us.
if(me->getVictim() && me->getVictim() && me->getVictim()->HasAura(57874, 0))
if(me->getVictim() && me->getVictim()->HasAura(57874, 0))
me->getThreatManager().modifyThreatPercent(me->getVictim(), -100);
DoMeleeAttackIfReady();