* add helping methods for manipulating unit's health and use it where applicable
* fix some conversion warnings and cleanup code (formatting, CRLF, tabs to spaces)

--HG--
branch : trunk
This commit is contained in:
azazel
2010-08-26 01:20:57 +06:00
parent bb5f7b6492
commit 341e6303ef
166 changed files with 445 additions and 416 deletions
@@ -265,7 +265,7 @@ class boss_alar : public CreatureScript
return;
case WE_REVIVE:
me->SetUInt32Value(UNIT_FIELD_BYTES_1, UNIT_STAND_STATE_STAND);
me->SetHealth(me->GetMaxHealth());
me->SetFullHealth();
me->SetSpeed(MOVE_RUN, DefaultMoveSpeedRate);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
DoZoneInCombat();
@@ -502,7 +502,7 @@ class mob_ember_of_alar : public CreatureScript
{
if (Unit* Alar = Unit::GetUnit((*me), pInstance->GetData64(DATA_ALAR)))
{
int AlarHealth = Alar->GetHealth() - Alar->GetMaxHealth()*0.03f;
int32 AlarHealth = int32(Alar->GetHealth()) - int32(Alar->CountPctFromMaxHealth(3));
if (AlarHealth > 0)
Alar->SetHealth(AlarHealth);
else
@@ -384,7 +384,7 @@ class boss_high_astromancer_solarian : public CreatureScript
VoidBolt_Timer -= diff;
}
//When Solarian reaches 20% she will transform into a huge void walker.
if (Phase != 4 && ((me->GetHealth()*100 / me->GetMaxHealth())<20))
if (Phase != 4 && me->HealthBelowPct(20))
{
Phase = 4;
//To make sure she wont be invisible or not selecatble
@@ -201,7 +201,7 @@ struct advisorbase_ai : public ScriptedAI
// double health for phase 3
me->SetMaxHealth(me->GetMaxHealth() * 2);
m_bDoubled_Health = true;
me->SetHealth(me->GetMaxHealth());
me->SetFullHealth();
me->SetStandState(UNIT_STAND_STATE_STAND);
DoCast(me, SPELL_RES_VISUAL, false);
@@ -809,7 +809,7 @@ class boss_kaelthas : public CreatureScript
//Phase 4 specific spells
if (Phase == 4)
{
if (me->GetHealth()*100 / me->GetMaxHealth() < 50)
if (HealthBelowPct(50))
{
if (m_pInstance)
m_pInstance->SetData(DATA_KAELTHASEVENT, 4);
@@ -1501,7 +1501,7 @@ class mob_phoenix_tk : public CreatureScript
//spell Burn should possible do this, but it doesn't, so do this for now.
uint32 dmg = urand(4500,5500);
if (me->GetHealth() > dmg)
me->SetHealth(uint32(me->GetHealth()-dmg));
me->ModifyHealth(-int32(dmg));
Cycle_Timer = 2000;
}
else
@@ -180,7 +180,7 @@ class boss_pathaleon_the_calculator : public CreatureScript
ArcaneExplosion_Timer -= diff;
}
if (!Enraged && me->GetHealth()*100 / me->GetMaxHealth() < 21)
if (!Enraged && HealthBelowPct(21))
{
DoCast(me, SPELL_FRENZY);
DoScriptText(SAY_ENRAGE, me);
@@ -190,7 +190,7 @@ class npc_millhouse_manastorm : public CreatureScript
if (!UpdateVictim())
return;
if (!LowHp && ((me->GetHealth()*100 / me->GetMaxHealth()) < 20))
if (!LowHp && HealthBelowPct(20))
{
DoScriptText(SAY_LOWHP, me);
LowHp = true;
@@ -125,9 +125,9 @@ class boss_harbinger_skyriss : public CreatureScript
if (!summon)
return;
if (IsImage66)
summon->SetHealth((summon->GetMaxHealth()*33)/100);
summon->SetHealth(summon->CountPctFromMaxHealth(33));
else
summon->SetHealth((summon->GetMaxHealth()*66)/100);
summon->SetHealth(summon->CountPctFromMaxHealth(66));
if (me->getVictim())
if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
summon->AI()->AttackStart(pTarget);
@@ -196,12 +196,12 @@ class boss_harbinger_skyriss : public CreatureScript
if (!UpdateVictim())
return;
if (!IsImage66 && ((me->GetHealth()*100) / me->GetMaxHealth() <= 66))
if (!IsImage66 && !HealthAbovePct(66))
{
DoSplit(66);
IsImage66 = true;
}
if (!IsImage33 && ((me->GetHealth()*100) / me->GetMaxHealth() <= 33))
if (!IsImage33 && !HealthAbovePct(33))
{
DoSplit(33);
IsImage33 = true;