From 341e6303effccfdbfb6b67ae0d8fe6933f56ed3b Mon Sep 17 00:00:00 2001 From: azazel Date: Thu, 26 Aug 2010 01:20:57 +0600 Subject: 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 --- .../AuchenaiCrypts/boss_exarch_maladaar.cpp | 2 +- .../SethekkHalls/boss_darkweaver_syth.cpp | 6 +++--- .../SethekkHalls/boss_tailonking_ikiss.cpp | 2 +- .../ShadowLabyrinth/boss_grandmaster_vorpil.cpp | 4 ++-- .../Auchindoun/ShadowLabyrinth/boss_murmur.cpp | 4 ++-- .../scripts/Outland/BlackTemple/boss_illidan.cpp | 21 ++++++++++----------- .../Outland/BlackTemple/boss_mother_shahraz.cpp | 2 +- .../Outland/BlackTemple/boss_shade_of_akama.cpp | 4 ++-- .../Outland/BlackTemple/illidari_council.cpp | 2 +- .../SerpentShrine/boss_fathomlord_karathress.cpp | 2 +- .../SerpentShrine/boss_lady_vashj.cpp | 4 ++-- .../SerpentShrine/boss_leotheras_the_blind.cpp | 2 +- .../SteamVault/boss_mekgineer_steamrigger.cpp | 6 +++--- .../CoilfangReservoir/underbog/boss_hungarfen.cpp | 2 +- .../Outland/GruulsLair/boss_high_king_maulgar.cpp | 2 +- .../HellfireRamparts/boss_omor_the_unscarred.cpp | 2 +- .../HellfireRamparts/boss_vazruden_the_herald.cpp | 2 +- .../HellfireRamparts/boss_watchkeeper_gargolmar.cpp | 4 ++-- .../MagtheridonsLair/boss_magtheridon.cpp | 4 ++-- .../ShatteredHalls/boss_nethekurse.cpp | 2 +- .../scripts/Outland/TempestKeep/Eye/boss_alar.cpp | 4 ++-- .../Outland/TempestKeep/Eye/boss_astromancer.cpp | 2 +- .../Outland/TempestKeep/Eye/boss_kaelthas.cpp | 6 +++--- .../Mechanar/boss_pathaleon_the_calculator.cpp | 2 +- .../Outland/TempestKeep/arcatraz/arcatraz.cpp | 2 +- .../TempestKeep/arcatraz/boss_harbinger_skyriss.cpp | 8 ++++---- src/server/scripts/Outland/boss_doomwalker.cpp | 2 +- src/server/scripts/Outland/hellfire_peninsula.cpp | 2 +- src/server/scripts/Outland/nagrand.cpp | 4 ++-- src/server/scripts/Outland/netherstorm.cpp | 6 +++--- src/server/scripts/Outland/shadowmoon_valley.cpp | 2 +- src/server/scripts/Outland/shattrath_city.cpp | 4 ++-- src/server/scripts/Outland/terokkar_forest.cpp | 2 +- 33 files changed, 62 insertions(+), 63 deletions(-) (limited to 'src/server/scripts/Outland') diff --git a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp index e4271da8bbd..84faf656f2b 100644 --- a/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp +++ b/src/server/scripts/Outland/Auchindoun/AuchenaiCrypts/boss_exarch_maladaar.cpp @@ -246,7 +246,7 @@ public: if (!UpdateVictim()) return; - if (!Avatar_summoned && ((me->GetHealth()*100) / me->GetMaxHealth() < 25)) + if (!Avatar_summoned && HealthBelowPct(25)) { if (me->IsNonMeleeSpellCasted(false)) me->InterruptNonMeleeSpells(true); diff --git a/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_darkweaver_syth.cpp b/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_darkweaver_syth.cpp index 57fbc1bb633..c91815dbbfd 100644 --- a/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_darkweaver_syth.cpp +++ b/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_darkweaver_syth.cpp @@ -134,19 +134,19 @@ public: if (!UpdateVictim()) return; - if (((me->GetHealth()*100) / me->GetMaxHealth() < 90) && !summon90) + if (HealthBelowPct(90) && !summon90) { SythSummoning(); summon90 = true; } - if (((me->GetHealth()*100) / me->GetMaxHealth() < 50) && !summon50) + if (HealthBelowPct(50) && !summon50) { SythSummoning(); summon50 = true; } - if (((me->GetHealth()*100) / me->GetMaxHealth() < 10) && !summon10) + if (HealthBelowPct(10) && !summon10) { SythSummoning(); summon10 = true; diff --git a/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_tailonking_ikiss.cpp b/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_tailonking_ikiss.cpp index f8e917d9e4d..8fb2cecc6a1 100644 --- a/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_tailonking_ikiss.cpp +++ b/src/server/scripts/Outland/Auchindoun/SethekkHalls/boss_tailonking_ikiss.cpp @@ -165,7 +165,7 @@ public: } else Sheep_Timer -= diff; //may not be correct time to cast - if (!ManaShield && ((me->GetHealth()*100) / me->GetMaxHealth() < 20)) + if (!ManaShield && HealthBelowPct(20)) { DoCast(me, SPELL_MANA_SHIELD); ManaShield = true; diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp index f436f5d56bd..f08a1454285 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_grandmaster_vorpil.cpp @@ -110,7 +110,7 @@ public: if (sacrificed) { me->AddAura(DUNGEON_MODE(SPELL_EMPOWERING_SHADOWS, H_SPELL_EMPOWERING_SHADOWS), Vorpil); - Vorpil->SetHealth(Vorpil->GetHealth() + Vorpil->GetMaxHealth()/25); + Vorpil->ModifyHealth(int32(Vorpil->CountPctFromMaxHealth(4))); DoCast(me, SPELL_SHADOW_NOVA, true); me->Kill(me); return; @@ -305,7 +305,7 @@ public: spawnVoidTraveler(); summonTraveler_Timer = 10000; //enrage at 20% - if ((me->GetHealth()*5) < me->GetMaxHealth()) + if (HealthBelowPct(20)) summonTraveler_Timer = 5000; } else summonTraveler_Timer -=diff; diff --git a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp index f19c211e593..e613f2f9d98 100644 --- a/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp +++ b/src/server/scripts/Outland/Auchindoun/ShadowLabyrinth/boss_murmur.cpp @@ -72,7 +72,7 @@ public: SonicBoom = false; //database should have `RegenHealth`=0 to prevent regen - uint32 hp = (me->GetMaxHealth()*40)/100; + uint32 hp = me->CountPctFromMaxHealth(40); if (hp) me->SetHealth(hp); me->ResetPlayerDamageReq(); } @@ -89,7 +89,7 @@ public: if (pTarget->HasAura(SPELL_SONIC_BOOM_CAST) && me->IsWithinDistInMap(pTarget, 34.0f)) { //This will be wrong calculation. Also, comments suggest it must deal damage - pTarget->SetHealth(uint32(pTarget->GetMaxHealth() - pTarget->GetMaxHealth() * 0.8)); + pTarget->SetHealth(pTarget->CountPctFromMaxHealth(20)); } } } diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index f1b3f746dec..344540208de 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -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(); diff --git a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp index 84687b83de7..ac7d89683ca 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp @@ -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); diff --git a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp index d6f141c0981..86234625d37 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp @@ -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; diff --git a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp index 8f90d42a469..51a2b03234e 100644 --- a/src/server/scripts/Outland/BlackTemple/illidari_council.cpp +++ b/src/server/scripts/Outland/BlackTemple/illidari_council.cpp @@ -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); } } diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp index f551ca70d52..e9775f7e775 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp @@ -275,7 +275,7 @@ public: } else Enrage_Timer -= diff; //Blessing of Tides Trigger - if ((me->GetHealth()*100 / me->GetMaxHealth()) <= 75 && !BlessingOfTides) + if (!HealthAbovePct(75) && !BlessingOfTides) { BlessingOfTides = true; bool continueTriggering = false; diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp index f31a36c8240..93c91f9b4c1 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_lady_vashj.cpp @@ -396,7 +396,7 @@ public: if (Phase == 1) { //Start phase 2 - if ((me->GetHealth()*100 / me->GetMaxHealth()) < 70) + if (HealthBelowPct(70)) { //Phase 2 begins when Vashj hits 70%. She will run to the middle of her platform and surround herself in a shield making her invulerable. Phase = 2; @@ -556,7 +556,7 @@ public: if (pInstance && pInstance->GetData(DATA_CANSTARTPHASE3)) { //set life 50% - me->SetHealth(me->GetMaxHealth()/2); + me->SetHealth(me->CountPctFromMaxHealth(50)); me->RemoveAurasDueToSpell(SPELL_MAGIC_BARRIER); diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp index 7a80ff6a0d5..d9cb84dbfe5 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp @@ -561,7 +561,7 @@ public: } else SwitchToHuman_Timer -= diff; } - if (!IsFinalForm && (me->GetHealth()*100 / me->GetMaxHealth()) < 15) + if (!IsFinalForm && HealthBelowPct(15)) { //at this point he divides himself in two parts CastConsumingMadness(); diff --git a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp index 92a837f67ab..b642cc78449 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SteamVault/boss_mekgineer_steamrigger.cpp @@ -154,7 +154,7 @@ public: if (!Summon75) { - if ((me->GetHealth()*100 / me->GetMaxHealth()) < 75) + if (HealthBelowPct(75)) { SummonMechanichs(); Summon75 = true; @@ -163,7 +163,7 @@ public: if (!Summon50) { - if ((me->GetHealth()*100 / me->GetMaxHealth()) < 50) + if (HealthBelowPct(50)) { SummonMechanichs(); Summon50 = true; @@ -172,7 +172,7 @@ public: if (!Summon25) { - if ((me->GetHealth()*100 / me->GetMaxHealth()) < 25) + if (HealthBelowPct(25)) { SummonMechanichs(); Summon25 = true; diff --git a/src/server/scripts/Outland/CoilfangReservoir/underbog/boss_hungarfen.cpp b/src/server/scripts/Outland/CoilfangReservoir/underbog/boss_hungarfen.cpp index b32feaa8133..795991bcafb 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/underbog/boss_hungarfen.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/underbog/boss_hungarfen.cpp @@ -64,7 +64,7 @@ public: if (!UpdateVictim()) return; - if ((me->GetHealth()*100) / me->GetMaxHealth() <= 20) + if (!HealthAbovePct(20)) { if (!Root) { diff --git a/src/server/scripts/Outland/GruulsLair/boss_high_king_maulgar.cpp b/src/server/scripts/Outland/GruulsLair/boss_high_king_maulgar.cpp index 3bf8111b8a6..565ed6b96d7 100644 --- a/src/server/scripts/Outland/GruulsLair/boss_high_king_maulgar.cpp +++ b/src/server/scripts/Outland/GruulsLair/boss_high_king_maulgar.cpp @@ -265,7 +265,7 @@ public: } else MightyBlow_Timer -= diff; //Entering Phase 2 - if (!Phase2 && (me->GetHealth()*100 / me->GetMaxHealth()) < 50) + if (!Phase2 && HealthBelowPct(50)) { Phase2 = true; DoScriptText(SAY_ENRAGE, me); diff --git a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp index 3d01c985ffe..71c4e1387a4 100644 --- a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_omor_the_unscarred.cpp @@ -177,7 +177,7 @@ class boss_omor_the_unscarred : public CreatureScript else OrbitalStrike_Timer -= diff; - if ((me->GetHealth()*100) / me->GetMaxHealth() < 20) + if (HealthBelowPct(20)) { if (DemonicShield_Timer <= diff) { diff --git a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp index d47723dc135..5cd1afbe706 100644 --- a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_vazruden_the_herald.cpp @@ -140,7 +140,7 @@ class boss_nazan : public CreatureScript if (flight) // phase 1 - the flight { Creature *Vazruden = Unit::GetCreature(*me,VazrudenGUID); - if (Fly_Timer < diff || !(Vazruden && Vazruden->isAlive() && (Vazruden->GetHealth()*5 > Vazruden->GetMaxHealth()))) + if (Fly_Timer < diff || !(Vazruden && Vazruden->isAlive() && Vazruden->HealthAbovePct(20))) { flight = false; BellowingRoar_Timer = 6000; diff --git a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_watchkeeper_gargolmar.cpp b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_watchkeeper_gargolmar.cpp index 645a65bdee2..3c7200d64ad 100644 --- a/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_watchkeeper_gargolmar.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/HellfireRamparts/boss_watchkeeper_gargolmar.cpp @@ -139,7 +139,7 @@ class boss_watchkeeper_gargolmar : public CreatureScript else Surge_Timer -= diff; - if ((me->GetHealth()*100) / me->GetMaxHealth() < 20) + if (HealthBelowPct(20)) { if (Retaliation_Timer <= diff) { @@ -152,7 +152,7 @@ class boss_watchkeeper_gargolmar : public CreatureScript if (!YelledForHeal) { - if ((me->GetHealth()*100) / me->GetMaxHealth() < 40) + if (HealthBelowPct(40)) { DoScriptText(SAY_HEAL, me); YelledForHeal = true; diff --git a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp index 8a27461723b..2d168a1f064 100644 --- a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp @@ -443,7 +443,7 @@ class boss_magtheridon : public CreatureScript else Blaze_Timer -= diff; - if (!Phase3 && me->GetHealth()*10 < me->GetMaxHealth()*3 + if (!Phase3 && HealthBelowPct(30) && !me->IsNonMeleeSpellCasted(false) // blast nova && !me->hasUnitState(UNIT_STAT_STUNNED)) // shadow cage and earthquake { @@ -568,7 +568,7 @@ class mob_hellfire_channeler : public CreatureScript if (DarkMending_Timer <= diff) { - if ((me->GetHealth()*100 / me->GetMaxHealth()) < 50) + if (HealthBelowPct(50)) DoCast(me, SPELL_DARK_MENDING); DarkMending_Timer = 10000 +(rand() % 10000); } diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp index ed1b60d6a1d..ce1a60809c2 100644 --- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_nethekurse.cpp @@ -293,7 +293,7 @@ class boss_grand_warlock_nethekurse : public CreatureScript else DeathCoil_Timer -= diff; - if ((me->GetHealth()*100) / me->GetMaxHealth() <= 20) + if (!HealthAbovePct(20)) Phase = true; DoMeleeAttackIfReady(); diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp index 05a1b86f79c..d913ec28aeb 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_alar.cpp @@ -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 diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp index ebccc21e969..abfc717df4a 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp @@ -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 diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index 265d1fea682..d6e049852ed 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -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 diff --git a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_pathaleon_the_calculator.cpp b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_pathaleon_the_calculator.cpp index a1da2ab0d03..8ef81e1de73 100644 --- a/src/server/scripts/Outland/TempestKeep/Mechanar/boss_pathaleon_the_calculator.cpp +++ b/src/server/scripts/Outland/TempestKeep/Mechanar/boss_pathaleon_the_calculator.cpp @@ -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); diff --git a/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp b/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp index 3799f1e1621..66204a30f0f 100644 --- a/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp +++ b/src/server/scripts/Outland/TempestKeep/arcatraz/arcatraz.cpp @@ -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; diff --git a/src/server/scripts/Outland/TempestKeep/arcatraz/boss_harbinger_skyriss.cpp b/src/server/scripts/Outland/TempestKeep/arcatraz/boss_harbinger_skyriss.cpp index 87113dfe706..a4bbbd9d049 100644 --- a/src/server/scripts/Outland/TempestKeep/arcatraz/boss_harbinger_skyriss.cpp +++ b/src/server/scripts/Outland/TempestKeep/arcatraz/boss_harbinger_skyriss.cpp @@ -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; diff --git a/src/server/scripts/Outland/boss_doomwalker.cpp b/src/server/scripts/Outland/boss_doomwalker.cpp index 6dd92ee2023..59cb33fed89 100644 --- a/src/server/scripts/Outland/boss_doomwalker.cpp +++ b/src/server/scripts/Outland/boss_doomwalker.cpp @@ -113,7 +113,7 @@ public: return; //Spell Enrage, when hp <= 20% gain enrage - if (((me->GetHealth()*100)/ me->GetMaxHealth()) <= 20) + if (!HealthAbovePct(20)) { if (Enrage_Timer <= diff) { diff --git a/src/server/scripts/Outland/hellfire_peninsula.cpp b/src/server/scripts/Outland/hellfire_peninsula.cpp index bdd5c1c56ba..b54fdcb5869 100644 --- a/src/server/scripts/Outland/hellfire_peninsula.cpp +++ b/src/server/scripts/Outland/hellfire_peninsula.cpp @@ -98,7 +98,7 @@ public: if (!UpdateVictim()) return; - if ((me->GetHealth()*100) / me->GetMaxHealth() < 30) + if (HealthBelowPct(30)) { me->setFaction(FACTION_FRIENDLY); me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); diff --git a/src/server/scripts/Outland/nagrand.cpp b/src/server/scripts/Outland/nagrand.cpp index 6f511d2e787..6007dd17728 100644 --- a/src/server/scripts/Outland/nagrand.cpp +++ b/src/server/scripts/Outland/nagrand.cpp @@ -178,7 +178,7 @@ public: void DamageTaken(Unit *done_by, uint32 & damage) { - if (done_by->GetTypeId() == TYPEID_PLAYER && (me->GetHealth() - damage)*100 / me->GetMaxHealth() < 30) + if (done_by->GetTypeId() == TYPEID_PLAYER && me->HealthBelowPctDamaged(30, damage)) { if (!bReset && CAST_PLR(done_by)->GetQuestStatus(9918) == QUEST_STATUS_INCOMPLETE) { @@ -718,7 +718,7 @@ public: else m_uiChainLightningTimer -= uiDiff; - if (me->GetHealth()*100 < me->GetMaxHealth()*30) + if (HealthBelowPct(30)) { if (m_uiHealTimer <= uiDiff) { diff --git a/src/server/scripts/Outland/netherstorm.cpp b/src/server/scripts/Outland/netherstorm.cpp index f56cacd754a..ff56a224802 100644 --- a/src/server/scripts/Outland/netherstorm.cpp +++ b/src/server/scripts/Outland/netherstorm.cpp @@ -818,7 +818,7 @@ public: if (Player *pPlayer = Unit::GetPlayer(*me, PlayerGUID)) // start: support for quest 10190 { - if (!Weak && me->GetHealth() < (me->GetMaxHealth() / 100 * WeakPercent) + if (!Weak && HealthBelowPct(WeakPercent) && pPlayer->GetQuestStatus(QUEST_RECHARGING_THE_BATTERIES) == QUEST_STATUS_INCOMPLETE) { DoScriptText(EMOTE_WEAK, me); @@ -827,11 +827,11 @@ public: if (Weak && !Drained && me->HasAura(SPELL_RECHARGING_BATTERY)) { Drained = true; - HpPercent = float(me->GetHealth()) / float(me->GetMaxHealth()); + HpPercent = me->GetHealthPct(); me->UpdateEntry(NPC_DRAINED_PHASE_HUNTER_ENTRY); - me->SetHealth(me->GetMaxHealth() * HpPercent); + me->SetHealth(me->CountPctFromMaxHealth(HpPercent)); me->LowerPlayerDamageReq(me->GetMaxHealth() - me->GetHealth()); me->SetInCombatWith(pPlayer); } diff --git a/src/server/scripts/Outland/shadowmoon_valley.cpp b/src/server/scripts/Outland/shadowmoon_valley.cpp index ddcb28a6ef6..23a1bfa364e 100644 --- a/src/server/scripts/Outland/shadowmoon_valley.cpp +++ b/src/server/scripts/Outland/shadowmoon_valley.cpp @@ -1102,7 +1102,7 @@ public: return; //TODO: add more abilities - if (me->GetHealth()*100 / me->GetMaxHealth() <= 30) + if (!HealthAbovePct(30)) { if (m_uiHealingTimer <= uiDiff) { diff --git a/src/server/scripts/Outland/shattrath_city.cpp b/src/server/scripts/Outland/shattrath_city.cpp index e0d81a78e01..bab1376fc00 100644 --- a/src/server/scripts/Outland/shattrath_city.cpp +++ b/src/server/scripts/Outland/shattrath_city.cpp @@ -167,7 +167,7 @@ public: void DamageTaken(Unit *done_by, uint32 &damage) { if (done_by->GetTypeId() == TYPEID_PLAYER) - if ((me->GetHealth()-damage)*100 / me->GetMaxHealth() < 20) + if (me->HealthBelowPctDamaged(20, damage)) { CAST_PLR(done_by)->GroupEventHappens(QUEST_10004,me); damage = 0; @@ -511,7 +511,7 @@ public: Attack = false; } - if ((me->GetHealth()*100)/me->GetMaxHealth() < 5 && !Done) + if (HealthBelowPct(5) && !Done) { me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->RemoveAllAuras(); diff --git a/src/server/scripts/Outland/terokkar_forest.cpp b/src/server/scripts/Outland/terokkar_forest.cpp index 7ac677bfce4..901a3beb6b8 100644 --- a/src/server/scripts/Outland/terokkar_forest.cpp +++ b/src/server/scripts/Outland/terokkar_forest.cpp @@ -92,7 +92,7 @@ public: void DamageTaken(Unit *done_by, uint32 &damage) { if (done_by->GetTypeId() == TYPEID_PLAYER) - if ((me->GetHealth()-damage)*100 / me->GetMaxHealth() < 30) + if (me->HealthBelowPctDamaged(30, damage)) { if (Group* pGroup = CAST_PLR(done_by)->GetGroup()) { -- cgit v1.2.3