* 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
@@ -29,7 +29,6 @@ EndScriptData */
#define GETGO(obj, guid) GameObject* obj = pInstance->instance->GetGameObject(guid)
#define GETUNIT(unit, guid) Unit* unit = Unit::GetUnit(*me, guid)
#define GETCRE(cre, guid) Creature* cre = Unit::GetCreature(*me, guid)
#define HPPCT(unit) unit->GetHealth()*100 / unit->GetMaxHealth()
/************* Quotes and Sounds ***********************/
// Gossip for when a player clicks Akama
@@ -967,17 +966,17 @@ public:
switch(Phase)
{
case PHASE_NORMAL:
if (HPPCT(me) < 65)
if (HealthBelowPct(65))
EnterPhase(PHASE_FLIGHT_SEQUENCE);
break;
case PHASE_NORMAL_2:
if (HPPCT(me) < 30)
if (HealthBelowPct(30))
EnterPhase(PHASE_TALK_SEQUENCE);
break;
case PHASE_NORMAL_MAIEV:
if (HPPCT(me) < 1)
if (HealthBelowPct(1))
EnterPhase(PHASE_TALK_SEQUENCE);
break;
@@ -1193,7 +1192,7 @@ public:
{
GETUNIT(Illidan, IllidanGUID);
if (Illidan && Illidan->getVictim() == me)
damage = me->GetMaxHealth()/10;
damage = me->CountPctFromMaxHealth(10);
if (damage >= me->GetHealth())
damage = 0;
}
@@ -1230,7 +1229,7 @@ public:
case PHASE_TALK_SEQUENCE:
if (Timer[EVENT_MAIEV_STEALTH])
{
me->SetHealth(me->GetMaxHealth());
me->SetFullHealth();
me->SetVisibility(VISIBILITY_ON);
Timer[EVENT_MAIEV_STEALTH] = 0;
}
@@ -1308,7 +1307,7 @@ public:
{
case EVENT_MAIEV_STEALTH:
{
me->SetHealth(me->GetMaxHealth());
me->SetFullHealth();
me->SetVisibility(VISIBILITY_ON);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
Timer[EVENT_MAIEV_STEALTH] = 0;
@@ -1349,7 +1348,7 @@ public:
break;
}
if (me->GetHealth()*100 / me->GetMaxHealth() < 50)
if (HealthBelowPct(50))
{
me->SetVisibility(VISIBILITY_OFF);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
@@ -1759,7 +1758,7 @@ public:
case PHASE_FIGHT_ILLIDAN:
{
GETUNIT(Illidan, IllidanGUID);
if (Illidan && HPPCT(Illidan) < 90)
if (Illidan && Illidan->HealthBelowPct(90))
EnterPhase(PHASE_TALK);
else
{
@@ -1783,7 +1782,7 @@ public:
}
Timer = 10000 + rand()%6000;
GETUNIT(Illidan, IllidanGUID);
if (Illidan && HPPCT(Illidan) < 10)
if (Illidan && Illidan->HealthBelowPct(10))
EnterPhase(PHASE_RETURN);
}
break;
@@ -1795,7 +1794,7 @@ public:
if (!UpdateVictim())
return;
if (me->GetHealth()*100 / me->GetMaxHealth() < 20)
if (HealthBelowPct(20))
DoCast(me, SPELL_HEALING_POTION);
DoMeleeAttackIfReady();
@@ -180,7 +180,7 @@ public:
if (!UpdateVictim())
return;
if (((me->GetHealth()*100 / me->GetMaxHealth()) < 10) && !Enraged)
if (HealthBelowPct(10) && !Enraged)
{
Enraged = true;
DoCast(me, SPELL_ENRAGE, true);
@@ -502,7 +502,7 @@ public:
me->RemoveAllAuras();
me->DeleteThreatList();
me->CombatStop();
//me->SetHealth(me->GetMaxHealth());
//me->SetFullHealth();
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
me->GetMotionMaster()->MoveTargetedHome();
}
@@ -713,7 +713,7 @@ public:
if (!EventBegun)
return;
if ((me->GetHealth()*100 / me->GetMaxHealth()) < 15 && !HasYelledOnce)
if (HealthBelowPct(15) && !HasYelledOnce)
{
DoScriptText(SAY_LOW_HEALTH, me);
HasYelledOnce = true;
@@ -439,7 +439,7 @@ struct boss_illidari_councilAI : public ScriptedAI
if (Creature* pUnit = Unit::GetCreature(*me, Council[i]))
if (pUnit != me && damage < pUnit->GetHealth())
{
pUnit->SetHealth(pUnit->GetHealth() - damage);
pUnit->ModifyHealth(-int32(damage));
pUnit->LowerPlayerDamageReq(damage);
}
}