Cleanup: implemented helper methods for manipulating percentage calculation and used it where appropriate (plus fixed some other warnings).
NOTE: Initially I just wanted to fix some warnings, but noticed that there is no common method for percentage calculation and various formulas are used many time in the code making it difficult to read and understand what the code actually does. So, I introduced several template methods for calculating percent values and adding those values to the original base. I replaced all the raw calculations throughout the code where found, but I could have missed something or could have made a mistake. So, please report any strange behaviour after this commit. If you ask me why I did it: for the sake of consistency and exact understanding what code means. If you see CalculatePct method, you clearly understand, that it find the value of x percent of y. And you can easily express, for example, spell behviour "reduces smth by x%" by the means of a method instead of recalling school maths. --HG-- branch : trunk
This commit is contained in:
@@ -75,9 +75,9 @@ uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32
|
||||
if (MSV <= 0)
|
||||
return AH_MINIMUM_DEPOSIT;
|
||||
|
||||
uint32 timeHr = (((time / 60) / 60) /12);
|
||||
float multiplier = (float)(entry->depositPercent * 3) / 100.0f;
|
||||
uint32 deposit = ((uint32)((float)MSV * multiplier * (float)count)/3) * 3 * timeHr;
|
||||
float multiplier = CalculatePctN(float(entry->depositPercent), 3);
|
||||
uint32 timeHr = (((time / 60) / 60) / 12);
|
||||
uint32 deposit = uint32(multiplier * MSV * count / 3) * timeHr * 3;
|
||||
|
||||
sLog.outDebug("MSV: %u", MSV);
|
||||
sLog.outDebug("Items: %u", count);
|
||||
@@ -500,7 +500,7 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTem
|
||||
//FIXME: found way for proper auctionhouse selection by another way
|
||||
// AuctionHouse.dbc have faction field with _player_ factions associated with auction house races.
|
||||
// but no easy way convert creature faction to player race faction for specific city
|
||||
switch(factionTemplateId)
|
||||
switch (factionTemplateId)
|
||||
{
|
||||
case 12: houseid = 1; break; // human
|
||||
case 29: houseid = 6; break; // orc, and generic for horde
|
||||
@@ -762,27 +762,22 @@ bool AuctionEntry::BuildAuctionInfo(WorldPacket & data) const
|
||||
//minimal outbid
|
||||
data << uint32(buyout); //auction->buyout
|
||||
data << uint32((expire_time-time(NULL))*IN_MILLISECONDS);//time left
|
||||
data << uint64(bidder) ; //auction->bidder current
|
||||
data << uint64(bidder); //auction->bidder current
|
||||
data << uint32(bid); //current bid
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 AuctionEntry::GetAuctionCut() const
|
||||
{
|
||||
int32 cut = int32(((double)auctionHouseEntry->cutPercent / 100.0f) * (double)sWorld.getRate(RATE_AUCTION_CUT)) * bid;
|
||||
if (cut > 0)
|
||||
return cut;
|
||||
else
|
||||
return 0;
|
||||
int32 cut = int32(CalculatePctU(sWorld.getRate(RATE_AUCTION_CUT), auctionHouseEntry->cutPercent)) * bid;
|
||||
return std::max(cut, 0);
|
||||
}
|
||||
|
||||
/// the sum of outbid is (1% from current bid)*5, if bid is very small, it is 1c
|
||||
uint32 AuctionEntry::GetAuctionOutBid() const
|
||||
{
|
||||
uint32 outbid = (uint32)((double)bid / 100.0f) * 5;
|
||||
if (!outbid)
|
||||
outbid = 1;
|
||||
return outbid;
|
||||
uint32 outbid = CalculatePctN(bid, 5);
|
||||
return outbid ? outbid : 1;
|
||||
}
|
||||
|
||||
void AuctionEntry::DeleteFromDB(SQLTransaction& trans) const
|
||||
|
||||
@@ -896,8 +896,8 @@ void Battleground::EndBattleground(uint32 winner)
|
||||
uint32 Battleground::GetBonusHonorFromKill(uint32 kills) const
|
||||
{
|
||||
//variable kills means how many honorable kills you scored (so we need kills * honor_for_one_kill)
|
||||
uint32 maxLevel = (GetMaxLevel() < 80) ? GetMaxLevel() : 80;
|
||||
return Trinity::Honor::hk_honor_at_level(maxLevel, kills);
|
||||
uint32 maxLevel = std::min(GetMaxLevel(), 80U);
|
||||
return Trinity::Honor::hk_honor_at_level(maxLevel, float(kills));
|
||||
}
|
||||
|
||||
uint32 Battleground::GetBattlemasterEntry() const
|
||||
@@ -1985,16 +1985,16 @@ void Battleground::RewardXPAtKill(Player* plr, Player* victim)
|
||||
// XP updated only for alive group member
|
||||
if (pGroupGuy->isAlive() && not_gray_member_with_max_level && pGroupGuy->getLevel() <= not_gray_member_with_max_level->getLevel())
|
||||
{
|
||||
uint32 itr_xp = (member_with_max_level == not_gray_member_with_max_level) ? uint32(xp*rate) : uint32((xp*rate/2)+1);
|
||||
uint32 itr_xp = (member_with_max_level == not_gray_member_with_max_level) ? uint32(xp * rate) : uint32((xp * rate / 2) + 1);
|
||||
|
||||
// handle SPELL_AURA_MOD_XP_PCT auras
|
||||
Unit::AuraEffectList const& ModXPPctAuras = plr->GetAuraEffectsByType(SPELL_AURA_MOD_XP_PCT);
|
||||
for (Unit::AuraEffectList::const_iterator i = ModXPPctAuras.begin(); i != ModXPPctAuras.end(); ++i)
|
||||
itr_xp = uint32(itr_xp*(1.0f + (*i)->GetAmount() / 100.0f));
|
||||
AddPctN(itr_xp, (*i)->GetAmount());
|
||||
|
||||
pGroupGuy->GiveXP(itr_xp, victim);
|
||||
if (Pet* pet = pGroupGuy->GetPet())
|
||||
pet->GivePetXP(itr_xp/2);
|
||||
pet->GivePetXP(itr_xp / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2009,7 +2009,7 @@ void Battleground::RewardXPAtKill(Player* plr, Player* victim)
|
||||
// handle SPELL_AURA_MOD_XP_PCT auras
|
||||
Unit::AuraEffectList const& ModXPPctAuras = plr->GetAuraEffectsByType(SPELL_AURA_MOD_XP_PCT);
|
||||
for (Unit::AuraEffectList::const_iterator i = ModXPPctAuras.begin(); i != ModXPPctAuras.end(); ++i)
|
||||
xp = uint32(xp*(1.0f + (*i)->GetAmount() / 100.0f));
|
||||
AddPctN(xp, (*i)->GetAmount());
|
||||
|
||||
plr->GiveXP(xp, victim);
|
||||
|
||||
|
||||
@@ -865,8 +865,8 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket *data, const uint6
|
||||
uint32 winner_arena = plr->GetRandomWinner() ? BG_REWARD_WINNER_ARENA_LAST : BG_REWARD_WINNER_ARENA_FIRST;
|
||||
uint32 loser_kills = plr->GetRandomWinner() ? BG_REWARD_LOSER_HONOR_LAST : BG_REWARD_LOSER_HONOR_FIRST;
|
||||
|
||||
winner_kills = Trinity::Honor::hk_honor_at_level(plr->getLevel(), winner_kills);
|
||||
loser_kills = Trinity::Honor::hk_honor_at_level(plr->getLevel(), loser_kills);
|
||||
winner_kills = Trinity::Honor::hk_honor_at_level(plr->getLevel(), float(winner_kills));
|
||||
loser_kills = Trinity::Honor::hk_honor_at_level(plr->getLevel(), float(loser_kills));
|
||||
|
||||
data->Initialize(SMSG_BATTLEFIELD_LIST);
|
||||
*data << uint64(guid); // battlemaster guid
|
||||
|
||||
@@ -58,8 +58,8 @@ class HostileReference : public Reference<Unit, ThreatManager>
|
||||
void addThreatPercent(int32 pPercent)
|
||||
{
|
||||
float tmpThreat = iThreat;
|
||||
tmpThreat = tmpThreat * (pPercent+100.0f) / 100.0f;
|
||||
addThreat(tmpThreat-iThreat);
|
||||
AddPctN(tmpThreat, pPercent);
|
||||
addThreat(tmpThreat - iThreat);
|
||||
}
|
||||
|
||||
float getThreat() const { return iThreat; }
|
||||
|
||||
@@ -614,17 +614,17 @@ void Creature::RegenerateMana()
|
||||
float ManaIncreaseRate = sWorld.getRate(RATE_POWER_MANA);
|
||||
float Spirit = GetStat(STAT_SPIRIT);
|
||||
|
||||
addvalue = uint32((Spirit/5.0f + 17.0f) * ManaIncreaseRate);
|
||||
addvalue = uint32((Spirit / 5.0f + 17.0f) * ManaIncreaseRate);
|
||||
}
|
||||
}
|
||||
else
|
||||
addvalue = maxValue/3;
|
||||
addvalue = maxValue / 3;
|
||||
|
||||
// Apply modifiers (if any).
|
||||
AuraEffectList const& ModPowerRegenPCTAuras = GetAuraEffectsByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT);
|
||||
for (AuraEffectList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i)
|
||||
if ((*i)->GetMiscValue() == POWER_MANA)
|
||||
addvalue = uint32(addvalue * ((*i)->GetAmount() + 100) / 100.0f);
|
||||
AddPctN(addvalue, (*i)->GetAmount());
|
||||
|
||||
addvalue += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_POWER_REGEN, POWER_MANA) * CREATURE_REGEN_INTERVAL / (5 * IN_MILLISECONDS);
|
||||
|
||||
@@ -661,7 +661,7 @@ void Creature::RegenerateHealth()
|
||||
// Apply modifiers (if any).
|
||||
AuraEffectList const& ModPowerRegenPCTAuras = GetAuraEffectsByType(SPELL_AURA_MOD_HEALTH_REGEN_PERCENT);
|
||||
for (AuraEffectList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i)
|
||||
addvalue = uint32(addvalue * ((*i)->GetAmount() + 100) / 100.0f);
|
||||
AddPctN(addvalue, (*i)->GetAmount());
|
||||
|
||||
addvalue += GetTotalAuraModifier(SPELL_AURA_MOD_REGEN) * CREATURE_REGEN_INTERVAL / (5 * IN_MILLISECONDS);
|
||||
|
||||
|
||||
@@ -229,8 +229,9 @@ class Object
|
||||
|
||||
void ApplyPercentModFloatValue(uint16 index, float val, bool apply)
|
||||
{
|
||||
val = val != -100.0f ? val : -99.9f ;
|
||||
SetFloatValue(index, GetFloatValue(index) * (apply?(100.0f+val)/100.0f : 100.0f / (100.0f+val)));
|
||||
float value = GetFloatValue(index);
|
||||
ApplyPercentModFloatVar(value, val, apply);
|
||||
SetFloatValue(index, value);
|
||||
}
|
||||
|
||||
void SetFlag(uint16 index, uint32 newFlag);
|
||||
|
||||
@@ -613,11 +613,11 @@ void Creature::Regenerate(Powers power)
|
||||
AuraEffectList const& ModPowerRegenPCTAuras = GetAuraEffectsByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT);
|
||||
for (AuraEffectList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i)
|
||||
if (Powers((*i)->GetMiscValue()) == power)
|
||||
addvalue *= ((*i)->GetAmount() + 100) / 100.0f;
|
||||
AddPctN(addvalue, (*i)->GetAmount());
|
||||
|
||||
addvalue += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_POWER_REGEN, power) * (isHunterPet()? PET_FOCUS_REGEN_INTERVAL : CREATURE_REGEN_INTERVAL) / (5 * IN_MILLISECONDS);
|
||||
|
||||
ModifyPower(power, (int32)addvalue);
|
||||
ModifyPower(power, int32(addvalue));
|
||||
}
|
||||
|
||||
void Pet::LoseHappiness()
|
||||
@@ -1940,7 +1940,7 @@ void Pet::CastPetAura(PetAura const* aura)
|
||||
|
||||
if (auraId == 35696) // Demonic Knowledge
|
||||
{
|
||||
int32 basePoints = int32(aura->GetDamage() * (GetStat(STAT_STAMINA) + GetStat(STAT_INTELLECT)) / 100);
|
||||
int32 basePoints = CalculatePctF(aura->GetDamage(), GetStat(STAT_STAMINA) + GetStat(STAT_INTELLECT));
|
||||
CastCustomSpell(this, auraId, &basePoints, NULL, NULL, true);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1045,22 +1045,22 @@ int32 Player::getMaxTimer(MirrorTimerType timer)
|
||||
switch (timer)
|
||||
{
|
||||
case FATIGUE_TIMER:
|
||||
return MINUTE*IN_MILLISECONDS;
|
||||
return MINUTE * IN_MILLISECONDS;
|
||||
case BREATH_TIMER:
|
||||
{
|
||||
if (!isAlive() || HasAuraType(SPELL_AURA_WATER_BREATHING) || GetSession()->GetSecurity() >= AccountTypes(sWorld.getIntConfig(CONFIG_DISABLE_BREATHING)))
|
||||
return DISABLED_MIRROR_TIMER;
|
||||
int32 UnderWaterTime = 3*MINUTE*IN_MILLISECONDS;
|
||||
int32 UnderWaterTime = 3 * MINUTE * IN_MILLISECONDS;
|
||||
AuraEffectList const& mModWaterBreathing = GetAuraEffectsByType(SPELL_AURA_MOD_WATER_BREATHING);
|
||||
for (AuraEffectList::const_iterator i = mModWaterBreathing.begin(); i != mModWaterBreathing.end(); ++i)
|
||||
UnderWaterTime = uint32(UnderWaterTime * (100.0f + (*i)->GetAmount()) / 100.0f);
|
||||
AddPctN(UnderWaterTime, (*i)->GetAmount());
|
||||
return UnderWaterTime;
|
||||
}
|
||||
case FIRE_TIMER:
|
||||
{
|
||||
if (!isAlive())
|
||||
return DISABLED_MIRROR_TIMER;
|
||||
return 1*IN_MILLISECONDS;
|
||||
return 1 * IN_MILLISECONDS;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
@@ -2259,7 +2259,7 @@ void Player::Regenerate(Powers power)
|
||||
AuraEffectList const& ModPowerRegenPCTAuras = GetAuraEffectsByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT);
|
||||
for (AuraEffectList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i)
|
||||
if (Powers((*i)->GetMiscValue()) == power)
|
||||
addvalue *= ((*i)->GetAmount() + 100) / 100.0f;
|
||||
AddPctN(addvalue, (*i)->GetAmount());
|
||||
|
||||
// Butchery requires combat for this effect
|
||||
if (power != POWER_RUNIC_POWER || isInCombat())
|
||||
@@ -2339,12 +2339,12 @@ void Player::RegenerateHealth()
|
||||
{
|
||||
AuraEffectList const& mModHealthRegenPct = GetAuraEffectsByType(SPELL_AURA_MOD_HEALTH_REGEN_PERCENT);
|
||||
for (AuraEffectList::const_iterator i = mModHealthRegenPct.begin(); i != mModHealthRegenPct.end(); ++i)
|
||||
addvalue *= (100.0f + (*i)->GetAmount()) / 100.0f;
|
||||
AddPctN(addvalue, (*i)->GetAmount());
|
||||
|
||||
addvalue += GetTotalAuraModifier(SPELL_AURA_MOD_REGEN) * 2 * IN_MILLISECONDS / (5 * IN_MILLISECONDS);
|
||||
}
|
||||
else if (HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT))
|
||||
addvalue *= GetTotalAuraModifier(SPELL_AURA_MOD_REGEN_DURING_COMBAT) / 100.0f;
|
||||
ApplyPctN(addvalue, GetTotalAuraModifier(SPELL_AURA_MOD_REGEN_DURING_COMBAT));
|
||||
|
||||
if (!IsStandState())
|
||||
addvalue *= 1.5;
|
||||
@@ -5357,7 +5357,7 @@ void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, floa
|
||||
|
||||
float val = 1.0f;
|
||||
|
||||
switch(modType)
|
||||
switch (modType)
|
||||
{
|
||||
case FLAT_MOD:
|
||||
m_auraBaseMod[modGroup][modType] += apply ? amount : -amount;
|
||||
@@ -5365,9 +5365,7 @@ void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, floa
|
||||
case PCT_MOD:
|
||||
if (amount <= -100.0f)
|
||||
amount = -200.0f;
|
||||
|
||||
val = (100.0f + amount) / 100.0f;
|
||||
m_auraBaseMod[modGroup][modType] *= apply ? val : (1.0f/val);
|
||||
ApplyPercentModFloatVar(m_auraBaseMod[modGroup][modType], amount, apply);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5617,7 +5615,7 @@ void Player::UpdateRating(CombatRating cr)
|
||||
AuraEffectList const& modRatingFromStat = GetAuraEffectsByType(SPELL_AURA_MOD_RATING_FROM_STAT);
|
||||
for (AuraEffectList::const_iterator i = modRatingFromStat.begin(); i != modRatingFromStat.end(); ++i)
|
||||
if ((*i)->GetMiscValue() & (1<<cr))
|
||||
amount += int32(GetStat(Stats((*i)->GetMiscValueB())) * (*i)->GetAmount() / 100.0f);
|
||||
amount += int32(CalculatePctN(GetStat(Stats((*i)->GetMiscValueB())), (*i)->GetAmount()));
|
||||
if (amount < 0)
|
||||
amount = 0;
|
||||
SetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + cr, uint32(amount));
|
||||
@@ -6893,7 +6891,7 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, int32 honor, bool pvpt
|
||||
honor_f /= groupsize;
|
||||
|
||||
// apply honor multiplier from aura (not stacking-get highest)
|
||||
honor_f *= (GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HONOR_GAIN_PCT) + 100) / 100.0f;
|
||||
AddPctN(honor_f, GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HONOR_GAIN_PCT));
|
||||
}
|
||||
|
||||
honor_f *= sWorld.getRate(RATE_HONOR);
|
||||
@@ -14525,7 +14523,7 @@ void Player::RewardQuest(Quest const *pQuest, uint32 reward, Object* questGiver,
|
||||
// handle SPELL_AURA_MOD_XP_QUEST_PCT auras
|
||||
Unit::AuraEffectList const& ModXPPctAuras = GetAuraEffectsByType(SPELL_AURA_MOD_XP_QUEST_PCT);
|
||||
for (Unit::AuraEffectList::const_iterator i = ModXPPctAuras.begin(); i != ModXPPctAuras.end(); ++i)
|
||||
XP = uint32(XP*(1.0f + (*i)->GetAmount() / 100.0f));
|
||||
AddPctN(XP, (*i)->GetAmount());
|
||||
|
||||
int32 moneyRew = 0;
|
||||
if (getLevel() < sWorld.getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
@@ -21860,16 +21858,16 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim)
|
||||
if (pGroupGuy->isAlive() && not_gray_member_with_max_level &&
|
||||
pGroupGuy->getLevel() <= not_gray_member_with_max_level->getLevel())
|
||||
{
|
||||
uint32 itr_xp = (member_with_max_level == not_gray_member_with_max_level) ? uint32(xp*rate) : uint32((xp*rate/2)+1);
|
||||
uint32 itr_xp = (member_with_max_level == not_gray_member_with_max_level) ? uint32(xp * rate) : uint32((xp * rate / 2) + 1);
|
||||
|
||||
// handle SPELL_AURA_MOD_XP_PCT auras
|
||||
Unit::AuraEffectList const& ModXPPctAuras = GetAuraEffectsByType(SPELL_AURA_MOD_XP_PCT);
|
||||
for (Unit::AuraEffectList::const_iterator i = ModXPPctAuras.begin(); i != ModXPPctAuras.end(); ++i)
|
||||
itr_xp = uint32(itr_xp*(1.0f + (*i)->GetAmount() / 100.0f));
|
||||
AddPctN(itr_xp, (*i)->GetAmount());
|
||||
|
||||
pGroupGuy->GiveXP(itr_xp, pVictim, group_rate);
|
||||
if (Pet* pet = pGroupGuy->GetPet())
|
||||
pet->GivePetXP(itr_xp/2);
|
||||
pet->GivePetXP(itr_xp / 2);
|
||||
}
|
||||
|
||||
// quest objectives updated only for alive group member or dead but with not released body
|
||||
@@ -21899,7 +21897,7 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim)
|
||||
// handle SPELL_AURA_MOD_XP_PCT auras
|
||||
Unit::AuraEffectList const& ModXPPctAuras = GetAuraEffectsByType(SPELL_AURA_MOD_XP_PCT);
|
||||
for (Unit::AuraEffectList::const_iterator i = ModXPPctAuras.begin(); i != ModXPPctAuras.end(); ++i)
|
||||
xp = uint32(xp*(1.0f + (*i)->GetAmount() / 100.0f));
|
||||
AddPctN(xp, (*i)->GetAmount());
|
||||
|
||||
GiveXP(xp, pVictim);
|
||||
|
||||
|
||||
@@ -2753,7 +2753,7 @@ template <class T> T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &bas
|
||||
if (mod->op == SPELLMOD_CASTING_TIME && basevalue >= T(10000) && mod->value <= -100)
|
||||
continue;
|
||||
|
||||
totalmul *= 1.0f + (float)mod->value / 100.0f;
|
||||
AddPctN(totalmul, mod->value);
|
||||
}
|
||||
|
||||
DropModCharge(mod, spell);
|
||||
|
||||
@@ -213,7 +213,7 @@ void Player::UpdateArmor()
|
||||
for (AuraEffectList::const_iterator i = mResbyIntellect.begin(); i != mResbyIntellect.end(); ++i)
|
||||
{
|
||||
if ((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
|
||||
value += int32(GetStat(Stats((*i)->GetMiscValueB())) * (*i)->GetAmount() / 100.0f);
|
||||
value += CalculatePctN(GetStat(Stats((*i)->GetMiscValueB())), (*i)->GetAmount());
|
||||
}
|
||||
|
||||
value *= GetModifierValue(unitMod, TOTAL_PCT);
|
||||
@@ -329,7 +329,7 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
|
||||
{
|
||||
ShapeshiftForm form = GetShapeshiftForm();
|
||||
// Check if Predatory Strikes is skilled
|
||||
float mLevelMult = 0.0;
|
||||
float mLevelMult = 0.0f;
|
||||
switch (form)
|
||||
{
|
||||
case FORM_CAT:
|
||||
@@ -343,7 +343,7 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
|
||||
// Predatory Strikes (effect 0)
|
||||
if ((*itr)->GetEffIndex() == 0 && (*itr)->GetSpellProto()->SpellIconID == 1563)
|
||||
{
|
||||
mLevelMult = (*itr)->GetAmount() / 100.0f;
|
||||
mLevelMult = CalculatePctN(1.0f, (*itr)->GetAmount());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -384,14 +384,14 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
|
||||
{
|
||||
AuraEffectList const& mRAPbyStat = GetAuraEffectsByType(SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT);
|
||||
for (AuraEffectList::const_iterator i = mRAPbyStat.begin(); i != mRAPbyStat.end(); ++i)
|
||||
attPowerMod += int32(GetStat(Stats((*i)->GetMiscValue())) * (*i)->GetAmount() / 100.0f);
|
||||
attPowerMod += CalculatePctN(GetStat(Stats((*i)->GetMiscValue())), (*i)->GetAmount());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AuraEffectList const& mAPbyStat = GetAuraEffectsByType(SPELL_AURA_MOD_ATTACK_POWER_OF_STAT_PERCENT);
|
||||
for (AuraEffectList::const_iterator i = mAPbyStat.begin(); i != mAPbyStat.end(); ++i)
|
||||
attPowerMod += int32(GetStat(Stats((*i)->GetMiscValue())) * (*i)->GetAmount() / 100.0f);
|
||||
attPowerMod += CalculatePctN(GetStat(Stats((*i)->GetMiscValue())), (*i)->GetAmount());
|
||||
|
||||
AuraEffectList const& mAPbyArmor = GetAuraEffectsByType(SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR);
|
||||
for (AuraEffectList::const_iterator iter = mAPbyArmor.begin(); iter != mAPbyArmor.end(); ++iter)
|
||||
@@ -739,7 +739,7 @@ void Player::UpdateManaRegen()
|
||||
int32 modManaRegenInterrupt = GetTotalAuraModifier(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT);
|
||||
if (modManaRegenInterrupt > 100)
|
||||
modManaRegenInterrupt = 100;
|
||||
SetStatFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER, power_regen_mp5 + power_regen * modManaRegenInterrupt / 100.0f);
|
||||
SetStatFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER, power_regen_mp5 + CalculatePctN(power_regen, modManaRegenInterrupt));
|
||||
|
||||
SetStatFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER, power_regen_mp5 + power_regen);
|
||||
}
|
||||
@@ -958,13 +958,13 @@ bool Guardian::UpdateStats(Stats stat)
|
||||
aurEff = owner->GetAuraEffect(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELLFAMILY_DEATHKNIGHT, 3010, 0);
|
||||
if (aurEff)
|
||||
{
|
||||
SpellEntry const* sProto = aurEff->GetSpellProto(); // Then get the SpellProto and add the dummy effect value
|
||||
mod += mod * (SpellMgr::CalculateSpellEffectAmount(sProto, 1) / 100.0f); // Ravenous Dead edits the original scale
|
||||
SpellEntry const* sProto = aurEff->GetSpellProto(); // Then get the SpellProto and add the dummy effect value
|
||||
AddPctN(mod, SpellMgr::CalculateSpellEffectAmount(sProto, 1)); // Ravenous Dead edits the original scale
|
||||
}
|
||||
// Glyph of the Ghoul
|
||||
aurEff = owner->GetAuraEffect(58686, 0);
|
||||
if (aurEff)
|
||||
mod += (aurEff->GetAmount() / 100.0f); // Glyph of the Ghoul adds a flat value to the scale mod
|
||||
mod += CalculatePctN(1.0f, aurEff->GetAmount()); // Glyph of the Ghoul adds a flat value to the scale mod
|
||||
ownersBonus = float(owner->GetStat(stat)) * mod;
|
||||
value += ownersBonus;
|
||||
}
|
||||
@@ -972,7 +972,7 @@ bool Guardian::UpdateStats(Stats stat)
|
||||
{
|
||||
if (owner->getClass() == CLASS_WARLOCK && isPet())
|
||||
{
|
||||
ownersBonus = float(owner->GetStat(STAT_STAMINA)) * 0.75f;
|
||||
ownersBonus = CalculatePctN(owner->GetStat(STAT_STAMINA), 75);
|
||||
value += ownersBonus;
|
||||
}
|
||||
else
|
||||
@@ -987,7 +987,7 @@ bool Guardian::UpdateStats(Stats stat)
|
||||
if (itr != ToPet()->m_spells.end()) // If pet has Wild Hunt
|
||||
{
|
||||
SpellEntry const* sProto = sSpellStore.LookupEntry(itr->first); // Then get the SpellProto and add the dummy effect value
|
||||
mod += mod * (SpellMgr::CalculateSpellEffectAmount(sProto, 0) / 100.0f);
|
||||
AddPctN(mod, SpellMgr::CalculateSpellEffectAmount(sProto, 0));
|
||||
}
|
||||
}
|
||||
ownersBonus = float(owner->GetStat(stat)) * mod;
|
||||
@@ -999,7 +999,7 @@ bool Guardian::UpdateStats(Stats stat)
|
||||
{
|
||||
if (owner->getClass() == CLASS_WARLOCK || owner->getClass() == CLASS_MAGE)
|
||||
{
|
||||
ownersBonus = float(owner->GetStat(stat)) * 0.3f;
|
||||
ownersBonus = CalculatePctN(owner->GetStat(stat), 30);
|
||||
value += ownersBonus;
|
||||
}
|
||||
}
|
||||
@@ -1051,7 +1051,7 @@ void Guardian::UpdateResistances(uint32 school)
|
||||
|
||||
// hunter and warlock pets gain 40% of owner's resistance
|
||||
if (isPet())
|
||||
value += float(m_owner->GetResistance(SpellSchools(school))) * 0.4f;
|
||||
value += float(CalculatePctN(m_owner->GetResistance(SpellSchools(school)), 40));
|
||||
|
||||
SetResistance(SpellSchools(school), int32(value));
|
||||
}
|
||||
@@ -1067,7 +1067,7 @@ void Guardian::UpdateArmor()
|
||||
|
||||
// hunter and warlock pets gain 35% of owner's armor value
|
||||
if (isPet())
|
||||
bonus_armor = 0.35f * float(m_owner->GetArmor());
|
||||
bonus_armor = float(CalculatePctN(m_owner->GetArmor(), 35));
|
||||
|
||||
value = GetModifierValue(unitMod, BASE_VALUE);
|
||||
value *= GetModifierValue(unitMod, BASE_PCT);
|
||||
@@ -1157,7 +1157,7 @@ void Guardian::UpdateAttackPowerAndDamage(bool ranged)
|
||||
if (itr != ToPet()->m_spells.end()) // If pet has Wild Hunt
|
||||
{
|
||||
SpellEntry const* sProto = sSpellStore.LookupEntry(itr->first); // Then get the SpellProto and add the dummy effect value
|
||||
mod += (SpellMgr::CalculateSpellEffectAmount(sProto, 1) / 100.0f);
|
||||
mod += CalculatePctN(1.0f, SpellMgr::CalculateSpellEffectAmount(sProto, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1275,8 +1275,8 @@ void Guardian::UpdateDamagePhysical(WeaponAttackType attType)
|
||||
{
|
||||
case 61682:
|
||||
case 61683:
|
||||
mindamage = mindamage * (100.0f-float((*itr)->GetAmount()))/100.0f;
|
||||
maxdamage = maxdamage * (100.0f-float((*itr)->GetAmount()))/100.0f;
|
||||
AddPctN(mindamage, -(*itr)->GetAmount());
|
||||
AddPctN(maxdamage, -(*itr)->GetAmount());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1211,8 +1211,8 @@ class Unit : public WorldObject
|
||||
inline bool HealthBelowPct(int32 pct) const { return GetHealth() * (uint64)100 < GetMaxHealth() * (uint64)pct; }
|
||||
inline bool HealthBelowPctDamaged(int32 pct, uint32 damage) const { return (int32(GetHealth()) - damage) * (int64)100 < GetMaxHealth() * (int64)pct; }
|
||||
inline bool HealthAbovePct(int32 pct) const { return GetHealth() * (uint64)100 > GetMaxHealth() * (uint64)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); }
|
||||
inline float GetHealthPct() const { return GetMaxHealth() ? 100.f * GetHealth() / GetMaxHealth() : 0.0f; }
|
||||
inline uint32 CountPctFromMaxHealth(int32 pct) const { return CalculatePctN(GetMaxHealth(), pct); }
|
||||
|
||||
void SetHealth(uint32 val);
|
||||
void SetMaxHealth(uint32 val);
|
||||
@@ -1885,7 +1885,7 @@ class Unit : public WorldObject
|
||||
void SetHover(bool on);
|
||||
bool isHover() const { return HasAuraType(SPELL_AURA_HOVER); }
|
||||
|
||||
int32 ApplyEffectModifiers(SpellEntry const* spellProto, uint8 effect_index, int32 value) const;
|
||||
float ApplyEffectModifiers(SpellEntry const* spellProto, uint8 effect_index, float value) const;
|
||||
int32 CalculateSpellDamage(Unit const* target, SpellEntry const* spellProto, uint8 effect_index, int32 const* basePoints = NULL) const;
|
||||
int32 CalcSpellDuration(SpellEntry const* spellProto);
|
||||
int32 ModSpellDuration(SpellEntry const* spellProto, Unit const* target, int32 duration, bool positive);
|
||||
|
||||
@@ -9011,7 +9011,7 @@ uint32 ObjectMgr::GetScriptId(const char *name)
|
||||
ScriptNameMap::const_iterator itr =
|
||||
std::lower_bound(m_scriptNames.begin(), m_scriptNames.end(), name);
|
||||
if (itr == m_scriptNames.end() || *itr != name) return 0;
|
||||
return itr - m_scriptNames.begin();
|
||||
return uint32(itr - m_scriptNames.begin());
|
||||
}
|
||||
|
||||
void ObjectMgr::CheckScripts(ScriptsType type, std::set<int32>& ids)
|
||||
|
||||
@@ -135,7 +135,7 @@ bool OPvPCapturePoint::SetCapturePointData(uint32 entry, uint32 map, float x, fl
|
||||
m_maxValue = (float)goinfo->capturePoint.maxTime;
|
||||
m_maxSpeed = m_maxValue / (goinfo->capturePoint.minTime ? goinfo->capturePoint.minTime : 60);
|
||||
m_neutralValuePct = goinfo->capturePoint.neutralPercent;
|
||||
m_minValue = m_maxValue * goinfo->capturePoint.neutralPercent / 100;
|
||||
m_minValue = CalculatePctU(m_maxValue, m_neutralValuePct);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ int WorldSocket::handle_input_missing_data (void)
|
||||
recv_size);
|
||||
|
||||
if (n <= 0)
|
||||
return n;
|
||||
return int(n);
|
||||
|
||||
message_block.wr_ptr (n);
|
||||
|
||||
|
||||
@@ -472,7 +472,7 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
|
||||
// Glyph of Fear, Glyph of Frost nova and similar auras
|
||||
if ((*itr)->GetMiscValue() == 7801)
|
||||
{
|
||||
amount += (int32)(amount*(*itr)->GetAmount()/100.0f);
|
||||
AddPctN(amount, (*itr)->GetAmount());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -493,7 +493,7 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
|
||||
DoneActualBenefit += caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.8068f;
|
||||
// Glyph of Ice Barrier: its weird having a SPELLMOD_ALL_EFFECTS here but its blizzards doing :)
|
||||
// Glyph of Ice Barrier is only applied at the spell damage bonus because it was already applied to the base value in CalculateSpellDamage
|
||||
DoneActualBenefit = caster->ApplyEffectModifiers(GetSpellProto(), m_effIndex, (int32)DoneActualBenefit);
|
||||
DoneActualBenefit = caster->ApplyEffectModifiers(GetSpellProto(), m_effIndex, DoneActualBenefit);
|
||||
}
|
||||
// Fire Ward
|
||||
else if(GetSpellProto()->SpellFamilyFlags[0] & 0x8 && GetSpellProto()->SpellFamilyFlags[2] & 0x8)
|
||||
@@ -520,27 +520,27 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
|
||||
// Power Word: Shield
|
||||
if (GetSpellProto()->SpellFamilyFlags[0] & 0x1 && GetSpellProto()->SpellFamilyFlags[2] & 0x400)
|
||||
{
|
||||
//+80.68% from sp bonus
|
||||
// +80.68% from sp bonus
|
||||
float bonus = 0.8068f;
|
||||
|
||||
// Borrowed Time
|
||||
if (AuraEffect const* pAurEff = caster->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_PRIEST, 2899, 1))
|
||||
bonus += (float)pAurEff->GetAmount() / 100.0f;
|
||||
bonus += CalculatePctN(1.0f, pAurEff->GetAmount());
|
||||
|
||||
DoneActualBenefit += caster->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto)) * bonus;
|
||||
// Improved PW: Shield: its weird having a SPELLMOD_ALL_EFFECTS here but its blizzards doing :)
|
||||
// Improved PW: Shield is only applied at the spell healing bonus because it was already applied to the base value in CalculateSpellDamage
|
||||
DoneActualBenefit = caster->ApplyEffectModifiers(GetSpellProto(), m_effIndex, (int32)DoneActualBenefit);
|
||||
DoneActualBenefit = caster->ApplyEffectModifiers(GetSpellProto(), m_effIndex, DoneActualBenefit);
|
||||
DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto());
|
||||
|
||||
amount += (int32)DoneActualBenefit;
|
||||
amount += int32(DoneActualBenefit);
|
||||
|
||||
// Twin Disciplines
|
||||
if (AuraEffect const* pAurEff = caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_PRIEST, 0x400000, 0, 0, caster->GetGUID()))
|
||||
amount *= (100.0f + pAurEff->GetAmount()) / 100.0f;
|
||||
AddPctN(amount, pAurEff->GetAmount());
|
||||
|
||||
// Focused Power
|
||||
amount *= caster->GetTotalAuraMultiplier(SPELL_AURA_MOD_HEALING_DONE_PERCENT);
|
||||
amount *= int32(caster->GetTotalAuraMultiplier(SPELL_AURA_MOD_HEALING_DONE_PERCENT));
|
||||
|
||||
return amount;
|
||||
}
|
||||
@@ -554,17 +554,17 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
|
||||
|
||||
DoneActualBenefit += caster->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto)) * bonus;
|
||||
// Divine Guardian is only applied at the spell healing bonus because it was already applied to the base value in CalculateSpellDamage
|
||||
DoneActualBenefit = caster->ApplyEffectModifiers(GetSpellProto(), m_effIndex, (int32)DoneActualBenefit);
|
||||
DoneActualBenefit = caster->ApplyEffectModifiers(GetSpellProto(), m_effIndex, DoneActualBenefit);
|
||||
DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto());
|
||||
|
||||
amount += (int32)DoneActualBenefit;
|
||||
|
||||
// Arena - Dampening
|
||||
if (AuraEffect const* pAurEff = caster->GetAuraEffect(74410, 0))
|
||||
amount *= (100.0f + pAurEff->GetAmount()) / 100.0f;
|
||||
AddPctN(amount, pAurEff->GetAmount());
|
||||
// Battleground - Dampening
|
||||
else if (AuraEffect const* pAurEff = caster->GetAuraEffect(74411, 0))
|
||||
amount *= (100.0f + pAurEff->GetAmount()) / 100.0f;
|
||||
AddPctN(amount, pAurEff->GetAmount());
|
||||
|
||||
return amount;
|
||||
}
|
||||
@@ -632,24 +632,25 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
|
||||
if (AuraEffect const * aurEff = caster->GetAuraEffect(34241,0))
|
||||
amount += cp * aurEff->GetAmount();
|
||||
|
||||
amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * cp / 100);
|
||||
amount += CalculatePctF(cp, caster->GetTotalAttackPowerValue(BASE_ATTACK));
|
||||
}
|
||||
// Rend
|
||||
else if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARRIOR && GetSpellProto()->SpellFamilyFlags[0] & 0x20)
|
||||
{
|
||||
m_canBeRecalculated = false;
|
||||
// $0.2*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick
|
||||
// $0.2 * (($MWB + $mwb) / 2 + $AP / 14 * $MWS) bonus per tick
|
||||
float ap = caster->GetTotalAttackPowerValue(BASE_ATTACK);
|
||||
int32 mws = caster->GetAttackTime(BASE_ATTACK);
|
||||
float mwb_min = caster->GetWeaponDamageRange(BASE_ATTACK,MINDAMAGE);
|
||||
float mwb_max = caster->GetWeaponDamageRange(BASE_ATTACK,MAXDAMAGE);
|
||||
amount+=caster->ApplyEffectModifiers(m_spellProto,m_effIndex,int32(((mwb_min+mwb_max)/2+ap*mws/14000)*0.2f));
|
||||
float mwb = ((mwb_min + mwb_max) / 2 + ap * mws / 14000) * 0.2f;
|
||||
amount += int32(caster->ApplyEffectModifiers(m_spellProto, m_effIndex, mwb));
|
||||
// "If used while your target is above 75% health, Rend does 35% more damage."
|
||||
// as for 3.1.3 only ranks above 9 (wrong tooltip?)
|
||||
if (sSpellMgr.GetSpellRank(m_spellProto->Id) >= 9)
|
||||
{
|
||||
if (GetBase()->GetUnitOwner()->HasAuraState(AURA_STATE_HEALTH_ABOVE_75_PERCENT, m_spellProto, caster))
|
||||
amount += int32(amount * SpellMgr::CalculateSpellEffectAmount(m_spellProto, 2, caster) / 100.0f);
|
||||
AddPctN(amount, SpellMgr::CalculateSpellEffectAmount(m_spellProto, 2, caster));
|
||||
}
|
||||
}
|
||||
// Unholy Blight damage over time effect
|
||||
@@ -670,10 +671,10 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
|
||||
}
|
||||
// Innervate
|
||||
else if (m_spellProto->Id == 29166)
|
||||
amount = int32(GetBase()->GetUnitOwner()->GetCreatePowers(POWER_MANA) * amount / (GetTotalTicks() * 100.0f));
|
||||
ApplyPctF(amount, float(GetBase()->GetUnitOwner()->GetCreatePowers(POWER_MANA)) / GetTotalTicks());
|
||||
// Owlkin Frenzy
|
||||
else if (m_spellProto->Id == 48391)
|
||||
amount = GetBase()->GetUnitOwner()->GetCreatePowers(POWER_MANA) * amount / 100;
|
||||
ApplyPctU(amount, GetBase()->GetUnitOwner()->GetCreatePowers(POWER_MANA));
|
||||
break;
|
||||
case SPELL_AURA_PERIODIC_HEAL:
|
||||
if (!caster)
|
||||
@@ -684,7 +685,7 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
|
||||
if (caster->GetTypeId() == TYPEID_PLAYER)
|
||||
// Bonus from Glyph of Lightwell
|
||||
if (AuraEffect* modHealing = caster->GetAuraEffect(55673, 0))
|
||||
amount = int32(amount * (100.0f + modHealing->GetAmount()) / 100.0f);
|
||||
AddPctN(amount, modHealing->GetAmount());
|
||||
}
|
||||
break;
|
||||
case SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN:
|
||||
@@ -749,7 +750,7 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
|
||||
case SPELL_AURA_MOD_INCREASE_ENERGY:
|
||||
// Hymn of Hope
|
||||
if (GetId() == 64904)
|
||||
amount = GetBase()->GetUnitOwner()->GetMaxPower(GetBase()->GetUnitOwner()->getPowerType()) * amount / 100;
|
||||
ApplyPctU(amount, GetBase()->GetUnitOwner()->GetMaxPower(GetBase()->GetUnitOwner()->getPowerType()));
|
||||
break;
|
||||
case SPELL_AURA_MOD_INCREASE_SPEED:
|
||||
// Dash - do not set speed if not in cat form
|
||||
@@ -1550,27 +1551,27 @@ void AuraEffect::PeriodicTick(AuraApplication * aurApp, Unit * caster) const
|
||||
|
||||
// Tenacity increase healing % taken
|
||||
if (AuraEffect const* Tenacity = target->GetAuraEffect(58549, 0))
|
||||
TakenTotalMod *= (Tenacity->GetAmount() + 100.0f) / 100.0f;
|
||||
AddPctN(TakenTotalMod, Tenacity->GetAmount());
|
||||
|
||||
// Healing taken percent
|
||||
float minval = (float)target->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_HEALING_PCT);
|
||||
if (minval)
|
||||
TakenTotalMod *= (100.0f + minval) / 100.0f;
|
||||
AddPctF(TakenTotalMod, minval);
|
||||
|
||||
float maxval = (float)target->GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HEALING_PCT);
|
||||
if (maxval)
|
||||
TakenTotalMod *= (100.0f + maxval) / 100.0f;
|
||||
AddPctF(TakenTotalMod, maxval);
|
||||
|
||||
// Healing over time taken percent
|
||||
float minval_hot = (float)target->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_HOT_PCT);
|
||||
if (minval_hot)
|
||||
TakenTotalMod *= (100.0f + minval_hot) / 100.0f;
|
||||
AddPctF(TakenTotalMod, minval_hot);
|
||||
|
||||
float maxval_hot = (float)target->GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HOT_PCT);
|
||||
if (maxval_hot)
|
||||
TakenTotalMod *= (100.0f + maxval_hot) / 100.0f;
|
||||
AddPctF(TakenTotalMod, maxval_hot);
|
||||
|
||||
TakenTotalMod = TakenTotalMod > 0.0f ? TakenTotalMod : 0.0f;
|
||||
TakenTotalMod = std::max(TakenTotalMod, 0.0f);
|
||||
|
||||
damage = uint32(target->CountPctFromMaxHealth(damage));
|
||||
damage = uint32(damage * TakenTotalMod);
|
||||
@@ -1670,8 +1671,8 @@ void AuraEffect::PeriodicTick(AuraApplication * aurApp, Unit * caster) const
|
||||
if (m_spellProto->ManaCostPercentage)
|
||||
{
|
||||
// max value
|
||||
uint32 maxmana = caster->GetMaxPower(power) * damage * 2 / 100;
|
||||
damage = target->GetMaxPower(power) * damage / 100;
|
||||
uint32 maxmana = CalculatePctF(caster->GetMaxPower(power), damage * 2.0f);
|
||||
ApplyPctU(damage, target->GetMaxPower(power));
|
||||
if (damage > maxmana)
|
||||
damage = maxmana;
|
||||
}
|
||||
@@ -1679,7 +1680,7 @@ void AuraEffect::PeriodicTick(AuraApplication * aurApp, Unit * caster) const
|
||||
sLog.outDetail("PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u",
|
||||
GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target->GetGUIDLow(), target->GetTypeId(), damage, GetId());
|
||||
|
||||
int32 drain_amount = target->GetPower(power) > damage ? damage : target->GetPower(power);
|
||||
int32 drain_amount = std::min(target->GetPower(power), damage);
|
||||
|
||||
// resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
|
||||
if (power == POWER_MANA)
|
||||
@@ -1699,7 +1700,7 @@ void AuraEffect::PeriodicTick(AuraApplication * aurApp, Unit * caster) const
|
||||
|
||||
if (gain_amount)
|
||||
{
|
||||
int32 gain = caster->ModifyPower(power,gain_amount);
|
||||
int32 gain = caster->ModifyPower(power, gain_amount);
|
||||
target->AddThreat(caster, float(gain) * 0.5f, GetSpellSchoolMask(GetSpellProto()), GetSpellProto());
|
||||
}
|
||||
|
||||
@@ -1735,7 +1736,7 @@ void AuraEffect::PeriodicTick(AuraApplication * aurApp, Unit * caster) const
|
||||
// Mana Feed - Drain Mana
|
||||
if (manaFeedVal > 0)
|
||||
{
|
||||
manaFeedVal = manaFeedVal * gain_amount / 100;
|
||||
ApplyPctN(manaFeedVal, gain_amount);
|
||||
caster->CastCustomSpell(caster, 32554, &manaFeedVal, NULL, NULL, true, NULL, this);
|
||||
}
|
||||
}
|
||||
@@ -5570,10 +5571,10 @@ void AuraEffect::HandleModPowerCostPCT(AuraApplication const * aurApp, uint8 mod
|
||||
|
||||
Unit * target = aurApp->GetTarget();
|
||||
|
||||
float amount = GetAmount() /100.0f;
|
||||
float amount = CalculatePctN(1.0f, GetAmount());
|
||||
for (int i = 0; i < MAX_SPELL_SCHOOL; ++i)
|
||||
if (GetMiscValue() & (1<<i))
|
||||
target->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+i,amount,apply);
|
||||
if (GetMiscValue() & (1 << i))
|
||||
target->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER + i, amount, apply);
|
||||
}
|
||||
|
||||
void AuraEffect::HandleModPowerCost(AuraApplication const * aurApp, uint8 mode, bool apply) const
|
||||
@@ -5930,7 +5931,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const * aurApp, uint8 mode, boo
|
||||
// restore mana
|
||||
if (caster)
|
||||
{
|
||||
int32 returnmana = (GetSpellProto()->ManaCostPercentage * caster->GetCreateMana() / 100) * stack / 2;
|
||||
int32 returnmana = CalculatePctU(caster->GetCreateMana(), GetSpellProto()->ManaCostPercentage) * stack / 2;
|
||||
caster->CastCustomSpell(caster, 64372, &returnmana, NULL, NULL, true, NULL, this, GetCasterGUID());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -988,10 +988,10 @@ void Aura::HandleAuraSpecificMods(AuraApplication const * aurApp, Unit * caster,
|
||||
case 48020: // Demonic Circle
|
||||
if (target->GetTypeId() == TYPEID_PLAYER)
|
||||
if (GameObject* obj = target->GetGameObject(48018))
|
||||
{
|
||||
target->ToPlayer()->TeleportTo(obj->GetMapId(),obj->GetPositionX(),obj->GetPositionY(),obj->GetPositionZ(),obj->GetOrientation());
|
||||
target->ToPlayer()->RemoveMovementImpairingAuras();
|
||||
}
|
||||
{
|
||||
target->ToPlayer()->TeleportTo(obj->GetMapId(),obj->GetPositionX(),obj->GetPositionY(),obj->GetPositionZ(),obj->GetOrientation());
|
||||
target->ToPlayer()->RemoveMovementImpairingAuras();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -1271,7 +1271,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const * aurApp, Unit * caster,
|
||||
else if (aurEff->GetId() == 47537)
|
||||
multiplier += 0.5f;
|
||||
|
||||
int32 basepoints0 = int32(multiplier * caster->GetMaxPower(POWER_MANA) / 100);
|
||||
int32 basepoints0 = int32(CalculatePctF(caster->GetMaxPower(POWER_MANA), multiplier));
|
||||
caster->CastCustomSpell(caster, 47755, &basepoints0, NULL, NULL, true);
|
||||
}
|
||||
// effect on aura target
|
||||
@@ -1285,7 +1285,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const * aurApp, Unit * caster,
|
||||
{
|
||||
case POWER_MANA:
|
||||
{
|
||||
int32 basepoints0 = 2 * (target->GetMaxPower(POWER_MANA) / 100);
|
||||
int32 basepoints0 = int32(CalculatePctN(target->GetMaxPower(POWER_MANA), 2));
|
||||
caster->CastCustomSpell(target, 63654, &basepoints0, NULL, NULL, true);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1298,7 +1298,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
|
||||
if (m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->SpellFamilyFlags[1] & 0x40000 && m_spellAura && m_spellAura->GetEffect(1))
|
||||
{
|
||||
AuraEffect * aurEff = m_spellAura->GetEffect(1);
|
||||
aurEff->SetAmount(aurEff->GetAmount() * damageInfo.damage / 100);
|
||||
aurEff->SetAmount(CalculatePctU(aurEff->GetAmount(), damageInfo.damage));
|
||||
}
|
||||
}
|
||||
// Passive spell hits/misses or active spells only misses (only triggers)
|
||||
@@ -6450,7 +6450,7 @@ void Spell::Delayed() // only called in DealDamage()
|
||||
if (delayReduce >= 100)
|
||||
return;
|
||||
|
||||
delaytime = delaytime * (100 - delayReduce) / 100;
|
||||
AddPctN(delaytime, -delayReduce);
|
||||
|
||||
if (int32(m_timer) + delaytime > m_casttime)
|
||||
{
|
||||
@@ -6478,14 +6478,14 @@ void Spell::DelayedChannel()
|
||||
return;
|
||||
|
||||
//check pushback reduce
|
||||
int32 delaytime = GetSpellDuration(m_spellInfo) * 25 / 100; // channeling delay is normally 25% of its time per hit
|
||||
int32 delaytime = CalculatePctN(GetSpellDuration(m_spellInfo), 25); // channeling delay is normally 25% of its time per hit
|
||||
int32 delayReduce = 100; // must be initialized to 100 for percent modifiers
|
||||
m_caster->ToPlayer()->ApplySpellMod(m_spellInfo->Id, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this);
|
||||
delayReduce += m_caster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100;
|
||||
if (delayReduce >= 100)
|
||||
return;
|
||||
|
||||
delaytime = delaytime * (100 - delayReduce) / 100;
|
||||
AddPctN(delaytime, -delayReduce);
|
||||
|
||||
if (int32(m_timer) <= delaytime)
|
||||
{
|
||||
|
||||
@@ -460,14 +460,14 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex)
|
||||
{
|
||||
// Bloodthirst
|
||||
if (m_spellInfo->SpellFamilyFlags[1] & 0x400)
|
||||
damage = uint32(damage * (m_caster->GetTotalAttackPowerValue(BASE_ATTACK)) / 100);
|
||||
ApplyPctF(damage, m_caster->GetTotalAttackPowerValue(BASE_ATTACK));
|
||||
// Shield Slam
|
||||
else if (m_spellInfo->SpellFamilyFlags[1] & 0x200 && m_spellInfo->Category == 1209)
|
||||
damage += m_caster->ApplyEffectModifiers(m_spellInfo,effIndex,int32(m_caster->GetShieldBlockValue()));
|
||||
damage += int32(m_caster->ApplyEffectModifiers(m_spellInfo, effIndex, float(m_caster->GetShieldBlockValue())));
|
||||
// Victory Rush
|
||||
else if (m_spellInfo->SpellFamilyFlags[1] & 0x100)
|
||||
{
|
||||
damage = uint32(damage * m_caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100);
|
||||
ApplyPctF(damage, m_caster->GetTotalAttackPowerValue(BASE_ATTACK));
|
||||
m_caster->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH, false);
|
||||
}
|
||||
// Shockwave
|
||||
@@ -475,7 +475,7 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex)
|
||||
{
|
||||
int32 pct = m_caster->CalculateSpellDamage(unitTarget, m_spellInfo, 2);
|
||||
if (pct > 0)
|
||||
damage+= int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * pct / 100);
|
||||
damage += int32(CalculatePctN(m_caster->GetTotalAttackPowerValue(BASE_ATTACK), pct));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -521,14 +521,14 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex)
|
||||
// found Immolate or Shadowflame
|
||||
if (aura)
|
||||
{
|
||||
uint32 pdamage = aura->GetAmount() > 0 ? aura->GetAmount() : 0;
|
||||
uint32 pdamage = uint32(std::max(aura->GetAmount(), 0));
|
||||
pdamage = m_caster->SpellDamageBonus(unitTarget, aura->GetSpellProto(), pdamage, DOT, aura->GetBase()->GetStackAmount());
|
||||
uint32 pct_dir = m_caster->CalculateSpellDamage(unitTarget, m_spellInfo, (effIndex + 1));
|
||||
uint8 baseTotalTicks = uint8(m_caster->CalcSpellDuration(aura->GetSpellProto()) / aura->GetSpellProto()->EffectAmplitude[0]);
|
||||
damage += pdamage * baseTotalTicks * pct_dir / 100;
|
||||
damage += int32(CalculatePctU(pdamage * baseTotalTicks, pct_dir));
|
||||
|
||||
uint32 pct_dot = m_caster->CalculateSpellDamage(unitTarget, m_spellInfo, (effIndex + 2)) / 3;
|
||||
m_spellValue->EffectBasePoints[1] = SpellMgr::CalculateSpellEffectBaseAmount(pdamage * baseTotalTicks * pct_dot / 100, m_spellInfo, 1);
|
||||
m_spellValue->EffectBasePoints[1] = SpellMgr::CalculateSpellEffectBaseAmount(int32(CalculatePctU(pdamage * baseTotalTicks, pct_dot)), m_spellInfo, 1);
|
||||
|
||||
apply_direct_bonus = false;
|
||||
// Glyph of Conflagrate
|
||||
@@ -542,10 +542,8 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex)
|
||||
else if (m_spellInfo->SpellFamilyFlags[1] & 0x400000)
|
||||
{
|
||||
if (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->isPet())
|
||||
{
|
||||
// Get DoTs on target by owner (5% increase by dot)
|
||||
damage += 5 * unitTarget->GetDoTsByCaster(m_caster->GetOwnerGUID()) / 100;
|
||||
}
|
||||
damage += int32(CalculatePctN(unitTarget->GetDoTsByCaster(m_caster->GetOwnerGUID()), 5));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -557,7 +555,7 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex)
|
||||
int32 back_damage = m_caster->SpellDamageBonus(unitTarget, m_spellInfo, (uint32)damage, SPELL_DIRECT_DAMAGE);
|
||||
// Pain and Suffering reduces damage
|
||||
if (AuraEffect * aurEff = m_caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, 2874, 0))
|
||||
back_damage -= aurEff->GetAmount() * back_damage / 100;
|
||||
AddPctN(back_damage, -aurEff->GetAmount());
|
||||
|
||||
if (back_damage < int32(unitTarget->GetHealth()))
|
||||
m_caster->CastCustomSpell(m_caster, 32409, &back_damage, 0, 0, true);
|
||||
@@ -579,7 +577,7 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex)
|
||||
// Glyph of Smite
|
||||
if (AuraEffect * aurEff = m_caster->GetAuraEffect(55692, 0))
|
||||
if (unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, 0x100000, 0, 0, m_caster->GetGUID()))
|
||||
damage += damage * aurEff->GetAmount() / 100;
|
||||
AddPctN(damage, aurEff->GetAmount());
|
||||
}
|
||||
// Improved Mind Blast (Mind Blast in shadow form bonus)
|
||||
else if (m_caster->GetShapeshiftForm() == FORM_SHADOW && (m_spellInfo->SpellFamilyFlags[0] & 0x00002000))
|
||||
@@ -610,7 +608,7 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex)
|
||||
float multiple = ap / 410 + m_spellInfo->EffectDamageMultiplier[effIndex];
|
||||
int32 energy = -(m_caster->ModifyPower(POWER_ENERGY, -30));
|
||||
damage += int32(energy * multiple);
|
||||
damage += int32(m_caster->ToPlayer()->GetComboPoints() * ap * 7 / 100);
|
||||
damage += int32(CalculatePctN(m_caster->ToPlayer()->GetComboPoints() * ap, 7));
|
||||
}
|
||||
// Wrath
|
||||
else if (m_spellInfo->SpellFamilyFlags[0] & 0x00000001)
|
||||
@@ -618,7 +616,7 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex)
|
||||
// Improved Insect Swarm
|
||||
if (AuraEffect const * aurEff = m_caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 1771, 0))
|
||||
if (unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, 0x00200000, 0, 0))
|
||||
damage = int32(damage*(100.0f+aurEff->GetAmount())/100.0f);
|
||||
AddPctN(damage, aurEff->GetAmount());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -739,7 +737,7 @@ void Spell::SpellDamageSchoolDmg(SpellEffIndex effIndex)
|
||||
// Shield of Righteousness
|
||||
if (m_spellInfo->SpellFamilyFlags[EFFECT_1] & 0x100000)
|
||||
{
|
||||
damage += m_caster->GetShieldBlockValue() * SpellMgr::CalculateSpellEffectAmount(m_spellInfo, EFFECT_1) / 100;
|
||||
damage += CalculatePctN(m_caster->GetShieldBlockValue(), SpellMgr::CalculateSpellEffectAmount(m_spellInfo, EFFECT_1));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -1255,7 +1253,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
|
||||
// Concussion Blow
|
||||
if (m_spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_WARRIOR_CONCUSSION_BLOW)
|
||||
{
|
||||
m_damage+= uint32(damage * m_caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100);
|
||||
m_damage += CalculatePctF(damage, m_caster->GetTotalAttackPowerValue(BASE_ATTACK));
|
||||
return;
|
||||
}
|
||||
switch(m_spellInfo->Id)
|
||||
@@ -1289,7 +1287,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
|
||||
|
||||
// Improved Life Tap mod
|
||||
if (AuraEffect const * aurEff = m_caster->GetDummyAuraEffect(SPELLFAMILY_WARLOCK, 208, 0))
|
||||
mana = (aurEff->GetAmount() + 100)* mana / 100;
|
||||
AddPctN(mana, aurEff->GetAmount());
|
||||
|
||||
m_caster->CastCustomSpell(unitTarget, 31818, &mana, NULL, NULL, true);
|
||||
|
||||
@@ -1300,7 +1298,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
|
||||
|
||||
if (manaFeedVal > 0)
|
||||
{
|
||||
manaFeedVal = manaFeedVal * mana / 100;
|
||||
ApplyPctN(manaFeedVal, mana);
|
||||
m_caster->CastCustomSpell(m_caster, 32553, &manaFeedVal, NULL, NULL, true, NULL);
|
||||
}
|
||||
}
|
||||
@@ -1333,7 +1331,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
|
||||
// Divine Storm
|
||||
if (m_spellInfo->SpellFamilyFlags[1] & SPELLFAMILYFLAG1_PALADIN_DIVINESTORM && effIndex == 1)
|
||||
{
|
||||
int32 dmg = m_damage * damage / 100;
|
||||
int32 dmg = CalculatePctN(m_damage, damage);
|
||||
if (!unitTarget)
|
||||
unitTarget = m_caster;
|
||||
m_caster->CastCustomSpell(unitTarget, 54171, &dmg, 0, 0, true);
|
||||
@@ -1383,7 +1381,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
|
||||
// Restorative Totems
|
||||
if (Unit *owner = m_caster->GetOwner())
|
||||
if (AuraEffect *dummy = owner->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, 338, 1))
|
||||
damage += damage * dummy->GetAmount() / 100;
|
||||
AddPctN(damage, dummy->GetAmount());
|
||||
|
||||
m_caster->CastCustomSpell(unitTarget, 52042, &damage, 0, 0, true, 0, 0, m_originalCasterGUID);
|
||||
return;
|
||||
@@ -1406,7 +1404,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
|
||||
{
|
||||
// Damage is increased by 25% if your off-hand weapon is enchanted with Flametongue.
|
||||
if (m_caster->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, 0x200000, 0, 0))
|
||||
m_damage += m_damage * damage / 100;
|
||||
AddPctN(m_damage, damage);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1419,7 +1417,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
|
||||
int32 bp = int32(count * m_caster->CountPctFromMaxHealth(int32(m_spellInfo->EffectDamageMultiplier[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);
|
||||
AddPctN(bp, m_caster->CalculateSpellDamage(m_caster, aurEff->GetSpellProto(), 2));
|
||||
m_caster->CastCustomSpell(m_caster, 45470, &bp, NULL, NULL, false);
|
||||
return;
|
||||
}
|
||||
@@ -2115,8 +2113,8 @@ void Spell::EffectPowerBurn(SpellEffIndex effIndex)
|
||||
// burn x% of target's mana, up to maximum of 2x% of caster's mana (Mana Burn)
|
||||
if (m_spellInfo->ManaCostPercentage)
|
||||
{
|
||||
int32 maxDamage = m_caster->GetMaxPower(powerType) * damage * 2 / 100;
|
||||
damage = unitTarget->GetMaxPower(powerType) * damage / 100;
|
||||
int32 maxDamage = int32(CalculatePctN(m_caster->GetMaxPower(powerType), damage * 2));
|
||||
damage = int32(CalculatePctN(unitTarget->GetMaxPower(powerType), damage));
|
||||
damage = std::min(damage, maxDamage);
|
||||
}
|
||||
|
||||
@@ -2224,7 +2222,7 @@ void Spell::SpellDamageHeal(SpellEffIndex /*effIndex*/)
|
||||
for (Unit::AuraEffectList::const_iterator i = Periodic.begin(); i != Periodic.end(); ++i)
|
||||
{
|
||||
if (m_caster->GetGUID() == (*i)->GetCasterGUID())
|
||||
addhealth += addhealth * aurEff->GetAmount() / 100;
|
||||
AddPctN(addhealth, aurEff->GetAmount());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2530,10 +2528,10 @@ void Spell::EffectEnergize(SpellEffIndex effIndex)
|
||||
case 31930: // Judgements of the Wise
|
||||
case 63375: // Improved Stormstrike
|
||||
case 68082: // Glyph of Seal of Command
|
||||
damage = damage * unitTarget->GetCreateMana() / 100;
|
||||
damage = int32(CalculatePctN(unitTarget->GetCreateMana(), damage));
|
||||
break;
|
||||
case 48542: // Revitalize
|
||||
damage = damage * unitTarget->GetMaxPower(power) / 100;
|
||||
damage = int32(CalculatePctN(unitTarget->GetMaxPower(power), damage));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -2616,7 +2614,7 @@ void Spell::EffectEnergizePct(SpellEffIndex effIndex)
|
||||
if (maxPower == 0)
|
||||
return;
|
||||
|
||||
uint32 gain = damage * maxPower / 100;
|
||||
uint32 gain = CalculatePctN(maxPower, damage);
|
||||
m_caster->EnergizeBySpell(unitTarget, m_spellInfo->Id, gain, power);
|
||||
}
|
||||
|
||||
@@ -3350,7 +3348,7 @@ void Spell::EffectAddHonor(SpellEffIndex /*effIndex*/)
|
||||
// do not allow to add too many honor for player (50 * 21) = 1040 at level 70, or (50 * 31) = 1550 at level 80
|
||||
if (damage <= 50)
|
||||
{
|
||||
uint32 honor_reward = Trinity::Honor::hk_honor_at_level(unitTarget->getLevel(), damage);
|
||||
uint32 honor_reward = Trinity::Honor::hk_honor_at_level(unitTarget->getLevel(), float(damage));
|
||||
unitTarget->ToPlayer()->RewardHonor(NULL, 1, honor_reward);
|
||||
sLog.outDebug("SpellEffect::AddHonor (spell_id %u) rewards %u honor points (scale) to player: %u", m_spellInfo->Id, honor_reward, unitTarget->ToPlayer()->GetGUIDLow());
|
||||
}
|
||||
@@ -3938,14 +3936,14 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
|
||||
// Seal of Command - Increase damage by 36% on every swing
|
||||
if (m_spellInfo->SpellFamilyFlags[0] & 0x2000000)
|
||||
{
|
||||
totalDamagePercentMod *= 1.36f; //136% damage
|
||||
totalDamagePercentMod *= 1.36f; // 136% damage
|
||||
}
|
||||
|
||||
// Seal of Command Unleashed
|
||||
else if (m_spellInfo->Id == 20467)
|
||||
{
|
||||
spell_bonus += int32(0.08f*m_caster->GetTotalAttackPowerValue(BASE_ATTACK));
|
||||
spell_bonus += int32(0.13f*m_caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellInfo)));
|
||||
spell_bonus += int32(0.08f * m_caster->GetTotalAttackPowerValue(BASE_ATTACK));
|
||||
spell_bonus += int32(0.13f * m_caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellInfo)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -3963,15 +3961,13 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
|
||||
if (m_spellInfo->SpellFamilyFlags[1] & 0x400)
|
||||
{
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
m_caster->ToPlayer()->AddComboPoints(unitTarget,1, this);
|
||||
m_caster->ToPlayer()->AddComboPoints(unitTarget, 1, this);
|
||||
}
|
||||
// Shred, Maul - Rend and Tear
|
||||
else if (m_spellInfo->SpellFamilyFlags[0] & 0x00008800 && unitTarget->HasAuraState(AURA_STATE_BLEEDING))
|
||||
{
|
||||
if (AuraEffect const* rendAndTear = m_caster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 2859, 0))
|
||||
{
|
||||
totalDamagePercentMod *= float((rendAndTear->GetAmount() + 100.0f) / 100.0f);
|
||||
}
|
||||
AddPctN(totalDamagePercentMod, rendAndTear->GetAmount());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -3979,7 +3975,7 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
|
||||
{
|
||||
// Kill Shot - bonus damage from Ranged Attack Power
|
||||
if (m_spellInfo->SpellFamilyFlags[1] & 0x800000)
|
||||
spell_bonus += int32(0.4f*m_caster->GetTotalAttackPowerValue(RANGED_ATTACK));
|
||||
spell_bonus += int32(0.4f * m_caster->GetTotalAttackPowerValue(RANGED_ATTACK));
|
||||
break;
|
||||
}
|
||||
case SPELLFAMILY_DEATHKNIGHT:
|
||||
@@ -3989,18 +3985,18 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
|
||||
{
|
||||
// Glyph of Plague Strike
|
||||
if (AuraEffect const * aurEff = m_caster->GetAuraEffect(58657, EFFECT_0))
|
||||
totalDamagePercentMod *= (aurEff->GetAmount() + 100.0f) / 100.0f;
|
||||
AddPctN(totalDamagePercentMod, aurEff->GetAmount());
|
||||
break;
|
||||
}
|
||||
// Blood Strike
|
||||
if (m_spellInfo->SpellFamilyFlags[EFFECT_0] & 0x400000)
|
||||
{
|
||||
totalDamagePercentMod *= ((SpellMgr::CalculateSpellEffectAmount(m_spellInfo, EFFECT_2) * unitTarget->GetDiseasesByCaster(m_caster->GetGUID()) / 2.0f) + 100.0f) / 100.0f;
|
||||
AddPctF(totalDamagePercentMod, SpellMgr::CalculateSpellEffectAmount(m_spellInfo, EFFECT_2) * unitTarget->GetDiseasesByCaster(m_caster->GetGUID()) / 2.0f);
|
||||
|
||||
// Glyph of Blood Strike
|
||||
if (m_caster->GetAuraEffect(59332, EFFECT_0))
|
||||
if (unitTarget->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED))
|
||||
totalDamagePercentMod *= (20 + 100.0f) / 100.0f;
|
||||
AddPctN(totalDamagePercentMod, 20);
|
||||
break;
|
||||
}
|
||||
// Death Strike
|
||||
@@ -4009,7 +4005,7 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
|
||||
// Glyph of Death Strike
|
||||
if (AuraEffect const * aurEff = m_caster->GetAuraEffect(59336, EFFECT_0))
|
||||
if (uint32 runic = std::min<uint32>(m_caster->GetPower(POWER_RUNIC_POWER), SpellMgr::CalculateSpellEffectAmount(aurEff->GetSpellProto(), EFFECT_1)))
|
||||
totalDamagePercentMod *= (runic + 100.0f) / 100.0f;
|
||||
AddPctN(totalDamagePercentMod, runic);
|
||||
break;
|
||||
}
|
||||
// Obliterate (12.5% more damage per disease)
|
||||
@@ -4022,19 +4018,19 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
|
||||
if (roll_chance_i(aurEff->GetAmount()))
|
||||
consumeDiseases = false;
|
||||
|
||||
totalDamagePercentMod *= ((SpellMgr::CalculateSpellEffectAmount(m_spellInfo, EFFECT_2) * unitTarget->GetDiseasesByCaster(m_caster->GetGUID(), consumeDiseases) / 2.0f) + 100.0f) / 100.0f;
|
||||
AddPctF(totalDamagePercentMod, SpellMgr::CalculateSpellEffectAmount(m_spellInfo, EFFECT_2) * unitTarget->GetDiseasesByCaster(m_caster->GetGUID(), consumeDiseases) / 2.0f);
|
||||
break;
|
||||
}
|
||||
// Blood-Caked Strike - Blood-Caked Blade
|
||||
if (m_spellInfo->SpellIconID == 1736)
|
||||
{
|
||||
totalDamagePercentMod *= ((unitTarget->GetDiseasesByCaster(m_caster->GetGUID()) * 12.5f) + 100.0f) / 100.0f;
|
||||
AddPctF(totalDamagePercentMod, unitTarget->GetDiseasesByCaster(m_caster->GetGUID()) * 12.5f);
|
||||
break;
|
||||
}
|
||||
// Heart Strike
|
||||
if (m_spellInfo->SpellFamilyFlags[EFFECT_0] & 0x1000000)
|
||||
{
|
||||
totalDamagePercentMod *= ((SpellMgr::CalculateSpellEffectAmount(m_spellInfo, EFFECT_2) * unitTarget->GetDiseasesByCaster(m_caster->GetGUID())) + 100.0f) / 100.0f;
|
||||
AddPctN(totalDamagePercentMod, SpellMgr::CalculateSpellEffectAmount(m_spellInfo, EFFECT_2) * unitTarget->GetDiseasesByCaster(m_caster->GetGUID()));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -4042,10 +4038,10 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
|
||||
}
|
||||
|
||||
bool normalized = false;
|
||||
float weaponDamagePercentMod = 1.0;
|
||||
float weaponDamagePercentMod = 1.0f;
|
||||
for (int j = 0; j < MAX_SPELL_EFFECTS; ++j)
|
||||
{
|
||||
switch(m_spellInfo->Effect[j])
|
||||
switch (m_spellInfo->Effect[j])
|
||||
{
|
||||
case SPELL_EFFECT_WEAPON_DAMAGE:
|
||||
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
|
||||
@@ -4056,7 +4052,7 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
|
||||
normalized = true;
|
||||
break;
|
||||
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
|
||||
weaponDamagePercentMod *= float(CalculateDamage(j,unitTarget)) / 100.0f;
|
||||
ApplyPctN(weaponDamagePercentMod, CalculateDamage(j, unitTarget));
|
||||
break;
|
||||
default:
|
||||
break; // not weapon damage effect, just skip
|
||||
@@ -4067,7 +4063,7 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
|
||||
if (fixed_bonus || spell_bonus)
|
||||
{
|
||||
UnitMods unitMod;
|
||||
switch(m_attackType)
|
||||
switch (m_attackType)
|
||||
{
|
||||
default:
|
||||
case BASE_ATTACK: unitMod = UNIT_MOD_DAMAGE_MAINHAND; break;
|
||||
@@ -4113,11 +4109,11 @@ void Spell::SpellDamageWeaponDmg(SpellEffIndex effIndex)
|
||||
weaponDamage = int32(weaponDamage * totalDamagePercentMod);
|
||||
|
||||
// prevent negative damage
|
||||
uint32 eff_damage = uint32(weaponDamage > 0 ? weaponDamage : 0);
|
||||
uint32 eff_damage(std::max(weaponDamage, 0));
|
||||
|
||||
// Add melee damage bonuses (also check for negative)
|
||||
m_caster->MeleeDamageBonus(unitTarget, &eff_damage, m_attackType, m_spellInfo);
|
||||
m_damage+= eff_damage;
|
||||
m_damage += eff_damage;
|
||||
}
|
||||
|
||||
void Spell::EffectThreat(SpellEffIndex /*effIndex*/)
|
||||
@@ -4154,7 +4150,7 @@ void Spell::EffectHealMaxHealth(SpellEffIndex /*effIndex*/)
|
||||
addhealth = unitTarget->GetMaxHealth() - unitTarget->GetHealth();
|
||||
|
||||
if (m_originalCaster)
|
||||
m_healing += m_originalCaster->SpellHealingBonus(unitTarget,m_spellInfo, addhealth, HEAL);
|
||||
m_healing += m_originalCaster->SpellHealingBonus(unitTarget, m_spellInfo, addhealth, HEAL);
|
||||
}
|
||||
|
||||
void Spell::EffectInterruptCast(SpellEffIndex effIndex)
|
||||
@@ -5811,7 +5807,7 @@ void Spell::EffectResurrect(SpellEffIndex effIndex)
|
||||
return;
|
||||
|
||||
uint32 health = pTarget->CountPctFromMaxHealth(damage);
|
||||
uint32 mana = pTarget->GetMaxPower(POWER_MANA) * damage / 100;
|
||||
uint32 mana = CalculatePctN(pTarget->GetMaxPower(POWER_MANA), damage);
|
||||
|
||||
ExecuteLogEffectResurrect(effIndex, pTarget);
|
||||
|
||||
@@ -5931,7 +5927,7 @@ void Spell::EffectSelfResurrect(SpellEffIndex effIndex)
|
||||
{
|
||||
health = unitTarget->CountPctFromMaxHealth(damage);
|
||||
if (unitTarget->GetMaxPower(POWER_MANA) > 0)
|
||||
mana = uint32(damage/100.0f*unitTarget->GetMaxPower(POWER_MANA));
|
||||
mana = CalculatePctN(unitTarget->GetMaxPower(POWER_MANA), damage);
|
||||
}
|
||||
|
||||
Player *plr = unitTarget->ToPlayer();
|
||||
@@ -6206,13 +6202,12 @@ void Spell::EffectDestroyAllTotems(SpellEffIndex /*effIndex*/)
|
||||
if (spellInfo)
|
||||
{
|
||||
mana += spellInfo->manaCost;
|
||||
mana += spellInfo->ManaCostPercentage * m_caster->GetCreateMana() / 100;
|
||||
mana += int32(CalculatePctU(m_caster->GetCreateMana(), spellInfo->ManaCostPercentage));
|
||||
}
|
||||
totem->ToTotem()->UnSummon();
|
||||
}
|
||||
}
|
||||
mana = mana * damage / 100;
|
||||
|
||||
ApplyPctN(mana, damage);
|
||||
if (mana)
|
||||
m_caster->CastCustomSpell(m_caster, 39104, &mana, NULL, NULL, true);
|
||||
}
|
||||
@@ -6253,7 +6248,7 @@ void Spell::EffectDurabilityDamagePCT(SpellEffIndex effIndex)
|
||||
// Possibly its mean -1 all player equipped items and -2 all items
|
||||
if (slot < 0)
|
||||
{
|
||||
unitTarget->ToPlayer()->DurabilityLossAll(double(damage)/100.0f, (slot < -1));
|
||||
unitTarget->ToPlayer()->DurabilityLossAll(float(damage) / 100.0f, (slot < -1));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6265,7 +6260,7 @@ void Spell::EffectDurabilityDamagePCT(SpellEffIndex effIndex)
|
||||
return;
|
||||
|
||||
if (Item* item = unitTarget->ToPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
|
||||
unitTarget->ToPlayer()->DurabilityLoss(item, double(damage)/100.0f);
|
||||
unitTarget->ToPlayer()->DurabilityLoss(item, float(damage) / 100.0f);
|
||||
}
|
||||
|
||||
void Spell::EffectModifyThreatPercent(SpellEffIndex /*effIndex*/)
|
||||
|
||||
@@ -392,16 +392,16 @@ uint32 CalculatePowerCost(SpellEntry const * spellInfo, Unit const * caster, Spe
|
||||
{
|
||||
// health as power used
|
||||
case POWER_HEALTH:
|
||||
powerCost += spellInfo->ManaCostPercentage * caster->GetCreateHealth() / 100;
|
||||
powerCost += int32(CalculatePctU(caster->GetCreateHealth(), spellInfo->ManaCostPercentage));
|
||||
break;
|
||||
case POWER_MANA:
|
||||
powerCost += spellInfo->ManaCostPercentage * caster->GetCreateMana() / 100;
|
||||
powerCost += int32(CalculatePctU(caster->GetCreateMana(), spellInfo->ManaCostPercentage));
|
||||
break;
|
||||
case POWER_RAGE:
|
||||
case POWER_FOCUS:
|
||||
case POWER_ENERGY:
|
||||
case POWER_HAPPINESS:
|
||||
powerCost += spellInfo->ManaCostPercentage * caster->GetMaxPower(Powers(spellInfo->powerType)) / 100;
|
||||
powerCost += int32(CalculatePctU(caster->GetMaxPower(Powers(spellInfo->powerType)), spellInfo->ManaCostPercentage));
|
||||
break;
|
||||
case POWER_RUNE:
|
||||
case POWER_RUNIC_POWER:
|
||||
@@ -1862,7 +1862,7 @@ int32 SpellMgr::CalculateSpellEffectAmount(SpellEntry const * spellEntry, uint8
|
||||
break;
|
||||
}
|
||||
|
||||
int32 value = basePoints;
|
||||
float value = float(basePoints);
|
||||
|
||||
// random damage
|
||||
if (caster)
|
||||
@@ -1871,7 +1871,7 @@ int32 SpellMgr::CalculateSpellEffectAmount(SpellEntry const * spellEntry, uint8
|
||||
if (caster->m_movedPlayer)
|
||||
if (uint8 comboPoints = caster->m_movedPlayer->GetComboPoints())
|
||||
if (float comboDamage = spellEntry->EffectPointsPerComboPoint[effIndex])
|
||||
value += int32(comboDamage * comboPoints);
|
||||
value += comboDamage * comboPoints;
|
||||
|
||||
value = caster->ApplyEffectModifiers(spellEntry, effIndex, value);
|
||||
|
||||
@@ -1884,11 +1884,11 @@ int32 SpellMgr::CalculateSpellEffectAmount(SpellEntry const * spellEntry, uint8
|
||||
spellEntry->EffectApplyAuraName[effIndex] != SPELL_AURA_MOD_INCREASE_SPEED &&
|
||||
spellEntry->EffectApplyAuraName[effIndex] != SPELL_AURA_MOD_DECREASE_SPEED)
|
||||
//there are many more: slow speed, -healing pct
|
||||
value = int32(value*0.25f*exp(caster->getLevel()*(70-spellEntry->spellLevel)/1000.0f));
|
||||
value *= 0.25f * exp(caster->getLevel() * (70 - spellEntry->spellLevel) / 1000.0f);
|
||||
//value = int32(value * (int32)getLevel() / (int32)(spellProto->spellLevel ? spellProto->spellLevel : 1));
|
||||
}
|
||||
|
||||
return value;
|
||||
return int32(value);
|
||||
}
|
||||
|
||||
int32 SpellMgr::CalculateSpellEffectBaseAmount(int32 value, SpellEntry const * spellEntry, uint8 effIndex)
|
||||
|
||||
@@ -140,7 +140,7 @@ public:
|
||||
Unit* caster = GetCaster();
|
||||
if (Unit* unitTarget = GetHitUnit())
|
||||
{
|
||||
int32 bp = (GetHitDamage() * GetEffectValue() * unitTarget->GetDiseasesByCaster(caster->GetGUID())) / 100;
|
||||
int32 bp = CalculatePctN(GetHitDamage(), GetEffectValue() * unitTarget->GetDiseasesByCaster(caster->GetGUID()));
|
||||
caster->CastCustomSpell(unitTarget, DK_SPELL_SCOURGE_STRIKE_TRIGGERED, &bp, NULL, NULL, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
int32 TickCount = aurEff->GetTotalTicks();
|
||||
spellId = HUNTER_SPELL_CHIMERA_SHOT_SERPENT;
|
||||
basePoint = caster->SpellDamageBonus(unitTarget, aura->GetSpellProto(), aurEff->GetAmount(), DOT, aura->GetStackAmount());
|
||||
basePoint = basePoint * TickCount * 40 / 100;
|
||||
ApplyPctN(basePoint, TickCount * 40);
|
||||
}
|
||||
// Viper Sting - Instantly restores mana to you equal to 60% of the total amount drained by your Viper Sting.
|
||||
else if (familyFlag[1] & 0x00000080)
|
||||
@@ -97,11 +97,11 @@ public:
|
||||
spellId = HUNTER_SPELL_CHIMERA_SHOT_VIPER;
|
||||
|
||||
// Amount of one aura tick
|
||||
basePoint = aurEff->GetAmount() * unitTarget->GetMaxPower(POWER_MANA) / 100 ;
|
||||
int32 casterBasePoint = aurEff->GetAmount() * unitTarget->GetMaxPower(POWER_MANA) / 50 ;
|
||||
basePoint = int32(CalculatePctN(unitTarget->GetMaxPower(POWER_MANA), aurEff->GetAmount()));
|
||||
int32 casterBasePoint = aurEff->GetAmount() * unitTarget->GetMaxPower(POWER_MANA) / 50; // TODO: WTF? caster uses unitTarget?
|
||||
if (basePoint > casterBasePoint)
|
||||
basePoint = casterBasePoint;
|
||||
basePoint = basePoint * TickCount * 60 / 100;
|
||||
ApplyPctN(basePoint, TickCount * 60);
|
||||
}
|
||||
// Scorpid Sting - Attempts to Disarm the target for 10 sec. This effect cannot occur more than once per 1 minute.
|
||||
else if (familyFlag[0] & 0x00008000)
|
||||
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
if (AuraEffect *dummy = owner->GetAuraEffect(SHAMAN_SPELL_GLYPH_OF_MANA_TIDE, 0))
|
||||
effValue += dummy->GetAmount();
|
||||
// Regenerate 6% of Total Mana Every 3 secs
|
||||
int32 effBasePoints0 = unitTarget->GetMaxPower(POWER_MANA) * effValue / 100;
|
||||
int32 effBasePoints0 = int32(CalculatePctN(unitTarget->GetMaxPower(POWER_MANA), effValue));
|
||||
caster->CastCustomSpell(unitTarget, SHAMAN_SPELL_MANA_TIDE_TOTEM, &effBasePoints0, NULL, NULL, true, NULL, NULL, GetOriginalCaster()->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ inline void ApplyModUInt32Var(uint32& var, int32 val, bool apply)
|
||||
{
|
||||
int32 cur = var;
|
||||
cur += (apply ? val : -val);
|
||||
if(cur < 0)
|
||||
if (cur < 0)
|
||||
cur = 0;
|
||||
var = cur;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ inline void ApplyModUInt32Var(uint32& var, int32 val, bool apply)
|
||||
inline void ApplyModFloatVar(float& var, float val, bool apply)
|
||||
{
|
||||
var += (apply ? val : -val);
|
||||
if(var < 0)
|
||||
if (var < 0)
|
||||
var = 0;
|
||||
}
|
||||
|
||||
@@ -96,9 +96,65 @@ inline void ApplyPercentModFloatVar(float& var, float val, bool apply)
|
||||
{
|
||||
if (val == -100.0f) // prevent set var to zero
|
||||
val = -99.99f;
|
||||
var *= (apply?(100.0f+val)/100.0f : 100.0f / (100.0f+val));
|
||||
var *= (apply ? (100.0f + val) / 100.0f : 100.0f / (100.0f + val));
|
||||
}
|
||||
|
||||
// Percentage calculation
|
||||
template <class T>
|
||||
inline T CalculatePctF(T base, float pct)
|
||||
{
|
||||
return T(base * pct / 100.0f);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T CalculatePctN(T base, int32 pct)
|
||||
{
|
||||
return T(base * float(pct) / 100.0f);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T CalculatePctU(T base, uint32 pct)
|
||||
{
|
||||
return T(base * float(pct) / 100.0f);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T AddPctF(T& base, float pct)
|
||||
{
|
||||
return base += CalculatePctF(base, pct);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T AddPctN(T& base, int32 pct)
|
||||
{
|
||||
return base += CalculatePctN(base, pct);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T AddPctU(T& base, uint32 pct)
|
||||
{
|
||||
return base += CalculatePctU(base, pct);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T ApplyPctF(T& base, float pct)
|
||||
{
|
||||
return base = CalculatePctF(base, pct);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T ApplyPctN(T& base, int32 pct)
|
||||
{
|
||||
return base = CalculatePctN(base, pct);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T ApplyPctU(T& base, uint32 pct)
|
||||
{
|
||||
return base = CalculatePctU(base, pct);
|
||||
}
|
||||
|
||||
// UTF8 handling
|
||||
bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr);
|
||||
// in wsize==max size of buffer, out wsize==real string size
|
||||
bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize);
|
||||
|
||||
Reference in New Issue
Block a user