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

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

Some files were not shown because too many files have changed in this diff Show More