diff options
author | azazel <none@none> | 2010-08-26 01:20:57 +0600 |
---|---|---|
committer | azazel <none@none> | 2010-08-26 01:20:57 +0600 |
commit | 341e6303effccfdbfb6b67ae0d8fe6933f56ed3b (patch) | |
tree | eff917fec707c7097a7b408ce15842ff24d8ddb4 | |
parent | bb5f7b64927713911331f81f9c0a5abc33e0c3ab (diff) |
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
166 files changed, 445 insertions, 416 deletions
diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp index ec236890fa8..ec0b12a0b42 100644 --- a/src/server/game/AI/EventAI/CreatureEventAI.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp @@ -141,7 +141,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction if (!me->isInCombat() || !me->GetMaxHealth()) return false; - uint32 perc = (me->GetHealth()*100) / me->GetMaxHealth(); + uint32 perc = uint32(me->GetHealthPct()); if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) return false; @@ -195,7 +195,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction if (!me->isInCombat() || !me->getVictim() || !me->getVictim()->GetMaxHealth()) return false; - uint32 perc = (me->getVictim()->GetHealth()*100) / me->getVictim()->GetMaxHealth(); + uint32 perc = uint32(me->getVictim()->GetHealthPct()); if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) return false; @@ -821,7 +821,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 case ACTION_T_SET_INVINCIBILITY_HP_LEVEL: { if (action.invincibility_hp_level.is_percent) - m_InvinceabilityHpLevel = me->GetMaxHealth()*action.invincibility_hp_level.hp_level/100; + m_InvinceabilityHpLevel = me->CountPctFromMaxHealth(action.invincibility_hp_level.hp_level); else m_InvinceabilityHpLevel = action.invincibility_hp_level.hp_level; break; diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index bf24ead82ad..6c304ecd346 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -153,7 +153,8 @@ struct ScriptedAI : public CreatureAI //Selects a unit from the creature's current aggro list Unit* SelectUnit(SelectAggroTarget pTarget, uint32 uiPosition); - bool HealthBelowPct(uint64 pct) const { return me->GetHealth() * 100 < me->GetMaxHealth() * pct; } + bool HealthBelowPct(uint32 pct) const { return me->HealthBelowPct(pct); } + bool HealthAbovePct(uint32 pct) const { return me->HealthAbovePct(pct); } //Returns spells that meet the specified criteria from the creatures spell list SpellEntry const* SelectSpell(Unit* Target, uint32 School, uint32 Mechanic, SelectTargetType Targets, uint32 PowerCostMin, uint32 PowerCostMax, float RangeMin, float RangeMax, SelectEffect Effect); diff --git a/src/server/game/AI/ScriptedAI/ScriptedGuardAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedGuardAI.cpp index 8dbaa750701..81dd4fcdc27 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedGuardAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedGuardAI.cpp @@ -103,7 +103,7 @@ void guardAI::UpdateAI(const uint32 diff) SpellEntry const *info = NULL; //Select a healing spell if less than 30% hp - if (me->GetHealth()*100 / me->GetMaxHealth() < 30) + if (HealthBelowPct(30)) info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); //No healing spell available, select a hostile spell @@ -134,7 +134,7 @@ void guardAI::UpdateAI(const uint32 diff) SpellEntry const *info = NULL; //Select a healing spell if less than 30% hp ONLY 33% of the time - if (me->GetHealth()*100 / me->GetMaxHealth() < 30 && rand() % 3 == 0) + if (HealthBelowPct(30) && rand() % 3 == 0) info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); //No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE) diff --git a/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp index 4ca55669245..864de9288a1 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp @@ -214,7 +214,7 @@ void SimpleAI::UpdateAI(const uint32 diff) if (Spell_Timer[i] <= diff) { //Check if this is a percentage based - if (Spell[i].First_Cast < 0 && Spell[i].First_Cast > -100 && me->GetHealth()*100 / me->GetMaxHealth() > uint32(-Spell[i].First_Cast)) + if (Spell[i].First_Cast < 0 && Spell[i].First_Cast > -100 && HealthAbovePct(uint32(-Spell[i].First_Cast))) continue; //Check Current spell diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index c41b06ae752..d840283040e 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -286,12 +286,14 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_LESS_HEALTH: if (!target || target->GetTypeId() != TYPEID_PLAYER) return false; - return target->GetHealth()*100 <= health.percent*target->GetMaxHealth(); + return !target->HealthAbovePct(health.percent); case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_DEAD: - if (!target || target->GetTypeId() != TYPEID_PLAYER || target->isAlive() || target->ToPlayer()->GetDeathTimer() == 0) - return false; - // flag set == must be same team, not set == different team - return (target->ToPlayer()->GetTeam() == source->GetTeam()) == (player_dead.own_team_flag != 0); + if (target && !target->isAlive()) + if (const Player* player = target->ToPlayer()) + if (player->GetDeathTimer() != 0) + // flag set == must be same team, not set == different team + return (player->GetTeam() == source->GetTeam()) == (player_dead.own_team_flag != 0); + return false; case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA: return source->HasAuraEffect(aura.spell_id,aura.effect_idx); case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AREA: diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index aa654a8f55b..f7958287ecd 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -821,7 +821,7 @@ void Battleground::EndBattleground(uint32 winner) } - plr->SetHealth(plr->GetMaxHealth()); + plr->SetFullHealth(); plr->SetPower(POWER_MANA, plr->GetMaxPower(POWER_MANA)); plr->CombatStopWithPets(true); @@ -1113,7 +1113,7 @@ void Battleground::AddPlayer(Player *plr) { plr->CastSpell(plr, SPELL_ARENA_PREPARATION, true); - plr->SetHealth(plr->GetMaxHealth()); + plr->SetFullHealth(); plr->SetPower(POWER_MANA, plr->GetMaxPower(POWER_MANA)); } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp index aaea9f10db2..8ee0064a440 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp @@ -474,7 +474,7 @@ void BattlegroundSA::TeleportPlayers() plr->SpawnCorpseBones(); } - plr->SetHealth(plr->GetMaxHealth()); + plr->SetFullHealth(); plr->SetPower(POWER_MANA, plr->GetMaxPower(POWER_MANA)); plr->CombatStopWithPets(true); diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp index b77fe69d553..601c2ed240a 100644 --- a/src/server/game/Chat/Commands/Level2.cpp +++ b/src/server/game/Chat/Commands/Level2.cpp @@ -3978,19 +3978,19 @@ bool ChatHandler::HandleCreatePetCommand(const char* /*args*/) // prepare visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()-1); - pet->GetCharmInfo()->SetPetNumber(sObjectMgr.GeneratePetNumber(), true); - // this enables pet details window (Shift+P) - pet->InitPetCreateSpells(); - pet->SetHealth(pet->GetMaxHealth()); + pet->GetCharmInfo()->SetPetNumber(sObjectMgr.GeneratePetNumber(), true); + // this enables pet details window (Shift+P) + pet->InitPetCreateSpells(); + pet->SetFullHealth(); - pet->GetMap()->Add(pet->ToCreature()); + pet->GetMap()->Add(pet->ToCreature()); - // visual effect for levelup - pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()); + // visual effect for levelup + pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()); - player->SetMinion(pet, true); - pet->SavePetToDB(PET_SAVE_AS_CURRENT); - player->PetSpellInitialize(); + player->SetMinion(pet, true); + pet->SavePetToDB(PET_SAVE_AS_CURRENT); + player->PetSpellInitialize(); return true; } diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index b63766bde6d..a3479bf417f 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -144,8 +144,7 @@ bool Condition::Meets(Player * player, Unit* targetOverride) if (targetOverride) target = targetOverride; if (target) - if ((target->GetHealth()*100 / target->GetMaxHealth()) <= mConditionValue1) - condMeets = true; + condMeets = !target->HealthAbovePct(mConditionValue1); break; } case CONDITION_TARGET_RANGE: diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index b829e8bed05..40db0009ebe 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1511,7 +1511,7 @@ void Creature::setDeathState(DeathState s) { //if (isPet()) // setActive(true); - SetHealth(GetMaxHealth()); + SetFullHealth(); SetLootRecipient(NULL); ResetPlayerDamageReq(); CreatureInfo const *cinfo = GetCreatureInfo(); @@ -2276,12 +2276,12 @@ uint8 Creature::getLevelForTarget(Unit const* target) const if (!isWorldBoss()) return Unit::getLevelForTarget(target); - uint16 level = target->getLevel()+sWorld.getIntConfig(CONFIG_WORLD_BOSS_LEVEL_DIFF); + uint16 level = target->getLevel() + sWorld.getIntConfig(CONFIG_WORLD_BOSS_LEVEL_DIFF); if (level < 1) return 1; if (level > 255) return 255; - return level; + return uint8(level); } std::string Creature::GetAIName() const diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 65638432277..9b5964bb4ff 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1986,7 +1986,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy pet->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048); pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); - pet->SetHealth(pet->GetMaxHealth()); + pet->SetFullHealth(); pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA)); pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL)); break; diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 9fc41f63ff6..70e42e6266f 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -240,7 +240,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c if (getPetType() == SUMMON_PET && !current) //all (?) summon pets come with full health when called, but not when they are current { - SetHealth(GetMaxHealth()); + SetFullHealth(); SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); } else @@ -1056,7 +1056,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel) UpdateAllStats(); - SetHealth(GetMaxHealth()); + SetFullHealth(); SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); return true; } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 8971f6be7b4..1375afe68b6 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -815,7 +815,7 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c // apply original stats mods before spell loading or item equipment that call before equip _RemoveStatsMods() UpdateMaxHealth(); // Update max Health (for add bonus from stamina) - SetHealth(GetMaxHealth()); + SetFullHealth(); if (getPowerType() == POWER_MANA) { UpdateMaxPower(POWER_MANA); // Update max Mana (for add bonus from intellect) @@ -2047,7 +2047,7 @@ void Player::ProcessDelayedOperations() if (GetMaxHealth() > m_resurrectHealth) SetHealth(m_resurrectHealth); else - SetHealth(GetMaxHealth()); + SetFullHealth(); if (GetMaxPower(POWER_MANA) > m_resurrectMana) SetPower(POWER_MANA, m_resurrectMana); @@ -2726,7 +2726,7 @@ void Player::GiveLevel(uint8 level) UpdateSkillsToMaxSkillsForLevel(); // set current level health and mana/energy to maximum after applying all mods. - SetHealth(GetMaxHealth()); + SetFullHealth(); SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); if (GetPower(POWER_RAGE) > GetMaxPower(POWER_RAGE)) @@ -2937,7 +2937,7 @@ void Player::InitStatsForLevel(bool reapplyMods) _ApplyAllStatBonuses(); // set current level health and mana/energy to maximum after applying all mods. - SetHealth(GetMaxHealth()); + SetFullHealth(); SetPower(POWER_MANA, GetMaxPower(POWER_MANA)); SetPower(POWER_ENERGY, GetMaxPower(POWER_ENERGY)); if (GetPower(POWER_RAGE) > GetMaxPower(POWER_RAGE)) @@ -6206,7 +6206,7 @@ void Player::SendActionButtons(uint32 state) const */ if (state != 2) { - for (uint16 button = 0; button < MAX_ACTION_BUTTONS; ++button) + for (uint8 button = 0; button < MAX_ACTION_BUTTONS; ++button) { ActionButtonList::const_iterator itr = m_actionButtons.find(button); if (itr != m_actionButtons.end() && itr->second.uState != ACTIONBUTTON_DELETED) @@ -9601,7 +9601,7 @@ Item* Player::GetItemByPos(uint8 bag, uint8 slot) const Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable /*= false*/) const { - uint16 slot; + uint8 slot; switch (attackType) { case BASE_ATTACK: slot = EQUIPMENT_SLOT_MAINHAND; break; @@ -21932,7 +21932,7 @@ void Player::ResurectUsingRequestData() if (GetMaxHealth() > m_resurrectHealth) SetHealth(m_resurrectHealth); else - SetHealth(GetMaxHealth()); + SetFullHealth(); if (GetMaxPower(POWER_MANA) > m_resurrectMana) SetPower(POWER_MANA, m_resurrectMana); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 3f41f3f67c7..95beb3b34d6 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -273,9 +273,9 @@ void Unit::Update(uint32 p_time) // update abilities available only for fraction of time UpdateReactives(p_time); - ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, GetHealth() < GetMaxHealth()*0.20f); - ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, GetHealth() < GetMaxHealth()*0.35f); - ModifyAuraState(AURA_STATE_HEALTH_ABOVE_75_PERCENT, GetHealth() > GetMaxHealth()*0.75f); + ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, HealthBelowPct(20)); + ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, HealthBelowPct(35)); + ModifyAuraState(AURA_STATE_HEALTH_ABOVE_75_PERCENT, HealthAbovePct(75)); i_motionMaster.UpdateMotion(p_time); } @@ -1922,7 +1922,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff if (spellProto->SpellIconID == 2135 && pVictim->GetTypeId() == TYPEID_PLAYER) { int32 remainingHealth = pVictim->GetHealth() - RemainingDamage; - uint32 allowedHealth = uint32(pVictim->GetMaxHealth() * 0.35f); + uint32 allowedHealth = pVictim->CountPctFromMaxHealth(35); // If damage kills us if (remainingHealth <= 0 && !pVictim->ToPlayer()->HasSpellCooldown(66235)) { @@ -1937,7 +1937,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff ? 1.0f : float(defenseSkillValue) / float(reqDefForMaxHeal); - int32 healAmount = int32(pVictim->GetMaxHealth() * (*i)->GetAmount() / 100.0f * pctFromDefense); + int32 healAmount = int32(pVictim->CountPctFromMaxHealth(uint32((*i)->GetAmount() * pctFromDefense))); pVictim->CastCustomSpell(pVictim, 66235, &healAmount, NULL, NULL, true); pVictim->ToPlayer()->AddSpellCooldown(66235,0,time(NULL) + 120); } @@ -1992,7 +1992,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff uint32 rank = sSpellMgr.GetSpellRank(spellProto->Id); SpellEntry const * talentProto = sSpellStore.LookupEntry(sSpellMgr.GetSpellWithRank(49189, rank)); - int32 minHp = int32((float)pVictim->GetMaxHealth() * (float)SpellMgr::CalculateSpellEffectAmount(talentProto, 0, (*i)->GetCaster()) / 100.0f); + int32 minHp = int32(pVictim->CountPctFromMaxHealth(SpellMgr::CalculateSpellEffectAmount(talentProto, 0, (*i)->GetCaster()))); // Damage that would take you below [effect0] health or taken while you are at [effect0] if (remainingHp < minHp) { @@ -2215,7 +2215,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff pVictim->CastSpell(pVictim,31231,true); pVictim->ToPlayer()->AddSpellCooldown(31231,0,time(NULL)+60); // with health > 10% lost health until health == 10%, in other case no losses - uint32 health10 = pVictim->GetMaxHealth()/10; + uint32 health10 = pVictim->CountPctFromMaxHealth(10); RemainingDamage = pVictim->GetHealth() > health10 ? pVictim->GetHealth() - health10 : 0; } break; @@ -2225,7 +2225,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff // Guardian Spirit if (preventDeathSpell->SpellIconID == 2873) { - int32 healAmount = pVictim->GetMaxHealth() * preventDeathAmount / 100; + int32 healAmount = int32(pVictim->CountPctFromMaxHealth(preventDeathAmount)); pVictim->RemoveAurasDueToSpell(preventDeathSpell->Id); pVictim->CastCustomSpell(pVictim, 48153, &healAmount, NULL, NULL, true); RemainingDamage = 0; @@ -6441,7 +6441,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger if (!target || !target->IsFriendlyTo(this)) return false; - basepoints0 = int32(target->GetMaxHealth() * triggerAmount / 100); + basepoints0 = int32(target->CountPctFromMaxHealth(triggerAmount)); triggered_spell_id = 56131; break; } @@ -6556,7 +6556,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger { if (triggerAmount <= 0) return false; - basepoints0 = triggerAmount * GetMaxHealth() / 100; + basepoints0 = int32(CountPctFromMaxHealth(triggerAmount)); target = this; triggered_spell_id = 34299; if (triggeredByAura->GetCasterGUID() != GetGUID()) @@ -6580,7 +6580,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger // Glyph of Rejuvenation case 54754: { - if (!pVictim || pVictim->GetHealth() >= triggerAmount * pVictim->GetMaxHealth()/100) + if (!pVictim || !pVictim->HealthBelowPct(uint32(triggerAmount))) return false; basepoints0 = int32(triggerAmount * damage / 100); triggered_spell_id = 54755; @@ -6939,7 +6939,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger if (pVictim->getPowerType() == POWER_MANA) { // 2% of base mana - basepoints0 = int32(pVictim->GetMaxHealth() * 2 / 100); + basepoints0 = int32(pVictim->CountPctFromMaxHealth(2)); pVictim->CastCustomSpell(pVictim, 20267, &basepoints0, 0, 0, true, 0, triggeredByAura); } return true; @@ -7662,7 +7662,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger // Vendetta if (dummySpell->SpellFamilyFlags[0] & 0x10000) { - basepoints0 = triggerAmount * GetMaxHealth() / 100; + basepoints0 = int32(CountPctFromMaxHealth(triggerAmount)); triggered_spell_id = 50181; target = this; break; @@ -8516,13 +8516,13 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig else if (auraSpellInfo->SpellIconID == 2013) { // Check health condition - should drop to less 30% (damage deal after this!) - if (!(10*(int32(GetHealth() - damage)) < 3 * GetMaxHealth())) + if (!HealthBelowPctDamaged(30, damage)) return false; if (pVictim && pVictim->isAlive()) pVictim->getThreatManager().modifyThreatPercent(this,-10); - basepoints0 = triggerAmount * GetMaxHealth() / 100; + basepoints0 = int32(CountPctFromMaxHealth(triggerAmount)); trigger_spell_id = 31616; target = this; } @@ -8603,8 +8603,8 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig // Deflection case 52420: { - if (GetHealth()*100 / GetMaxHealth() >= 35) - return false; + if (!HealthBelowPct(35)) + return false; break; } @@ -8612,7 +8612,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig case 28845: { // When your health drops below 20% - if (GetHealth() - damage > GetMaxHealth() / 5 || GetHealth() < GetMaxHealth() / 5) + if (HealthBelowPctDamaged(20, damage) || HealthBelowPct(20)) return false; break; } @@ -8620,7 +8620,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig case 31255: { // whenever you deal damage to a target who is below 20% health. - if (!pVictim || !pVictim->isAlive() || (pVictim->GetHealth() > pVictim->GetMaxHealth() / 5)) + if (!pVictim || !pVictim->isAlive() || pVictim->HealthAbovePct(20)) return false; target = this; @@ -8633,7 +8633,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig return false; // Not give if target already have full health - if (pVictim->GetHealth() == pVictim->GetMaxHealth()) + if (pVictim->IsFullHealth()) return false; // If your Greater Heal brings the target to full health, you gain $37595s1 mana. if (pVictim->GetHealth() + damage < pVictim->GetMaxHealth()) @@ -8644,7 +8644,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig case 40971: { // If your target is below $s1% health - if (!pVictim || !pVictim->isAlive() || (pVictim->GetHealth() > pVictim->GetMaxHealth() * triggerAmount / 100)) + if (!pVictim || !pVictim->isAlive() || pVictim->HealthAbovePct(triggerAmount)) return false; break; } @@ -8756,7 +8756,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig // Bloodthirst (($m/100)% of max health) case 23880: { - basepoints0 = int32(GetMaxHealth() * triggerAmount / 100); + basepoints0 = int32(CountPctFromMaxHealth(triggerAmount)); break; } // Shamanistic Rage triggered spell @@ -10276,7 +10276,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 // Merciless Combat if ((*i)->GetSpellProto()->SpellIconID == 2656) { - if ((pVictim->GetMaxHealth() * 35 / 100) >= pVictim->GetHealth()) + if (!pVictim->HealthAbovePct(35)) DoneTotalMod *= (100.0f+(*i)->GetAmount())/100.0f; } // Tundra Stalker @@ -10750,7 +10750,7 @@ bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM case 21: // Test of Faith case 6935: case 6918: - if (pVictim->GetHealth() < pVictim->GetMaxHealth()/2) + if (pVictim->HealthBelowPct(50)) crit_chance+=(*i)->GetAmount(); break; default: @@ -10962,7 +10962,7 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint case 21: // Test of Faith case 6935: case 6918: - if (pVictim->GetHealth() < pVictim->GetMaxHealth()/2) + if (pVictim->HealthBelowPct(50)) DoneTotalMod *=((*i)->GetAmount() + 100.0f)/100.0f; break; case 7798: // Glyph of Regrowth @@ -11500,7 +11500,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att // Merciless Combat if ((*i)->GetSpellProto()->SpellIconID == 2656) { - if ((pVictim->GetMaxHealth() * 35 / 100) >= pVictim->GetHealth()) + if (!pVictim->HealthAbovePct(35)) DoneTotalMod *= (100.0f+(*i)->GetAmount())/100.0f; } // Tundra Stalker @@ -13802,19 +13802,19 @@ void CharmInfo::LoadPetActionBar(const std::string& data) for (iter = tokens.begin(), index = ACTION_BAR_INDEX_START; index < ACTION_BAR_INDEX_END; ++iter, ++index) { // use unsigned cast to avoid sign negative format use at long-> ActiveStates (int) conversion - uint8 type = atol((*iter).c_str()); + ActiveStates type = ActiveStates(atol(iter->c_str())); ++iter; - uint32 action = atol((*iter).c_str()); + uint32 action = uint32(atol(iter->c_str())); - PetActionBar[index].SetActionAndType(action,ActiveStates(type)); + PetActionBar[index].SetActionAndType(action, type); // check correctness if (PetActionBar[index].IsActionBarForSpell()) { if (!sSpellStore.LookupEntry(PetActionBar[index].GetAction())) - SetActionBar(index,0,ACT_PASSIVE); + SetActionBar(index, 0, ACT_PASSIVE); else if (!IsAutocastableSpell(PetActionBar[index].GetAction())) - SetActionBar(index,PetActionBar[index].GetAction(),ACT_PASSIVE); + SetActionBar(index, PetActionBar[index].GetAction(), ACT_PASSIVE); } } } @@ -14810,7 +14810,7 @@ bool Unit::InitTamedPet(Pet * pet, uint8 level, uint32 spell_id) // this enables pet details window (Shift+P) pet->InitPetCreateSpells(); //pet->InitLevelupSpellsForLevel(); - pet->SetHealth(pet->GetMaxHealth()); + pet->SetFullHealth(); return true; } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 596d7d15078..b451c56e4a1 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1211,8 +1211,17 @@ class Unit : public WorldObject uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); } uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); } + + inline bool IsFullHealth() const { return GetHealth() == GetMaxHealth(); } + inline bool HealthBelowPct(int32 pct) const { return GetHealth() * 100 < GetMaxHealth() * pct; } + inline bool HealthBelowPctDamaged(int32 pct, uint32 damage) const { return (int32(GetHealth()) - damage) * 100 < GetMaxHealth() * pct; } + inline bool HealthAbovePct(int32 pct) const { return GetHealth() * 100 > GetMaxHealth() * pct; } + inline float GetHealthPct() const { return GetMaxHealth() ? 100.f * GetHealth() / GetMaxHealth() : 0.0f; } + inline uint32 CountPctFromMaxHealth(int32 pct) const { return uint32(float(pct) * GetMaxHealth() / 100.0f); } + void SetHealth(uint32 val); void SetMaxHealth(uint32 val); + inline void SetFullHealth() { SetHealth(GetMaxHealth()); } int32 ModifyHealth(int32 val); int32 GetHealthGain(int32 dVal); diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 9fb6624193c..331257ca673 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -3247,25 +3247,25 @@ void Map::ScriptsProcess() } else { - pTarget = source->ToPlayer(); - if (pTarget) - { - if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER) - { - sLog.outError("%s target is not unit, gameobject or player (TypeId: %u, Entry: %u, GUID: %u), skipping.", - step.script->GetDebugInfo().c_str(), target->GetTypeId(), target->GetEntry(), target->GetGUIDLow()); - break; - } - worldObject = dynamic_cast<WorldObject*>(target); - } - else - { - sLog.outError("%s neither source nor target is player (source: TypeId: %u, Entry: %u, GUID: %u; target: TypeId: %u, Entry: %u, GUID: %u), skipping.", - step.script->GetDebugInfo().c_str(), - source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUIDLow() : 0, - target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUIDLow() : 0); - break; - } + pTarget = source->ToPlayer(); + if (pTarget) + { + if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER) + { + sLog.outError("%s target is not unit, gameobject or player (TypeId: %u, Entry: %u, GUID: %u), skipping.", + step.script->GetDebugInfo().c_str(), target->GetTypeId(), target->GetEntry(), target->GetGUIDLow()); + break; + } + worldObject = dynamic_cast<WorldObject*>(target); + } + else + { + sLog.outError("%s neither source nor target is player (source: TypeId: %u, Entry: %u, GUID: %u; target: TypeId: %u, Entry: %u, GUID: %u), skipping.", + step.script->GetDebugInfo().c_str(), + source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUIDLow() : 0, + target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUIDLow() : 0); + break; + } } // quest id and flags checked at script loading diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 7dd8ad17957..7df7350f344 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -451,7 +451,7 @@ int32 AuraEffect::CalculateAmount(Unit * caster) m_canBeRecalculated = false; if (!m_spellProto->procFlags) break; - amount = int32(GetBase()->GetUnitOwner()->GetMaxHealth()*0.10f); + amount = int32(GetBase()->GetUnitOwner()->CountPctFromMaxHealth(10)); if (caster) { // Glyphs increasing damage cap @@ -717,7 +717,7 @@ int32 AuraEffect::CalculateAmount(Unit * caster) case SPELL_AURA_MOD_INCREASE_HEALTH: // Vampiric Blood if (GetId() == 55233) - amount = GetBase()->GetUnitOwner()->GetMaxHealth() * amount / 100; + amount = GetBase()->GetUnitOwner()->CountPctFromMaxHealth(amount); break; case SPELL_AURA_MOD_INCREASE_ENERGY: // Hymn of Hope @@ -1288,7 +1288,7 @@ void AuraEffect::PeriodicTick(Unit * target, Unit * caster) const { case 43093: case 31956: case 38801: // Grievous Wound case 35321: case 38363: case 39215: // Gushing Wound - if (target->GetHealth() == target->GetMaxHealth()) + if (target->IsFullHealth()) { target->RemoveAurasDueToSpell(GetId()); return; @@ -1300,7 +1300,7 @@ void AuraEffect::PeriodicTick(Unit * target, Unit * caster) const GetEffIndex() < 2 && GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_DUMMY ? caster->CalculateSpellDamage(target, GetSpellProto(),GetEffIndex()+1) : 100; - if (target->GetHealth()*100 >= target->GetMaxHealth()*percent) + if (!target->HealthBelowPct(percent)) { target->RemoveAurasDueToSpell(GetId()); return; @@ -1358,7 +1358,7 @@ void AuraEffect::PeriodicTick(Unit * target, Unit * caster) const } } else - damage = uint32(target->GetMaxHealth()*damage/100); + damage = uint32(target->CountPctFromMaxHealth(damage)); bool crit = IsPeriodicTickCrit(target, caster); if (crit) @@ -1523,7 +1523,7 @@ void AuraEffect::PeriodicTick(Unit * target, Unit * caster) const if (target != caster && GetSpellProto()->AttributesEx2 & SPELL_ATTR_EX2_HEALTH_FUNNEL && !caster->isAlive()) break; - if (GetBase()->GetDuration() == -1 && target->GetHealth() == target->GetMaxHealth()) + if (GetBase()->GetDuration() == -1 && target->IsFullHealth()) break; // ignore non positive values (can be result apply spellmods to aura damage @@ -1558,7 +1558,7 @@ void AuraEffect::PeriodicTick(Unit * target, Unit * caster) const TakenTotalMod = TakenTotalMod > 0.0f ? TakenTotalMod : 0.0f; - damage = uint32(target->GetMaxHealth() * damage / 100); + damage = uint32(target->CountPctFromMaxHealth(damage)); damage = uint32(damage * TakenTotalMod); } else @@ -1894,7 +1894,7 @@ void AuraEffect::PeriodicDummyTick(Unit * target, Unit * caster) const case 51687: case 51688: case 51689: - if (target->getVictim() && (target->GetHealth() * 100 / target->GetMaxHealth() > target->getVictim()->GetHealth() * 100 / target->getVictim()->GetMaxHealth())) { + if (target->getVictim() && (target->GetHealthPct() > target->getVictim()->GetHealthPct())) { if (!target->HasAura(58670)) { int32 basepoints = SpellMgr::CalculateSpellEffectAmount(GetSpellProto(), 0); target->CastCustomSpell(target, 58670, &basepoints, 0, 0, true); @@ -2052,12 +2052,12 @@ void AuraEffect::PeriodicDummyTick(Unit * target, Unit * caster) const { // Feeding Frenzy Rank 1 case 53511: - if (target->getVictim() && target->getVictim()->GetHealth() * 100 < target->getVictim()->GetMaxHealth() * 35) + if (target->getVictim() && target->getVictim()->HealthBelowPct(35)) target->CastSpell(target, 60096, true, 0, this); return; // Feeding Frenzy Rank 2 case 53512: - if (target->getVictim() && target->getVictim()->GetHealth() * 100 < target->getVictim()->GetMaxHealth() * 35) + if (target->getVictim() && target->getVictim()->HealthBelowPct(35)) target->CastSpell(target, 60097, true, 0, this); return; default: @@ -2078,7 +2078,7 @@ void AuraEffect::PeriodicDummyTick(Unit * target, Unit * caster) const switch (GetId()) { case 49016: // Hysteria - uint32 damage = uint32(target->GetMaxHealth()*0.01f); + uint32 damage = uint32(target->CountPctFromMaxHealth(1)); target->DealDamage(target, damage, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); break; } @@ -2153,7 +2153,7 @@ void AuraEffect::TriggerSpell(Unit * target, Unit * caster) const case 24379: case 23493: { - int32 heal = caster->GetMaxHealth() / 10; + int32 heal = caster->CountPctFromMaxHealth(10); caster->DealHeal(target, heal, auraSpellInfo); int32 mana = caster->GetMaxPower(POWER_MANA); @@ -2176,7 +2176,7 @@ void AuraEffect::TriggerSpell(Unit * target, Unit * caster) const return; // Frost Blast case 27808: - caster->CastCustomSpell(29879, SPELLVALUE_BASE_POINT0, int32((float)target->GetMaxHealth()*0.21f), target, true, NULL, this); + caster->CastCustomSpell(29879, SPELLVALUE_BASE_POINT0, int32(target->CountPctFromMaxHealth(21)), target, true, NULL, this); return; // Detonate Mana case 27819: @@ -4735,9 +4735,7 @@ void AuraEffect::HandleModTotalPercentStat(AuraApplication const * aurApp, uint8 //recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag) if ((GetMiscValue() == STAT_STAMINA) && (maxHPValue > 0) && (m_spellProto->Attributes & 0x10)) { - // hmm... why is newHPValue a uint64 here? - // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed - uint64 newHPValue = (target->GetMaxHealth() * curHPValue) / maxHPValue; + uint32 newHPValue = target->CountPctFromMaxHealth(int32(100.0f * curHPValue / maxHPValue)); target->SetHealth(newHPValue); } } @@ -4925,10 +4923,10 @@ void AuraEffect::HandleAuraModIncreaseHealthPercent(AuraApplication const * aurA Unit * target = aurApp->GetTarget(); // Unit will keep hp% after MaxHealth being modified if unit is alive. - float percent = ((float)target->GetHealth()) / target->GetMaxHealth(); + float percent = target->GetHealthPct(); target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_PCT, float(GetAmount()), apply); if (target->isAlive()) - target->SetHealth(uint32(target->GetMaxHealth()*percent)); + target->SetHealth(target->CountPctFromMaxHealth(percent)); } void AuraEffect::HandleAuraIncreaseBaseHealthPercent(AuraApplication const * aurApp, uint8 mode, bool apply) const @@ -6085,7 +6083,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const * aurApp, uint8 mode, boo if (!target->IsInFeralForm()) break; - int32 bp0 = int32(target->GetMaxHealth() * GetAmount() / 100); + int32 bp0 = int32(target->CountPctFromMaxHealth(GetAmount())); target->CastCustomSpell(target, 50322, &bp0, NULL, NULL, true); } else diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 2b929e5ba07..2831bbce8cd 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -1516,7 +1516,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const * aurApp, Unit * caster, break; if (apply) { - if (target != caster && target->GetHealth() <= target->GetMaxHealth() / 4) + if (target != caster && !target->HealthAbovePct(25)) caster->CastSpell(caster, 200000, true); } else diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 64694c502c6..f8128a632ea 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -1757,7 +1757,7 @@ struct ChainHealingOrder : public std::binary_function<const Unit*, const Unit*, else*/ if (Target->GetTypeId() == TYPEID_PLAYER && MainTarget->GetTypeId() == TYPEID_PLAYER && Target->ToPlayer()->IsInSameRaidWith(MainTarget->ToPlayer())) { - if (Target->GetHealth() == Target->GetMaxHealth()) + if (Target->IsFullHealth()) return 40000; else return 20000 - Target->GetMaxHealth() + Target->GetHealth(); @@ -1792,7 +1792,7 @@ void Spell::SearchChainTarget(std::list<Unit*> &TagUnitMap, float max_range, uin { SearchAreaTarget(tempUnitMap, max_range, PUSH_CHAIN, SPELL_TARGETS_ALLY); tempUnitMap.sort(ChainHealingOrder(m_caster)); - //if (cur->GetHealth() == cur->GetMaxHealth() && tempUnitMap.size()) + //if (cur->IsFullHealth() && tempUnitMap.size()) // cur = tempUnitMap.front(); } else @@ -6050,7 +6050,7 @@ SpellCastResult Spell::CheckItems() if (m_spellInfo->Effect[i] == SPELL_EFFECT_HEAL) { - if (m_targets.getUnitTarget()->GetHealth() == m_targets.getUnitTarget()->GetMaxHealth()) + if (m_targets.getUnitTarget()->IsFullHealth()) { failReason = SPELL_FAILED_ALREADY_AT_FULL_HEALTH; continue; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 3e870182e63..29a51df0caf 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -415,13 +415,13 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx) // Cataclysmic Bolt case 38441: { - damage = unitTarget->GetMaxHealth() / 2; + damage = unitTarget->CountPctFromMaxHealth(50); break; } // Tympanic Tantrum case 62775: { - damage = unitTarget->GetMaxHealth() / 10; + damage = unitTarget->CountPctFromMaxHealth(10); break; } // Gargoyle Strike @@ -1264,11 +1264,11 @@ void Spell::EffectDummy(uint32 i) } case 47170: // Impale Leviroth { - if (!unitTarget && unitTarget->GetEntry() != 26452 && ((unitTarget->GetHealth() / unitTarget->GetMaxHealth()) * 100.0f) > 95.0f) - return; + if (!unitTarget && unitTarget->GetEntry() != 26452 && unitTarget->HealthAbovePct(95)) + return; - m_caster->DealDamage(unitTarget, uint32(unitTarget->GetMaxHealth()*0.93f)); - return; + m_caster->DealDamage(unitTarget, unitTarget->CountPctFromMaxHealth(93)); + return; } case 49357: // Brewfest Mount Transformation if (m_caster->GetTypeId() != TYPEID_PLAYER) @@ -1679,7 +1679,7 @@ void Spell::EffectDummy(uint32 i) if (m_spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_DK_DEATH_STRIKE) { uint32 count = unitTarget->GetDiseasesByCaster(m_caster->GetGUID()); - int32 bp = int32(count * m_caster->GetMaxHealth() * m_spellInfo->DmgMultiplier[0] / 100); + int32 bp = int32(count * m_caster->CountPctFromMaxHealth(m_spellInfo->DmgMultiplier[0])); // Improved Death Strike if (AuraEffect const * aurEff = m_caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, 2751, 0)) bp = int32(bp * (m_caster->CalculateSpellDamage(m_caster, aurEff->GetSpellProto(), 2) + 100.0f) / 100.0f); @@ -2557,7 +2557,7 @@ void Spell::SpellDamageHeal(uint32 /*i*/) } // Death Pact - return pct of max health to caster else if (m_spellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && m_spellInfo->SpellFamilyFlags[0] & 0x00080000) - addhealth = caster->SpellHealingBonus(unitTarget, m_spellInfo, int32(caster->GetMaxHealth() * damage / 100.0f), HEAL); + addhealth = caster->SpellHealingBonus(unitTarget, m_spellInfo, int32(caster->CountPctFromMaxHealth(damage)), HEAL); else addhealth = caster->SpellHealingBonus(unitTarget, m_spellInfo, addhealth, HEAL); @@ -2584,7 +2584,7 @@ void Spell::EffectHealPct(uint32 /*i*/) if (m_spellInfo->Id == 59754 && unitTarget == m_caster) return; - uint32 addhealth = caster->SpellHealingBonus(unitTarget, m_spellInfo, uint32(unitTarget->GetMaxHealth() * damage / 100.0f), HEAL); + uint32 addhealth = caster->SpellHealingBonus(unitTarget, m_spellInfo, unitTarget->CountPctFromMaxHealth(damage), HEAL); //if (Player *modOwner = m_caster->GetSpellModOwner()) // modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DAMAGE, addhealth, this); @@ -4733,7 +4733,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) case 54426: if (unitTarget) { - int32 damage = int32((int32)unitTarget->GetHealth() - (int32)unitTarget->GetMaxHealth() * 0.05f); + int32 damage = int32(unitTarget->GetHealth()) - int32(unitTarget->CountPctFromMaxHealth(5)); if (damage > 0) m_caster->CastCustomSpell(28375, SPELLVALUE_BASE_POINT0, damage, unitTarget); } @@ -6113,7 +6113,7 @@ void Spell::EffectResurrect(uint32 /*effIndex*/) if (pTarget->isRessurectRequested()) // already have one active request return; - uint32 health = pTarget->GetMaxHealth() * damage / 100; + uint32 health = pTarget->CountPctFromMaxHealth(damage); uint32 mana = pTarget->GetMaxPower(POWER_MANA) * damage / 100; pTarget->setResurrectRequestData(m_caster->GetGUID(), m_caster->GetMapId(), m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ(), health, mana); @@ -6241,7 +6241,7 @@ void Spell::EffectSelfResurrect(uint32 i) // percent case else { - health = uint32(damage/100.0f*unitTarget->GetMaxHealth()); + health = unitTarget->CountPctFromMaxHealth(damage); if (unitTarget->GetMaxPower(POWER_MANA) > 0) mana = uint32(damage/100.0f*unitTarget->GetMaxPower(POWER_MANA)); } @@ -6495,7 +6495,7 @@ void Spell::EffectSummonDeadPet(uint32 /*i*/) pet->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); pet->setDeathState(ALIVE); pet->clearUnitState(UNIT_STAT_ALL_STATE); - pet->SetHealth(uint32(pet->GetMaxHealth()*(float(damage)/100))); + pet->SetHealth(pet->CountPctFromMaxHealth(damage)); //pet->AIM_Initialize(); //_player->PetSpellInitialize(); diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp index 77719cc80a2..95f523268d4 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/blackrock_depths.cpp @@ -418,7 +418,7 @@ public: } else ThunderClap_Timer -= diff; //FireballVolley_Timer - if (me->GetHealth()*100 / me->GetMaxHealth() < 51) + if (HealthBelowPct(51)) { if (FireballVolley_Timer <= diff) { diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_general_angerforge.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_general_angerforge.cpp index 135b774ad95..2b483b4ae43 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_general_angerforge.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_general_angerforge.cpp @@ -105,7 +105,7 @@ public: } else Cleave_Timer -= diff; //Adds_Timer - if (me->GetHealth()*100 / me->GetMaxHealth() < 21) + if (HealthBelowPct(21)) { if (Adds_Timer <= diff) { @@ -119,7 +119,7 @@ public: } //Summon Medics - if (!Medics && me->GetHealth()*100 / me->GetMaxHealth() < 21) + if (!Medics && HealthBelowPct(21)) { SummonMedics(me->getVictim()); SummonMedics(me->getVictim()); diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_grizzle.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_grizzle.cpp index da7ba6fa7d5..bf81f6144d9 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_grizzle.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_grizzle.cpp @@ -77,7 +77,7 @@ public: } else GroundTremor_Timer -= diff; //Frenzy_Timer - if (me->GetHealth()*100 / me->GetMaxHealth() < 51) + if (HealthBelowPct(51)) { if (Frenzy_Timer <= diff) { diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_magmus.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_magmus.cpp index 3ce46b15d9d..90fc17043dd 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_magmus.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_magmus.cpp @@ -77,7 +77,7 @@ public: } else FieryBurst_Timer -= diff; //WarStomp_Timer - if (me->GetHealth()*100 / me->GetMaxHealth() < 51) + if (HealthBelowPct(51)) { if (WarStomp_Timer <= diff) { diff --git a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_tomb_of_seven.cpp b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_tomb_of_seven.cpp index 8f427c66fed..0d6fda9430f 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_tomb_of_seven.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockDepths/boss_tomb_of_seven.cpp @@ -240,7 +240,7 @@ public: } else DemonArmor_Timer -= diff; //Summon Voidwalkers - if (!Voidwalkers && me->GetHealth()*100 / me->GetMaxHealth() < 51) + if (!Voidwalkers && HealthBelowPct(51)) { DoCast(me->getVictim(), SPELL_SUMMON_VOIDWALKERS, true); Voidwalkers = true; diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_gyth.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_gyth.cpp index 7382b9acafc..fe2d8682e2c 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_gyth.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_gyth.cpp @@ -184,8 +184,7 @@ public: } else Flamebreath_Timer -= diff; //Summon Rend - if (!SummonedRend && me->GetHealth()*100 / me->GetMaxHealth() < 11 - && me->GetHealth() > 0) + if (!SummonedRend && HealthBelowPct(11) && me->GetHealth() > 0) { //summon Rend and Change model to normal Gyth //Interrupt any spell casting diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_halycon.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_halycon.cpp index 42031639071..f7dd65fcf68 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_halycon.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_halycon.cpp @@ -83,7 +83,7 @@ public: } else MightyBlow_Timer -= diff; //Summon Gizrul - if (!Summoned && me->GetHealth()*100 / me->GetMaxHealth() < 25) + if (!Summoned && HealthBelowPct(25)) { me->SummonCreature(10268,ADD_1X,ADD_1Y,ADD_1Z,ADD_1O,TEMPSUMMON_TIMED_DESPAWN,300000); Summoned = true; diff --git a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_overlord_wyrmthalak.cpp b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_overlord_wyrmthalak.cpp index 1ec09bdf429..257a1cfad8f 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_overlord_wyrmthalak.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockSpire/boss_overlord_wyrmthalak.cpp @@ -108,7 +108,7 @@ public: } else Knockaway_Timer -= diff; //Summon two Beserks - if (!Summoned && me->GetHealth()*100 / me->GetMaxHealth() < 51) + if (!Summoned && HealthBelowPct(51)) { Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM,0, 100, true); diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp index 4c20fa56c6e..334745acb73 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_chromaggus.cpp @@ -288,7 +288,7 @@ public: } else Frenzy_Timer -= diff; //Enrage if not already enraged and below 20% - if (!Enraged && (me->GetHealth()*100 / me->GetMaxHealth()) < 20) + if (!Enraged && HealthBelowPct(20)) { DoCast(me, SPELL_ENRAGE); Enraged = true; diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_nefarian.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_nefarian.cpp index 441012f8eb6..9035619eeed 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_nefarian.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_nefarian.cpp @@ -218,7 +218,7 @@ public: } else ClassCall_Timer -= diff; //Phase3 begins when we are below X health - if (!Phase3 && (me->GetHealth()*100 / me->GetMaxHealth()) < 20) + if (!Phase3 && HealthBelowPct(20)) { Phase3 = true; DoScriptText(SAY_RAISE_SKELETONS, me); diff --git a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_vaelastrasz.cpp b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_vaelastrasz.cpp index 59dc92df6f5..f5329889d8f 100644 --- a/src/server/scripts/EasternKingdoms/BlackwingLair/boss_vaelastrasz.cpp +++ b/src/server/scripts/EasternKingdoms/BlackwingLair/boss_vaelastrasz.cpp @@ -141,7 +141,7 @@ public: { DoCast(me, SPELL_ESSENCEOFTHERED); DoZoneInCombat(); - me->SetHealth(int(me->GetMaxHealth()*.3)); + me->SetHealth(me->CountPctFromMaxHealth(30)); } void UpdateAI(const uint32 diff) @@ -184,7 +184,7 @@ public: return; // Yell if hp lower than 15% - if (me->GetHealth()*100 / me->GetMaxHealth() < 15 && !HasYelled) + if (HealthBelowPct(15) && !HasYelled) { DoScriptText(SAY_HALFLIFE, me); HasYelled = true; diff --git a/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp b/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp index b0bc9cc3711..6fbc83e05a3 100644 --- a/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp +++ b/src/server/scripts/EasternKingdoms/Deadmines/boss_mr_smite.cpp @@ -121,7 +121,7 @@ public: } else uiNimbleReflexesTimer -= uiDiff; /*END ACID-AI*/ - if (uiHealth == 0 && me->GetHealth()*100 / me->GetMaxHealth() <= 66 || uiHealth == 1 && me->GetHealth()*100 / me->GetMaxHealth() <= 33) + if (uiHealth == 0 && !HealthAbovePct(66) || uiHealth == 1 && !HealthAbovePct(33)) { ++uiHealth; DoCastAOE(SPELL_SMITE_STOMP,false); @@ -130,7 +130,7 @@ public: if (GameObject* pGo = GameObject::GetGameObject((*me),pInstance->GetData64(DATA_SMITE_CHEST))) { me->GetMotionMaster()->Clear(); - me->GetMotionMaster()->MovePoint(1,-3.00+pGo->GetPositionX(),pGo->GetPositionY(),pGo->GetPositionZ()); + me->GetMotionMaster()->MovePoint(1, pGo->GetPositionX() - 3.0f, pGo->GetPositionY(), pGo->GetPositionZ()); } } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp index 2216bfd17ee..00d80f06771 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_curator.cpp @@ -169,7 +169,7 @@ public: AddTimer = 10000; } else AddTimer -= diff; - if (me->GetHealth()*100 / me->GetMaxHealth() <= 15) + if (!HealthAbovePct(15)) { Enraged = true; DoCast(me, SPELL_ENRAGE); diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp index d82617124d6..af4f061fe3d 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp @@ -151,7 +151,7 @@ public: if (!UpdateVictim()) return; - if (Phase == 1 && (me->GetHealth()*100)/me->GetMaxHealth() < 95) + if (Phase == 1 && HealthBelowPct(95)) { Phase = 2; if (Creature* pAttumen = me->SummonCreature(SUMMON_ATTUMEN, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 30000)) @@ -162,7 +162,7 @@ public: DoScriptText(RAND(SAY_APPEAR1,SAY_APPEAR2,SAY_APPEAR3), pAttumen); } } - else if (Phase == 2 && (me->GetHealth()*100)/me->GetMaxHealth() < 25) + else if (Phase == 2 && HealthBelowPct(25)) { if (Unit *pAttumen = Unit::GetUnit(*me, Attumen)) Mount(pAttumen); @@ -295,7 +295,7 @@ void boss_attumen::boss_attumenAI::UpdateAI(const uint32 diff) } else { - if ((me->GetHealth()*100)/me->GetMaxHealth() < 25) + if (HealthBelowPct(25)) { Creature *pMidnight = Unit::GetCreature(*me, Midnight); if (pMidnight && pMidnight->GetTypeId() == TYPEID_UNIT) diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp index 78391612fd7..f2bd6edc774 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_moroes.cpp @@ -243,7 +243,7 @@ public: return; } - if (!Enrage && me->GetHealth()*100 / me->GetMaxHealth() < 30) + if (!Enrage && HealthBelowPct(30)) { DoCast(me, SPELL_FRENZY); Enrage = true; diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp index 886853663be..45dc02db4d7 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_nightbane.cpp @@ -341,8 +341,7 @@ public: SearingCindersTimer = 10000; } else SearingCindersTimer -= diff; - uint32 Prozent; - Prozent = (me->GetHealth()*100) / me->GetMaxHealth(); + uint32 Prozent = uint32(me->GetHealthPct()); if (Prozent < 75 && FlyCount == 0) // first take off 75% TakeOff(); diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp index a84da32fb03..b70fc098d0e 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_prince_malchezaar.cpp @@ -397,7 +397,7 @@ public: if (phase == 1) { - if ((me->GetHealth()*100) / me->GetMaxHealth() < 60) + if (HealthBelowPct(60)) { me->InterruptNonMeleeSpells(false); @@ -432,7 +432,7 @@ public: } else if (phase == 2) { - if ((me->GetHealth()*100) / me->GetMaxHealth() < 30) + if (HealthBelowPct(30)) { InfernalTimer = 15000; diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp index a517c94b0c3..44fec322a99 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp @@ -416,7 +416,7 @@ public: SuperCastTimer = urand(35000,40000); } else SuperCastTimer -= diff; - if (!ElementalsSpawned && me->GetHealth()*100 / me->GetMaxHealth() < 40) + if (!ElementalsSpawned && HealthBelowPct(40)) { ElementalsSpawned = true; diff --git a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp index f95437dd83b..2c71770311d 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/bosses_opera.cpp @@ -988,7 +988,7 @@ void PretendToDie(Creature* pCreature) void Resurrect(Creature *pTarget) { pTarget->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - pTarget->SetHealth(pTarget->GetMaxHealth()); + pTarget->SetFullHealth(); pTarget->SetStandState(UNIT_STAND_STATE_STAND); pTarget->CastSpell(pTarget, SPELL_RES_VISUAL, true); if (pTarget->getVictim()) diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp index 56117dd4733..0b900103e4e 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_felblood_kaelthas.cpp @@ -334,7 +334,7 @@ public: } else FlameStrikeTimer -= diff; // Below 50% - if (me->GetMaxHealth() * 0.5f > me->GetHealth()) + if (HealthBelowPct(50)) { me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true); me->StopMoving(); diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp index c4c63c038a0..7f3b23142e2 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp @@ -461,7 +461,7 @@ struct boss_priestess_lackey_commonAI : public ScriptedAI void UpdateAI(const uint32 diff) { - if (!UsedPotion && (me->GetHealth()*100 / me->GetMaxHealth()) < 25) + if (!UsedPotion && HealthBelowPct(25)) { DoCast(me, SPELL_HEALING_POTION); UsedPotion = true; @@ -803,7 +803,7 @@ public: } } else Polymorph_Timer -= diff; - if (((me->GetHealth()*100 / me->GetMaxHealth()) < 35) && !HasIceBlocked) + if (HealthBelowPct(35) && !HasIceBlocked) { DoCast(me, SPELL_ICE_BLOCK); HasIceBlocked = true; diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp index 1bd20622d13..a1c4caaaea1 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp @@ -132,7 +132,7 @@ public: if (!Enraged) { //used for check, when Vexallus cast adds 85%, 70%, 55%, 40%, 25% - if ((me->GetHealth()*100 / me->GetMaxHealth()) <= (100-(INTERVAL_MODIFIER*IntervalHealthAmount))) + if (!HealthAbovePct(100 - INTERVAL_MODIFIER * IntervalHealthAmount)) { //increase amount, unless we're at 10%, then we switch and return if (IntervalHealthAmount == INTERVAL_SWITCH) diff --git a/src/server/scripts/EasternKingdoms/MoltenCore/boss_baron_geddon.cpp b/src/server/scripts/EasternKingdoms/MoltenCore/boss_baron_geddon.cpp index 9dd5f0ffd1f..36569a63d45 100644 --- a/src/server/scripts/EasternKingdoms/MoltenCore/boss_baron_geddon.cpp +++ b/src/server/scripts/EasternKingdoms/MoltenCore/boss_baron_geddon.cpp @@ -67,7 +67,7 @@ public: return; //If we are <2% hp cast Armageddom - if (me->GetHealth()*100 / me->GetMaxHealth() <= 2) + if (!HealthAbovePct(2)) { me->InterruptNonMeleeSpells(true); DoCast(me, SPELL_ARMAGEDDOM); diff --git a/src/server/scripts/EasternKingdoms/MoltenCore/boss_garr.cpp b/src/server/scripts/EasternKingdoms/MoltenCore/boss_garr.cpp index be8eb00b34b..965c8f517d2 100644 --- a/src/server/scripts/EasternKingdoms/MoltenCore/boss_garr.cpp +++ b/src/server/scripts/EasternKingdoms/MoltenCore/boss_garr.cpp @@ -130,7 +130,7 @@ public: } else Immolate_Timer -= diff; //Cast Erruption and let them die - if (me->GetHealth() <= me->GetMaxHealth() * 0.10) + if (!HealthAbovePct(10)) { DoCast(me->getVictim(), SPELL_ERUPTION); me->setDeathState(JUST_DIED); diff --git a/src/server/scripts/EasternKingdoms/MoltenCore/boss_golemagg.cpp b/src/server/scripts/EasternKingdoms/MoltenCore/boss_golemagg.cpp index b785b51de93..446bab0a1b2 100644 --- a/src/server/scripts/EasternKingdoms/MoltenCore/boss_golemagg.cpp +++ b/src/server/scripts/EasternKingdoms/MoltenCore/boss_golemagg.cpp @@ -96,7 +96,7 @@ public: m_uiPyroblastTimer -= uiDiff; // Enrage - if (!m_bEnraged && me->GetHealth()*100 < me->GetMaxHealth()*10) + if (!m_bEnraged && HealthBelowPct(10)) { DoCast(me, SPELL_ENRAGE); m_bEnraged = true; @@ -159,7 +159,7 @@ public: void DamageTaken(Unit* /*pDoneBy*/, uint32& uiDamage) { - if (me->GetHealth()*100 < me->GetMaxHealth()*50) + if (HealthBelowPct(50)) { if (m_pInstance) { @@ -168,7 +168,7 @@ public: if (pGolemagg->isAlive()) { DoScriptText(EMOTE_LOWHP, me); - me->SetHealth(me->GetMaxHealth()); + me->SetFullHealth(); } else uiDamage = me->GetHealth(); diff --git a/src/server/scripts/EasternKingdoms/MoltenCore/boss_majordomo_executus.cpp b/src/server/scripts/EasternKingdoms/MoltenCore/boss_majordomo_executus.cpp index 17379de47a1..5e7bae31f10 100644 --- a/src/server/scripts/EasternKingdoms/MoltenCore/boss_majordomo_executus.cpp +++ b/src/server/scripts/EasternKingdoms/MoltenCore/boss_majordomo_executus.cpp @@ -97,7 +97,7 @@ public: return; //Cast Ageis if less than 50% hp - if (me->GetHealth()*100 / me->GetMaxHealth() < 50) + if (HealthBelowPct(50)) { DoCast(me, SPELL_AEGIS); } diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp index 5eaa74a5211..d42923cd901 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp @@ -393,9 +393,9 @@ public: bool OnGossipHello(Player* pPlayer, Creature* pCreature) { - if (pPlayer->GetQuestStatus(QUEST_DEATH_CHALLENGE) == QUEST_STATUS_INCOMPLETE && pCreature->GetHealth() == pCreature->GetMaxHealth()) + if (pPlayer->GetQuestStatus(QUEST_DEATH_CHALLENGE) == QUEST_STATUS_INCOMPLETE && pCreature->IsFullHealth()) { - if (pPlayer->GetHealth() * 10 < pPlayer->GetMaxHealth()) + if (pPlayer->HealthBelowPct(10)) return true; if (pPlayer->isInCombat() || pCreature->isInCombat()) @@ -496,8 +496,7 @@ public: EnterEvadeMode(); return; } - else if (me->getVictim()->GetTypeId() == TYPEID_PLAYER - && me->getVictim()->GetHealth() * 10 < me->getVictim()->GetMaxHealth()) + else if (me->getVictim()->GetTypeId() == TYPEID_PLAYER && me->getVictim()->HealthBelowPct(10)) { me->getVictim()->CastSpell(me->getVictim(), 7267, true); // beg me->getVictim()->RemoveGameObject(SPELL_DUEL_FLAG, true); diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_arcanist_doan.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_arcanist_doan.cpp index 8acd4e782ac..8d1fe7d6117 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_arcanist_doan.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_arcanist_doan.cpp @@ -86,7 +86,7 @@ public: return; //If we are <50% hp cast Arcane Bubble - if (!bShielded && me->GetHealth()*100 / me->GetMaxHealth() <= 50) + if (!bShielded && !HealthAbovePct(50)) { //wait if we already casting if (me->IsNonMeleeSpellCasted(false)) diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_azshir_the_sleepless.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_azshir_the_sleepless.cpp index 3a0b3eaa5a9..f421e447408 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_azshir_the_sleepless.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_azshir_the_sleepless.cpp @@ -64,7 +64,7 @@ public: return; //If we are <50% hp cast Soul Siphon rank 1 - if (me->GetHealth()*100 / me->GetMaxHealth() <= 50 && !me->IsNonMeleeSpellCasted(false)) + if (!HealthAbovePct(50) && !me->IsNonMeleeSpellCasted(false)) { //SoulSiphon_Timer if (SoulSiphon_Timer <= diff) diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_bloodmage_thalnos.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_bloodmage_thalnos.cpp index 9634bafb642..30a6c729796 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_bloodmage_thalnos.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_bloodmage_thalnos.cpp @@ -82,7 +82,7 @@ public: return; //If we are <35% hp - if (!HpYell && ((me->GetHealth()*100) / me->GetMaxHealth() <= 35)) + if (!HpYell && !HealthAbovePct(35)) { DoScriptText(SAY_HEALTH, me); HpYell = true; diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp index ca36128561e..096f58fe809 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_headless_horseman.cpp @@ -267,11 +267,11 @@ public: switch(Phase) { case 1: - if (((me->GetHealth() - damage)*100)/me->GetMaxHealth() < 67) + if (me->HealthBelowPctDamaged(67, damage)) Disappear(); break; case 2: - if (((me->GetHealth() - damage)*100)/me->GetMaxHealth() < 34) + if (me->HealthBelowPctDamaged(34, damage)) Disappear(); break; case 3: @@ -280,7 +280,7 @@ public: die = true; withbody = true; wait = 300; - damage = me->GetHealth() - me->GetMaxHealth()/100; + damage = me->GetHealth() - me->CountPctFromMaxHealth(1); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->StopMoving(); //me->GetMotionMaster()->MoveIdle(); @@ -585,7 +585,7 @@ public: withhead = true; me->RemoveAllAuras(); me->SetName("Headless Horseman"); - me->SetHealth(me->GetMaxHealth()); + me->SetFullHealth(); SaySound(SAY_REJOINED); DoCast(me, SPELL_HEAD); caster->GetMotionMaster()->Clear(false); @@ -607,7 +607,7 @@ public: { withhead = false; returned = false; - damage = me->GetHealth() - me->GetMaxHealth()/100; + damage = me->GetHealth() - me->CountPctFromMaxHealth(1); me->RemoveAllAuras(); me->SetName("Headless Horseman, Unhorsed"); @@ -727,7 +727,7 @@ public: if (regen <= diff) { regen = 1000; //"body calls head" - if (me->GetHealth()/me->GetMaxHealth() == 1 && !returned) + if (me->IsFullHealth() && !returned) { if (Phase > 1) --Phase; @@ -891,7 +891,7 @@ void mob_head::mob_headAI::Disappear() me->RemoveAllAuras(); body->RemoveAurasDueToSpell(SPELL_IMMUNE);//hack, SpellHit doesn't calls if body has immune aura DoCast(body, SPELL_FLYING_HEAD); - me->SetHealth(me->GetMaxHealth()); + me->SetFullHealth(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->GetMotionMaster()->MoveIdle(); diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp index d94ece456c0..ff9171994b5 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_herod.cpp @@ -89,7 +89,7 @@ public: return; //If we are <30% hp goes Enraged - if (!Enrage && me->GetHealth()*100 / me->GetMaxHealth() <= 30 && !me->IsNonMeleeSpellCasted(false)) + if (!Enrage && !HealthAbovePct(30) && !me->IsNonMeleeSpellCasted(false)) { DoScriptText(EMOTE_ENRAGE, me); DoScriptText(SAY_ENRAGE, me); diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_high_inquisitor_fairbanks.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_high_inquisitor_fairbanks.cpp index d149eb280bd..bb6b3e9f26c 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_high_inquisitor_fairbanks.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_high_inquisitor_fairbanks.cpp @@ -78,7 +78,7 @@ public: return; //If we are <25% hp cast Heal - if (me->GetHealth()*100 / me->GetMaxHealth() <= 25 && !me->IsNonMeleeSpellCasted(false) && Heal_Timer <= diff) + if (!HealthAbovePct(25) && !me->IsNonMeleeSpellCasted(false) && Heal_Timer <= diff) { DoCast(me, SPELL_HEAL); Heal_Timer = 30000; @@ -103,7 +103,7 @@ public: } else Sleep_Timer -= diff; //PowerWordShield_Timer - if (!PowerWordShield && me->GetHealth()*100 / me->GetMaxHealth() <= 25) + if (!PowerWordShield && !HealthAbovePct(25)) { DoCast(me, SPELL_POWERWORDSHIELD); PowerWordShield = true; diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_interrogator_vishas.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_interrogator_vishas.cpp index 23c6562e9c2..57335665e71 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_interrogator_vishas.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_interrogator_vishas.cpp @@ -91,13 +91,13 @@ public: return; //If we are low on hp Do sayings - if (!Yell60 && ((me->GetHealth()*100) / me->GetMaxHealth() <= 60)) + if (!Yell60 && !HealthAbovePct(60)) { DoScriptText(SAY_HEALTH1, me); Yell60 = true; } - if (!Yell30 && ((me->GetHealth()*100) / me->GetMaxHealth() <= 30)) + if (!Yell30 && !HealthAbovePct(30)) { DoScriptText(SAY_HEALTH2, me); Yell30 = true; diff --git a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp index 7ae7311b4eb..aa7ae7f762c 100644 --- a/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletMonastery/boss_mograine_and_whitemane.cpp @@ -299,7 +299,7 @@ public: } //Cast Deep sleep when health is less than 50% - if (!m_bCanResurrectCheck && me->GetHealth()*100 / me->GetMaxHealth() <= 50) + if (!m_bCanResurrectCheck && !HealthAbovePct(50)) { if (me->IsNonMeleeSpellCasted(false)) me->InterruptNonMeleeSpells(false); @@ -319,7 +319,7 @@ public: { Creature* pTarget = NULL; - if (me->GetHealth() <= me->GetMaxHealth()*0.75f) + if (!HealthAbovePct(75)) pTarget = me; if (m_pInstance) @@ -327,7 +327,7 @@ public: if (Creature* pMograine = Unit::GetCreature((*me), m_pInstance->GetData64(DATA_MOGRAINE))) { // checking m_bCanResurrectCheck prevents her healing Mograine while he is "faking death" - if (m_bCanResurrectCheck && pMograine->isAlive() && pMograine->GetHealth() <= pMograine->GetMaxHealth()*0.75f) + if (m_bCanResurrectCheck && pMograine->isAlive() && !pMograine->HealthAbovePct(75)) pTarget = pMograine; } } diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp index 677a02b0187..8b306f1f148 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp @@ -120,7 +120,7 @@ public: //Teleporting Random Target to one of the six pre boss rooms and spawn 3-4 skeletons near the gamer. //We will only telport if gandling has more than 3% of hp so teleported gamers can always loot. - if (me->GetHealth()*100 / me->GetMaxHealth() > 3) + if (HealthAbovePct(3)) { if (Teleport_Timer <= diff) { diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_doctor_theolen_krastinov.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_doctor_theolen_krastinov.cpp index 0bac76be60b..1915ac60f9e 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_doctor_theolen_krastinov.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_doctor_theolen_krastinov.cpp @@ -96,7 +96,7 @@ public: m_uiBackhand_Timer -= uiDiff; //Frenzy_Timer - if (me->GetHealth()*100 / me->GetMaxHealth() < 26) + if (HealthBelowPct(26)) { if (m_uiFrenzy_Timer <= uiDiff) { diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_kormok.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_kormok.cpp index 1f24d0511db..2524113d668 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_kormok.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_kormok.cpp @@ -105,7 +105,7 @@ public: } else Minion_Timer -= diff; //Summon 2 Bone Mages - if (!Mages && me->GetHealth()*100 / me->GetMaxHealth() < 26) + if (!Mages && HealthBelowPct(26)) { //Cast SummonMages(me->getVictim()); diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_vectus.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_vectus.cpp index 51e9df14349..e320d3aca3b 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_vectus.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_vectus.cpp @@ -84,7 +84,7 @@ public: m_uiBlastWave_Timer -= uiDiff; //Frenzy_Timer - if (me->GetHealth()*100 / me->GetMaxHealth() < 25) + if (HealthBelowPct(25)) { if (m_uiFrenzy_Timer <= uiDiff) { diff --git a/src/server/scripts/EasternKingdoms/Stratholme/boss_dathrohan_balnazzar.cpp b/src/server/scripts/EasternKingdoms/Stratholme/boss_dathrohan_balnazzar.cpp index baf040dbaa4..01f29ee504f 100644 --- a/src/server/scripts/EasternKingdoms/Stratholme/boss_dathrohan_balnazzar.cpp +++ b/src/server/scripts/EasternKingdoms/Stratholme/boss_dathrohan_balnazzar.cpp @@ -156,7 +156,7 @@ public: } else m_uiHolyStrike_Timer -= uiDiff; //BalnazzarTransform - if (me->GetHealth()*100 / me->GetMaxHealth() < 40) + if (HealthBelowPct(40)) { if (me->IsNonMeleeSpellCasted(false)) me->InterruptNonMeleeSpells(false); diff --git a/src/server/scripts/EasternKingdoms/Stratholme/boss_order_of_silver_hand.cpp b/src/server/scripts/EasternKingdoms/Stratholme/boss_order_of_silver_hand.cpp index 6e4eb25fb12..4906c9837a6 100644 --- a/src/server/scripts/EasternKingdoms/Stratholme/boss_order_of_silver_hand.cpp +++ b/src/server/scripts/EasternKingdoms/Stratholme/boss_order_of_silver_hand.cpp @@ -131,7 +131,7 @@ public: if (HolyLight_Timer <= diff) { - if (me->GetHealth()*5 < me->GetMaxHealth()) + if (HealthBelowPct(20)) { DoCast(me, SPELL_HOLY_LIGHT); HolyLight_Timer = 20000; @@ -140,7 +140,7 @@ public: if (DivineShield_Timer <= diff) { - if (me->GetHealth()*20 < me->GetMaxHealth()) + if (HealthBelowPct(5)) { DoCast(me, SPELL_DIVINE_SHIELD); DivineShield_Timer = 40000; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp index a5e68861f66..05933fae7b7 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_brutallus.cpp @@ -244,7 +244,7 @@ public: case 7: me->Kill(Madrigosa); DoScriptText(YELL_MADR_DEATH, Madrigosa); - me->SetHealth(me->GetMaxHealth()); + me->SetFullHealth(); me->AttackStop(); IntroPhaseTimer = 4000; ++IntroPhase; diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index 78051871384..dd55ae7d404 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -166,7 +166,7 @@ public: me->SetVisibility(VISIBILITY_ON); me->SetStandState(UNIT_STAND_STATE_SLEEP); } - me->SetHealth(me->GetMaxHealth());//dunno why it does not resets health at evade.. + me->SetFullHealth();//dunno why it does not resets health at evade.. ArcaneBuffetTimer = 8000; FrostBreathTimer = 15000; WildMagicTimer = 10000; @@ -598,7 +598,7 @@ public: void Reset() { - me->SetHealth(me->GetMaxHealth());//dunno why it does not resets health at evade.. + me->SetFullHealth();//dunno why it does not resets health at evade.. me->setActive(true); if (pInstance) { diff --git a/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp b/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp index 8fa378037f7..c6c742f9688 100644 --- a/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp +++ b/src/server/scripts/EasternKingdoms/Uldaman/boss_archaedas.cpp @@ -154,7 +154,7 @@ class boss_archaedas : public CreatureScript } else WallMinionTimer -= diff; //If we are <66 summon the guardians - if (!guardiansAwake && me->GetHealth()*100 / me->GetMaxHealth() <= 66) { + if (!guardiansAwake && !HealthAbovePct(66)) { ActivateMinion(pInstance->GetData64(5),true); // EarthenGuardian1 ActivateMinion(pInstance->GetData64(6),true); // EarthenGuardian2 ActivateMinion(pInstance->GetData64(7),true); // EarthenGuardian3 @@ -167,7 +167,7 @@ class boss_archaedas : public CreatureScript } //If we are <33 summon the vault walkers - if (!vaultWalkersAwake && me->GetHealth()*100 / me->GetMaxHealth() <= 33) { + if (!vaultWalkersAwake && !HealthAbovePct(33)) { ActivateMinion(pInstance->GetData64(1),true); // VaultWalker1 ActivateMinion(pInstance->GetData64(2),true); // VaultWalker2 ActivateMinion(pInstance->GetData64(3),true); // VaultWalker3 diff --git a/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp b/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp index da4b6a67cc9..5b9ce931cd1 100644 --- a/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp +++ b/src/server/scripts/EasternKingdoms/Uldaman/boss_ironaya.cpp @@ -67,7 +67,7 @@ class boss_ironaya : public CreatureScript return; //If we are <50% hp do knockaway ONCE - if (!hasCastedKnockaway && me->GetHealth()*2 < me->GetMaxHealth()) + if (!hasCastedKnockaway && HealthBelowPct(50)) { DoCast(me->getVictim(), SPELL_KNOCKAWAY, true); @@ -91,7 +91,7 @@ class boss_ironaya : public CreatureScript Arcing_Timer = 13000; } else Arcing_Timer -= diff; - if (!hasCastedWstomp && me->GetHealth()*4 < me->GetMaxHealth()) + if (!hasCastedWstomp && HealthBelowPct(25)) { DoCast(me, SPELL_WSTOMP); hasCastedWstomp = true; diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp index 5b43bbbfd10..c604659148c 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp @@ -244,7 +244,7 @@ class boss_halazzi : public CreatureScript if (Phase == PHASE_LYNX) if (CheckTimer <= diff) { - if (me->GetHealth() * 4 < me->GetMaxHealth() * (3 - TransformCount)) + if (HealthBelowPct(25 * (3 - TransformCount))) EnterPhase(PHASE_SPLIT); CheckTimer = 1000; } else CheckTimer -= diff; @@ -273,12 +273,12 @@ class boss_halazzi : public CreatureScript if (Phase == PHASE_HUMAN) if (CheckTimer <= diff) { - if (((me->GetHealth()*100) / me->GetMaxHealth() <= 20)/*me->GetHealth() * 10 < me->GetMaxHealth()*/) + if (!HealthAbovePct(20) /*HealthBelowPct(10)*/) EnterPhase(PHASE_MERGE); else { Unit *Lynx = Unit::GetUnit(*me, LynxGUID); - if (Lynx && ((Lynx->GetHealth()*100) / Lynx->GetMaxHealth() <= 20)/*Lynx->GetHealth() * 10 < Lynx->GetMaxHealth()*/) + if (Lynx && !Lynx->HealthAbovePct(20) /*Lynx->HealthBelowPct(10)*/) EnterPhase(PHASE_MERGE); } CheckTimer = 1000; diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp index e5a98ee686d..5823b135a2d 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_janalai.cpp @@ -344,7 +344,7 @@ class boss_janalai : public CreatureScript return; //enrage if under 25% hp before 5 min. - if (!enraged && me->GetHealth() * 4 < me->GetMaxHealth()) + if (!enraged && HealthBelowPct(25)) EnrageTimer = 0; if (EnrageTimer <= diff) @@ -394,7 +394,7 @@ class boss_janalai : public CreatureScript if (!noeggs) { - if (100 * me->GetHealth() < 35 * me->GetMaxHealth()) + if (HealthBelowPct(35)) { DoScriptText(SAY_ALL_EGGS, me); diff --git a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp index 964ae32fb59..719264a4d6b 100644 --- a/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp +++ b/src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp @@ -191,7 +191,7 @@ class boss_zuljin : public CreatureScript Phase = 0; - health_20 = me->GetMaxHealth()*0.2f; + health_20 = me->CountPctFromMaxHealth(20); Intro_Timer = 37000; Berserk_Timer = 600000; diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_jeklik.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_jeklik.cpp index 26c10986ad5..0afd99d0c5f 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_jeklik.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_jeklik.cpp @@ -109,7 +109,7 @@ class boss_jeklik : public CreatureScript if (me->getVictim() && me->isAlive()) { - if ((me->GetHealth()*100 / me->GetMaxHealth() > 50)) + if (HealthAbovePct(50)) { if (Charge_Timer <= diff) { diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp index 90adeb5743a..1199acfda15 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp @@ -244,7 +244,7 @@ class boss_mandokir : public CreatureScript } else Fear_Timer -=diff; //Mortal Strike if target below 50% hp - if (me->getVictim() && me->getVictim()->GetHealth() < me->getVictim()->GetMaxHealth()*0.5) + if (me->getVictim() && me->getVictim()->HealthBelowPct(50)) { if (MortalStrike_Timer <= diff) { diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp index 0bbe81f900f..083df57f385 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_thekal.cpp @@ -139,7 +139,7 @@ class boss_thekal : public CreatureScript pLorKhan->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); pLorKhan->setFaction(14); pLorKhan->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - pLorKhan->SetHealth(int(pLorKhan->GetMaxHealth()*1.0)); + pLorKhan->SetFullHealth(); m_pInstance->SetData(TYPE_LORKHAN, DONE); } @@ -154,7 +154,7 @@ class boss_thekal : public CreatureScript pZath->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); pZath->setFaction(14); pZath->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - pZath->SetHealth(int(pZath->GetMaxHealth()*1.0)); + pZath->SetFullHealth(); m_pInstance->SetData(TYPE_ZATH, DONE); } @@ -176,7 +176,7 @@ class boss_thekal : public CreatureScript Silence_Timer = 20000 + rand()%5000; } else Silence_Timer -= diff; - if (!PhaseTwo && !WasDead && me->GetHealth() <= me->GetMaxHealth() * 0.05) + if (!PhaseTwo && !WasDead && !HealthAbovePct(5)) { me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->SetStandState(UNIT_STAND_STATE_SLEEP); @@ -197,7 +197,7 @@ class boss_thekal : public CreatureScript me->SetFloatValue(OBJECT_FIELD_SCALE_X, 2.00f); me->SetStandState(UNIT_STAND_STATE_STAND); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); - me->SetHealth(int(me->GetMaxHealth()*1.0)); + me->SetFullHealth(); const CreatureInfo *cinfo = me->GetCreatureInfo(); me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, (cinfo->mindmg +((cinfo->mindmg/100) * 40))); me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, (cinfo->maxdmg +((cinfo->maxdmg/100) * 40))); @@ -207,7 +207,7 @@ class boss_thekal : public CreatureScript } else Resurrect_Timer -= diff; } - if ((me->GetHealth()*100 / me->GetMaxHealth() == 100) && WasDead) + if (me->IsFullHealth() && WasDead) { WasDead = false; } @@ -244,7 +244,7 @@ class boss_thekal : public CreatureScript SummonTigers_Timer = 10000 + rand()%4000; } else SummonTigers_Timer -= diff; - if ((me->GetHealth()*100 / me->GetMaxHealth() < 11) && !Enraged) + if (HealthBelowPct(11) && !Enraged) { DoCast(me, SPELL_ENRAGE); Enraged = true; @@ -376,7 +376,7 @@ class mob_zealot_lorkhan : public CreatureScript pThekal->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); pThekal->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); pThekal->setFaction(14); - pThekal->SetHealth(int(pThekal->GetMaxHealth()*1.0)); + pThekal->SetFullHealth(); } } @@ -388,7 +388,7 @@ class mob_zealot_lorkhan : public CreatureScript pZath->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); pZath->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); pZath->setFaction(14); - pZath->SetHealth(int(pZath->GetMaxHealth()*1.0)); + pZath->SetFullHealth(); } } } @@ -396,7 +396,7 @@ class mob_zealot_lorkhan : public CreatureScript Check_Timer = 5000; } else Check_Timer -= diff; - if (me->GetHealth() <= me->GetMaxHealth() * 0.05) + if (!HealthAbovePct(5)) { me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->SetStandState(UNIT_STAND_STATE_SLEEP); @@ -526,7 +526,7 @@ class mob_zealot_zath : public CreatureScript pLorKhan->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); pLorKhan->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); pLorKhan->setFaction(14); - pLorKhan->SetHealth(int(pLorKhan->GetMaxHealth()*1.0)); + pLorKhan->SetFullHealth(); } } @@ -538,7 +538,7 @@ class mob_zealot_zath : public CreatureScript pThekal->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); pThekal->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); pThekal->setFaction(14); - pThekal->SetHealth(int(pThekal->GetMaxHealth()*1.0)); + pThekal->SetFullHealth(); } } } @@ -546,7 +546,7 @@ class mob_zealot_zath : public CreatureScript Check_Timer = 5000; } else Check_Timer -= diff; - if (me->GetHealth() <= me->GetMaxHealth() * 0.05) + if (!HealthAbovePct(5)) { me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->SetStandState(UNIT_STAND_STATE_SLEEP); diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_venoxis.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_venoxis.cpp index cee1ea50032..3dfe5056891 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_venoxis.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_venoxis.cpp @@ -100,7 +100,7 @@ class boss_venoxis : public CreatureScript if (!UpdateVictim()) return; - if ((me->GetHealth()*100 / me->GetMaxHealth() > 50)) + if (HealthAbovePct(50)) { if (Dispell_Timer <= diff) { @@ -180,7 +180,7 @@ class boss_venoxis : public CreatureScript VenomSpit_Timer = 15000 + rand()%5000; } else VenomSpit_Timer -= diff; - if (PhaseTwo && (me->GetHealth()*100 / me->GetMaxHealth() < 11)) + if (PhaseTwo && HealthBelowPct(11)) { if (!InBerserk) { diff --git a/src/server/scripts/EasternKingdoms/eversong_woods.cpp b/src/server/scripts/EasternKingdoms/eversong_woods.cpp index 6dab06ff8b8..ee9d1530dac 100644 --- a/src/server/scripts/EasternKingdoms/eversong_woods.cpp +++ b/src/server/scripts/EasternKingdoms/eversong_woods.cpp @@ -271,7 +271,7 @@ public: // healer if (spellFlashLight) - if (me->GetHealth()*100 / me->GetMaxHealth() < 70) + if (HealthBelowPct(70)) if (timerFlashLight <= diff) { DoCast(me, SPELL_FLASH_OF_LIGHT); diff --git a/src/server/scripts/EasternKingdoms/stormwind_city.cpp b/src/server/scripts/EasternKingdoms/stormwind_city.cpp index 63a7a5b7167..17368bb6794 100644 --- a/src/server/scripts/EasternKingdoms/stormwind_city.cpp +++ b/src/server/scripts/EasternKingdoms/stormwind_city.cpp @@ -133,7 +133,7 @@ public: void DamageTaken(Unit* pDoneBy, uint32 &uiDamage) { - if (uiDamage > me->GetHealth() || ((me->GetHealth() - uiDamage)*100 / me->GetMaxHealth() < 15)) + if (uiDamage > me->GetHealth() || me->HealthBelowPctDamaged(15, uiDamage)) { //Take 0 damage uiDamage = 0; @@ -207,7 +207,7 @@ public: void DamageTaken(Unit* pDoneBy, uint32 &uiDamage) { - if (uiDamage > me->GetHealth() || ((me->GetHealth() - uiDamage)*100 / me->GetMaxHealth() < 15)) + if (uiDamage > me->GetHealth() || me->HealthBelowPctDamaged(15, uiDamage)) { uiDamage = 0; diff --git a/src/server/scripts/EasternKingdoms/tirisfal_glades.cpp b/src/server/scripts/EasternKingdoms/tirisfal_glades.cpp index dcab41fbc9e..031ee584246 100644 --- a/src/server/scripts/EasternKingdoms/tirisfal_glades.cpp +++ b/src/server/scripts/EasternKingdoms/tirisfal_glades.cpp @@ -96,7 +96,7 @@ public: void DamageTaken(Unit* pDoneBy, uint32 &uiDamage) { - if (uiDamage > me->GetHealth() || ((me->GetHealth() - uiDamage)*100 / me->GetMaxHealth() < 15)) + if (uiDamage > me->GetHealth() || me->HealthBelowPctDamaged(15, uiDamage)) { uiDamage = 0; diff --git a/src/server/scripts/EasternKingdoms/wetlands.cpp b/src/server/scripts/EasternKingdoms/wetlands.cpp index 3dce0f98411..01e103843f7 100644 --- a/src/server/scripts/EasternKingdoms/wetlands.cpp +++ b/src/server/scripts/EasternKingdoms/wetlands.cpp @@ -113,7 +113,7 @@ public: void DamageTaken(Unit* /*pDoneBy*/, uint32& uiDamage) { - if (me->GetHealth()*100 < me->GetMaxHealth()*20) + if (HealthBelowPct(20)) { if (Player* pPlayer = GetPlayerForEscort()) { diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp index 4e2bc5ecc0b..5c4fb5264d1 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp @@ -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(); diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp index e4d35ada722..bae2ce1e16f 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/EscapeFromDurnholdeKeep/old_hillsbrad.cpp @@ -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; diff --git a/src/server/scripts/Kalimdor/Maraudon/boss_landslide.cpp b/src/server/scripts/Kalimdor/Maraudon/boss_landslide.cpp index 34acecf8d23..ae7a2048bc6 100644 --- a/src/server/scripts/Kalimdor/Maraudon/boss_landslide.cpp +++ b/src/server/scripts/Kalimdor/Maraudon/boss_landslide.cpp @@ -78,7 +78,7 @@ public: } else Trample_Timer -= diff; //Landslide - if (me->GetHealth()*100 / me->GetMaxHealth() < 50) + if (HealthBelowPct(50)) { if (Landslide_Timer <= diff) { diff --git a/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp b/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp index 4c31c533ba7..a369ec98c02 100644 --- a/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp +++ b/src/server/scripts/Kalimdor/OnyxiasLair/boss_onyxia.cpp @@ -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) diff --git a/src/server/scripts/Kalimdor/RazorfenDowns/boss_amnennar_the_coldbringer.cpp b/src/server/scripts/Kalimdor/RazorfenDowns/boss_amnennar_the_coldbringer.cpp index 2c75f3a5b6e..6017aa3f91f 100644 --- a/src/server/scripts/Kalimdor/RazorfenDowns/boss_amnennar_the_coldbringer.cpp +++ b/src/server/scripts/Kalimdor/RazorfenDowns/boss_amnennar_the_coldbringer.cpp @@ -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); diff --git a/src/server/scripts/Kalimdor/RazorfenDowns/instance_razorfen_downs.cpp b/src/server/scripts/Kalimdor/RazorfenDowns/instance_razorfen_downs.cpp index 8e218d882fb..6aad9c69986 100644 --- a/src/server/scripts/Kalimdor/RazorfenDowns/instance_razorfen_downs.cpp +++ b/src/server/scripts/Kalimdor/RazorfenDowns/instance_razorfen_downs.cpp @@ -41,7 +41,7 @@ public: uint32 m_auiEncounter[MAX_ENCOUNTER]; - uint8 uiGongWaves; + uint16 uiGongWaves; std::string str_data; diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp index fc87f7e9d40..68ab6a58f23 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ayamiss.cpp @@ -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; } diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp index b0215c466ae..c65d195393d 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_kurinnaxx.cpp @@ -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); diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/instance_ruins_of_ahnqiraj.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/instance_ruins_of_ahnqiraj.cpp index 05026aa331b..ceed7550455 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/instance_ruins_of_ahnqiraj.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/instance_ruins_of_ahnqiraj.cpp @@ -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() diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp index 0b17972139a..d5ce9bd5428 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp @@ -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; diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp index 851054afc27..8dc5a08622c 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp @@ -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); diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_fankriss.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_fankriss.cpp index 63283665518..cf00031ebac 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_fankriss.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_fankriss.cpp @@ -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) { diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_huhuran.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_huhuran.cpp index 097f27ed8ba..7377bd5bb2a 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_huhuran.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_huhuran.cpp @@ -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); diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp index cbf9ce05196..c19303fd6e3 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_sartura.cpp @@ -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; diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp index 40e5bb57938..80803f0ff9f 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_skeram.cpp @@ -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 diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp index ca9d2e6fb51..018af2b22b1 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_twinemperors.cpp @@ -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) diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/mob_anubisath_sentinel.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/mob_anubisath_sentinel.cpp index 93ede297ad0..d4e7758ca3a 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/mob_anubisath_sentinel.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/mob_anubisath_sentinel.cpp @@ -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); } } diff --git a/src/server/scripts/Kalimdor/azuremyst_isle.cpp b/src/server/scripts/Kalimdor/azuremyst_isle.cpp index bed937d5a9d..eb3d0755833 100644 --- a/src/server/scripts/Kalimdor/azuremyst_isle.cpp +++ b/src/server/scripts/Kalimdor/azuremyst_isle.cpp @@ -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; diff --git a/src/server/scripts/Kalimdor/boss_azuregos.cpp b/src/server/scripts/Kalimdor/boss_azuregos.cpp index a1fc6638d8d..c4f508442f1 100644 --- a/src/server/scripts/Kalimdor/boss_azuregos.cpp +++ b/src/server/scripts/Kalimdor/boss_azuregos.cpp @@ -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; diff --git a/src/server/scripts/Kalimdor/dustwallow_marsh.cpp b/src/server/scripts/Kalimdor/dustwallow_marsh.cpp index e572514f251..fd87938469d 100644 --- a/src/server/scripts/Kalimdor/dustwallow_marsh.cpp +++ b/src/server/scripts/Kalimdor/dustwallow_marsh.cpp @@ -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; diff --git a/src/server/scripts/Kalimdor/tanaris.cpp b/src/server/scripts/Kalimdor/tanaris.cpp index 6f017f32493..5907d3bc149 100644 --- a/src/server/scripts/Kalimdor/tanaris.cpp +++ b/src/server/scripts/Kalimdor/tanaris.cpp @@ -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); diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp index 223c75d1a27..e5870139291 100644 --- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp @@ -96,12 +96,7 @@ public: if (!Victim || !Victim->HasAura(DUNGEON_MODE(SPELL_LEECH_POISON, H_SPELL_LEECH_POISON)) || !me->isAlive()) return; - uint32 health = me->GetMaxHealth()/10; - - if ((me->GetHealth()+health) >= me->GetMaxHealth()) - me->SetHealth(me->GetMaxHealth()); - else - me->SetHealth(me->GetHealth()+health); + me->ModifyHealth(int32(me->CountPctFromMaxHealth(10))); } void JustDied(Unit* /*Killer*/) diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp index 879338f50d4..410190f6638 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp @@ -293,7 +293,7 @@ public: } else uiRenewTimer -= uiDiff; - if (!bHealth && me->GetHealth()*100 / me->GetMaxHealth() <= 25) + if (!bHealth && !HealthAbovePct(25)) { me->InterruptNonMeleeSpells(true); DoCastAOE(SPELL_HOLY_NOVA,false); diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp index ee06c38ed9e..be28b0c3e8b 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp @@ -159,7 +159,7 @@ public: if (bEventInProgress) if (uiResurrectTimer <= uiDiff) { - me->SetHealth(me->GetMaxHealth()); + me->SetFullHealth(); DoCast(me,SPELL_BLACK_KNIGHT_RES,true); uiPhase++; uiResurrectTimer = 4000; @@ -257,7 +257,7 @@ public: } } - if (!me->hasUnitState(UNIT_STAT_ROOT) && !me->GetHealth()*100 / me->GetMaxHealth() <= 0) + if (!me->hasUnitState(UNIT_STAT_ROOT) && !me->HealthBelowPct(1)) DoMeleeAttackIfReady(); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp index 9cd5c55af1b..8d2910db245 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp @@ -43,8 +43,8 @@ public: uint32 m_auiEncounter[MAX_ENCOUNTER]; - uint8 uiMovementDone; - uint8 uiGrandChampionsDeaths; + uint16 uiMovementDone; + uint16 uiGrandChampionsDeaths; uint8 uiArgentSoldierDeaths; uint64 uiAnnouncerGUID; diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp index dab58de66d7..6e52f36b64d 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp @@ -107,7 +107,8 @@ enum SummonActions ACTION_SHADOW_STRIKE, ACTION_SCARAB_SUBMERGE, }; -
const Position SphereSpawn[6] = + +const Position SphereSpawn[6] = { { 786.6439f, 108.2498f, 155.6701f, 0 }, { 806.8429f, 150.5902f, 155.6701f, 0 }, @@ -115,7 +116,9 @@ enum SummonActions { 744.3701f, 119.5211f, 155.6701f, 0 }, { 710.0211f, 120.8152f, 155.6701f, 0 }, { 706.6383f, 161.5266f, 155.6701f, 0 }, -};
class boss_anubarak_trial : public CreatureScript +}; + +class boss_anubarak_trial : public CreatureScript { public: boss_anubarak_trial() : CreatureScript("boss_anubarak_trial") { } @@ -400,7 +403,8 @@ public: }; -
class mob_swarm_scarab : public CreatureScript + +class mob_swarm_scarab : public CreatureScript { public: mob_swarm_scarab() : CreatureScript("mob_swarm_scarab") { } @@ -467,7 +471,8 @@ public: }; -
class mob_nerubian_burrower : public CreatureScript + +class mob_nerubian_burrower : public CreatureScript { public: mob_nerubian_burrower() : CreatureScript("mob_nerubian_burrower") { } @@ -544,7 +549,8 @@ public: }; -
class mob_frost_sphere : public CreatureScript + +class mob_frost_sphere : public CreatureScript { public: mob_frost_sphere() : CreatureScript("mob_frost_sphere") { } @@ -624,7 +630,8 @@ public: }; -
class mob_anubarak_spike : public CreatureScript + +class mob_anubarak_spike : public CreatureScript { public: mob_anubarak_spike() : CreatureScript("mob_anubarak_spike") { } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp index c106b59e347..fa3aad195f2 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp @@ -47,7 +47,8 @@ enum eSpells SPELL_ANTI_AOE = 68595, SPELL_PVP_TRINKET = 65547, }; -
class boss_toc_champion_controller : public CreatureScript + +class boss_toc_champion_controller : public CreatureScript { public: boss_toc_champion_controller() : CreatureScript("boss_toc_champion_controller") { } @@ -447,7 +448,8 @@ enum eDruidSpells SPELL_THORNS = 66068, SPELL_NATURE_GRASP = 66071, //1 min cd, self buff }; -
class mob_toc_druid : public CreatureScript + +class mob_toc_druid : public CreatureScript { public: mob_toc_druid() : CreatureScript("mob_toc_druid") { } @@ -542,7 +544,8 @@ enum eShamanSpells AURA_EXHAUSTION = 57723, AURA_SATED = 57724, }; -
class mob_toc_shaman : public CreatureScript + +class mob_toc_shaman : public CreatureScript { public: mob_toc_shaman() : CreatureScript("mob_toc_shaman") { } @@ -634,7 +637,8 @@ enum ePaladinSpells SPELL_HAND_OF_PROTECTION = 66009, SPELL_HAMMER_OF_JUSTICE = 66613, }; -
class mob_toc_paladin : public CreatureScript + +class mob_toc_paladin : public CreatureScript { public: mob_toc_paladin() : CreatureScript("mob_toc_paladin") { } @@ -682,7 +686,7 @@ public: if (m_uiHandOfProtectionTimer <= uiDiff) { if (Unit *pTarget = DoSelectLowestHpFriendly(40.0f)) - if (pTarget->GetHealth() * 100 < pTarget->GetMaxHealth() * 15) // HealthBelowPct(15) + if (pTarget->HealthBelowPct(15)) DoCast(pTarget,SPELL_HAND_OF_PROTECTION); m_uiHandOfProtectionTimer = urand(0*IN_MILLISECONDS,360*IN_MILLISECONDS); } else m_uiHandOfProtectionTimer -= uiDiff; @@ -739,7 +743,9 @@ enum ePriestSpells SPELL_DISPEL = 65546, SPELL_PSYCHIC_SCREAM = 65543, SPELL_MANA_BURN = 66100, -};
class mob_toc_priest : public CreatureScript +}; + +class mob_toc_priest : public CreatureScript { public: mob_toc_priest() : CreatureScript("mob_toc_priest") { } @@ -819,7 +825,8 @@ enum eShadowPriestSpells SPELL_DISPERSION = 65544, SPELL_SHADOWFORM = 16592, }; -
class mob_toc_shadow_priest : public CreatureScript + +class mob_toc_shadow_priest : public CreatureScript { public: mob_toc_shadow_priest() : CreatureScript("mob_toc_shadow_priest") { } @@ -930,7 +937,9 @@ enum eWarlockSpells SPELL_UNSTABLE_AFFLICTION = 65812, SPELL_SUMMON_FELHUNTER = 67514, H_SPELL_UNSTABLE_AFFLICTION = 68155, //15s -};
class mob_toc_warlock : public CreatureScript +}; + +class mob_toc_warlock : public CreatureScript { public: mob_toc_warlock() : CreatureScript("mob_toc_warlock") { } @@ -1035,7 +1044,9 @@ enum eMageSpells SPELL_FROSTBOLT = 65807, SPELL_ICE_BLOCK = 65802, //5min SPELL_POLYMORPH = 65801, //15s -};
class mob_toc_mage : public CreatureScript +}; + +class mob_toc_mage : public CreatureScript { public: mob_toc_mage() : CreatureScript("mob_toc_mage") { } @@ -1137,7 +1148,8 @@ enum eHunterSpells SPELL_WYVERN_STING = 65877, //60s SPELL_CALL_PET = 67777, }; -
class mob_toc_hunter : public CreatureScript + +class mob_toc_hunter : public CreatureScript { public: mob_toc_hunter() : CreatureScript("mob_toc_hunter") { } @@ -1251,7 +1263,9 @@ enum eBoomkinSpells SPELL_MOONFIRE = 65856, //5s SPELL_STARFIRE = 65854, SPELL_WRATH = 65862, -};
class mob_toc_boomkin : public CreatureScript +}; + +class mob_toc_boomkin : public CreatureScript { public: mob_toc_boomkin() : CreatureScript("mob_toc_boomkin") { } @@ -1353,7 +1367,9 @@ enum eWarriorSpells SPELL_SUNDER_ARMOR = 65936, SPELL_SHATTERING_THROW = 65940, SPELL_RETALIATION = 65932, -};
class mob_toc_warrior : public CreatureScript +}; + +class mob_toc_warrior : public CreatureScript { public: mob_toc_warrior() : CreatureScript("mob_toc_warrior") { } @@ -1465,7 +1481,9 @@ enum eDeathKnightSpells SPELL_ICEBOUND_FORTITUDE = 66023, //1min SPELL_ICY_TOUCH = 66021, //8sec SPELL_STRANGULATE = 66018, //2min -};
class mob_toc_dk : public CreatureScript +}; + +class mob_toc_dk : public CreatureScript { public: mob_toc_dk() : CreatureScript("mob_toc_dk") { } @@ -1565,7 +1583,9 @@ enum eRogueSpells SPELL_SHADOWSTEP = 66178, //30sec SPELL_HEMORRHAGE = 65954, SPELL_EVISCERATE = 65957, -};
class mob_toc_rogue : public CreatureScript +}; + +class mob_toc_rogue : public CreatureScript { public: mob_toc_rogue() : CreatureScript("mob_toc_rogue") { } @@ -1663,7 +1683,8 @@ enum eEnhShamanSpells SPELL_LAVA_LASH = 65974, SPELL_STORMSTRIKE = 65970, }; -
class mob_toc_enh_shaman : public CreatureScript + +class mob_toc_enh_shaman : public CreatureScript { public: mob_toc_enh_shaman() : CreatureScript("mob_toc_enh_shaman") { } @@ -1796,7 +1817,8 @@ enum eRetroPaladinSpells SPELL_REPENTANCE = 66008, //60sec cd SPELL_SEAL_OF_COMMAND = 66004, //no cd }; -
class mob_toc_retro_paladin : public CreatureScript + +class mob_toc_retro_paladin : public CreatureScript { public: mob_toc_retro_paladin() : CreatureScript("mob_toc_retro_paladin") { } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp index 7b5fba4ca82..55c730d8f3b 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp @@ -261,7 +261,7 @@ struct boss_twin_baseAI : public ScriptedAI if (caster->ToCreature() == me) if (spell->Effect[0] == 136) //Effect Heal if (m_pInstance) - m_pInstance->SetData(DATA_HEALTH_TWIN_SHARED, me->GetHealth() + me->GetMaxHealth()*spell->EffectBasePoints[0]/100); + m_pInstance->SetData(DATA_HEALTH_TWIN_SHARED, me->GetHealth() + me->CountPctFromMaxHealth(spell->EffectBasePoints[0])); } void SummonColorballs(uint8 quantity) @@ -270,7 +270,7 @@ struct boss_twin_baseAI : public ScriptedAI float y = y0; for (uint8 i = 0; i < quantity; i++) { - float x = urand(x0-r,x0+r); + float x = float(urand(uint32(x0 - r), uint32(x0 + r))); if (urand(0,1)) y = y0 + sqrt(pow(r,2) - pow((x-x0),2)); else @@ -420,7 +420,8 @@ struct boss_twin_baseAI : public ScriptedAI /*###### ## boss_fjola ######*/ -
class boss_fjola : public CreatureScript + +class boss_fjola : public CreatureScript { public: boss_fjola() : CreatureScript("boss_fjola") { } @@ -479,7 +480,8 @@ public: /*###### ## boss_eydis ######*/ -
class boss_eydis : public CreatureScript + +class boss_eydis : public CreatureScript { public: boss_eydis() : CreatureScript("boss_eydis") { } @@ -520,7 +522,8 @@ public: }; -
class mob_essence_of_twin : public CreatureScript + +class mob_essence_of_twin : public CreatureScript { public: mob_essence_of_twin() : CreatureScript("mob_essence_of_twin") { } @@ -560,7 +563,7 @@ struct mob_unleashed_ballAI : public ScriptedAI { float x0 = ToCCommonLoc[1].GetPositionX(), y0 = ToCCommonLoc[1].GetPositionY(), r = 47.0f; float y = y0; - float x = urand(x0-r,x0+r); + float x = float(urand(uint32(x0 - r), uint32(x0 + r))); if (urand(0,1)) y = y0 + sqrt(pow(r,2) - pow((x-x0),2)); else @@ -594,7 +597,8 @@ struct mob_unleashed_ballAI : public ScriptedAI } } }; -
class mob_unleashed_dark : public CreatureScript + +class mob_unleashed_dark : public CreatureScript { public: mob_unleashed_dark() : CreatureScript("mob_unleashed_dark") { } @@ -627,7 +631,8 @@ public: }; -
class mob_unleashed_light : public CreatureScript + +class mob_unleashed_light : public CreatureScript { public: mob_unleashed_light() : CreatureScript("mob_unleashed_light") { } diff --git a/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp b/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp index 1d6a9869d71..9ee754b4a56 100644 --- a/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp +++ b/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp @@ -63,7 +63,7 @@ public: uint64 uiNovosCrystal3; uint64 uiNovosCrystal4; - uint8 m_auiEncounter[MAX_ENCOUNTER]; + uint16 m_auiEncounter[MAX_ENCOUNTER]; std::string str_data; diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp index 995443196e3..beaeb180618 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_scourgelord_tyrannus.cpp @@ -124,7 +124,7 @@ public: me->ExitVehicle(); // restore health if any damage done during intro - me->SetHealth(me->GetMaxHealth()); + me->SetFullHealth(); if (pInstance) pInstance->SetData(DATA_TYRANNUS_EVENT, IN_PROGRESS); diff --git a/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp b/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp index 5635fe54559..ccc832470e6 100644 --- a/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp +++ b/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp @@ -105,7 +105,7 @@ public: if (!UpdateVictim()) return; - if (!bHealth && HealthBelowPct(50) && !HealthBelowPct(5)) + if (!bHealth && HealthBelowPct(50) && !HealthBelowPct(5)) { CreatureState(me, false); DoCast(me,SPELL_FREEZE_ANIM); @@ -140,7 +140,7 @@ public: void JustSummoned(Creature* pSummon) { if (HealthBelowPct(5)) - pSummon->DealDamage(pSummon, pSummon->GetHealth() * 0.5 , NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + pSummon->DealDamage(pSummon, pSummon->GetHealth() * 0.5, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); pSummon->AI()->AttackStart(me->getVictim()); } }; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp index daaed063994..bb66a727bb4 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp @@ -498,8 +498,7 @@ class spell_marrowgar_bone_storm : public SpellScriptLoader return; float distVar = distance >= 20.0f ? 4 : (10.0f/3.0f); - dmg /= distance / distVar; - SetHitDamage(dmg); + SetHitDamage(int32(dmg * distVar / distance)); } void Register() diff --git a/src/server/scripts/Northrend/Naxxramas/boss_gluth.cpp b/src/server/scripts/Northrend/Naxxramas/boss_gluth.cpp index ee3c89eac72..f80e355b65c 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_gluth.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_gluth.cpp @@ -134,7 +134,7 @@ public: if (me->IsWithinMeleeRange(me->getVictim())) { me->Kill(me->getVictim()); - me->ModifyHealth(me->GetMaxHealth() * 0.05f); + me->ModifyHealth(int32(me->CountPctFromMaxHealth(5))); } } else diff --git a/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp b/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp index 9acecc7337c..62762a2ea0f 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_grobbulus.cpp @@ -94,7 +94,7 @@ public: if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1)) if (!pTarget->HasAura(SPELL_MUTATING_INJECTION)) DoCast(pTarget, SPELL_MUTATING_INJECTION); - events.ScheduleEvent(EVENT_INJECT, 8000 + 12000 * ((float)me->GetHealth() / me->GetMaxHealth())); + events.ScheduleEvent(EVENT_INJECT, 8000 + uint32(120 * me->GetHealthPct())); return; } } diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp index 42ab62cc5c1..07591841af7 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_ormorok.cpp @@ -142,7 +142,7 @@ public: uiCrystalSpikesTimer2 = 200; } else uiCrystalSpikesTimer2 -= diff; - if (!bFrenzy && (me->GetHealth() < me->GetMaxHealth() * 0.25)) + if (!bFrenzy && HealthBelowPct(25)) { DoCast(me, SPELL_FRENZY); bFrenzy = true; diff --git a/src/server/scripts/Northrend/ObsidianSanctum/boss_sartharion.cpp b/src/server/scripts/Northrend/ObsidianSanctum/boss_sartharion.cpp index 4538a73b7e8..37898942545 100644 --- a/src/server/scripts/Northrend/ObsidianSanctum/boss_sartharion.cpp +++ b/src/server/scripts/Northrend/ObsidianSanctum/boss_sartharion.cpp @@ -569,7 +569,7 @@ public: Unit* pVesp = Unit::GetUnit(*me, pInstance ? pInstance->GetData64(DATA_VESPERON) : 0); //spell will target dragons, if they are still alive at 35% - if (!m_bIsBerserk && (me->GetHealth()*100 / me->GetMaxHealth()) <= 35 + if (!m_bIsBerserk && !HealthAbovePct(35) && ((pTene && pTene->isAlive()) || (pShad && pShad->isAlive()) || (pVesp && pVesp->isAlive()))) { DoScriptText(SAY_SARTHARION_BERSERK, me); diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp index f4d14262a23..bfaac47683f 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp @@ -202,7 +202,7 @@ public: m_uiLightningNova_Timer -= uiDiff; // Health check - if ((me->GetHealth()*100 / me->GetMaxHealth()) < (100-(25*m_uiHealthAmountModifier))) + if (HealthBelowPct(100 - 25 * m_uiHealthAmountModifier)) { switch(m_uiHealthAmountModifier) { diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp index 081c6292d58..b5293f76be5 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp @@ -312,7 +312,7 @@ public: } // Health check - if (!m_bCanShatterGolem && (me->GetHealth()*100 / me->GetMaxHealth()) < (100-(20*m_uiHealthAmountModifier))) + if (!m_bCanShatterGolem && me->HealthBelowPct(100 - 20 * m_uiHealthAmountModifier)) { ++m_uiHealthAmountModifier; diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp b/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp index 6925b9f6982..851a628fc23 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp +++ b/src/server/scripts/Northrend/Ulduar/ulduar/boss_assembly_of_iron.cpp @@ -190,11 +190,11 @@ public: { if (Creature* Brundir = Unit::GetCreature(*me, pInstance ? pInstance->GetData64(DATA_STORMCALLER_BRUNDIR) : 0)) if (Brundir->isAlive()) - Brundir->SetHealth(Brundir->GetMaxHealth()); + Brundir->SetFullHealth(); if (Creature* Molgeim = Unit::GetCreature(*me, pInstance ? pInstance->GetData64(DATA_RUNEMASTER_MOLGEIM) : 0)) if (Molgeim->isAlive()) - Molgeim->SetHealth(Molgeim->GetMaxHealth()); + Molgeim->SetFullHealth(); DoCast(SPELL_SUPERCHARGE); } @@ -315,11 +315,11 @@ public: { if (Creature* Steelbreaker = Unit::GetCreature(*me, pInstance ? pInstance->GetData64(DATA_STEELBREAKER) : 0)) if (Steelbreaker->isAlive()) - Steelbreaker->SetHealth(Steelbreaker->GetMaxHealth()); + Steelbreaker->SetFullHealth(); if (Creature* Brundir = Unit::GetCreature((*me), pInstance ? pInstance->GetData64(DATA_STORMCALLER_BRUNDIR) : 0)) if (Brundir->isAlive()) - Brundir->SetHealth(Brundir->GetMaxHealth()); + Brundir->SetFullHealth(); DoCast(me, SPELL_SUPERCHARGE); } @@ -521,11 +521,11 @@ public: { if (Creature* Steelbreaker = Unit::GetCreature(*me, pInstance ? pInstance->GetData64(DATA_STEELBREAKER) : 0)) if (Steelbreaker->isAlive()) - Steelbreaker->SetHealth(Steelbreaker->GetMaxHealth()); + Steelbreaker->SetFullHealth(); if (Creature* Molgeim = Unit::GetCreature(*me, pInstance ? pInstance->GetData64(DATA_RUNEMASTER_MOLGEIM) : 0)) if (Molgeim->isAlive()) - Molgeim->SetHealth(Molgeim->GetMaxHealth()); + Molgeim->SetFullHealth(); DoCast(SPELL_SUPERCHARGE); } diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_razorscale.cpp b/src/server/scripts/Northrend/Ulduar/ulduar/boss_razorscale.cpp index 424a80e6c48..c4de6b47d22 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_razorscale.cpp +++ b/src/server/scripts/Northrend/Ulduar/ulduar/boss_razorscale.cpp @@ -131,13 +131,13 @@ public: if (me->getVictim() && !me->getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself()) me->Kill(me->getVictim()); - if ((me->GetHealth()*100 / me->GetMaxHealth()) < 99 && Phase == 1) // TODO: Only land (exit Phase 1) if brought down with harpoon guns! This is important! + if (HealthBelowPct(99) && Phase == 1) // TODO: Only land (exit Phase 1) if brought down with harpoon guns! This is important! { Phase = 2; DoScriptText(SAY_PHASE_2_TRANS, me); // Audio: "Move quickly! She won't remain grounded for long!" } - if ((me->GetHealth()*100 / me->GetMaxHealth()) < 33 && Phase == 2) // Health under 33%, Razorscale can't fly anymore. + if (HealthBelowPct(33) && Phase == 2) // Health under 33%, Razorscale can't fly anymore. { Phase = 3; DoScriptText(SAY_PHASE_3_TRANS, me); // "Razorscale lands permanently!" diff --git a/src/server/scripts/Northrend/Ulduar/ulduar/boss_xt002.cpp b/src/server/scripts/Northrend/Ulduar/ulduar/boss_xt002.cpp index 7cb8dba721f..498106bcb7b 100644 --- a/src/server/scripts/Northrend/Ulduar/ulduar/boss_xt002.cpp +++ b/src/server/scripts/Northrend/Ulduar/ulduar/boss_xt002.cpp @@ -254,7 +254,7 @@ public: enterHardMode = true; // set max health - me->SetHealth(me->GetMaxHealth()); + me->SetFullHealth(); // Get his heartbreak buff me->CastSpell(me, RAID_MODE(SPELL_HEARTBREAK_10, SPELL_HEARTBREAK_25), true); @@ -611,7 +611,7 @@ public: // TODO Send raid message // Increase health with 1 percent - pXT002->ModifyHealth(pXT002->GetMaxHealth() * 0.01); + pXT002->ModifyHealth(int32(pXT002->CountPctFromMaxHealth(1))); // Despawns the scrapbot me->ForcedDespawn(); diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_ymiron.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_ymiron.cpp index 6c17e0c764b..c0847e5cd47 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_ymiron.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_ymiron.cpp @@ -318,7 +318,7 @@ public: } else m_uiAbility_TORGYN_Timer -= diff; // Health check ----------------------------------------------------------------------------- - if ((me->GetHealth()*100 / me->GetMaxHealth()) < (100-(m_uiHealthAmountMultipler * m_uiHealthAmountModifier))) + if (me->HealthBelowPct(100 - m_uiHealthAmountMultipler * m_uiHealthAmountModifier)) { uint8 m_uiOrder = m_uiHealthAmountModifier - 1; ++m_uiHealthAmountModifier; diff --git a/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp b/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp index 5052457c5e3..3b59dee2108 100644 --- a/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp +++ b/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp @@ -142,7 +142,7 @@ public: if (minion && minion->isAlive()) { minion->CastSpell(me, SPELL_OVERCHARGED, true); - minion->SetHealth(minion->GetMaxHealth()); + minion->SetFullHealth(); DoScriptText(EMOTE_OVERCHARGE, me); events.ScheduleEvent(EVENT_OVERCHARGE, 45000); } diff --git a/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp b/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp index bfb83f893a2..8e2f8659d43 100644 --- a/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp +++ b/src/server/scripts/Northrend/VioletHold/boss_erekem.cpp @@ -238,11 +238,11 @@ public: return me->GetGUID(); Creature *pGuard1 = Unit::GetCreature(*me, pInstance ? pInstance->GetData64(DATA_EREKEM_GUARD_1) : 0); - if (pGuard1 && pGuard1->isAlive() && (pGuard1->GetHealth()*100 <= pGuard1->GetMaxHealth() * 75)) + if (pGuard1 && pGuard1->isAlive() && !pGuard1->HealthAbovePct(75)) return pGuard1->GetGUID(); Creature *pGuard2 = Unit::GetCreature(*me, pInstance ? pInstance->GetData64(DATA_EREKEM_GUARD_2) : 0); - if (pGuard2 && pGuard2->isAlive() && (pGuard2->GetHealth()*100 <= pGuard2->GetMaxHealth() * 75)) + if (pGuard2 && pGuard2->isAlive() && !pGuard2->HealthAbovePct(75)) return pGuard2->GetGUID(); return 0; diff --git a/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp b/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp index 0425fc24712..01353d0128d 100644 --- a/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp +++ b/src/server/scripts/Northrend/VioletHold/boss_ichoron.cpp @@ -162,7 +162,7 @@ public: switch(param) { case ACTION_WATER_ELEMENT_HIT: - me->SetHealth(me->GetHealth() + me->GetMaxHealth() * 0.01f); + me->ModifyHealth(int32(me->CountPctFromMaxHealth(1))); if (bIsExploded) DoExplodeCompleted(); @@ -170,8 +170,8 @@ public: bAchievement = false; break; case ACTION_WATER_ELEMENT_KILLED: - uint32 damage = (me->GetMaxHealth()*3)/100; - me->SetHealth(me->GetHealth() - damage); + uint32 damage = me->CountPctFromMaxHealth(3); + me->ModifyHealth(-int32(damage)); me->LowerPlayerDamageReq(damage); break; } diff --git a/src/server/scripts/Northrend/borean_tundra.cpp b/src/server/scripts/Northrend/borean_tundra.cpp index c98daec247e..f77d7804f51 100644 --- a/src/server/scripts/Northrend/borean_tundra.cpp +++ b/src/server/scripts/Northrend/borean_tundra.cpp @@ -1620,7 +1620,7 @@ public: void SpellHit(Unit* pCaster, const SpellEntry* pSpell) { - if (pSpell->Id == SPELL_ARCANE_CHAINS && pCaster->GetTypeId() == TYPEID_PLAYER && me->GetHealth()*100 / me->GetMaxHealth() <= 50 && !bEnslaved) + if (pSpell->Id == SPELL_ARCANE_CHAINS && pCaster->GetTypeId() == TYPEID_PLAYER && !HealthAbovePct(50) && !bEnslaved) { EnterEvadeMode(); //We make sure that the npc is not attacking the player! me->SetReactState(REACT_PASSIVE); diff --git a/src/server/scripts/Northrend/zuldrak.cpp b/src/server/scripts/Northrend/zuldrak.cpp index f6a0a3f00df..9eb8ff8157f 100644 --- a/src/server/scripts/Northrend/zuldrak.cpp +++ b/src/server/scripts/Northrend/zuldrak.cpp @@ -646,7 +646,7 @@ public: uiFishyScentTimer = 20000; } else uiFishyScentTimer -= uiDiff; - if (!bSummoned && me->GetHealth()*100 / me->GetMaxHealth() <= 50) + if (!bSummoned && !HealthAbovePct(50)) { DoScriptText(SAY_CALL_FOR_HELP ,me); //DoCast(me->getVictim(), SPELL_SUMMON_WHISKER); petai is not working correctly??? @@ -771,7 +771,7 @@ public: uiChargeTimer = 15000; } else uiChargeTimer -= uiDiff; - if (!bEnrage && me->GetHealth()*100 / me->GetMaxHealth() <= 20) + if (!bEnrage && !HealthAbovePct(20)) { DoCast(me, SPELL_ENRAGE); bEnrage = true; @@ -968,7 +968,7 @@ public: } } - if (bThunderClap && me->GetHealth()*100 / me->GetMaxHealth() <= 10) + if (bThunderClap && !HealthAbovePct(10)) { DoCastAOE(SPELL_THUNDERCLAP); bThunderClap = true; @@ -994,7 +994,7 @@ public: uiStinkyBeardTimer = 15000; } else uiStinkyBeardTimer -= uiDiff; - if (!bEnrage && me->GetHealth()*100 / me->GetMaxHealth() <= 20) + if (!bEnrage && !HealthAbovePct(20)) { DoCast(me, SPELL_ENRAGE_STINKBEARD); bEnrage = true; @@ -1119,7 +1119,7 @@ public: uiElementalSpellTimer = urand(5000,8000); } else uiElementalSpellTimer -= uiDiff; - if (!bAddAttack && me->GetHealth()*100 / me->GetMaxHealth() <= 20) + if (!bAddAttack && !HealthAbovePct(20)) { if (!SummonList.empty()) for (std::list<uint64>::const_iterator itr = SummonList.begin(); itr != SummonList.end(); ++itr) 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()) { diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp index 8d6f078355a..32a22260ed4 100644 --- a/src/server/scripts/Spells/spell_dk.cpp +++ b/src/server/scripts/Spells/spell_dk.cpp @@ -54,7 +54,7 @@ public: int32 bp = 0; // Living ghoul as a target if (unitTarget->isAlive()) - bp = unitTarget->GetMaxHealth() * 0.25f; + bp = int32(unitTarget->CountPctFromMaxHealth(25)); // Some corpse else bp = GetEffectValue(); diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 931914ea03e..f54803c900e 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -85,7 +85,7 @@ public: if (NewPet->getDeathState() == DEAD) NewPet->setDeathState(ALIVE); - NewPet->SetHealth(NewPet->GetMaxHealth()); + NewPet->SetFullHealth(); NewPet->SetPower(NewPet->getPowerType(),NewPet->GetMaxPower(NewPet->getPowerType())); switch (NewPet->GetEntry()) diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 106384c6320..ae54bfe297d 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -184,7 +184,7 @@ public: void HandleDummy(SpellEffIndex /*effIndex*/) { Unit *caster = GetCaster(); - int32 healthModSpellBasePoints0 = int32(caster->GetMaxHealth()*0.3); + int32 healthModSpellBasePoints0 = int32(caster->CountPctFromMaxHealth(30)); caster->CastCustomSpell(caster, HUNTER_PET_SPELL_LAST_STAND_TRIGGERED, &healthModSpellBasePoints0, NULL, NULL, true, NULL); } diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index 448a468cdf2..64dc02425df 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -74,7 +74,7 @@ public: case CREATURE_FAMILY_VOIDWALKER: { SpellEntry const* spellInfo = sSpellStore.LookupEntry(WARLOCK_DEMONIC_EMPOWERMENT_VOIDWALKER); - int32 hp = targetCreature->GetMaxHealth() * GetCaster()->CalculateSpellDamage(targetCreature, spellInfo, 0) / 100; + int32 hp = int32(targetCreature->CountPctFromMaxHealth(GetCaster()->CalculateSpellDamage(targetCreature, spellInfo, 0))); targetCreature->CastCustomSpell(targetCreature, WARLOCK_DEMONIC_EMPOWERMENT_VOIDWALKER, &hp, NULL, NULL, true); //unitTarget->CastSpell(unitTarget, 54441, true); break; diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp index 48a37395b81..85c7c57ad05 100644 --- a/src/server/scripts/Spells/spell_warrior.cpp +++ b/src/server/scripts/Spells/spell_warrior.cpp @@ -44,7 +44,7 @@ class spell_warr_last_stand : public SpellScriptLoader void HandleDummy(SpellEffIndex /*effIndex*/) { - int32 healthModSpellBasePoints0 = int32(GetCaster()->GetMaxHealth() * 0.3); + int32 healthModSpellBasePoints0 = int32(GetCaster()->CountPctFromMaxHealth(30)); GetCaster()->CastCustomSpell(GetCaster(), WARRIOR_SPELL_LAST_STAND_TRIGGERED, &healthModSpellBasePoints0, NULL, NULL, true, NULL); } diff --git a/src/server/scripts/World/boss_emeriss.cpp b/src/server/scripts/World/boss_emeriss.cpp index eedd7a90f22..db19ccbbeb4 100644 --- a/src/server/scripts/World/boss_emeriss.cpp +++ b/src/server/scripts/World/boss_emeriss.cpp @@ -112,7 +112,7 @@ public: //CorruptionofEarth_Timer //CorruptionofEarth at 75%, 50% and 25% - if ((me->GetHealth()*100 / me->GetMaxHealth()) <= (100-(25*m_uiCorruptionsCasted))) + if (!HealthAbovePct(100 - 25 * m_uiCorruptionsCasted)) { ++m_uiCorruptionsCasted; // prevent casting twice on same hp DoScriptText(SAY_CASTCORRUPTION, me); diff --git a/src/server/scripts/World/boss_taerar.cpp b/src/server/scripts/World/boss_taerar.cpp index cef9db43e1c..8e5e66629e6 100644 --- a/src/server/scripts/World/boss_taerar.cpp +++ b/src/server/scripts/World/boss_taerar.cpp @@ -162,7 +162,7 @@ public: m_uiBellowingRoar_Timer -= uiDiff; //Summon 3 Shades at 75%, 50% and 25% (if bShades is true we already left in line 117, no need to check here again) - if (!m_bShades && (me->GetHealth()*100 / me->GetMaxHealth()) <= (100-(25*m_uiShadesSummoned))) + if (!m_bShades && !HealthAbovePct(100 - 25 * m_uiShadesSummoned)) { if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0)) { diff --git a/src/server/scripts/World/boss_ysondre.cpp b/src/server/scripts/World/boss_ysondre.cpp index 97cbbecf0e6..0371d516776 100644 --- a/src/server/scripts/World/boss_ysondre.cpp +++ b/src/server/scripts/World/boss_ysondre.cpp @@ -128,7 +128,7 @@ public: m_uiLightningWave_Timer -= uiDiff; //Summon Druids - if ((me->GetHealth()*100 / me->GetMaxHealth()) <= (100-(25*m_uiSummonDruidModifier))) + if (!HealthAbovePct(100 - 25 * m_uiSummonDruidModifier)) { DoScriptText(SAY_SUMMONDRUIDS, me); diff --git a/src/server/scripts/World/mob_generic_creature.cpp b/src/server/scripts/World/mob_generic_creature.cpp index 0b1317f9b99..19f7c990eae 100644 --- a/src/server/scripts/World/mob_generic_creature.cpp +++ b/src/server/scripts/World/mob_generic_creature.cpp @@ -97,7 +97,7 @@ public: SpellEntry const *info = NULL; //Select a healing spell if less than 30% hp - if (me->GetHealth()*100 / me->GetMaxHealth() < 30) + if (HealthBelowPct(30)) info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); //No healing spell available, select a hostile spell @@ -128,7 +128,7 @@ public: SpellEntry const *info = NULL; //Select a healing spell if less than 30% hp ONLY 33% of the time - if (me->GetHealth()*100 / me->GetMaxHealth() < 30 && rand() % 3 == 0) + if (HealthBelowPct(30) && rand() % 3 == 0) info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING); //No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE) diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index f5f56ab6783..f205f2ab099 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -723,15 +723,15 @@ public: { //lower max health case 12923: case 12938: //Injured Soldier - me->SetHealth(uint32(me->GetMaxHealth()*.75)); + me->SetHealth(me->CountPctFromMaxHealth(75)); break; case 12924: case 12936: //Badly injured Soldier - me->SetHealth(uint32(me->GetMaxHealth()*.50)); + me->SetHealth(me->CountPctFromMaxHealth(50)); break; case 12925: case 12937: //Critically injured Soldier - me->SetHealth(uint32(me->GetMaxHealth()*.25)); + me->SetHealth(me->CountPctFromMaxHealth(25)); break; } } @@ -782,7 +782,7 @@ public: //lower HP on every world tick makes it a useful counter, not officlone though if (me->isAlive() && me->GetHealth() > 6) { - me->SetHealth(uint32(me->GetHealth()-5)); + me->ModifyHealth(-5); } if (me->isAlive() && me->GetHealth() <= 6) @@ -924,7 +924,7 @@ public: me->SetStandState(UNIT_STAND_STATE_KNEEL); //expect database to have RegenHealth=0 - me->SetHealth(int(me->GetMaxHealth()*0.7f)); + me->SetHealth(me->CountPctFromMaxHealth(70)); } void EnterCombat(Unit * /*who*/) {} |