Core:
* 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:
@@ -116,7 +116,7 @@ public:
|
||||
{
|
||||
if (Unit* Archimonde = Unit::GetUnit((*me), ArchimondeGUID))
|
||||
{
|
||||
if ((((Archimonde->GetHealth()*100) / Archimonde->GetMaxHealth()) < 2) || !Archimonde->isAlive())
|
||||
if (Archimonde->HealthBelowPct(2) || !Archimonde->isAlive())
|
||||
DoCast(me, SPELL_DENOUEMENT_WISP);
|
||||
else
|
||||
DoCast(Archimonde, SPELL_ANCIENT_SPARK);
|
||||
@@ -504,14 +504,14 @@ public:
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
|
||||
if (((me->GetHealth()*100 / me->GetMaxHealth()) < 10) && !BelowTenPercent && !Enraged)
|
||||
if (me->HealthBelowPct(10) && !BelowTenPercent && !Enraged)
|
||||
BelowTenPercent = true;
|
||||
|
||||
if (!Enraged)
|
||||
{
|
||||
if (EnrageTimer <= diff)
|
||||
{
|
||||
if ((me->GetHealth()*100 / me->GetMaxHealth()) > 10)
|
||||
if (HealthAbovePct(10))
|
||||
{
|
||||
me->GetMotionMaster()->Clear(false);
|
||||
me->GetMotionMaster()->MoveIdle();
|
||||
|
||||
@@ -551,7 +551,7 @@ public:
|
||||
return;
|
||||
|
||||
//TODO: add his abilities'n-crap here
|
||||
if (!LowHp && ((me->GetHealth()*100 / me->GetMaxHealth()) < 20))
|
||||
if (!LowHp && HealthBelowPct(20))
|
||||
{
|
||||
DoScriptText(RAND(SAY_TH_RANDOM_LOW_HP1,SAY_TH_RANDOM_LOW_HP2), me);
|
||||
LowHp = true;
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
} else Trample_Timer -= diff;
|
||||
|
||||
//Landslide
|
||||
if (me->GetHealth()*100 / me->GetMaxHealth() < 50)
|
||||
if (HealthBelowPct(50))
|
||||
{
|
||||
if (Landslide_Timer <= diff)
|
||||
{
|
||||
|
||||
@@ -344,7 +344,7 @@ public:
|
||||
//Specific to PHASE_START || PHASE_END
|
||||
if (m_uiPhase == PHASE_START)
|
||||
{
|
||||
if (me->GetHealth()*100 / me->GetMaxHealth() < 60)
|
||||
if (HealthBelowPct(60))
|
||||
{
|
||||
SetCombatMovement(false);
|
||||
m_uiPhase = PHASE_BREATH;
|
||||
@@ -406,7 +406,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (me->GetHealth()*100 / me->GetMaxHealth() < 40)
|
||||
if (HealthBelowPct(40))
|
||||
{
|
||||
m_uiPhase = PHASE_END;
|
||||
if (m_pInstance)
|
||||
|
||||
@@ -102,20 +102,20 @@ public:
|
||||
FrostNova_Timer = 15000;
|
||||
} else FrostNova_Timer -= diff;
|
||||
|
||||
if (!Spectrals60 && me->GetHealth()*100 / me->GetMaxHealth() < 60)
|
||||
if (!Spectrals60 && HealthBelowPct(60))
|
||||
{
|
||||
DoScriptText(SAY_SUMMON60, me);
|
||||
DoCast(me->getVictim(), SPELL_FROST_SPECTRES);
|
||||
Spectrals60 = true;
|
||||
}
|
||||
|
||||
if (!Hp && me->GetHealth()*100 / me->GetMaxHealth() < 50)
|
||||
if (!Hp && HealthBelowPct(50))
|
||||
{
|
||||
DoScriptText(SAY_HP, me);
|
||||
Hp = true;
|
||||
}
|
||||
|
||||
if (!Spectrals30 && me->GetHealth()*100 / me->GetMaxHealth() < 30)
|
||||
if (!Spectrals30 && HealthBelowPct(30))
|
||||
{
|
||||
DoScriptText(SAY_SUMMON30, me);
|
||||
DoCast(me->getVictim(), SPELL_FROST_SPECTRES);
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
|
||||
uint32 m_auiEncounter[MAX_ENCOUNTER];
|
||||
|
||||
uint8 uiGongWaves;
|
||||
uint16 uiGongWaves;
|
||||
|
||||
std::string str_data;
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
return;
|
||||
|
||||
//If he is 70% start phase 2
|
||||
if (phase == 1 && me->GetHealth()*100 / me->GetMaxHealth() <= 70 && !me->IsNonMeleeSpellCasted(false))
|
||||
if (phase == 1 && !HealthAbovePct(70) && !me->IsNonMeleeSpellCasted(false))
|
||||
{
|
||||
phase=2;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
return;
|
||||
|
||||
//If we are <30% cast enrage
|
||||
if (!bIsEnraged && me->GetHealth()*100 / me->GetMaxHealth() <= 30 && !me->IsNonMeleeSpellCasted(false))
|
||||
if (!bIsEnraged && !HealthAbovePct(30) && !me->IsNonMeleeSpellCasted(false))
|
||||
{
|
||||
bIsEnraged = true;
|
||||
DoCast(me, SPELL_ENRAGE);
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
uint64 uiAyamiss;
|
||||
uint64 uiOssirian;
|
||||
|
||||
uint8 m_auiEncounter[MAX_ENCOUNTER];
|
||||
uint16 m_auiEncounter[MAX_ENCOUNTER];
|
||||
std::string str_data;
|
||||
|
||||
void Initialize()
|
||||
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
ToxicVolley_Timer = 10000 + rand()%5000;
|
||||
} else ToxicVolley_Timer -= diff;
|
||||
|
||||
if (me->GetHealth() <= me->GetMaxHealth() * 0.05 && !Death)
|
||||
if (!HealthAbovePct(5) && !Death)
|
||||
{
|
||||
DoCast(me->getVictim(), SPELL_POISON_CLOUD);
|
||||
Death = true;
|
||||
|
||||
@@ -357,9 +357,9 @@ public:
|
||||
{
|
||||
//Set angle and cast
|
||||
if (ClockWise)
|
||||
me->SetOrientation(DarkGlareAngle + ((float)DarkGlareTick*PI/35));
|
||||
me->SetOrientation(DarkGlareAngle + DarkGlareTick * M_PI / 35);
|
||||
else
|
||||
me->SetOrientation(DarkGlareAngle - ((float)DarkGlareTick*PI/35));
|
||||
me->SetOrientation(DarkGlareAngle - DarkGlareTick * M_PI / 35);
|
||||
|
||||
me->StopMoving();
|
||||
|
||||
@@ -666,7 +666,7 @@ public:
|
||||
//Switch to c'thun model
|
||||
me->InterruptNonMeleeSpells(false);
|
||||
DoCast(me, SPELL_TRANSFORM, false);
|
||||
me->SetHealth(me->GetMaxHealth());
|
||||
me->SetFullHealth();
|
||||
|
||||
me->SetVisibility(VISIBILITY_ON);
|
||||
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
|
||||
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
|
||||
// Teleporting Random Target to one of the three tunnels and spawn 4 hatchlings near the gamer.
|
||||
//We will only telport if fankriss has more than 3% of hp so teleported gamers can always loot.
|
||||
if (me->GetHealth()*100 / me->GetMaxHealth() > 3)
|
||||
if (HealthAbovePct(3))
|
||||
{
|
||||
if (SpawnHatchlings_Timer <= diff)
|
||||
{
|
||||
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
FrenzyBack_Timer = 15000;
|
||||
} else FrenzyBack_Timer -= diff;
|
||||
|
||||
if (!Berserk && me->GetHealth()*100 / me->GetMaxHealth() < 31)
|
||||
if (!Berserk && HealthBelowPct(31))
|
||||
{
|
||||
me->InterruptNonMeleeSpells(false);
|
||||
DoScriptText(EMOTE_GENERIC_BERSERK, me);
|
||||
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
//If she is 20% enrage
|
||||
if (!Enraged)
|
||||
{
|
||||
if (me->GetHealth()*100 / me->GetMaxHealth() <= 20 && !me->IsNonMeleeSpellCasted(false))
|
||||
if (!HealthAbovePct(20) && !me->IsNonMeleeSpellCasted(false))
|
||||
{
|
||||
DoCast(me, SPELL_ENRAGE);
|
||||
Enraged = true;
|
||||
|
||||
@@ -174,15 +174,14 @@ public:
|
||||
Blink_Timer= 20000 + rand()%20000;
|
||||
} else Blink_Timer -= diff;
|
||||
|
||||
int procent = (int) (me->GetHealth()*100 / me->GetMaxHealth() +0.5f);
|
||||
int procent = (int) (me->GetHealthPct() + 0.5f);
|
||||
|
||||
//Summoning 2 Images and teleporting to a random position on 75% health
|
||||
if ((!Images75 && !IsImage) && (procent <= 75 && procent > 70))
|
||||
DoSplit(75);
|
||||
|
||||
//Summoning 2 Images and teleporting to a random position on 50% health
|
||||
if ((!Images50 && !IsImage) &&
|
||||
(procent <= 50 && procent > 45))
|
||||
if ((!Images50 && !IsImage) && (procent <= 50 && procent > 45))
|
||||
DoSplit(50);
|
||||
|
||||
//Summoning 2 Images and teleporting to a random position on 25% health
|
||||
|
||||
@@ -423,7 +423,7 @@ public:
|
||||
pTarget->setFaction(14);
|
||||
pTarget->AI()->AttackStart(me->getThreatManager().getHostilTarget());
|
||||
pTarget->AddAura(SPELL_MUTATE_BUG, pTarget);
|
||||
pTarget->SetHealth(pTarget->GetMaxHealth());
|
||||
pTarget->SetFullHealth();
|
||||
}
|
||||
|
||||
void UpdateAI(const uint32 diff)
|
||||
@@ -512,7 +512,7 @@ public:
|
||||
{
|
||||
pTarget->setFaction(14);
|
||||
pTarget->AddAura(SPELL_EXPLODEBUG, pTarget);
|
||||
pTarget->SetHealth(pTarget->GetMaxHealth());
|
||||
pTarget->SetFullHealth();
|
||||
}
|
||||
|
||||
void UpdateAI(const uint32 diff)
|
||||
|
||||
@@ -251,10 +251,7 @@ public:
|
||||
continue;
|
||||
if (sent->isDead())
|
||||
continue;
|
||||
uint32 h = sent->GetHealth() + (sent->GetMaxHealth() / 2);
|
||||
if (h > sent->GetMaxHealth())
|
||||
h = sent->GetMaxHealth();
|
||||
sent->SetHealth(h);
|
||||
sent->ModifyHealth(int32(sent->CountPctFromMaxHealth(50)));
|
||||
CAST_AI(aqsentinelAI, sent->AI())->GainSentinelAbility(ability);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
|
||||
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
|
||||
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
|
||||
me->SetHealth(int(me->GetMaxHealth()*.1));
|
||||
me->SetHealth(me->CountPctFromMaxHealth(10));
|
||||
me->SetStandState(UNIT_STAND_STATE_SLEEP);
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ public:
|
||||
void Reset()
|
||||
{
|
||||
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
|
||||
me->SetHealth(int(me->GetMaxHealth()*.15));
|
||||
me->SetHealth(me->CountPctFromMaxHealth(15));
|
||||
switch (rand()%2)
|
||||
{
|
||||
case 0: me->SetStandState(UNIT_STAND_STATE_SIT); break;
|
||||
|
||||
@@ -142,7 +142,7 @@ public:
|
||||
} else Cleave_Timer -= diff;
|
||||
|
||||
//Enrage_Timer
|
||||
if (me->GetHealth()*100 / me->GetMaxHealth() < 26 && !Enraged)
|
||||
if (HealthBelowPct(26) && !Enraged)
|
||||
{
|
||||
DoCast(me, SPELL_ENRAGE);
|
||||
Enraged = true;
|
||||
|
||||
@@ -344,7 +344,7 @@ public:
|
||||
|
||||
void DamageTaken(Unit* pDoneBy, uint32 &uiDamage)
|
||||
{
|
||||
if (uiDamage > me->GetHealth() || ((me->GetHealth() - uiDamage)*100 / me->GetMaxHealth() < 20))
|
||||
if (uiDamage > me->GetHealth() || me->HealthBelowPctDamaged(20, uiDamage))
|
||||
{
|
||||
uiDamage = 0;
|
||||
|
||||
|
||||
@@ -410,7 +410,7 @@ public:
|
||||
if (quest->GetQuestId() == Q_OOX17)
|
||||
{
|
||||
pCreature->setFaction(113);
|
||||
pCreature->SetHealth(pCreature->GetMaxHealth());
|
||||
pCreature->SetFullHealth();
|
||||
pCreature->SetUInt32Value(UNIT_FIELD_BYTES_1,0);
|
||||
pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
|
||||
DoScriptText(SAY_OOX_START, pCreature);
|
||||
|
||||
Reference in New Issue
Block a user