diff --git a/sql/base/characters_database.sql b/sql/base/characters_database.sql index 9c127807f8..97f3e5662b 100644 --- a/sql/base/characters_database.sql +++ b/sql/base/characters_database.sql @@ -547,8 +547,8 @@ CREATE TABLE `character_aura_effect` ( `spell` int unsigned NOT NULL, `effectMask` int unsigned NOT NULL, `effectIndex` tinyint unsigned NOT NULL, - `amount` int NOT NULL DEFAULT '0', - `baseAmount` int NOT NULL DEFAULT '0', + `amount` double NOT NULL DEFAULT '0', + `baseAmount` double NOT NULL DEFAULT '0', PRIMARY KEY (`guid`,`casterGuid`,`itemGuid`,`spell`,`effectMask`,`effectIndex`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Player System'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -3392,8 +3392,8 @@ CREATE TABLE `pet_aura_effect` ( `spell` int unsigned NOT NULL, `effectMask` int unsigned NOT NULL, `effectIndex` tinyint unsigned NOT NULL, - `amount` int NOT NULL DEFAULT '0', - `baseAmount` int NOT NULL DEFAULT '0', + `amount` double NOT NULL DEFAULT '0', + `baseAmount` double NOT NULL DEFAULT '0', PRIMARY KEY (`guid`,`casterGuid`,`spell`,`effectMask`,`effectIndex`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Pet System'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -3918,7 +3918,8 @@ INSERT INTO `updates` VALUES ('2026_01_14_00_characters.sql','FF5D889A41BBD9F9827489DEC08BCA9DB457933E','ARCHIVED','2026-01-14 23:40:33',0), ('2026_01_28_00_characters.sql','807B6622970E81089806C3B45C6C7A32EF531BCA','ARCHIVED','2026-01-25 21:53:51',0), ('2026_02_06_00_characters.sql','90735F4481A137E79B8371F291008CF6051657AC','ARCHIVED','2026-02-06 12:45:48',0), -('2026_03_21_00_characters.sql','87963F4E341B195D4B4C4514A3119092DF127431','RELEASED','2026-03-21 00:42:13',0); +('2026_03_21_00_characters.sql','87963F4E341B195D4B4C4514A3119092DF127431','RELEASED','2026-03-21 00:42:13',0), +('2026_04_08_00_characters.sql','5A7FC8264EBD524E4EBAACF53D1CE89C6FF0D255','RELEASED','2026-04-07 10:24:16',0); /*!40000 ALTER TABLE `updates` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/updates/characters/master/2026_04_08_00_characters.sql b/sql/updates/characters/master/2026_04_08_00_characters.sql new file mode 100644 index 0000000000..42354b9731 --- /dev/null +++ b/sql/updates/characters/master/2026_04_08_00_characters.sql @@ -0,0 +1,7 @@ +ALTER TABLE `character_aura_effect` + MODIFY `amount` double NOT NULL DEFAULT 0 AFTER `effectIndex`, + MODIFY `baseAmount` double NOT NULL DEFAULT 0 AFTER `amount`; + +ALTER TABLE `pet_aura_effect` + MODIFY `amount` double NOT NULL DEFAULT 0 AFTER `effectIndex`, + MODIFY `baseAmount` double NOT NULL DEFAULT 0 AFTER `amount`; diff --git a/sql/updates/world/master/2026_04_08_00_world.sql b/sql/updates/world/master/2026_04_08_00_world.sql new file mode 100644 index 0000000000..df1c465046 --- /dev/null +++ b/sql/updates/world/master/2026_04_08_00_world.sql @@ -0,0 +1,11 @@ +UPDATE `trinity_string` SET + `content_default`=REPLACE(`content_default`,'%i','%.2f'), + `content_loc1`=REPLACE(`content_loc1`,'%i','%.2f'), + `content_loc2`=REPLACE(`content_loc2`,'%i','%.2f'), + `content_loc3`=REPLACE(`content_loc3`,'%i','%.2f'), + `content_loc4`=REPLACE(`content_loc4`,'%i','%.2f'), + `content_loc5`=REPLACE(`content_loc5`,'%i','%.2f'), + `content_loc6`=REPLACE(`content_loc6`,'%i','%.2f'), + `content_loc7`=REPLACE(`content_loc7`,'%i','%.2f'), + `content_loc8`=REPLACE(`content_loc8`,'%i','%.2f') + WHERE `entry`=470; diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp index 6ac504e456..7a4f50d89b 100644 --- a/src/server/game/Combat/ThreatManager.cpp +++ b/src/server/game/Combat/ThreatManager.cpp @@ -776,7 +776,7 @@ void ThreatManager::RemoveMeFromThreatLists(bool (*unitFilter)(Unit const* other void ThreatManager::UpdateMyTempModifiers() { - int32 mod = 0; + SpellEffectValue mod = 0; for (AuraEffect const* eff : _owner->GetAuraEffectsByType(SPELL_AURA_MOD_TOTAL_THREAT)) mod += eff->GetAmount(); @@ -802,7 +802,7 @@ void ThreatManager::UpdateMySpellSchoolModifiers() _multiSchoolModifiers.clear(); } -void ThreatManager::RegisterRedirectThreat(uint32 spellId, ObjectGuid const& victim, uint32 pct) +void ThreatManager::RegisterRedirectThreat(uint32 spellId, ObjectGuid const& victim, float pct) { _redirectRegistry[spellId][victim] = pct; UpdateRedirectInfo(); @@ -927,11 +927,11 @@ void ThreatManager::PurgeThreatenedByMeRef(ObjectGuid const& guid) void ThreatManager::UpdateRedirectInfo() { _redirectInfo.clear(); - uint32 totalPct = 0; + float totalPct = 0; for (auto const& pair : _redirectRegistry) // (spellid, victim -> pct) for (auto const& victimPair : pair.second) // (victim,pct) { - uint32 thisPct = std::min(100 - totalPct, victimPair.second); + float thisPct = std::min(100.0f - totalPct, victimPair.second); if (thisPct > 0) { _redirectInfo.push_back({ victimPair.first, thisPct }); diff --git a/src/server/game/Combat/ThreatManager.h b/src/server/game/Combat/ThreatManager.h index d1ac06d380..4e0b44987f 100644 --- a/src/server/game/Combat/ThreatManager.h +++ b/src/server/game/Combat/ThreatManager.h @@ -143,7 +143,7 @@ class TC_GAME_API ThreatManager void AddThreat(Unit* target, float amount, SpellInfo const* spell = nullptr, bool ignoreModifiers = false, bool ignoreRedirects = false); void ScaleThreat(Unit* target, float factor); // Modify target's threat by +percent% - void ModifyThreatByPercent(Unit* target, int32 percent) { if (percent) ScaleThreat(target, 0.01f*float(100 + percent)); } + void ModifyThreatByPercent(Unit* target, float percent) { if (percent) ScaleThreat(target, 0.01f * (100.0f + percent)); } // Resets the specified unit's threat to zero void ResetThreat(Unit* target) { ScaleThreat(target, 0.0f); } // Sets the specified unit's threat to be equal to the highest entry on the threat list @@ -176,7 +176,7 @@ class TC_GAME_API ThreatManager ///== REDIRECT SYSTEM == // Register a redirection effect that redirects pct% of threat generated by owner to victim - void RegisterRedirectThreat(uint32 spellId, ObjectGuid const& victim, uint32 pct); + void RegisterRedirectThreat(uint32 spellId, ObjectGuid const& victim, float pct); // Unregister a redirection effort for all victims void UnregisterRedirectThreat(uint32 spellId); // Unregister a redirection effect for a specific victim @@ -226,8 +226,8 @@ class TC_GAME_API ThreatManager // redirect system (is kind of dumb, but that's because none of the redirection spells actually have any aura effect associated with them, so spellscript needs to deal with it) void UpdateRedirectInfo(); - std::vector> _redirectInfo; // current redirection targets and percentages (updated from registry in ThreatManager::UpdateRedirectInfo) - std::unordered_map> _redirectRegistry; // spellid -> (victim -> pct); all redirection effects on us (removal individually managed by spell scripts because blizzard is dumb) + std::vector> _redirectInfo; // current redirection targets and percentages (updated from registry in ThreatManager::UpdateRedirectInfo) + std::unordered_map> _redirectRegistry; // spellid -> (victim -> pct); all redirection effects on us (removal individually managed by spell scripts because blizzard is dumb) public: ThreatManager(ThreatManager const&) = delete; @@ -268,7 +268,7 @@ class TC_GAME_API ThreatReference Creature* GetOwner() const { return _owner; } Unit* GetVictim() const { return _victim; } - float GetThreat() const { return std::max(_baseAmount + (float)_tempModifier, 0.0f); } + float GetThreat() const { return std::max(_baseAmount + _tempModifier, 0.0f); } OnlineState GetOnlineState() const { return _online; } bool IsOnline() const { return (_online >= ONLINE_STATE_ONLINE); } bool IsAvailable() const { return (_online > ONLINE_STATE_OFFLINE); } @@ -290,7 +290,7 @@ class TC_GAME_API ThreatReference explicit ThreatReference(ThreatManager* mgr, Unit* victim) : _owner(reinterpret_cast(mgr->_owner)), _mgr(*mgr), _victim(victim), - _baseAmount(0.0f), _tempModifier(0), _taunted(TAUNT_STATE_NONE) + _baseAmount(0.0f), _tempModifier(0.0f), _taunted(TAUNT_STATE_NONE) { _online = ONLINE_STATE_OFFLINE; } @@ -309,7 +309,7 @@ class TC_GAME_API ThreatReference Unit* const _victim; OnlineState _online; float _baseAmount; - int32 _tempModifier; // Temporary effects (auras with SPELL_AURA_MOD_TOTAL_THREAT) - set from victim's threatmanager in ThreatManager::UpdateMyTempModifiers + float _tempModifier; // Temporary effects (auras with SPELL_AURA_MOD_TOTAL_THREAT) - set from victim's threatmanager in ThreatManager::UpdateMyTempModifiers TauntState _taunted; public: diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 7911d88a3c..ff5bcffb71 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -4672,7 +4672,7 @@ SpellInfo const* GameObject::GetSpellForLock(Player const* player) const if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(playerSpell.first, GetMap()->GetDifficultyID())) for (auto&& effect : spell->GetEffects()) if (effect.Effect == SPELL_EFFECT_OPEN_LOCK && effect.MiscValue == lock->Index[i]) - if (effect.CalcValue(player) >= int32(lock->Skill[i])) + if (effect.CalcValueAsInt(player) >= int32(lock->Skill[i])) return spell; } diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 83f8131378..1e667af9a4 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1676,15 +1676,6 @@ Player* WorldObject::GetSpellModOwner() const return nullptr; } -// function uses real base points (typically value - 1) -int32 WorldObject::CalculateSpellDamage(Unit const* target, SpellEffectInfo const& spellEffectInfo, int32 const* basePoints /*= nullptr*/, float* variance /*= nullptr*/, uint32 castItemId /*= 0*/, int32 itemLevel /*= -1*/) const -{ - if (variance) - *variance = 0.0f; - - return spellEffectInfo.CalcValue(this, basePoints, target, variance, castItemId, itemLevel); -} - float WorldObject::GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const { if (!spellInfo->RangeEntry) @@ -1912,7 +1903,7 @@ SpellMissInfo WorldObject::MagicSpellHitResult(Unit* victim, SpellInfo const* sp int32 levelBasedHitDiff = leveldif; // Base hit chance from attacker and victim levels - int32 modHitChance = 100; + float modHitChance = 100; if (levelBasedHitDiff >= 0) { if (victim->GetTypeId() != TYPEID_PLAYER) @@ -1959,7 +1950,7 @@ SpellMissInfo WorldObject::MagicSpellHitResult(Unit* victim, SpellInfo const* sp return SPELL_MISS_MISS; // Chance resist mechanic (select max value from every mechanic spell effect) - int32 resist_chance = victim->GetMechanicResistChance(spellInfo) * 100; + int32 resist_chance = victim->GetMechanicResistChance(spellInfo) * 100.0f; // Roll chance if (resist_chance > 0 && rand < (tmp += resist_chance)) @@ -1968,7 +1959,7 @@ SpellMissInfo WorldObject::MagicSpellHitResult(Unit* victim, SpellInfo const* sp // cast by caster in front of victim if (!victim->HasUnitState(UNIT_STATE_CONTROLLED) && (victim->HasInArc(float(M_PI), this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))) { - int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100; + int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100.0f; if (deflect_chance > 0 && rand < (tmp += deflect_chance)) return SPELL_MISS_DEFLECT; } @@ -2010,10 +2001,10 @@ SpellMissInfo WorldObject::SpellHitResult(Unit* victim, SpellInfo const* spellIn // Try victim reflect spell if (canReflect) { - int32 reflectchance = victim->GetTotalAuraModifier(SPELL_AURA_REFLECT_SPELLS); + float reflectchance = victim->GetTotalAuraModifier(SPELL_AURA_REFLECT_SPELLS); reflectchance += victim->GetTotalAuraModifierByMiscMask(SPELL_AURA_REFLECT_SPELLS_SCHOOL, spellInfo->GetSchoolMask()); - if (reflectchance > 0 && roll_chance_i(reflectchance)) + if (reflectchance > 0 && roll_chance_f(reflectchance)) return spellInfo->HasAttribute(SPELL_ATTR7_REFLECTION_ONLY_DEFENDS) ? SPELL_MISS_DEFLECT : SPELL_MISS_REFLECT; } diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index af70caa042..af641e62ac 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -447,7 +447,6 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation Player* GetAffectingPlayer() const; Player* GetSpellModOwner() const; - int32 CalculateSpellDamage(Unit const* target, SpellEffectInfo const& spellEffectInfo, int32 const* basePoints = nullptr, float* variance = nullptr, uint32 castItemId = 0, int32 itemLevel = -1) const; // target dependent range checks float GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const; diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 669fcb3628..2e64f411e8 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -1199,8 +1199,8 @@ void Pet::_LoadAuras(PreparedQueryResult auraResult, PreparedQueryResult effectR AuraKey key{ casterGuid, itemGuid, fields[1].GetUInt32(), fields[2].GetUInt32() }; AuraLoadEffectInfo& info = effectInfo[key]; - info.Amounts[effectIndex] = fields[4].GetInt32(); - info.BaseAmounts[effectIndex] = fields[5].GetInt32(); + info.Amounts[effectIndex] = fields[4].GetDouble(); + info.BaseAmounts[effectIndex] = fields[5].GetDouble(); } } while (effectResult->NextRow()); } @@ -1337,8 +1337,8 @@ void Pet::_SaveAuras(CharacterDatabaseTransaction trans) stmt->setUInt32(index++, key.SpellId); stmt->setUInt32(index++, key.EffectMask); stmt->setUInt8(index++, effect->GetEffIndex()); - stmt->setInt32(index++, effect->GetAmount()); - stmt->setInt32(index++, effect->GetBaseAmount()); + stmt->setDouble(index++, effect->GetAmount()); + stmt->setDouble(index++, effect->GetBaseAmount()); trans->Append(stmt); } } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 1063a323d6..554ecb39d7 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -5350,7 +5350,7 @@ void Player::UpdateRating(CombatRating cr) if (amount < 0) amount = 0; - uint32 oldRating = m_activePlayerData->CombatRatings[cr]; + int32 oldRating = m_activePlayerData->CombatRatings[cr]; SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::CombatRatings, cr), amount); bool affectStats = CanModifyStats(); @@ -8536,7 +8536,7 @@ void Player::ApplyArtifactPowerRank(Item* artifact, ArtifactPowerRankEntry const args.SetCastItem(artifact); if (artifactPowerRank->AuraPointsOverride) for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) - args.AddSpellMod(SpellValueMod(SPELLVALUE_BASE_POINT0 + AsUnderlyingType(spellEffectInfo.EffectIndex)), artifactPowerRank->AuraPointsOverride); + args.AddSpellMod(SpellValueModFloat(SPELLVALUE_BASE_POINT0 + AsUnderlyingType(spellEffectInfo.EffectIndex)), artifactPowerRank->AuraPointsOverride); CastSpell(this, artifactPowerRank->SpellID, args); } @@ -8837,7 +8837,7 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) if (spellEffectInfo.IsEffect()) - args.AddSpellMod(static_cast(SPELLVALUE_BASE_POINT0 + AsUnderlyingType(spellEffectInfo.EffectIndex)), CalculatePct(spellEffectInfo.CalcValue(this), effectPct)); + args.AddSpellMod(static_cast(SPELLVALUE_BASE_POINT0 + AsUnderlyingType(spellEffectInfo.EffectIndex)), CalculatePct(spellEffectInfo.CalcValue(this), effectPct)); } CastSpell(target, spellInfo->Id, args); } @@ -19038,8 +19038,8 @@ void Player::_LoadAuras(PreparedQueryResult auraResult, PreparedQueryResult effe itemGuid.SetRawValue(rawGuidBytes); AuraKey key{ casterGuid, itemGuid, fields[2].GetUInt32(), fields[3].GetUInt32() }; AuraLoadEffectInfo& info = effectInfo[key]; - info.Amounts[effectIndex] = fields[5].GetInt32(); - info.BaseAmounts[effectIndex] = fields[6].GetInt32(); + info.Amounts[effectIndex] = fields[5].GetDouble(); + info.BaseAmounts[effectIndex] = fields[6].GetDouble(); } } while (effectResult->NextRow()); @@ -20999,8 +20999,8 @@ void Player::_SaveAuras(CharacterDatabaseTransaction trans) stmt->setUInt32(index++, key.SpellId); stmt->setUInt32(index++, key.EffectMask); stmt->setUInt8(index++, effect->GetEffIndex()); - stmt->setInt32(index++, effect->GetAmount()); - stmt->setInt32(index++, effect->GetBaseAmount()); + stmt->setDouble(index++, effect->GetAmount()); + stmt->setDouble(index++, effect->GetBaseAmount()); trans->Append(stmt); } } @@ -22845,7 +22845,7 @@ void Player::GetSpellModValues(SpellInfo const* spellInfo, SpellModOp op, Spell* if (base + *flat == 0) continue; - int32 value = static_cast(mod)->value; + float value = static_cast(mod)->value; if (value == 0) continue; @@ -23871,7 +23871,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin price = uint64(floor(price * GetReputationPriceDiscount(creature))); price = pProto->GetBuyPrice() > 0 ? std::max(uint64(1), price) : price; - if (int32 priceMod = GetTotalAuraModifier(SPELL_AURA_MOD_VENDOR_ITEMS_PRICES)) + if (float priceMod = GetTotalAuraModifier(SPELL_AURA_MOD_VENDOR_ITEMS_PRICES)) price -= CalculatePct(price, priceMod); if (!HasEnoughMoney(price)) @@ -27045,12 +27045,12 @@ uint8 Player::GetRunesState() const uint32 Player::GetRuneBaseCooldown() const { - float cooldown = RUNE_BASE_COOLDOWN; + double cooldown = RUNE_BASE_COOLDOWN; AuraEffectList const& regenAura = GetAuraEffectsByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT); for (AuraEffectList::const_iterator i = regenAura.begin();i != regenAura.end(); ++i) if ((*i)->GetMiscValue() == POWER_RUNES) - cooldown *= 1.0f - (*i)->GetAmount() / 100.0f; + cooldown *= 1.0 - (*i)->GetAmount() / 100.0; // Runes cooldown are now affected by player's haste from equipment ... float hastePct = GetRatingBonusValue(CR_HASTE_MELEE); @@ -27060,9 +27060,9 @@ uint32 Player::GetRuneBaseCooldown() const hastePct += GetTotalAuraModifier(SPELL_AURA_MOD_MELEE_HASTE_2); hastePct += GetTotalAuraModifier(SPELL_AURA_MOD_MELEE_HASTE_3); - cooldown *= 1.0f - (hastePct / 100.0f); + cooldown *= 1.0f - (hastePct / 100.0f); - return cooldown; + return static_cast(cooldown); } void Player::SetRuneCooldown(uint8 index, uint32 cooldown) @@ -27458,7 +27458,7 @@ void Player::HandleFall(MovementInfo const& movementInfo) !HasAuraType(SPELL_AURA_FLY) && !IsImmunedToDamage(SPELL_SCHOOL_MASK_NORMAL)) { //Safe fall, fall height reduction - int32 safe_fall = GetTotalAuraModifier(SPELL_AURA_SAFE_FALL); + float safe_fall = GetTotalAuraModifier(SPELL_AURA_SAFE_FALL); float damageperc = 0.018f*(z_diff-safe_fall)-0.2426f; diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 254a31bca3..96325bd34b 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -283,7 +283,7 @@ struct SpellPctModifierByClassMask : SpellModifierByClassMask SpellPctModifierByClassMask(SpellModOp _op, uint32 _spellId, Aura* _ownerAura, flag128 _mask) : SpellModifierByClassMask(_op, SPELLMOD_PCT, _spellId, _ownerAura, _mask) { } - int32 value = { }; + float value = { }; }; struct SpellFlatModifierByLabel : SpellModifier diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index 5f30a33685..ecc7f9f35a 100644 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -177,7 +177,7 @@ void Player::UpdateSpellDamageAndHealingBonus() for (uint16 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::ModDamageDoneNeg, i), - std::accumulate(modDamageAuras.begin(), modDamageAuras.end(), 0, [i](int32 negativeMod, AuraEffect const* aurEff) + std::accumulate(modDamageAuras.begin(), modDamageAuras.end(), 0, [i](SpellEffectValue negativeMod, AuraEffect const* aurEff) { if (aurEff->GetAmount() < 0 && aurEff->GetMiscValue() & (1 << i)) negativeMod += aurEff->GetAmount(); @@ -758,7 +758,7 @@ void Player::UpdateRangedHitChances() void Player::UpdateSpellHitChances() { - m_modSpellHitChance = 15.0f + (float)GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE); + m_modSpellHitChance = 15.0f + GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE); m_modSpellHitChance += GetRatingBonusValue(CR_HIT_SPELL); } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index a555c31e0e..dd6aee117e 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -1618,7 +1618,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) continue; } - uint32 damage = aurEff->GetAmount(); + uint32 damage = aurEff->GetAmountAsInt(); if (Unit* caster = aurEff->GetCaster()) { damage = caster->SpellDamageBonusDone(this, spellInfo, damage, SPELL_DIRECT_DAMAGE, aurEff->GetSpellEffectInfo()); @@ -1684,12 +1684,12 @@ void Unit::HandleEmoteCommand(Emote emoteId, Player* target /*=nullptr*/, Trinit armor *= victim->GetArmorMultiplierForTarget(attacker); // bypass enemy armor by SPELL_AURA_BYPASS_ARMOR_FOR_CASTER - int32 armorBypassPct = 0; + SpellEffectValue armorBypassPct = 0; AuraEffectList const & reductionAuras = victim->GetAuraEffectsByType(SPELL_AURA_BYPASS_ARMOR_FOR_CASTER); for (AuraEffectList::const_iterator i = reductionAuras.begin(); i != reductionAuras.end(); ++i) if ((*i)->GetCasterGUID() == attacker->GetGUID()) armorBypassPct += (*i)->GetAmount(); - armor = CalculatePct(armor, 100 - std::min(armorBypassPct, 100)); + armor = CalculatePct(armor, 100 - std::min(armorBypassPct, 100.0)); // Ignore enemy armor by SPELL_AURA_MOD_TARGET_RESISTANCE aura armor += attacker->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, SPELL_SCHOOL_MASK_NORMAL); @@ -1801,13 +1801,13 @@ void Unit::HandleEmoteCommand(Emote emoteId, Player* target /*=nullptr*/, Trinit float damageResisted = damage * resistance / 10.f; if (damageResisted > 0.0f) // if any damage was resisted { - int32 ignoredResistance = 0; + float ignoredResistance = 0.0f; if (attacker) ignoredResistance += attacker->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_IGNORE_TARGET_RESIST, schoolMask); - ignoredResistance = std::min(ignoredResistance, 100); - ApplyPct(damageResisted, 100 - ignoredResistance); + ignoredResistance = std::min(ignoredResistance, 100.0f); + ApplyPct(damageResisted, 100.0f - ignoredResistance); // Spells with melee and magic school mask, decide whether resistance or armor absorb is higher if (spellInfo && spellInfo->HasAttribute(SPELL_ATTR0_CU_SCHOOLMASK_NORMAL_WITH_MAGIC)) @@ -1905,7 +1905,7 @@ void Unit::HandleEmoteCommand(Emote emoteId, Player* target /*=nullptr*/, Trinit continue; // get amount which can be still absorbed by the aura - int32 currentAbsorb = absorbAurEff->GetAmount(); + int32 currentAbsorb = absorbAurEff->GetAmountAsInt(); // aura with infinite absorb amount - let the scripts handle absorbtion amount, set here to 0 for safety if (currentAbsorb < 0) currentAbsorb = 0; @@ -1973,7 +1973,7 @@ void Unit::HandleEmoteCommand(Emote emoteId, Player* target /*=nullptr*/, Trinit continue; // get amount which can be still absorbed by the aura - int32 currentAbsorb = absorbAurEff->GetAmount(); + int32 currentAbsorb = absorbAurEff->GetAmountAsInt(); // aura with infinite absorb amount - let the scripts handle absorbtion amount, set here to 0 for safety if (currentAbsorb < 0) currentAbsorb = 0; @@ -2115,7 +2115,7 @@ void Unit::HandleEmoteCommand(Emote emoteId, Player* target /*=nullptr*/, Trinit continue; // get amount which can be still absorbed by the aura - int32 currentAbsorb = absorbAurEff->GetAmount(); + int32 currentAbsorb = absorbAurEff->GetAmountAsInt(); // aura with infinite absorb amount - let the scripts handle absorbtion amount, set here to 0 for safety if (currentAbsorb < 0) currentAbsorb = 0; @@ -2569,17 +2569,17 @@ void Unit::SendMeleeAttackStop(Unit* victim) bool Unit::IsBlockCritical() const { - if (roll_chance_i(GetTotalAuraModifier(SPELL_AURA_MOD_BLOCK_CRIT_CHANCE))) + if (roll_chance_f(GetTotalAuraModifier(SPELL_AURA_MOD_BLOCK_CRIT_CHANCE))) return true; return false; } -int32 Unit::GetMechanicResistChance(SpellInfo const* spellInfo) const +float Unit::GetMechanicResistChance(SpellInfo const* spellInfo) const { if (!spellInfo) return 0; - int32 resistMech = 0; + float resistMech = 0; for (SpellEffectInfo const& effect : spellInfo->GetEffects()) { if (!effect.IsEffect()) @@ -2588,13 +2588,13 @@ int32 Unit::GetMechanicResistChance(SpellInfo const* spellInfo) const int32 effectMech = spellInfo->GetEffectMechanic(effect.EffectIndex); if (effectMech) { - int32 temp = GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_MECHANIC_RESISTANCE, effectMech); + float temp = GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_MECHANIC_RESISTANCE, effectMech); if (resistMech < temp) resistMech = temp; } } - return std::max(resistMech, 0); + return std::max(resistMech, 0.0f); } bool Unit::CanUseAttackType(uint8 attacktype) const @@ -2635,7 +2635,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo return SPELL_MISS_MISS; // Chance resist mechanic - int32 resist_chance = victim->GetMechanicResistChance(spellInfo) * 100; + int32 resist_chance = victim->GetMechanicResistChance(spellInfo) * 100.0f; tmp += resist_chance; if (roll < tmp) return SPELL_MISS_RESIST; @@ -2665,7 +2665,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo // only if in front if (!victim->HasUnitState(UNIT_STATE_CONTROLLED) && (victim->HasInArc(float(M_PI), this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))) { - int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100; + int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100.0f; tmp += deflect_chance; if (roll < tmp) return SPELL_MISS_DEFLECT; @@ -3412,13 +3412,13 @@ Aura* Unit::_TryStackingOrRefreshingExistingAura(AuraCreateInfo& createInfo) if (!auraEff) continue; - int32 bp; + SpellEffectValue bp; if (createInfo.BaseAmount) bp = *(createInfo.BaseAmount + spellEffectInfo.EffectIndex); else - bp = int32(spellEffectInfo.BasePoints); + bp = spellEffectInfo.BasePoints; - int32* oldBP = const_cast(&(auraEff->m_baseAmount)); + SpellEffectValue* oldBP = const_cast(&(auraEff->m_baseAmount)); if (spellEffectInfo.EffectAttributes.HasFlag(SpellEffectAttributes::AuraPointsStack)) *oldBP += bp; else @@ -4038,8 +4038,8 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGUID, W Aura* aura = iter->second; if (aura->GetCasterGUID() == casterGUID) { - std::array damage = { }; - std::array baseDamage = { }; + std::array damage = { }; + std::array baseDamage = { }; std::bitset effMask; std::bitset recalculateMask; Unit* caster = aura->GetCaster(); @@ -4844,7 +4844,7 @@ bool Unit::HasAuraTypeWithValue(AuraType auraType, int32 value) const { AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auraType); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) - if (value == (*i)->GetAmount()) + if (value == (*i)->GetAmountAsInt()) return true; return false; } @@ -4978,14 +4978,14 @@ uint32 Unit::GetDoTsByCaster(ObjectGuid casterGUID) const return dots; } -int32 Unit::GetTotalAuraModifier(AuraType auraType, std::function const& predicate) const +float Unit::GetTotalAuraModifier(AuraType auraType, std::function const& predicate) const { AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auraType); if (mTotalAuraList.empty()) - return 0; + return 0.0f; - std::map sameEffectSpellGroup; - int32 modifier = 0; + std::map sameEffectSpellGroup; + SpellEffectValue modifier = 0; for (AuraEffect const* aurEff : mTotalAuraList) { @@ -4993,7 +4993,7 @@ int32 Unit::GetTotalAuraModifier(AuraType auraType, std::functionAddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), static_cast(auraType), aurEff->GetAmount(), sameEffectSpellGroup)) + if (!sSpellMgr->AddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), auraType, aurEff->GetAmount(), sameEffectSpellGroup)) modifier += aurEff->GetAmount(); } } @@ -5002,7 +5002,7 @@ int32 Unit::GetTotalAuraModifier(AuraType auraType, std::functionsecond; - return modifier; + return static_cast(modifier); } float Unit::GetTotalAuraMultiplier(AuraType auraType, std::function const& predicate) const @@ -5011,8 +5011,8 @@ float Unit::GetTotalAuraMultiplier(AuraType auraType, std::function sameEffectSpellGroup; - float multiplier = 1.0f; + std::map sameEffectSpellGroup; + SpellEffectValue multiplier = 1.0; for (AuraEffect const* aurEff : mTotalAuraList) { @@ -5020,7 +5020,7 @@ float Unit::GetTotalAuraMultiplier(AuraType auraType, std::functionAddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), static_cast(auraType), aurEff->GetAmount(), sameEffectSpellGroup)) + if (!sSpellMgr->AddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), auraType, aurEff->GetAmount(), sameEffectSpellGroup)) AddPct(multiplier, aurEff->GetAmount()); } } @@ -5029,42 +5029,42 @@ float Unit::GetTotalAuraMultiplier(AuraType auraType, std::functionsecond); - return multiplier; + return static_cast(multiplier); } -int32 Unit::GetMaxPositiveAuraModifier(AuraType auraType, std::function const& predicate) const +float Unit::GetMaxPositiveAuraModifier(AuraType auraType, std::function const& predicate) const { AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auraType); if (mTotalAuraList.empty()) - return 0; + return 0.0f; - int32 modifier = 0; + SpellEffectValue modifier = 0; for (AuraEffect const* aurEff : mTotalAuraList) { if (predicate(aurEff)) modifier = std::max(modifier, aurEff->GetAmount()); } - return modifier; + return static_cast(modifier); } -int32 Unit::GetMaxNegativeAuraModifier(AuraType auraType, std::function const& predicate) const +float Unit::GetMaxNegativeAuraModifier(AuraType auraType, std::function const& predicate) const { AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auraType); if (mTotalAuraList.empty()) - return 0; + return 0.0f; - int32 modifier = 0; + SpellEffectValue modifier = 0; for (AuraEffect const* aurEff : mTotalAuraList) { if (predicate(aurEff)) modifier = std::min(modifier, aurEff->GetAmount()); } - return modifier; + return static_cast(modifier); } -int32 Unit::GetTotalAuraModifier(AuraType auraType) const +float Unit::GetTotalAuraModifier(AuraType auraType) const { return GetTotalAuraModifier(auraType, [](AuraEffect const* /*aurEff*/) { return true; }); } @@ -5074,17 +5074,17 @@ float Unit::GetTotalAuraMultiplier(AuraType auraType) const return GetTotalAuraMultiplier(auraType, [](AuraEffect const* /*aurEff*/) { return true; }); } -int32 Unit::GetMaxPositiveAuraModifier(AuraType auraType) const +float Unit::GetMaxPositiveAuraModifier(AuraType auraType) const { return GetMaxPositiveAuraModifier(auraType, [](AuraEffect const* /*aurEff*/) { return true; }); } -int32 Unit::GetMaxNegativeAuraModifier(AuraType auraType) const +float Unit::GetMaxNegativeAuraModifier(AuraType auraType) const { return GetMaxNegativeAuraModifier(auraType, [](AuraEffect const* /*aurEff*/) { return true; }); } -int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auraType, uint32 miscMask) const +float Unit::GetTotalAuraModifierByMiscMask(AuraType auraType, uint32 miscMask) const { return GetTotalAuraModifier(auraType, [miscMask](AuraEffect const* aurEff) -> bool { @@ -5104,7 +5104,7 @@ float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auraType, uint32 miscMask) }); } -int32 Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auraType, uint32 miscMask, AuraEffect const* except /*= nullptr*/) const +float Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auraType, uint32 miscMask, AuraEffect const* except /*= nullptr*/) const { return GetMaxPositiveAuraModifier(auraType, [miscMask, except](AuraEffect const* aurEff) -> bool { @@ -5114,7 +5114,7 @@ int32 Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auraType, uint32 miscM }); } -int32 Unit::GetMaxNegativeAuraModifierByMiscMask(AuraType auraType, uint32 miscMask) const +float Unit::GetMaxNegativeAuraModifierByMiscMask(AuraType auraType, uint32 miscMask) const { return GetMaxNegativeAuraModifier(auraType, [miscMask](AuraEffect const* aurEff) -> bool { @@ -5124,7 +5124,7 @@ int32 Unit::GetMaxNegativeAuraModifierByMiscMask(AuraType auraType, uint32 miscM }); } -int32 Unit::GetTotalAuraModifierByMiscValue(AuraType auraType, int32 miscValue) const +float Unit::GetTotalAuraModifierByMiscValue(AuraType auraType, int32 miscValue) const { return GetTotalAuraModifier(auraType, [miscValue](AuraEffect const* aurEff) -> bool { @@ -5144,7 +5144,7 @@ float Unit::GetTotalAuraMultiplierByMiscValue(AuraType auraType, int32 miscValue }); } -int32 Unit::GetMaxPositiveAuraModifierByMiscValue(AuraType auraType, int32 miscValue) const +float Unit::GetMaxPositiveAuraModifierByMiscValue(AuraType auraType, int32 miscValue) const { return GetMaxPositiveAuraModifier(auraType, [miscValue](AuraEffect const* aurEff) -> bool { @@ -5154,7 +5154,7 @@ int32 Unit::GetMaxPositiveAuraModifierByMiscValue(AuraType auraType, int32 miscV }); } -int32 Unit::GetMaxNegativeAuraModifierByMiscValue(AuraType auraType, int32 miscValue) const +float Unit::GetMaxNegativeAuraModifierByMiscValue(AuraType auraType, int32 miscValue) const { return GetMaxNegativeAuraModifier(auraType, [miscValue](AuraEffect const* aurEff) -> bool { @@ -5164,7 +5164,7 @@ int32 Unit::GetMaxNegativeAuraModifierByMiscValue(AuraType auraType, int32 miscV }); } -int32 Unit::GetTotalAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const +float Unit::GetTotalAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const { return GetTotalAuraModifier(auraType, [affectedSpell](AuraEffect const* aurEff) -> bool { @@ -5184,7 +5184,7 @@ float Unit::GetTotalAuraMultiplierByAffectMask(AuraType auraType, SpellInfo cons }); } -int32 Unit::GetMaxPositiveAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const +float Unit::GetMaxPositiveAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const { return GetMaxPositiveAuraModifier(auraType, [affectedSpell](AuraEffect const* aurEff) -> bool { @@ -5194,7 +5194,7 @@ int32 Unit::GetMaxPositiveAuraModifierByAffectMask(AuraType auraType, SpellInfo }); } -int32 Unit::GetMaxNegativeAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const +float Unit::GetMaxNegativeAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const { return GetMaxNegativeAuraModifier(auraType, [affectedSpell](AuraEffect const* aurEff) -> bool { @@ -7485,7 +7485,7 @@ float Unit::SpellHealingPctDone(Unit* victim, SpellInfo const* spellProto) const float healthPctDiff = 100.0f - victim->GetHealthPct(); for (AuraEffect const* healingDonePctVsTargetHealth : GetAuraEffectsByType(SPELL_AURA_MOD_HEALING_DONE_PCT_VERSUS_TARGET_HEALTH)) if (healingDonePctVsTargetHealth->IsAffectingSpell(spellProto)) - AddPct(DoneTotalMod, CalculatePct(float(healingDonePctVsTargetHealth->GetAmount()), healthPctDiff)); + AddPct(DoneTotalMod, CalculatePct(healingDonePctVsTargetHealth->GetAmount(), healthPctDiff)); return DoneTotalMod; } @@ -8468,9 +8468,9 @@ void Unit::UpdateMountCapability() for (AuraEffect* aurEff : mounts) { aurEff->RecalculateAmount(); - if (!aurEff->GetAmount()) + if (!aurEff->GetAmountAsInt()) aurEff->GetBase()->Remove(); - else if (MountCapabilityEntry const* capability = sMountCapabilityStore.LookupEntry(aurEff->GetAmount())) // aura may get removed by interrupt flag, reapply + else if (MountCapabilityEntry const* capability = sMountCapabilityStore.LookupEntry(aurEff->GetAmountAsInt())) // aura may get removed by interrupt flag, reapply { SetFlightCapabilityID(capability->FlightCapabilityID, true); @@ -8669,7 +8669,7 @@ void Unit::TriggerOnHealthChangeAuras(uint64 oldVal, uint64 newVal) AuraEffectVector effects = CopyAuraEffectList(GetAuraEffectsByType(SPELL_AURA_TRIGGER_SPELL_ON_HEALTH_PCT)); for (AuraEffect const* effect : effects) { - uint32 triggerHealthPct = effect->GetAmount(); + SpellEffectValue triggerHealthPct = effect->GetAmount(); uint32 triggerSpell = effect->GetSpellEffectInfo().TriggerSpell; uint64 threshold = CountPctFromMaxHealth(triggerHealthPct); @@ -8775,7 +8775,7 @@ void Unit::SetVisible(bool x) void Unit::UpdateSpeed(UnitMoveType mtype) { - int32 main_speed_mod = 0; + float main_speed_mod = 0.0f; float stack_bonus = 1.0f; float non_stack_bonus = 1.0f; @@ -8817,7 +8817,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype) stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_VEHICLE_SPEED_ALWAYS); // for some spells this mod is applied on vehicle owner - int32 owner_speed_mod = 0; + float owner_speed_mod = 0.0f; if (Unit* owner = GetCharmer()) owner_speed_mod = owner->GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_VEHICLE_FLIGHT_SPEED); @@ -8861,7 +8861,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype) // Normalize speed by 191 aura SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED if need /// @todo possible affect only on MOVE_RUN - if (int32 normalization = GetMaxPositiveAuraModifier(SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED)) + if (float normalization = GetMaxPositiveAuraModifier(SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED)) { if (Creature* creature = ToCreature()) if (CreatureImmunities const* immunities = SpellMgr::GetCreatureImmunities(creature->GetCreatureTemplate()->CreatureImmunitiesId)) @@ -8877,7 +8877,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype) if (mtype == MOVE_RUN) { // force minimum speed rate @ aura 437 SPELL_AURA_MOD_MINIMUM_SPEED_RATE - if (int32 minSpeedMod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_MINIMUM_SPEED_RATE)) + if (float minSpeedMod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_MINIMUM_SPEED_RATE)) { float minSpeed = minSpeedMod / (IsControlledByPlayer() ? playerBaseMoveSpeed[mtype] : baseMoveSpeed[mtype]); if (speed < minSpeed) @@ -8909,11 +8909,11 @@ void Unit::UpdateSpeed(UnitMoveType mtype) } // Apply strongest slow aura mod to speed - int32 slow = GetMaxNegativeAuraModifier(SPELL_AURA_MOD_DECREASE_SPEED); + float slow = GetMaxNegativeAuraModifier(SPELL_AURA_MOD_DECREASE_SPEED); if (slow) AddPct(speed, slow); - if (float minSpeedMod = (float)GetMaxPositiveAuraModifier(SPELL_AURA_MOD_MINIMUM_SPEED)) + if (float minSpeedMod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_MINIMUM_SPEED)) { float baseMinSpeed = 1.0f; if (!GetOwnerGUID().IsPlayer() && !IsHunterPet() && GetTypeId() == TYPEID_UNIT) @@ -9056,10 +9056,10 @@ void Unit::UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle speedType, bool clientUp if (rateAura != SPELL_AURA_NONE) { // take only lowest negative and highest positive auras - these effects do not stack - if (int32 neg = GetMaxNegativeAuraModifier(rateAura, [](AuraEffect const* mod) { return mod->GetAmount() > 0 && mod->GetAmount() < 100; })) + if (float neg = GetMaxNegativeAuraModifier(rateAura, [](AuraEffect const* mod) { return mod->GetAmount() > 0 && mod->GetAmount() < 100; })) ApplyPct(newValue, neg); - if (int32 pos = GetMaxPositiveAuraModifier(rateAura, [](AuraEffect const* mod) { return mod->GetAmount() > 100; })) + if (float pos = GetMaxPositiveAuraModifier(rateAura, [](AuraEffect const* mod) { return mod->GetAmount() > 100; })) ApplyPct(newValue, pos); } @@ -9107,13 +9107,13 @@ void Unit::UpdateAdvFlyingSpeed(AdvFlyingRateTypeRange speedType, bool clientUpd if (rateAura != SPELL_AURA_NONE) { // take only lowest negative and highest positive auras - these effects do not stack - if (int32 neg = GetMaxNegativeAuraModifier(rateAura, [](AuraEffect const* mod) { return mod->GetAmount() > 0 && mod->GetAmount() < 100; })) + if (float neg = GetMaxNegativeAuraModifier(rateAura, [](AuraEffect const* mod) { return mod->GetAmount() > 0 && mod->GetAmount() < 100; })) { ApplyPct(min, neg); ApplyPct(max, neg); } - if (int32 pos = GetMaxPositiveAuraModifier(rateAura, [](AuraEffect const* mod) { return mod->GetAmount() > 100; })) + if (float pos = GetMaxPositiveAuraModifier(rateAura, [](AuraEffect const* mod) { return mod->GetAmount() > 100; })) { ApplyPct(min, pos); ApplyPct(max, pos); @@ -10111,11 +10111,11 @@ void Unit::TriggerOnPowerChangeAuras(Powers power, int32 oldVal, int32 newVal) { if (effect->GetMiscValue() == power) { - int32 effectAmount = effect->GetAmount(); + SpellEffectValue effectAmount = effect->GetAmount(); uint32 triggerSpell = effect->GetSpellEffectInfo().TriggerSpell; - float oldValueCheck = oldVal; - float newValueCheck = newVal; + SpellEffectValue oldValueCheck = oldVal; + SpellEffectValue newValueCheck = newVal; if (effect->GetAuraType() == SPELL_AURA_TRIGGER_SPELL_ON_POWER_PCT) { @@ -10768,7 +10768,7 @@ bool Unit::IsPolymorphed() const void Unit::RecalculateObjectScale() { - int32 scaleAuras = GetTotalAuraModifier(SPELL_AURA_MOD_SCALE) + GetTotalAuraModifier(SPELL_AURA_MOD_SCALE_2); + float scaleAuras = GetTotalAuraModifier(SPELL_AURA_MOD_SCALE) + GetTotalAuraModifier(SPELL_AURA_MOD_SCALE_2); float scale = GetNativeObjectScale() + CalculatePct(1.0f, scaleAuras); float scaleMin = GetTypeId() == TYPEID_PLAYER ? 0.1f : 0.01f; SetObjectScale(std::max(scale, scaleMin)); @@ -12707,14 +12707,14 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId, uint32 spellId, TriggerC { CastSpellExtraArgs args(flags); args.OriginalCaster = origCasterGUID; - args.AddSpellMod(SpellValueMod(SPELLVALUE_BASE_POINT0 + effectIndex), seatId + 1); + args.AddSpellMod(SpellValueModFloat(SPELLVALUE_BASE_POINT0 + effectIndex), seatId + 1); castResult = caster->CastSpell(target, spellId, args); } else // This can happen during Player::_LoadAuras { - std::array bp = { }; + std::array bp = { }; for (SpellEffectInfo const& spellEffectInfo : spellEntry->GetEffects()) - bp[spellEffectInfo.EffectIndex] = int32(spellEffectInfo.BasePoints); + bp[spellEffectInfo.EffectIndex] = spellEffectInfo.BasePoints; bp[effectIndex] = seatId; @@ -14124,9 +14124,9 @@ void Unit::ClearValuesChangesMask() WorldObject::ClearValuesChangesMask(); } -int32 Unit::GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEff, AuraType auraType, bool checkMiscValue /*= false*/, int32 miscValue /*= 0*/) const +SpellEffectValue Unit::GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEff, AuraType auraType, bool checkMiscValue /*= false*/, int32 miscValue /*= 0*/) const { - int32 val = 0; + SpellEffectValue val = 0; SpellSpellGroupMapBounds spellGroup = sSpellMgr->GetSpellSpellGroupMapBounds(aurEff->GetSpellInfo()->GetFirstRankSpell()->Id); for (SpellSpellGroupMap::const_iterator itr = spellGroup.first; itr != spellGroup.second ; ++itr) { @@ -14157,7 +14157,7 @@ bool Unit::IsHighestExclusiveAura(Aura const* aura, bool removeOtherAuraApplicat return true; } -bool Unit::IsHighestExclusiveAuraEffect(SpellInfo const* spellInfo, AuraType auraType, int32 effectAmount, uint32 auraEffectMask, bool removeOtherAuraApplications /*= false*/) +bool Unit::IsHighestExclusiveAuraEffect(SpellInfo const* spellInfo, AuraType auraType, SpellEffectValue effectAmount, uint32 auraEffectMask, bool removeOtherAuraApplications /*= false*/) { AuraEffectList const& auras = GetAuraEffectsByType(auraType); for (Unit::AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end();) @@ -14167,7 +14167,7 @@ bool Unit::IsHighestExclusiveAuraEffect(SpellInfo const* spellInfo, AuraType aur if (sSpellMgr->CheckSpellGroupStackRules(spellInfo, existingAurEff->GetSpellInfo()) == SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST) { - int64 diff = int64(abs(effectAmount)) - int64(abs(existingAurEff->GetAmount())); + SpellEffectValue diff = abs(effectAmount) - abs(existingAurEff->GetAmount()); if (!diff) { // treat the aura with more effects as stronger @@ -14346,9 +14346,9 @@ SpellInfo const* Unit::GetCastSpellInfo(SpellInfo const* spellInfo, TriggerCastF for (AuraEffect const* auraEffect : GetAuraEffectsByType(type)) { bool matches = auraEffect->GetMiscValue() ? uint32(auraEffect->GetMiscValue()) == spellInfo->Id : auraEffect->IsAffectingSpell(spellInfo); - if (matches && context->AddSpell(auraEffect->GetAmount())) + if (matches && context->AddSpell(auraEffect->GetAmountAsInt())) { - if (SpellInfo const* newInfo = sSpellMgr->GetSpellInfo(auraEffect->GetAmount(), GetMap()->GetDifficultyID())) + if (SpellInfo const* newInfo = sSpellMgr->GetSpellInfo(auraEffect->GetAmountAsInt(), GetMap()->GetDifficultyID())) { if (auraEffect->GetSpellInfo()->HasAttribute(SPELL_ATTR8_IGNORE_SPELLCAST_OVERRIDE_COST)) triggerFlag |= TRIGGERED_IGNORE_POWER_COST; diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 01a3534a0d..1efe5cab50 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -789,13 +789,13 @@ class TC_GAME_API Unit : public WorldObject uint64 GetMaxHealth() const { return m_unitData->MaxHealth; } bool IsFullHealth() const { return GetHealth() == GetMaxHealth(); } - bool HealthBelowPct(int32 pct) const { return GetHealth() < CountPctFromMaxHealth(pct); } - bool HealthBelowPctDamaged(int32 pct, uint32 damage) const { return int64(GetHealth()) - int64(damage) < int64(CountPctFromMaxHealth(pct)); } - bool HealthAbovePct(int32 pct) const { return GetHealth() > CountPctFromMaxHealth(pct); } - bool HealthAbovePctHealed(int32 pct, uint32 heal) const { return uint64(GetHealth()) + uint64(heal) > CountPctFromMaxHealth(pct); } + bool HealthBelowPct(float pct) const { return GetHealth() < CountPctFromMaxHealth(pct); } + bool HealthBelowPctDamaged(float pct, uint32 damage) const { return int64(GetHealth()) - int64(damage) < int64(CountPctFromMaxHealth(pct)); } + bool HealthAbovePct(float pct) const { return GetHealth() > CountPctFromMaxHealth(pct); } + bool HealthAbovePctHealed(float pct, uint32 heal) const { return uint64(GetHealth()) + uint64(heal) > CountPctFromMaxHealth(pct); } float GetHealthPct() const { return GetMaxHealth() ? 100.f * GetHealth() / GetMaxHealth() : 0.0f; } - uint64 CountPctFromMaxHealth(int32 pct) const { return CalculatePct(GetMaxHealth(), pct); } - uint64 CountPctFromCurHealth(int32 pct) const { return CalculatePct(GetHealth(), pct); } + uint64 CountPctFromMaxHealth(float pct) const { return CalculatePct(GetMaxHealth(), pct); } + uint64 CountPctFromCurHealth(float pct) const { return CalculatePct(GetHealth(), pct); } void SetHealth(uint64 val); void SetMaxHealth(uint64 val); @@ -982,7 +982,7 @@ class TC_GAME_API Unit : public WorldObject float GetUnitCriticalChanceDone(WeaponAttackType attackType) const; float GetUnitCriticalChanceTaken(Unit const* attacker, WeaponAttackType attackType, float critDone) const; float GetUnitCriticalChanceAgainst(WeaponAttackType attackType, Unit const* victim) const; - int32 GetMechanicResistChance(SpellInfo const* spellInfo) const; + float GetMechanicResistChance(SpellInfo const* spellInfo) const; bool CanUseAttackType(uint8 attacktype) const; virtual float GetBlockPercent(uint8 /*attackerLevel*/) const { return 30.0f; } @@ -1378,30 +1378,30 @@ class TC_GAME_API Unit : public WorldObject uint32 GetDiseasesByCaster(ObjectGuid casterGUID, bool remove = false); uint32 GetDoTsByCaster(ObjectGuid casterGUID) const; - int32 GetTotalAuraModifier(AuraType auraType) const; + float GetTotalAuraModifier(AuraType auraType) const; float GetTotalAuraMultiplier(AuraType auraType) const; - int32 GetMaxPositiveAuraModifier(AuraType auraType) const; - int32 GetMaxNegativeAuraModifier(AuraType auraType) const; + float GetMaxPositiveAuraModifier(AuraType auraType) const; + float GetMaxNegativeAuraModifier(AuraType auraType) const; - int32 GetTotalAuraModifier(AuraType auraType, std::function const& predicate) const; + float GetTotalAuraModifier(AuraType auraType, std::function const& predicate) const; float GetTotalAuraMultiplier(AuraType auraType, std::function const& predicate) const; - int32 GetMaxPositiveAuraModifier(AuraType auraType, std::function const& predicate) const; - int32 GetMaxNegativeAuraModifier(AuraType auraType, std::function const& predicate) const; + float GetMaxPositiveAuraModifier(AuraType auraType, std::function const& predicate) const; + float GetMaxNegativeAuraModifier(AuraType auraType, std::function const& predicate) const; - int32 GetTotalAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask) const; + float GetTotalAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask) const; float GetTotalAuraMultiplierByMiscMask(AuraType auraType, uint32 misc_mask) const; - int32 GetMaxPositiveAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask, AuraEffect const* except = nullptr) const; - int32 GetMaxNegativeAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask) const; + float GetMaxPositiveAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask, AuraEffect const* except = nullptr) const; + float GetMaxNegativeAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask) const; - int32 GetTotalAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const; + float GetTotalAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const; float GetTotalAuraMultiplierByMiscValue(AuraType auraType, int32 misc_value) const; - int32 GetMaxPositiveAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const; - int32 GetMaxNegativeAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const; + float GetMaxPositiveAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const; + float GetMaxNegativeAuraModifierByMiscValue(AuraType auraType, int32 misc_value) const; - int32 GetTotalAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; + float GetTotalAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; float GetTotalAuraMultiplierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; - int32 GetMaxPositiveAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; - int32 GetMaxNegativeAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; + float GetMaxPositiveAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; + float GetMaxNegativeAuraModifierByAffectMask(AuraType auraType, SpellInfo const* affectedSpell) const; void InitStatBuffMods(); void UpdateStatBuffMod(Stats stat); @@ -1833,9 +1833,9 @@ class TC_GAME_API Unit : public WorldObject // Movement info std::unique_ptr movespline; - int32 GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEff, AuraType auraType, bool checkMiscValue = false, int32 miscValue = 0) const; + SpellEffectValue GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEff, AuraType auraType, bool checkMiscValue = false, int32 miscValue = 0) const; bool IsHighestExclusiveAura(Aura const* aura, bool removeOtherAuraApplications = false); - bool IsHighestExclusiveAuraEffect(SpellInfo const* spellInfo, AuraType auraType, int32 effectAmount, uint32 auraEffectMask, bool removeOtherAuraApplications = false); + bool IsHighestExclusiveAuraEffect(SpellInfo const* spellInfo, AuraType auraType, SpellEffectValue effectAmount, uint32 auraEffectMask, bool removeOtherAuraApplications = false); virtual void Talk(std::string_view text, ChatMsg msgType, Language language, float textRange, WorldObject const* target); virtual void Say(std::string_view text, Language language, WorldObject const* target = nullptr); diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index a4b33d1c72..6553dd05ba 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -646,7 +646,7 @@ void WorldSession::SendListInventory(ObjectGuid vendorGuid) uint64 price = uint64(floor(itemTemplate->GetBuyPrice() * discountMod)); price = itemTemplate->GetBuyPrice() > 0 ? std::max(uint64(1), price) : price; - if (int32 priceMod = _player->GetTotalAuraModifier(SPELL_AURA_MOD_VENDOR_ITEMS_PRICES)) + if (float priceMod = _player->GetTotalAuraModifier(SPELL_AURA_MOD_VENDOR_ITEMS_PRICES)) price -= CalculatePct(price, priceMod); item.MuID = slot + 1; // client expects counting to start at 1 diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index 7393fd4a54..d6cff6931d 100644 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -899,7 +899,7 @@ enum SpellAttr12 : uint32 SPELL_ATTR12_UNK18 = 0x00040000, // TITLE Unknown attribute 18@Attr12 SPELL_ATTR12_UNK19 = 0x00080000, // TITLE Unknown attribute 19@Attr12 SPELL_ATTR12_UNK20 = 0x00100000, // TITLE Unknown attribute 20@Attr12 - SPELL_ATTR12_UNK21 = 0x00200000, // TITLE Unknown attribute 21@Attr12 + SPELL_ATTR12_USE_FLOAT_VALUES_FOR_SCALING_AMOUNTS = 0x00200000, // TITLE Use float values for scaling amounts SPELL_ATTR12_UNK22 = 0x00400000, // TITLE Unknown attribute 22@Attr12 SPELL_ATTR12_START_COOLDOWN_ON_CAST_START = 0x00800000, // TITLE Trigger Cooldown On Spell Start SPELL_ATTR12_IS_GARRISON_BUFF = 0x01000000, // TITLE Never Learn diff --git a/src/server/game/Miscellaneous/enuminfo_SharedDefines.cpp b/src/server/game/Miscellaneous/enuminfo_SharedDefines.cpp index d12843edf0..6009a7cf0b 100644 --- a/src/server/game/Miscellaneous/enuminfo_SharedDefines.cpp +++ b/src/server/game/Miscellaneous/enuminfo_SharedDefines.cpp @@ -1846,7 +1846,7 @@ TC_API_EXPORT EnumText EnumUtils::ToString(SpellAttr12 value) case SPELL_ATTR12_UNK18: return { "SPELL_ATTR12_UNK18", "Unknown attribute 18@Attr12", "" }; case SPELL_ATTR12_UNK19: return { "SPELL_ATTR12_UNK19", "Unknown attribute 19@Attr12", "" }; case SPELL_ATTR12_UNK20: return { "SPELL_ATTR12_UNK20", "Unknown attribute 20@Attr12", "" }; - case SPELL_ATTR12_UNK21: return { "SPELL_ATTR12_UNK21", "Unknown attribute 21@Attr12", "" }; + case SPELL_ATTR12_USE_FLOAT_VALUES_FOR_SCALING_AMOUNTS: return { "SPELL_ATTR12_USE_FLOAT_VALUES_FOR_SCALING_AMOUNTS", "Use float values for scaling amounts", "" }; case SPELL_ATTR12_UNK22: return { "SPELL_ATTR12_UNK22", "Unknown attribute 22@Attr12", "" }; case SPELL_ATTR12_START_COOLDOWN_ON_CAST_START: return { "SPELL_ATTR12_START_COOLDOWN_ON_CAST_START", "Trigger Cooldown On Spell Start", "" }; case SPELL_ATTR12_IS_GARRISON_BUFF: return { "SPELL_ATTR12_IS_GARRISON_BUFF", "Never Learn", "" }; @@ -1890,7 +1890,7 @@ TC_API_EXPORT SpellAttr12 EnumUtils::FromIndex(size_t index) case 18: return SPELL_ATTR12_UNK18; case 19: return SPELL_ATTR12_UNK19; case 20: return SPELL_ATTR12_UNK20; - case 21: return SPELL_ATTR12_UNK21; + case 21: return SPELL_ATTR12_USE_FLOAT_VALUES_FOR_SCALING_AMOUNTS; case 22: return SPELL_ATTR12_UNK22; case 23: return SPELL_ATTR12_START_COOLDOWN_ON_CAST_START; case 24: return SPELL_ATTR12_IS_GARRISON_BUFF; @@ -1931,7 +1931,7 @@ TC_API_EXPORT size_t EnumUtils::ToIndex(SpellAttr12 value) case SPELL_ATTR12_UNK18: return 18; case SPELL_ATTR12_UNK19: return 19; case SPELL_ATTR12_UNK20: return 20; - case SPELL_ATTR12_UNK21: return 21; + case SPELL_ATTR12_USE_FLOAT_VALUES_FOR_SCALING_AMOUNTS: return 21; case SPELL_ATTR12_UNK22: return 22; case SPELL_ATTR12_START_COOLDOWN_ON_CAST_START: return 23; case SPELL_ATTR12_IS_GARRISON_BUFF: return 24; diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 69fb1b45e3..91116e6ebc 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -727,7 +727,7 @@ NonDefaultConstructible AuraEffectHandler[TOTAL_AURAS]= &AuraEffect::HandleNULL, //655 SPELL_AURA_MOD_TRANSMOG_OUTFIT_UPDATE_COST }; -AuraEffect::AuraEffect(Aura* base, SpellEffectInfo const& spellEfffectInfo, int32 const* baseAmount, Unit* caster) : +AuraEffect::AuraEffect(Aura* base, SpellEffectInfo const& spellEfffectInfo, SpellEffectValue const* baseAmount, Unit* caster) : m_base(base), m_spellInfo(base->GetSpellInfo()), m_effectInfo(spellEfffectInfo), m_spellmod(nullptr), m_baseAmount(baseAmount ? *baseAmount : spellEfffectInfo.CalcBaseValue(caster, base->GetType() == UNIT_AURA_TYPE ? base->GetOwner()->ToUnit() : nullptr, base->GetCastItemId(), base->GetCastItemLevel())), _amount(), _periodicTimer(0), _period(0), _ticksDone(0), @@ -768,12 +768,12 @@ void AuraEffect::GetApplicationList(Container& applicationContainer) const } } -int32 AuraEffect::CalculateAmount(Unit* caster) +SpellEffectValue AuraEffect::CalculateAmount(Unit* caster) { Unit* unitOwner = GetBase()->GetOwner()->ToUnit(); // default amount calculation - int32 amount = GetSpellEffectInfo().CalcValue(caster, &m_baseAmount, unitOwner, nullptr, GetBase()->GetCastItemId(), GetBase()->GetCastItemLevel()); + SpellEffectValue amount = GetSpellEffectInfo().CalcValue(caster, &m_baseAmount, unitOwner, nullptr, GetBase()->GetCastItemId(), GetBase()->GetCastItemLevel()); // custom amount calculations go here switch (GetAuraType()) @@ -825,7 +825,7 @@ int32 AuraEffect::CalculateAmount(Unit* caster) Unit::AuraEffectList const& periodicAuras = unitOwner->GetAuraEffectsByType(GetAuraType()); if (uint32 totalTicks = GetTotalTicks()) { - amount = std::accumulate(std::begin(periodicAuras), std::end(periodicAuras), amount, [&](int32 val, AuraEffect const* aurEff) + amount = std::accumulate(std::begin(periodicAuras), std::end(periodicAuras), amount, [&](SpellEffectValue val, AuraEffect const* aurEff) { if (aurEff->GetCasterGUID() == GetCasterGUID() && aurEff->GetId() == GetId() && aurEff->GetEffIndex() == GetEffIndex()) val += aurEff->GetEstimatedAmount().value_or(aurEff->GetAmount()) * static_cast(aurEff->GetRemainingTicks()) / static_cast(totalTicks); @@ -838,13 +838,38 @@ int32 AuraEffect::CalculateAmount(Unit* caster) if (!GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes::SuppressPointsStacking)) amount *= GetBase()->GetStackAmount(); + switch (GetAuraType()) + { + case SPELL_AURA_PERIODIC_DAMAGE: + case SPELL_AURA_PERIODIC_HEAL: + case SPELL_AURA_PERIODIC_LEECH: + case SPELL_AURA_PERIODIC_HEALTH_FUNNEL: + case SPELL_AURA_PERIODIC_WEAPON_PERCENT_DAMAGE: + case SPELL_AURA_DAMAGE_SHIELD: + case SPELL_AURA_PROC_TRIGGER_DAMAGE: + case SPELL_AURA_OBS_MOD_HEALTH: + case SPELL_AURA_OBS_MOD_POWER: + case SPELL_AURA_PERIODIC_ENERGIZE: + case SPELL_AURA_PERIODIC_MANA_LEECH: + case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: + case SPELL_AURA_POWER_BURN: + amount = std::round(amount); + break; + default: + break; + } + + amount = std::clamp(amount, SpellEffectInfo::MinValue, SpellEffectInfo::MaxValue); + _estimatedAmount = CalculateEstimatedAmount(caster, amount); + if (_estimatedAmount) + _estimatedAmount = std::clamp(*_estimatedAmount, SpellEffectInfo::MinValue, SpellEffectInfo::MaxValue); return amount; } -Optional AuraEffect::CalculateEstimatedAmount(Unit const* caster, Unit* target, SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, - int32 amount, uint8 stack, AuraEffect const* aurEff) +Optional AuraEffect::CalculateEstimatedAmount(Unit const* caster, Unit* target, SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, + SpellEffectValue amount, uint8 stack, AuraEffect const* aurEff) { uint32 stackAmountForBonuses = !spellEffectInfo.EffectAttributes.HasFlag(SpellEffectAttributes::SuppressPointsStacking) ? stack : 1; @@ -862,7 +887,7 @@ Optional AuraEffect::CalculateEstimatedAmount(Unit const* caster, Unit* t return {}; } -Optional AuraEffect::CalculateEstimatedAmount(Unit const* caster, int32 amount) const +Optional AuraEffect::CalculateEstimatedAmount(Unit const* caster, SpellEffectValue amount) const { if (!caster || GetBase()->GetType() != UNIT_AURA_TYPE) return {}; @@ -870,16 +895,16 @@ Optional AuraEffect::CalculateEstimatedAmount(Unit const* caster, int32 a return CalculateEstimatedAmount(caster, GetBase()->GetUnitOwner(), GetSpellInfo(), GetSpellEffectInfo(), amount, GetBase()->GetStackAmount(), this); } -float AuraEffect::CalculateEstimatedfTotalPeriodicAmount(Unit* caster, Unit* target, SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, - float amount, uint8 stack) +SpellEffectValue AuraEffect::CalculateEstimatedfTotalPeriodicAmount(Unit const* caster, Unit* target, SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, + SpellEffectValue amount, uint8 stack) { int32 maxDuration = Aura::CalcMaxDuration(spellInfo, caster, nullptr); if (maxDuration <= 0) - return 0.0f; + return 0.0; int32 period = spellEffectInfo.ApplyAuraPeriod; if (!period) - return 0.0f; + return 0.0; if (Player* modOwner = caster->GetSpellModOwner()) modOwner->ApplySpellMod(spellInfo, SpellModOp::Period, period); @@ -893,7 +918,7 @@ float AuraEffect::CalculateEstimatedfTotalPeriodicAmount(Unit* caster, Unit* tar period = int32(period * caster->m_unitData->ModHaste); if (!period) - return 0.0f; + return 0.0; float totalTicks = float(maxDuration) / period; if (spellInfo->HasAttribute(SPELL_ATTR5_EXTRA_INITIAL_PERIOD)) @@ -1008,7 +1033,7 @@ void AuraEffect::CalculateSpellMod() case SPELL_AURA_ADD_FLAT_MODIFIER: if (!m_spellmod) m_spellmod = new SpellFlatModifierByClassMask(SpellModOp(GetMiscValue()), GetId(), GetBase(), GetSpellEffectInfo().SpellClassMask); - static_cast(m_spellmod)->value = GetAmount(); + static_cast(m_spellmod)->value = GetAmountAsInt(); break; case SPELL_AURA_ADD_PCT_MODIFIER: if (!m_spellmod) @@ -1018,7 +1043,7 @@ void AuraEffect::CalculateSpellMod() case SPELL_AURA_ADD_FLAT_MODIFIER_BY_SPELL_LABEL: if (!m_spellmod) m_spellmod = new SpellFlatModifierByLabel(SpellModOp(GetMiscValue()), GetId(), GetBase(), GetMiscValueB()); - static_cast(m_spellmod)->value.ModifierValue = GetAmount(); + static_cast(m_spellmod)->value.ModifierValue = GetAmountAsInt(); break; case SPELL_AURA_ADD_PCT_MODIFIER_BY_SPELL_LABEL: if (!m_spellmod) @@ -1057,7 +1082,7 @@ void AuraEffect::CalculateSpellMod() } } -void AuraEffect::ChangeAmount(int32 newAmount, bool mark, bool onStackOrReapply, AuraEffect const* triggeredBy /* = nullptr */) +void AuraEffect::ChangeAmount(SpellEffectValue newAmount, bool mark, bool onStackOrReapply, AuraEffect const* triggeredBy /* = nullptr */) { // Reapply if amount change uint8 handleMask = 0; @@ -1624,14 +1649,14 @@ void AuraEffect::HandleModInvisibilityDetect(AuraApplication const* aurApp, uint if (apply) { target->m_invisibilityDetect.AddFlag(type); - target->m_invisibilityDetect.AddValue(type, GetAmount()); + target->m_invisibilityDetect.AddValue(type, GetAmountAsInt()); } else { if (!target->HasAuraType(SPELL_AURA_MOD_INVISIBILITY_DETECT)) target->m_invisibilityDetect.DelFlag(type); - target->m_invisibilityDetect.AddValue(type, -GetAmount()); + target->m_invisibilityDetect.AddValue(type, -GetAmountAsInt()); } // call functions which may have additional effects after changing state of unit @@ -1655,7 +1680,7 @@ void AuraEffect::HandleModInvisibility(AuraApplication const* aurApp, uint8 mode playerTarget->AddAuraVision(PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW); target->m_invisibility.AddFlag(type); - target->m_invisibility.AddValue(type, GetAmount()); + target->m_invisibility.AddValue(type, GetAmountAsInt()); target->SetVisFlag(UNIT_VIS_FLAGS_INVISIBLE); } @@ -1675,7 +1700,7 @@ void AuraEffect::HandleModInvisibility(AuraApplication const* aurApp, uint8 mode if (!target->HasAuraType(SPELL_AURA_MOD_INVISIBILITY)) target->RemoveVisFlag(UNIT_VIS_FLAGS_INVISIBLE); - target->m_invisibility.AddValue(type, -GetAmount()); + target->m_invisibility.AddValue(type, -GetAmountAsInt()); } // call functions which may have additional effects after changing state of unit @@ -1700,14 +1725,14 @@ void AuraEffect::HandleModStealthDetect(AuraApplication const* aurApp, uint8 mod if (apply) { target->m_stealthDetect.AddFlag(type); - target->m_stealthDetect.AddValue(type, GetAmount()); + target->m_stealthDetect.AddValue(type, GetAmountAsInt()); } else { if (!target->HasAuraType(SPELL_AURA_MOD_STEALTH_DETECT)) target->m_stealthDetect.DelFlag(type); - target->m_stealthDetect.AddValue(type, -GetAmount()); + target->m_stealthDetect.AddValue(type, -GetAmountAsInt()); } // call functions which may have additional effects after changing state of unit @@ -1726,7 +1751,7 @@ void AuraEffect::HandleModStealth(AuraApplication const* aurApp, uint8 mode, boo if (apply) { target->m_stealth.AddFlag(type); - target->m_stealth.AddValue(type, GetAmount()); + target->m_stealth.AddValue(type, GetAmountAsInt()); target->SetVisFlag(UNIT_VIS_FLAGS_STEALTHED); if (Player * playerTarget = target->ToPlayer()) @@ -1734,7 +1759,7 @@ void AuraEffect::HandleModStealth(AuraApplication const* aurApp, uint8 mode, boo } else { - target->m_stealth.AddValue(type, -GetAmount()); + target->m_stealth.AddValue(type, -GetAmountAsInt()); if (!target->HasAuraType(SPELL_AURA_MOD_STEALTH)) // if last SPELL_AURA_MOD_STEALTH { @@ -1766,9 +1791,9 @@ void AuraEffect::HandleModStealthLevel(AuraApplication const* aurApp, uint8 mode StealthType type = StealthType(GetMiscValue()); if (apply) - target->m_stealth.AddValue(type, GetAmount()); + target->m_stealth.AddValue(type, GetAmountAsInt()); else - target->m_stealth.AddValue(type, -GetAmount()); + target->m_stealth.AddValue(type, -GetAmountAsInt()); // call functions which may have additional effects after changing state of unit if (target->IsInWorld()) @@ -2693,7 +2718,7 @@ void AuraEffect::HandleAuraModSkill(AuraApplication const* aurApp, uint8 mode, b return; uint32 prot = GetMiscValue(); - int32 points = GetAmount(); + int32 points = GetAmountAsInt(); if (prot == SKILL_DEFENSE) return; @@ -2798,7 +2823,7 @@ void AuraEffect::HandleAuraMounted(AuraApplication const* aurApp, uint8 mode, bo // cast speed aura if (mode & AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK) { - if (MountCapabilityEntry const* mountCapability = sMountCapabilityStore.LookupEntry(GetAmount())) + if (MountCapabilityEntry const* mountCapability = sMountCapabilityStore.LookupEntry(GetAmountAsInt())) { target->SetFlightCapabilityID(mountCapability->FlightCapabilityID, true); target->CastSpell(target, mountCapability->ModSpellAuraID, this); @@ -2822,7 +2847,7 @@ void AuraEffect::HandleAuraMounted(AuraApplication const* aurApp, uint8 mode, bo if (mode & AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK) // remove speed aura - if (MountCapabilityEntry const* mountCapability = sMountCapabilityStore.LookupEntry(GetAmount())) + if (MountCapabilityEntry const* mountCapability = sMountCapabilityStore.LookupEntry(GetAmountAsInt())) target->RemoveAurasDueToSpell(mountCapability->ModSpellAuraID, target->GetGUID()); target->SetFlightCapabilityID(0, true); @@ -3325,7 +3350,7 @@ void AuraEffect::HandleAuraControlVehicle(AuraApplication const* aurApp, uint8 m // so this break such spells or most of them. // Current formula about m_amount: effect base points + dieside - 1 // TO DO: Reasearch more about 0/0 and fix it. - caster->_EnterVehicle(target->GetVehicleKit(), GetAmount() - 1, aurApp); + caster->_EnterVehicle(target->GetVehicleKit(), GetAmountAsInt() - 1, aurApp); } else { @@ -3726,11 +3751,11 @@ void AuraEffect::HandleModTargetResistance(AuraApplication const* aurApp, uint8 // show armor penetration if (target->GetTypeId() == TYPEID_PLAYER && (GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)) - target->ApplyModTargetPhysicalResistance(GetAmount(), apply); + target->ApplyModTargetPhysicalResistance(GetAmountAsInt(), apply); // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy if (target->GetTypeId() == TYPEID_PLAYER && (GetMiscValue() & SPELL_SCHOOL_MASK_SPELL) == SPELL_SCHOOL_MASK_SPELL) - target->ApplyModTargetResistance(GetAmount(), apply); + target->ApplyModTargetResistance(GetAmountAsInt(), apply); } /********************************/ @@ -3749,7 +3774,7 @@ void AuraEffect::HandleAuraModStat(AuraApplication const* aurApp, uint8 mode, bo } Unit* target = aurApp->GetTarget(); - int32 spellGroupVal = target->GetHighestExclusiveSameEffectSpellGroupValue(this, SPELL_AURA_MOD_STAT, true, GetMiscValue()); + SpellEffectValue spellGroupVal = target->GetHighestExclusiveSameEffectSpellGroupValue(this, SPELL_AURA_MOD_STAT, true, GetMiscValue()); if (std::abs(spellGroupVal) >= std::abs(GetAmount())) return; @@ -4086,11 +4111,11 @@ void AuraEffect::HandleAuraModIncreaseHealth(AuraApplication const* aurApp, uint Unit* target = aurApp->GetTarget(); - int32 const amt = apply ? GetAmount() : -GetAmount(); + int32 const amt = apply ? GetAmountAsInt() : -GetAmountAsInt(); if (amt < 0) target->ModifyHealth(std::max(1 - target->GetHealth(), amt)); - target->HandleStatFlatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, GetAmount(), apply); + target->HandleStatFlatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, GetAmountAsInt(), apply); if (amt > 0) target->ModifyHealth(amt); @@ -4319,7 +4344,7 @@ void AuraEffect::HandleTriggerSpellOnHealthPercent(AuraApplication const* aurApp return; Unit* target = aurApp->GetTarget(); - int32 thresholdPct = GetAmount(); + SpellEffectValue thresholdPct = GetAmount(); uint32 triggerSpell = GetSpellEffectInfo().TriggerSpell; switch (AuraTriggerOnHealthChangeDirection(GetMiscValue())) @@ -4491,7 +4516,7 @@ void AuraEffect::HandleModCastingSpeed(AuraApplication const* aurApp, uint8 mode return; } - int32 spellGroupVal = target->GetHighestExclusiveSameEffectSpellGroupValue(this, GetAuraType()); + SpellEffectValue spellGroupVal = target->GetHighestExclusiveSameEffectSpellGroupValue(this, GetAuraType()); if (std::abs(spellGroupVal) >= std::abs(GetAmount())) return; @@ -4520,7 +4545,7 @@ void AuraEffect::HandleModCombatSpeedPct(AuraApplication const* aurApp, uint8 mo return; Unit* target = aurApp->GetTarget(); - int32 spellGroupVal = target->GetHighestExclusiveSameEffectSpellGroupValue(this, SPELL_AURA_MELEE_SLOW); + SpellEffectValue spellGroupVal = target->GetHighestExclusiveSameEffectSpellGroupValue(this, SPELL_AURA_MELEE_SLOW); if (std::abs(spellGroupVal) >= std::abs(GetAmount())) return; @@ -4555,7 +4580,7 @@ void AuraEffect::HandleModMeleeSpeedPct(AuraApplication const* aurApp, uint8 mod //! ToDo: Haste auras with the same handler _CAN'T_ stack together Unit* target = aurApp->GetTarget(); - int32 spellGroupVal = target->GetHighestExclusiveSameEffectSpellGroupValue(this, SPELL_AURA_MOD_MELEE_HASTE); + SpellEffectValue spellGroupVal = target->GetHighestExclusiveSameEffectSpellGroupValue(this, SPELL_AURA_MOD_MELEE_HASTE); if (std::abs(spellGroupVal) >= std::abs(GetAmount())) return; @@ -4595,7 +4620,7 @@ void AuraEffect::HandleModRating(AuraApplication const* aurApp, uint8 mode, bool for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating) if (GetMiscValue() & (1 << rating)) - target->ToPlayer()->ApplyRatingMod(CombatRating(rating), GetAmount(), apply); + target->ToPlayer()->ApplyRatingMod(CombatRating(rating), GetAmountAsInt(), apply); } void AuraEffect::HandleModRatingPct(AuraApplication const* aurApp, uint8 mode, bool /*apply*/) const @@ -4698,10 +4723,10 @@ void AuraEffect::HandleModDamageDone(AuraApplication const* aurApp, uint8 mode, for (uint16 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) if (GetMiscValue() & (1 << i)) { - if (GetAmount() >= 0) - playerTarget->ApplyModDamageDonePos(SpellSchools(i), GetAmount(), apply); + if (GetAmountAsInt() >= 0) + playerTarget->ApplyModDamageDonePos(SpellSchools(i), GetAmountAsInt(), apply); else - playerTarget->ApplyModDamageDoneNeg(SpellSchools(i), GetAmount(), apply); + playerTarget->ApplyModDamageDoneNeg(SpellSchools(i), GetAmountAsInt(), apply); } if (Guardian* pet = playerTarget->GetGuardianPet()) @@ -4789,7 +4814,7 @@ void AuraEffect::HandleModPowerCost(AuraApplication const* aurApp, uint8 mode, b for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) if (GetMiscValue() & (1 << i)) - target->ApplyModManaCostModifier(SpellSchools(i), GetAmount(), apply); + target->ApplyModManaCostModifier(SpellSchools(i), GetAmountAsInt(), apply); } void AuraEffect::HandleArenaPreparation(AuraApplication const* aurApp, uint8 mode, bool apply) const @@ -4949,7 +4974,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool break; case 52172: // Coyote Spirit Despawn Aura case 60244: // Blood Parrot Despawn Aura - target->CastSpell(nullptr, GetAmount(), this); + target->CastSpell(nullptr, GetAmountAsInt(), this); break; case 91604: // Restricted Flight Area if (aurApp->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE) @@ -4960,7 +4985,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool case SPELLFAMILY_DEATHKNIGHT: // Summon Gargoyle (Dismiss Gargoyle at remove) if (GetId() == 61777) - target->CastSpell(target, GetAmount(), this); + target->CastSpell(target, GetAmountAsInt(), this); break; default: break; @@ -5134,7 +5159,7 @@ void AuraEffect::HandleChannelDeathItem(AuraApplication const* aurApp, uint8 mod Unit* target = aurApp->GetTarget(); // Item amount - if (GetAmount() <= 0) + if (GetAmountAsInt() <= 0) return; if (GetSpellEffectInfo().ItemType == 0) @@ -5151,7 +5176,7 @@ void AuraEffect::HandleChannelDeathItem(AuraApplication const* aurApp, uint8 mod //Adding items uint32 noSpaceForCount = 0; - uint32 count = GetAmount(); + uint32 count = GetAmountAsInt(); ItemPosCountVec dest; InventoryResult msg = plCaster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, GetSpellEffectInfo().ItemType, count, &noSpaceForCount); @@ -5194,7 +5219,7 @@ void AuraEffect::HandleForceReaction(AuraApplication const* aurApp, uint8 mode, return; uint32 factionId = GetMiscValue(); - ReputationRank factionRank = ReputationRank(GetAmount()); + ReputationRank factionRank = ReputationRank(GetAmountAsInt()); player->GetReputationMgr().ApplyForceReaction(factionId, factionRank, apply); @@ -5342,7 +5367,7 @@ void AuraEffect::HandleTriggerSpellOnPowerPercent(AuraApplication const* aurApp, Unit* target = aurApp->GetTarget(); - int32 effectAmount = GetAmount(); + SpellEffectValue effectAmount = GetAmount(); uint32 triggerSpell = GetSpellEffectInfo().TriggerSpell; int32 maxPower = target->GetMaxPower(Powers(GetMiscValue())); if (!maxPower) @@ -5374,7 +5399,7 @@ void AuraEffect::HandleTriggerSpellOnPowerAmount(AuraApplication const* aurApp, Unit* target = aurApp->GetTarget(); - int32 effectAmount = GetAmount(); + SpellEffectValue effectAmount = GetAmount(); uint32 triggerSpell = GetSpellEffectInfo().TriggerSpell; float powerAmount = target->GetPower(Powers(GetMiscValue())); @@ -5440,20 +5465,20 @@ void AuraEffect::HandleAuraModFakeInebriation(AuraApplication const* aurApp, uin if (apply) { target->m_invisibilityDetect.AddFlag(INVISIBILITY_DRUNK); - target->m_invisibilityDetect.AddValue(INVISIBILITY_DRUNK, GetAmount()); + target->m_invisibilityDetect.AddValue(INVISIBILITY_DRUNK, GetAmountAsInt()); if (Player* playerTarget = target->ToPlayer()) - playerTarget->ApplyModFakeInebriation(GetAmount(), true); + playerTarget->ApplyModFakeInebriation(GetAmountAsInt(), true); } else { bool removeDetect = !target->HasAuraType(SPELL_AURA_MOD_FAKE_INEBRIATE); - target->m_invisibilityDetect.AddValue(INVISIBILITY_DRUNK, -GetAmount()); + target->m_invisibilityDetect.AddValue(INVISIBILITY_DRUNK, -GetAmountAsInt()); if (Player* playerTarget = target->ToPlayer()) { - playerTarget->ApplyModFakeInebriation(GetAmount(), false); + playerTarget->ApplyModFakeInebriation(GetAmountAsInt(), false); if (removeDetect) removeDetect = !playerTarget->GetDrunkValue(); @@ -5606,7 +5631,7 @@ void AuraEffect::HandlePeriodicTriggerSpellWithValueAuraTick(Unit* target, Unit* CastSpellExtraArgs args(this); args.SetTriggerFlags(TRIGGERED_FULL_MASK & ~(TRIGGERED_IGNORE_POWER_COST | TRIGGERED_IGNORE_REAGENT_COST)); for (std::size_t i = 0; i < triggeredSpellInfo->GetEffects().size(); ++i) - args.AddSpellMod(SpellValueMod(SPELLVALUE_BASE_POINT0 + i), GetAmount()); + args.AddSpellMod(SpellValueModFloat(SPELLVALUE_BASE_POINT0 + i), GetAmount()); triggerCaster->CastSpell(target, triggerSpellId, args); TC_LOG_DEBUG("spells.aura.effect", "AuraEffect::HandlePeriodicTriggerSpellWithValueAuraTick: Spell {} Trigger {}", GetId(), triggeredSpellInfo->Id); } @@ -5637,7 +5662,7 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const uint32 stackAmountForBonuses = !GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes::SuppressPointsStacking) ? GetBase()->GetStackAmount() : 1; // ignore negative values (can be result apply spellmods to aura damage - uint32 damage = std::max(GetAmount(), 0); + uint32 damage = std::max(GetAmountAsInt(), 0); // Script Hook For HandlePeriodicDamageAurasTick -- Allow scripts to change the Damage pre class mitigation calculations sScriptMgr->ModifyPeriodicDamageAurasTick(target, caster, damage); @@ -5771,7 +5796,7 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c uint32 stackAmountForBonuses = !GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes::SuppressPointsStacking) ? GetBase()->GetStackAmount() : 1; // ignore negative values (can be result apply spellmods to aura damage - uint32 damage = std::max(GetAmount(), 0); + uint32 damage = std::max(GetAmountAsInt(), 0); if (caster) damage = caster->SpellDamageBonusDone(target, GetSpellInfo(), damage, DOT, GetSpellEffectInfo(), stackAmountForBonuses, nullptr, this); @@ -5862,7 +5887,7 @@ void AuraEffect::HandlePeriodicHealthFunnelAuraTick(Unit* target, Unit* caster) return; } - uint32 damage = std::max(GetAmount(), 0); + uint32 damage = std::max(GetAmountAsInt(), 0); // do not kill health donator if (caster->GetHealth() < damage) damage = caster->GetHealth() - 1; @@ -5899,7 +5924,7 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const uint32 stackAmountForBonuses = !GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes::SuppressPointsStacking) ? GetBase()->GetStackAmount() : 1; // ignore negative values (can be result apply spellmods to aura damage - uint32 damage = std::max(GetAmount(), 0); + uint32 damage = std::max(GetAmountAsInt(), 0); if (GetAuraType() == SPELL_AURA_OBS_MOD_HEALTH) damage = uint32(target->CountPctFromMaxHealth(damage)); @@ -5957,7 +5982,7 @@ void AuraEffect::HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) con return; // ignore negative values (can be result apply spellmods to aura damage - int32 drainAmount = std::max(GetAmount(), 0); + int32 drainAmount = std::max(GetAmountAsInt(), 0); TC_LOG_DEBUG("spells.aura.effect", "PeriodicTick: {} power leech of {} for {} dmg inflicted by {}", GetCasterGUID().ToString(), target->GetGUID().ToString(), drainAmount, GetId()); @@ -5981,7 +6006,7 @@ void AuraEffect::HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) con // Drain Mana - Mana Feed effect if (caster->GetGuardianPet() && m_spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellInfo->SpellFamilyFlags[0] & 0x00000010) { - int32 manaFeedVal = 0; + SpellEffectValue manaFeedVal = 0; if (AuraEffect const* aurEff = GetBase()->GetEffect(EFFECT_1)) manaFeedVal = aurEff->GetAmount(); @@ -6028,7 +6053,7 @@ void AuraEffect::HandleObsModPowerAuraTick(Unit* target, Unit* caster) const return; } - int32 amount = GetAmount() * target->GetMaxPower(powerType) / 100; + int32 amount = CalculatePct(target->GetMaxPower(powerType), GetAmount()); TC_LOG_DEBUG("spells.aura.effect", "PeriodicTick: {} energize {} for {} dmg inflicted by {}", GetCasterGUID().ToString(), target->GetGUID().ToString(), amount, GetId()); @@ -6058,7 +6083,7 @@ void AuraEffect::HandlePeriodicEnergizeAuraTick(Unit* target, Unit* caster) cons return; // ignore negative values (can be result apply spellmods to aura damage - int32 amount = std::max(GetAmount(), 0); + int32 amount = std::max(GetAmountAsInt(), 0); SpellPeriodicAuraLogInfo pInfo(this, amount, amount, 0, 0, 0, 0.0f, false); @@ -6086,7 +6111,7 @@ void AuraEffect::HandlePeriodicPowerBurnAuraTick(Unit* target, Unit* caster) con } // ignore negative values (can be result apply spellmods to aura damage - int32 damage = std::max(GetAmount(), 0); + int32 damage = std::max(GetAmountAsInt(), 0); uint32 gain = uint32(-target->ModifyPower(powerType, -damage)); @@ -6135,7 +6160,7 @@ float AuraEffect::CalcPeriodicCritChance(Unit const* caster) const void AuraEffect::HandleBreakableCCAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo) { - int32 const damageLeft = GetAmount() - static_cast(eventInfo.GetDamageInfo()->GetDamage()); + SpellEffectValue const damageLeft = GetAmount() - static_cast(eventInfo.GetDamageInfo()->GetDamage()); if (damageLeft <= 0) aurApp->GetTarget()->RemoveAura(aurApp); @@ -6206,7 +6231,7 @@ void AuraEffect::HandleProcTriggerDamageAuraProc(AuraApplication* aurApp, ProcEv } SpellNonMeleeDamage damageInfo(target, triggerTarget, GetSpellInfo(), GetBase()->GetSpellVisual(), GetSpellInfo()->SchoolMask, GetBase()->GetCastId()); - uint32 damage = target->SpellDamageBonusDone(triggerTarget, GetSpellInfo(), GetAmount(), SPELL_DIRECT_DAMAGE, GetSpellEffectInfo(), 1, nullptr, this); + uint32 damage = target->SpellDamageBonusDone(triggerTarget, GetSpellInfo(), GetAmountAsInt(), SPELL_DIRECT_DAMAGE, GetSpellEffectInfo(), 1, nullptr, this); damage = triggerTarget->SpellDamageBonusTaken(target, GetSpellInfo(), damage, SPELL_DIRECT_DAMAGE); target->CalculateSpellDamageTaken(&damageInfo, damage, GetSpellInfo()); Unit::DealDamageMods(damageInfo.attacker, damageInfo.target, damageInfo.damage, &damageInfo.absorb); @@ -6257,9 +6282,9 @@ void AuraEffect::HandleModSpellCategoryCooldown(AuraApplication const* aurApp, u return; if (apply) - target->AddSpellCategoryCooldownMod(GetMiscValue(), GetAmount()); + target->AddSpellCategoryCooldownMod(GetMiscValue(), GetAmountAsInt()); else - target->RemoveSpellCategoryCooldownMod(GetMiscValue(), GetAmount()); + target->RemoveSpellCategoryCooldownMod(GetMiscValue(), GetAmountAsInt()); } void AuraEffect::HandleModRecoveryRate(AuraApplication const* aurApp, uint8 mode, bool apply) const diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h index 97bc61885a..4f02394b71 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -28,13 +28,13 @@ typedef void(AuraEffect::*pAuraEffectHandler)(AuraApplication const* aurApp, uin class TC_GAME_API AuraEffect { - friend void Aura::_InitEffects(uint32 effMask, Unit* caster, int32 const* baseAmount); + friend void Aura::_InitEffects(uint32 effMask, Unit* caster, SpellEffectValue const* baseAmount); friend Aura::~Aura(); friend class Unit; private: ~AuraEffect(); - explicit AuraEffect(Aura* base, SpellEffectInfo const& spellEfffectInfo, int32 const* baseAmount, Unit* caster); + explicit AuraEffect(Aura* base, SpellEffectInfo const& spellEfffectInfo, SpellEffectValue const* baseAmount, Unit* caster); public: Unit* GetCaster() const { return GetBase()->GetCaster(); } @@ -50,27 +50,28 @@ class TC_GAME_API AuraEffect SpellInfo const* GetSpellInfo() const { return m_spellInfo; } uint32 GetId() const { return m_spellInfo->Id; } SpellEffIndex GetEffIndex() const { return m_effectInfo.EffectIndex; } - int32 GetBaseAmount() const { return m_baseAmount; } + SpellEffectValue GetBaseAmount() const { return m_baseAmount; } int32 GetPeriod() const { return _period; } int32 GetMiscValueB() const { return GetSpellEffectInfo().MiscValueB; } int32 GetMiscValue() const { return GetSpellEffectInfo().MiscValue; } AuraType GetAuraType() const { return GetSpellEffectInfo().ApplyAuraName; } - int32 GetAmount() const { return _amount; } - void SetAmount(int32 amount) { _amount = amount; m_canBeRecalculated = false; } + int32 GetAmountAsInt() const { return static_cast(_amount); } + SpellEffectValue GetAmount() const { return _amount; } + void SetAmount(SpellEffectValue amount) { _amount = amount; m_canBeRecalculated = false; } - Optional GetEstimatedAmount() const { return _estimatedAmount; } + Optional GetEstimatedAmount() const { return _estimatedAmount; } int32 GetPeriodicTimer() const { return _periodicTimer; } void SetPeriodicTimer(int32 periodicTimer) { _periodicTimer = periodicTimer; } - int32 CalculateAmount(Unit* caster); - static Optional CalculateEstimatedAmount(Unit const* caster, Unit* target, SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, int32 amount, uint8 stack, AuraEffect const* aurEff); - Optional CalculateEstimatedAmount(Unit const* caster, int32 amount) const; - static float CalculateEstimatedfTotalPeriodicAmount(Unit* caster, Unit* target, SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, float amount, uint8 stack); + SpellEffectValue CalculateAmount(Unit* caster); + static Optional CalculateEstimatedAmount(Unit const* caster, Unit* target, SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, SpellEffectValue amount, uint8 stack, AuraEffect const* aurEff); + Optional CalculateEstimatedAmount(Unit const* caster, SpellEffectValue amount) const; + static SpellEffectValue CalculateEstimatedfTotalPeriodicAmount(Unit const* caster, Unit* target, SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, SpellEffectValue amount, uint8 stack); void CalculatePeriodic(Unit* caster, bool resetPeriodicTimer = true, bool load = false); void CalculateSpellMod(); - void ChangeAmount(int32 newAmount, bool mark = true, bool onStackOrReapply = false, AuraEffect const* triggeredBy = nullptr); + void ChangeAmount(SpellEffectValue newAmount, bool mark = true, bool onStackOrReapply = false, AuraEffect const* triggeredBy = nullptr); void RecalculateAmount(AuraEffect const* triggeredBy = nullptr) { if (!CanBeRecalculated()) return; ChangeAmount(CalculateAmount(GetCaster()), false, false, triggeredBy); } void RecalculateAmount(Unit* caster, AuraEffect const* triggeredBy = nullptr) { if (!CanBeRecalculated()) return; ChangeAmount(CalculateAmount(caster), false, false, triggeredBy); } bool CanBeRecalculated() const { return m_canBeRecalculated; } @@ -115,9 +116,9 @@ class TC_GAME_API AuraEffect SpellModifier* m_spellmod; - int32 const m_baseAmount; - int32 _amount; - Optional _estimatedAmount; // for periodic damage and healing auras this will include damage done bonuses + SpellEffectValue const m_baseAmount; + SpellEffectValue _amount; + Optional _estimatedAmount; // for periodic damage and healing auras this will include damage done bonuses // periodic stuff int32 _periodicTimer; diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 3a68549f23..58de70ec82 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -511,7 +511,7 @@ AuraScript* Aura::GetScriptByType(std::type_info const& type) const return nullptr; } -void Aura::_InitEffects(uint32 effMask, Unit* caster, int32 const* baseAmount) +void Aura::_InitEffects(uint32 effMask, Unit* caster, SpellEffectValue const* baseAmount) { // shouldn't be in constructor - functions in AuraEffect::AuraEffect use polymorphism _effects.resize(GetSpellInfo()->GetEffects().size()); @@ -1273,7 +1273,7 @@ AuraKey Aura::GenerateKey(uint32& recalculateMask) const return key; } -void Aura::SetLoadedState(int32 maxDuration, int32 duration, int32 charges, uint32 recalculateMask, int32* amount) +void Aura::SetLoadedState(int32 maxDuration, int32 duration, int32 charges, uint32 recalculateMask, SpellEffectValue const* amount) { m_maxDuration = maxDuration; m_duration = duration; @@ -1541,7 +1541,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b // effect on caster if (AuraEffect const* aurEff = aura->GetEffect(0)) { - float multiplier = float(aurEff->GetAmount()); + SpellEffectValue multiplier = aurEff->GetAmount(); CastSpellExtraArgs args(TRIGGERED_FULL_MASK); args.SetOriginalCastId(GetCastId()); args.AddSpellMod(SPELLVALUE_BASE_POINT0, CalculatePct(caster->GetMaxPower(POWER_MANA), multiplier)); @@ -2217,7 +2217,7 @@ void Aura::CallScriptEffectUpdatePeriodicHandlers(AuraEffect* aurEff) } } -void Aura::CallScriptEffectCalcAmountHandlers(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated) +void Aura::CallScriptEffectCalcAmountHandlers(AuraEffect const* aurEff, SpellEffectValue& amount, bool& canBeRecalculated) { for (AuraScript* script : m_loadedScripts) { diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index 101e32a516..872f964bfc 100644 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -113,7 +113,7 @@ struct TC_GAME_API AuraCreateInfo AuraCreateInfo& SetCasterGUID(ObjectGuid const& guid) { CasterGUID = guid; return *this; } AuraCreateInfo& SetCaster(Unit* caster) { Caster = caster; return *this; } - AuraCreateInfo& SetBaseAmount(int32 const* bp) { BaseAmount = bp; return *this; } + AuraCreateInfo& SetBaseAmount(SpellEffectValue const* bp) { BaseAmount = bp; return *this; } AuraCreateInfo& SetCastItem(ObjectGuid const& guid, uint32 itemId, int32 itemLevel) { CastItemGUID = guid; CastItemId = itemId; CastItemLevel = itemLevel; return *this; } AuraCreateInfo& SetPeriodicReset(bool reset) { ResetPeriodicTimer = reset; return *this; } AuraCreateInfo& SetIsRefresh(bool* isRefresh) { IsRefresh = isRefresh; return *this; } @@ -126,7 +126,7 @@ struct TC_GAME_API AuraCreateInfo ObjectGuid CasterGUID; Unit* Caster = nullptr; - int32 const* BaseAmount = nullptr; + SpellEffectValue const* BaseAmount = nullptr; ObjectGuid CastItemGUID; uint32 CastItemId = 0; int32 CastItemLevel = -1; @@ -160,8 +160,8 @@ struct AuraKey struct AuraLoadEffectInfo { - std::array Amounts; - std::array BaseAmounts; + std::array Amounts; + std::array BaseAmounts; }; class TC_GAME_API Aura @@ -176,7 +176,7 @@ class TC_GAME_API Aura static Aura* TryCreate(AuraCreateInfo& createInfo); static Aura* Create(AuraCreateInfo& createInfo); explicit Aura(AuraCreateInfo const& createInfo); - void _InitEffects(uint32 effMask, Unit* caster, int32 const* baseAmount); + void _InitEffects(uint32 effMask, Unit* caster, SpellEffectValue const* baseAmount); virtual ~Aura(); SpellInfo const* GetSpellInfo() const { return m_spellInfo; } @@ -269,7 +269,7 @@ class TC_GAME_API Aura * @return Aura key. */ AuraKey GenerateKey(uint32& recalculateMask) const; - void SetLoadedState(int32 maxDuration, int32 duration, int32 charges, uint32 recalculateMask, int32* amount); + void SetLoadedState(int32 maxDuration, int32 duration, int32 charges, uint32 recalculateMask, SpellEffectValue const* amount); // helpers for aura effects bool CanPeriodicTickCrit() const; @@ -323,7 +323,7 @@ class TC_GAME_API Aura void CallScriptAfterEffectRemoveHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, AuraEffectHandleModes mode); bool CallScriptEffectPeriodicHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp); void CallScriptEffectUpdatePeriodicHandlers(AuraEffect* aurEff); - void CallScriptEffectCalcAmountHandlers(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated); + void CallScriptEffectCalcAmountHandlers(AuraEffect const* aurEff, SpellEffectValue& amount, bool& canBeRecalculated); void CallScriptEffectCalcPeriodicHandlers(AuraEffect const* aurEff, bool& isPeriodic, int32& amplitude); void CallScriptEffectCalcSpellModHandlers(AuraEffect const* aurEff, SpellModifier*& spellMod); void CallScriptEffectCalcCritChanceHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, Unit const* victim, float& critChance); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 440dbb0acd..d73bcdc3e2 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -438,10 +438,12 @@ void SpellCastTargets::Update(WorldObject* caster) SpellValue::SpellValue(SpellInfo const* proto, WorldObject const* caster) { - memset(EffectBasePoints, 0, sizeof(EffectBasePoints)); for (SpellEffectInfo const& spellEffectInfo : proto->GetEffects()) EffectBasePoints[spellEffectInfo.EffectIndex] = spellEffectInfo.CalcBaseValue(caster, nullptr, 0, -1); + for (std::size_t i = proto->GetEffects().size(); i < std::size(EffectBasePoints); ++i) + EffectBasePoints[i] = 0.0; + CustomBasePointsMask = 0; MaxAffectedTargets = proto->MaxAffectedTargets; RadiusMod = 1.0f; @@ -549,7 +551,7 @@ m_spellValue(new SpellValue(m_spellInfo, caster)), _spellEvent(nullptr) gameObjTarget = nullptr; m_corpseTarget = nullptr; destTarget = nullptr; - damage = 0; + effectValue = 0.0; targetMissInfo = SPELL_MISS_NONE; variance = 0.0f; effectHandleMode = SPELL_EFFECT_HANDLE_LAUNCH; @@ -5015,9 +5017,9 @@ int32 Spell::GetSpellCastDataAmmo() return ammoDisplayID; } -static std::pair CalcPredictedHealing(SpellInfo const* spellInfo, Unit const* unitCaster, Unit* target, uint32 castItemEntry, int32 castItemLevel, Spell* spell, bool withPeriodic) +static std::pair CalcPredictedHealing(SpellInfo const* spellInfo, Unit const* unitCaster, Unit* target, uint32 castItemEntry, int32 castItemLevel, Spell* spell, bool withPeriodic) { - int32 points = 0; + SpellEffectValue points = 0; SpellHealPredictionType type = SPELL_HEAL_PREDICTION_TARGET; for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) { @@ -5072,7 +5074,7 @@ void Spell::UpdateSpellHealPrediction(WorldPackets::Spells::SpellHealPrediction& if (Unit* target = m_targets.GetUnitTarget()) { auto [points, type] = CalcPredictedHealing(m_spellInfo, unitCaster, target, m_castItemEntry, m_castItemLevel, this, withPeriodic); - healPrediction.Points = points; + healPrediction.Points = static_cast(points); healPrediction.Type = type; } @@ -5761,7 +5763,7 @@ void Spell::HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGoT destTarget = &m_destTargets[spellEffectInfo.EffectIndex]._position; effectInfo = &spellEffectInfo; - damage = CalculateDamage(spellEffectInfo, unitTarget, &variance); + effectValue = CalculateDamage(spellEffectInfo, unitTarget, &variance); bool preventDefault = CallScriptEffectHandlers(spellEffectInfo.EffectIndex, mode); @@ -6517,7 +6519,7 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32 Optional petSlot; if (!spellEffectInfo.MiscValue) { - petSlot = PetSaveMode(spellEffectInfo.CalcValue()); + petSlot = PetSaveMode(spellEffectInfo.CalcValueAsInt()); // No pet can be summoned if any pet is dead for (Optional const& activePet : playerCaster->GetPetStable()->ActivePets) @@ -6849,8 +6851,8 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32 if (target->GetOwner() && target->GetOwner()->GetTypeId() == TYPEID_PLAYER) return SPELL_FAILED_TARGET_IS_PLAYER_CONTROLLED; - int32 value = CalculateDamage(spellEffectInfo, target); - if (value && int32(target->GetLevelForTarget(m_caster)) > value) + SpellEffectValue value = CalculateDamage(spellEffectInfo, target); + if (value && target->GetLevelForTarget(m_caster) > value) return SPELL_FAILED_HIGHLEVEL; } @@ -7244,10 +7246,14 @@ SpellCastResult Spell::CheckMovement() const return SPELL_CAST_OK; } -int32 Spell::CalculateDamage(SpellEffectInfo const& spellEffectInfo, Unit const* target, float* var /*= nullptr*/) const +SpellEffectValue Spell::CalculateDamage(SpellEffectInfo const& spellEffectInfo, Unit const* target, float* var /*= nullptr*/) const { + if (var) + *var = 0.0f; + bool needRecalculateBasePoints = !(m_spellValue->CustomBasePointsMask & (1 << spellEffectInfo.EffectIndex)); - return m_caster->CalculateSpellDamage(target, spellEffectInfo, needRecalculateBasePoints ? nullptr : &m_spellValue->EffectBasePoints[spellEffectInfo.EffectIndex], var, m_castItemEntry, m_castItemLevel); + SpellEffectValue* basePoints = needRecalculateBasePoints ? nullptr : &m_spellValue->EffectBasePoints[spellEffectInfo.EffectIndex]; + return spellEffectInfo.CalcValue(m_caster, basePoints, target, var, m_castItemEntry, m_castItemLevel); } bool Spell::CanAutoCast(Unit* target) @@ -7685,7 +7691,7 @@ SpellCastResult Spell::CheckItems(int32* param1 /*= nullptr*/, int32* param2 /*= if (!itemTemplate) return SPELL_FAILED_ITEM_NOT_FOUND; - uint32 createCount = std::clamp(spellEffectInfo.CalcValue(), 1u, itemTemplate->GetMaxStackSize()); + uint32 createCount = std::clamp(spellEffectInfo.CalcValueAsInt(), 1u, itemTemplate->GetMaxStackSize()); ItemPosCountVec dest; InventoryResult msg = target->ToPlayer()->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, spellEffectInfo.ItemType, createCount); if (msg != EQUIP_ERR_OK) @@ -7707,7 +7713,7 @@ SpellCastResult Spell::CheckItems(int32* param1 /*= nullptr*/, int32* param2 /*= return SPELL_FAILED_DONT_REPORT; } else if (m_spellInfo->GetEffects().size() > EFFECT_1) - player->CastSpell(player, m_spellInfo->GetEffect(EFFECT_1).CalcValue(), CastSpellExtraArgs() + player->CastSpell(player, m_spellInfo->GetEffect(EFFECT_1).CalcValueAsInt(), CastSpellExtraArgs() .SetTriggeringSpell(this)); // move this to anywhere return SPELL_FAILED_DONT_REPORT; } @@ -8045,10 +8051,10 @@ void Spell::Delayed() // only called in DealDamage() //check pushback reduce int32 delaytime = 500; // spellcasting delay is normally 500ms - int32 delayReduce = 100; // must be initialized to 100 for percent modifiers + float delayReduce = 100.0f; // must be initialized to 100 for percent modifiers if (Player* player = unitCaster->GetSpellModOwner()) player->ApplySpellMod(m_spellInfo, SpellModOp::ResistPushback, delayReduce, this); - delayReduce += unitCaster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100; + delayReduce += unitCaster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100.0f; if (delayReduce >= 100) return; @@ -8087,10 +8093,10 @@ void Spell::DelayedChannel() int32 delaytime = CalculatePct(duration, 25); // channeling delay is normally 25% of its time per hit - int32 delayReduce = 100; // must be initialized to 100 for percent modifiers + float delayReduce = 100.0f; // must be initialized to 100 for percent modifiers if (Player* player = unitCaster->GetSpellModOwner()) player->ApplySpellMod(m_spellInfo, SpellModOp::ResistPushback, delayReduce, this); - delayReduce += unitCaster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100; + delayReduce += unitCaster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100.0f; if (delayReduce >= 100) return; @@ -8227,8 +8233,8 @@ bool Spell::CheckEffectTarget(Unit const* target, SpellEffectInfo const& spellEf return false; if (!target->GetCharmerGUID().IsEmpty()) return false; - if (int32 value = CalculateDamage(spellEffectInfo, target)) - if ((int32)target->GetLevelForTarget(m_caster) > value) + if (SpellEffectValue value = CalculateDamage(spellEffectInfo, target)) + if (target->GetLevelForTarget(m_caster) > value) return false; break; default: @@ -8743,7 +8749,7 @@ SpellCastResult Spell::CanOpenLock(SpellEffectInfo const& effect, uint32 lockId, // skill bonus provided by casting spell (mostly item spells) // add the effect base points modifier from the spell cast (cheat lock / skeleton key etc.) if (effect.TargetA.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET || effect.TargetB.GetTarget() == TARGET_GAMEOBJECT_ITEM_TARGET) - skillValue += effect.CalcValue(); + skillValue += effect.CalcValueAsInt(); if (skillValue < reqSkillValue) return SPELL_FAILED_LOW_CASTLEVEL; @@ -8769,7 +8775,7 @@ void Spell::SetSpellValue(CastSpellExtraArgsInit::SpellValueOverride const& valu { if (value.Type >= SPELLVALUE_BASE_POINT0 && value.Type < SPELLVALUE_BASE_POINT_END) { - m_spellValue->EffectBasePoints[value.Type - SPELLVALUE_BASE_POINT0] = value.Value.I; + m_spellValue->EffectBasePoints[value.Type - SPELLVALUE_BASE_POINT0] = value.Value.F; m_spellValue->CustomBasePointsMask |= 1 << (value.Type - SPELLVALUE_BASE_POINT0); return; } @@ -8798,7 +8804,7 @@ void Spell::SetSpellValue(CastSpellExtraArgsInit::SpellValueOverride const& valu m_spellValue->CriticalChance = value.Value.F; break; case SPELLVALUE_DURATION_PCT: - m_spellValue->DurationMul = value.Value.F / 100.0f; + m_spellValue->DurationMul = value.Value.F / 100.0; break; default: break; @@ -9186,9 +9192,9 @@ void Spell::PrepareTriggersExecutedOnHit() { // calculate the chance using spell base amount, because aura amount is not updated on combo-points change // this possibly needs fixing - int32 auraBaseAmount = aurEff->GetBaseAmount(); + SpellEffectValue auraBaseAmount = aurEff->GetBaseAmount(); // proc chance is stored in effect amount - int32 chance = unitCaster->CalculateSpellDamage(nullptr, aurEff->GetSpellEffectInfo(), &auraBaseAmount); + int32 chance = aurEff->GetSpellEffectInfo().CalcValueAsInt(unitCaster, &auraBaseAmount); chance *= aurEff->GetBase()->GetStackAmount(); // build trigger and add to the list diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index cb8bcc4f1b..28ce4960de 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -239,7 +239,7 @@ struct SpellLogEffect struct SpellValue { explicit SpellValue(SpellInfo const* proto, WorldObject const* caster); - int32 EffectBasePoints[MAX_SPELL_EFFECTS]; + SpellEffectValue EffectBasePoints[MAX_SPELL_EFFECTS]; uint32 CustomBasePointsMask; uint32 MaxAffectedTargets; float RadiusMod; @@ -543,7 +543,7 @@ class TC_GAME_API Spell bool CheckSpellCancelsConfuse(int32* param1) const; bool CheckSpellCancelsNoActions(int32* param1) const; - int32 CalculateDamage(SpellEffectInfo const& spellEffectInfo, Unit const* target, float* var = nullptr) const; + SpellEffectValue CalculateDamage(SpellEffectInfo const& spellEffectInfo, Unit const* target, float* var = nullptr) const; void Delayed(); void DelayedChannel(); @@ -799,7 +799,8 @@ class TC_GAME_API Spell GameObject* gameObjTarget; Corpse* m_corpseTarget; WorldLocation* destTarget; - int32 damage; + SpellEffectValue effectValue; + inline int32 GetEffectValueAsInt() const { return static_cast(effectValue); } SpellMissInfo targetMissInfo; float variance; SpellEffectHandleMode effectHandleMode; @@ -865,7 +866,7 @@ class TC_GAME_API Spell // info set at PreprocessTarget, used by DoTargetSpellHit DiminishingGroup DRGroup = DIMINISHING_NONE; int32 AuraDuration = 0; - int32 AuraBasePoints[MAX_SPELL_EFFECTS] = { }; + SpellEffectValue AuraBasePoints[MAX_SPELL_EFFECTS] = { }; UnitAura* HitAura = nullptr; ProcFlagsHit ProcHitMask = { }; diff --git a/src/server/game/Spells/SpellDefines.h b/src/server/game/Spells/SpellDefines.h index 2415f72501..50fa4eca45 100644 --- a/src/server/game/Spells/SpellDefines.h +++ b/src/server/game/Spells/SpellDefines.h @@ -212,7 +212,18 @@ enum class SpellPvpModifier : uint8 enum SpellValueMod : int32 { - SPELLVALUE_BASE_POINT0, + SPELLVALUE_MAX_TARGETS, + SPELLVALUE_AURA_STACK, + SPELLVALUE_DURATION, + SPELLVALUE_PARENT_SPELL_TARGET_COUNT, + SPELLVALUE_PARENT_SPELL_TARGET_INDEX, + + SPELLVALUE_INT_END +}; + +enum SpellValueModFloat : int32 +{ + SPELLVALUE_BASE_POINT0 = uint8(SPELLVALUE_INT_END), SPELLVALUE_BASE_POINT1, SPELLVALUE_BASE_POINT2, SPELLVALUE_BASE_POINT3, @@ -247,18 +258,7 @@ enum SpellValueMod : int32 SPELLVALUE_BASE_POINT_END, - SPELLVALUE_MAX_TARGETS = SPELLVALUE_BASE_POINT_END, - SPELLVALUE_AURA_STACK, - SPELLVALUE_DURATION, - SPELLVALUE_PARENT_SPELL_TARGET_COUNT, - SPELLVALUE_PARENT_SPELL_TARGET_INDEX, - - SPELLVALUE_INT_END -}; - -enum SpellValueModFloat : int32 -{ - SPELLVALUE_RADIUS_MOD = uint8(SPELLVALUE_INT_END), + SPELLVALUE_RADIUS_MOD = SPELLVALUE_BASE_POINT_END, SPELLVALUE_CRIT_CHANCE, SPELLVALUE_DURATION_PCT, }; @@ -493,12 +493,12 @@ struct CastSpellExtraArgsInit struct SpellValueOverride { SpellValueOverride(SpellValueMod mod, int32 val) : Type(mod) { Value.I = val; } - SpellValueOverride(SpellValueModFloat mod, float val) : Type(mod) { Value.F = val; } + SpellValueOverride(SpellValueModFloat mod, SpellEffectValue val) : Type(mod) { Value.F = val; } int32 Type; union { - float F; + SpellEffectValue F; int32 I; } Value; }; @@ -518,7 +518,7 @@ struct TC_GAME_API CastSpellExtraArgs : public CastSpellExtraArgsInit CastSpellExtraArgs(AuraEffect const* eff) { TriggerFlags = TRIGGERED_FULL_MASK; SetTriggeringAura(eff); } CastSpellExtraArgs(Difficulty castDifficulty) { CastDifficulty = castDifficulty; } CastSpellExtraArgs(SpellValueMod mod, int32 val) { SpellValueOverrides.emplace_back(mod, val); } - CastSpellExtraArgs(SpellValueModFloat mod, float val) { SpellValueOverrides.emplace_back(mod, val); } + CastSpellExtraArgs(SpellValueModFloat mod, SpellEffectValue val) { SpellValueOverrides.emplace_back(mod, val); } CastSpellExtraArgs(CastSpellExtraArgsInit&& init) : CastSpellExtraArgsInit(std::move(init)) { SetTriggeringSpell(TriggeringSpell); } CastSpellExtraArgs(CastSpellExtraArgs const& other); @@ -537,8 +537,8 @@ struct TC_GAME_API CastSpellExtraArgs : public CastSpellExtraArgsInit CastSpellExtraArgs& SetCastDifficulty(Difficulty castDifficulty) { CastDifficulty = castDifficulty; return *this; } CastSpellExtraArgs& SetOriginalCastId(ObjectGuid const& castId) { OriginalCastId = castId; return *this; } CastSpellExtraArgs& AddSpellMod(SpellValueMod mod, int32 val) { SpellValueOverrides.emplace_back(mod, val); return *this; } - CastSpellExtraArgs& AddSpellMod(SpellValueModFloat mod, float val) { SpellValueOverrides.emplace_back(mod, val); return *this; } - CastSpellExtraArgs& AddSpellBP0(int32 val) { return AddSpellMod(SPELLVALUE_BASE_POINT0, val); } // because i don't want to type SPELLVALUE_BASE_POINT0 300 times + CastSpellExtraArgs& AddSpellMod(SpellValueModFloat mod, SpellEffectValue val) { SpellValueOverrides.emplace_back(mod, val); return *this; } + CastSpellExtraArgs& AddSpellBP0(SpellEffectValue val) { return AddSpellMod(SPELLVALUE_BASE_POINT0, val); } // because i don't want to type SPELLVALUE_BASE_POINT0 300 times CastSpellExtraArgs& SetCustomArg(std::any customArg) { CustomArg = std::move(customArg); return *this; } CastSpellExtraArgs& SetScriptResult(Scripting::v2::ActionResultSetter&& scriptResult) { ScriptResult = std::move(scriptResult); return *this; } CastSpellExtraArgs& SetScriptWaitsForSpellHit(bool scriptWaitsForSpellHit) { ScriptWaitsForSpellHit = scriptWaitsForSpellHit; return *this; } diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 5ca21302a6..d261fcc2f5 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -477,7 +477,7 @@ void Spell::EffectResurrectNew() if (player->IsResurrectRequested()) // already have one active request return; - uint32 health = damage; + uint32 health = GetEffectValueAsInt(); uint32 mana = effectInfo->MiscValue; ExecuteLogEffectResurrect(SpellEffectName(effectInfo->Effect), player); player->SetResurrectRequestData(m_caster, health, mana, 0); @@ -516,6 +516,7 @@ void Spell::EffectEnvironmentalDMG() if (!unitTarget || !unitTarget->IsAlive()) return; + uint32 damage = GetEffectValueAsInt(); // CalcAbsorbResist already in Player::EnvironmentalDamage if (unitTarget->GetTypeId() == TYPEID_PLAYER) unitTarget->ToPlayer()->EnvironmentalDamage(DAMAGE_FIRE, damage); @@ -543,6 +544,7 @@ void Spell::EffectSchoolDMG() if (unitTarget && unitTarget->IsAlive()) { + int32 damage = GetEffectValueAsInt(); bool apply_direct_bonus = true; // Meteor like spells (divided damage to targets) @@ -556,9 +558,9 @@ void Spell::EffectSchoolDMG() Unit* unitCaster = GetUnitCasterForEffectHandlers(); if (unitCaster && apply_direct_bonus) { - uint32 bonus = unitCaster->SpellDamageBonusDone(unitTarget, m_spellInfo, (uint32)damage, SPELL_DIRECT_DAMAGE, *effectInfo, 1, this); - damage = bonus + uint32(bonus * variance); - damage = unitTarget->SpellDamageBonusTaken(unitCaster, m_spellInfo, (uint32)damage, SPELL_DIRECT_DAMAGE); + int32 bonus = unitCaster->SpellDamageBonusDone(unitTarget, m_spellInfo, damage, SPELL_DIRECT_DAMAGE, *effectInfo, 1, this); + damage = bonus + int32(bonus * variance); + damage = unitTarget->SpellDamageBonusTaken(unitCaster, m_spellInfo, damage, SPELL_DIRECT_DAMAGE); } m_damage += damage; @@ -690,7 +692,7 @@ void Spell::EffectTriggerSpell() delay = Milliseconds(effectInfo->MiscValue); m_caster->m_Events.AddEventAtOffset([caster = m_caster, targets, originalCaster = m_originalCasterGUID, castItemGuid = m_castItemGUID, originalCastId = m_castId, - spellEffectInfo = effectInfo, value = damage, itemLevel = m_castItemLevel, targetCount, targetIndex]() mutable + spellEffectInfo = effectInfo, value = effectValue, itemLevel = m_castItemLevel, targetCount, targetIndex]() mutable { targets.Update(caster); // refresh pointers stored in targets @@ -707,7 +709,7 @@ void Spell::EffectTriggerSpell() // set basepoints for trigger with value effect if (spellEffectInfo->Effect == SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE) for (std::size_t i = 0; i < spellInfo->GetEffects().size(); ++i) - args.AddSpellMod(SpellValueMod(SPELLVALUE_BASE_POINT0 + i), value); + args.AddSpellMod(SpellValueModFloat(SPELLVALUE_BASE_POINT0 + i), value); if (targetCount) args.AddSpellMod(SPELLVALUE_PARENT_SPELL_TARGET_COUNT, *targetCount); @@ -773,7 +775,7 @@ void Spell::EffectTriggerMissileSpell() // set basepoints for trigger with value effect if (effectInfo->Effect == SPELL_EFFECT_TRIGGER_MISSILE_SPELL_WITH_VALUE) for (std::size_t i = 0; i < spellInfo->GetEffects().size(); ++i) - args.AddSpellMod(SpellValueMod(SPELLVALUE_BASE_POINT0 + i), damage); + args.AddSpellMod(SpellValueModFloat(SPELLVALUE_BASE_POINT0 + i), effectValue); if (targetCount) args.AddSpellMod(SPELLVALUE_PARENT_SPELL_TARGET_COUNT, *targetCount); @@ -809,20 +811,20 @@ void Spell::EffectForceCast() return; } - if (effectInfo->Effect == SPELL_EFFECT_FORCE_CAST && damage) + if (effectInfo->Effect == SPELL_EFFECT_FORCE_CAST) { switch (m_spellInfo->Id) { case 52588: // Skeletal Gryphon Escape case 48598: // Ride Flamebringer Cue - unitTarget->RemoveAura(damage); + unitTarget->RemoveAura(GetEffectValueAsInt()); break; case 52463: // Hide In Mine Car case 52349: // Overtake { CastSpellExtraArgs args(TRIGGERED_FULL_MASK); args.SetOriginalCaster(m_originalCasterGUID); - args.AddSpellMod(SPELLVALUE_BASE_POINT0, damage); + args.AddSpellMod(SPELLVALUE_BASE_POINT0, effectValue); unitTarget->CastSpell(unitTarget, spellInfo->Id, args); return; } @@ -840,7 +842,7 @@ void Spell::EffectForceCast() CastSpellExtraArgs args(TRIGGERED_FULL_MASK & ~(TRIGGERED_IGNORE_POWER_COST | TRIGGERED_CAST_DIRECTLY | TRIGGERED_IGNORE_REAGENT_COST)); if (effectInfo->Effect == SPELL_EFFECT_FORCE_CAST_WITH_VALUE) for (std::size_t i = 0; i < spellInfo->GetEffects().size(); ++i) - args.AddSpellMod(SpellValueMod(SPELLVALUE_BASE_POINT0 + i), damage); + args.AddSpellMod(SpellValueModFloat(SPELLVALUE_BASE_POINT0 + i), effectValue); unitTarget->CastSpell(m_caster, spellInfo->Id, args); } @@ -1148,31 +1150,32 @@ void Spell::EffectPowerDrain() if (effectInfo->MiscValue < 0 || effectInfo->MiscValue >= int8(MAX_POWERS)) return; + int32 drainAmount = GetEffectValueAsInt(); Powers powerType = Powers(effectInfo->MiscValue); - if (!unitTarget || !unitTarget->IsAlive() || unitTarget->GetPowerType() != powerType || damage < 0) + if (!unitTarget || !unitTarget->IsAlive() || unitTarget->GetPowerType() != powerType || drainAmount < 0) return; Unit* unitCaster = GetUnitCasterForEffectHandlers(); // add spell damage bonus if (unitCaster) { - uint32 bonus = unitCaster->SpellDamageBonusDone(unitTarget, m_spellInfo, uint32(damage), SPELL_DIRECT_DAMAGE, *effectInfo, 1, this); - damage = bonus + uint32(bonus * variance); - damage = unitTarget->SpellDamageBonusTaken(unitCaster, m_spellInfo, uint32(damage), SPELL_DIRECT_DAMAGE); + int32 bonus = unitCaster->SpellDamageBonusDone(unitTarget, m_spellInfo, drainAmount, SPELL_DIRECT_DAMAGE, *effectInfo, 1, this); + drainAmount = bonus + int32(bonus * variance); + drainAmount = unitTarget->SpellDamageBonusTaken(unitCaster, m_spellInfo, drainAmount, SPELL_DIRECT_DAMAGE); } - int32 newDamage = -(unitTarget->ModifyPower(powerType, -damage)); + int32 damage = -unitTarget->ModifyPower(powerType, -drainAmount); // Don't restore from self drain float gainMultiplier = 0.f; if (unitCaster && unitCaster != unitTarget) { gainMultiplier = effectInfo->CalcValueMultiplier(unitCaster, this); - int32 const gain = int32(newDamage * gainMultiplier); + int32 const gain = int32(damage * gainMultiplier); unitCaster->EnergizeBySpell(unitCaster, m_spellInfo, gain, powerType); } - ExecuteLogEffectTakeTargetPower(SpellEffectName(effectInfo->Effect), unitTarget, powerType, newDamage, gainMultiplier); + ExecuteLogEffectTakeTargetPower(SpellEffectName(effectInfo->Effect), unitTarget, powerType, damage, gainMultiplier); } void Spell::EffectSendEvent() @@ -1221,21 +1224,22 @@ void Spell::EffectPowerBurn() if (effectInfo->MiscValue < 0 || effectInfo->MiscValue >= int8(MAX_POWERS)) return; + int32 burnAmount = GetEffectValueAsInt(); Powers powerType = Powers(effectInfo->MiscValue); - if (!unitTarget || !unitTarget->IsAlive() || unitTarget->GetPowerType() != powerType || damage < 0) + if (!unitTarget || !unitTarget->IsAlive() || unitTarget->GetPowerType() != powerType || burnAmount < 0) return; - int32 newDamage = -(unitTarget->ModifyPower(powerType, -damage)); + int32 damage = -unitTarget->ModifyPower(powerType, -burnAmount); // NO - Not a typo - EffectPowerBurn uses effect value multiplier - not effect damage multiplier float dmgMultiplier = effectInfo->CalcValueMultiplier(GetUnitCasterForEffectHandlers(), this); // add log data before multiplication (need power amount, not damage) - ExecuteLogEffectTakeTargetPower(SpellEffectName(effectInfo->Effect), unitTarget, powerType, newDamage, 0.0f); + ExecuteLogEffectTakeTargetPower(SpellEffectName(effectInfo->Effect), unitTarget, powerType, damage, 0.0f); - newDamage = int32(newDamage * dmgMultiplier); + damage = int32(damage * dmgMultiplier); - m_damage += newDamage; + m_damage += damage; } void Spell::EffectHeal() @@ -1243,7 +1247,9 @@ void Spell::EffectHeal() if (effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH_TARGET) return; - if (!unitTarget || !unitTarget->IsAlive() || damage < 0) + int32 addhealth = GetEffectValueAsInt(); + + if (!unitTarget || !unitTarget->IsAlive() || addhealth < 0) return; Unit* unitCaster = GetUnitCasterForEffectHandlers(); @@ -1252,8 +1258,6 @@ void Spell::EffectHeal() if (!unitCaster) return; - int32 addhealth = damage; - // Vessel of the Naaru (Vial of the Sunwell trinket) ///@todo: move this to scripts if (m_spellInfo->Id == 45064) @@ -1270,11 +1274,11 @@ void Spell::EffectHeal() } // Death Pact - return pct of max health to caster else if (m_spellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && m_spellInfo->SpellFamilyFlags[0] & 0x00080000) - addhealth = unitCaster->SpellHealingBonusDone(unitTarget, m_spellInfo, int32(unitCaster->CountPctFromMaxHealth(damage)), HEAL, *effectInfo, 1, this); + addhealth = unitCaster->SpellHealingBonusDone(unitTarget, m_spellInfo, int32(unitCaster->CountPctFromMaxHealth(addhealth)), HEAL, *effectInfo, 1, this); else { - uint32 bonus = unitCaster->SpellHealingBonusDone(unitTarget, m_spellInfo, addhealth, HEAL, *effectInfo, 1, this); - addhealth = bonus + uint32(bonus * variance); + int32 bonus = unitCaster->SpellHealingBonusDone(unitTarget, m_spellInfo, addhealth, HEAL, *effectInfo, 1, this); + addhealth = bonus + int32(bonus * variance); } addhealth = unitTarget->SpellHealingBonusTaken(unitCaster, m_spellInfo, addhealth, HEAL); @@ -1291,10 +1295,10 @@ void Spell::EffectHealPct() if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (!unitTarget || !unitTarget->IsAlive() || damage < 0) + if (!unitTarget || !unitTarget->IsAlive() || effectValue < 0) return; - uint32 heal = unitTarget->CountPctFromMaxHealth(damage); + int32 heal = unitTarget->CountPctFromMaxHealth(effectValue); if (Unit* unitCaster = GetUnitCasterForEffectHandlers()) { heal = unitCaster->SpellHealingBonusDone(unitTarget, m_spellInfo, heal, HEAL, *effectInfo, 1, this); @@ -1309,15 +1313,15 @@ void Spell::EffectHealMechanical() if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (!unitTarget || !unitTarget->IsAlive() || damage < 0) + if (!unitTarget || !unitTarget->IsAlive() || effectValue < 0) return; Unit* unitCaster = GetUnitCasterForEffectHandlers(); - uint32 heal = damage; + int32 heal = GetEffectValueAsInt(); if (unitCaster) heal = unitCaster->SpellHealingBonusDone(unitTarget, m_spellInfo, heal, HEAL, *effectInfo, 1, this); - heal += uint32(heal * variance); + heal += int32(heal * variance); if (unitCaster) heal = unitTarget->SpellHealingBonusTaken(unitCaster, m_spellInfo, heal, HEAL); @@ -1329,20 +1333,19 @@ void Spell::EffectHealthLeech() if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; + int32 damage = GetEffectValueAsInt(); if (!unitTarget || !unitTarget->IsAlive() || damage < 0) return; Unit* unitCaster = GetUnitCasterForEffectHandlers(); - uint32 bonus = 0; + int32 bonus = 0; if (unitCaster) - bonus = unitCaster->SpellDamageBonusDone(unitTarget, m_spellInfo, uint32(damage), SPELL_DIRECT_DAMAGE, *effectInfo, 1, this); + bonus = unitCaster->SpellDamageBonusDone(unitTarget, m_spellInfo, damage, SPELL_DIRECT_DAMAGE, *effectInfo, 1, this); - damage = bonus + uint32(bonus * variance); + damage = bonus + int32(bonus * variance); if (unitCaster) - damage = unitTarget->SpellDamageBonusTaken(unitCaster, m_spellInfo, uint32(damage), SPELL_DIRECT_DAMAGE); - - TC_LOG_DEBUG("spells", "HealthLeech :{}", damage); + damage = unitTarget->SpellDamageBonusTaken(unitCaster, m_spellInfo, damage, SPELL_DIRECT_DAMAGE); float healMultiplier = effectInfo->CalcValueMultiplier(unitCaster, this); @@ -1354,7 +1357,7 @@ void Spell::EffectHealthLeech() damage -= absorb; // get max possible damage, don't count overkill for heal - uint32 healthGain = uint32(-unitTarget->GetHealthGain(-damage) * healMultiplier); + int32 healthGain = int32(-unitTarget->GetHealthGain(-damage) * healMultiplier); if (unitCaster && unitCaster->IsAlive()) { @@ -1381,12 +1384,7 @@ void Spell::DoCreateItem(uint32 itemId, ItemContext context /*= ItemContext::NON return; } - uint32 num_to_add = damage; - - if (num_to_add < 1) - num_to_add = 1; - if (num_to_add > pProto->GetMaxStackSize()) - num_to_add = pProto->GetMaxStackSize(); + uint32 num_to_add = std::clamp(GetEffectValueAsInt(), 1, pProto->GetMaxStackSize()); /* == gem perfection handling == */ // this is bad, should be done using spell_loot_template (and conditions) @@ -1591,29 +1589,30 @@ void Spell::EffectEnergize() if (unitTarget->GetMaxPower(power) == 0) return; + int32 energizeAmount = GetEffectValueAsInt(); // Some level depends spells switch (m_spellInfo->Id) { case 24571: // Blood Fury // Instantly increases your rage by ${(300-10*$max(0,$PL-60))/10}. - damage -= 10 * std::max(0, std::min(30, unitCaster->GetLevel() - 60)); + energizeAmount -= 10 * std::max(0, std::min(30, unitCaster->GetLevel() - 60)); break; case 24532: // Burst of Energy // Instantly increases your energy by ${60-4*$max(0,$min(15,$PL-60))}. - damage -= 4 * std::max(0, std::min(15, unitCaster->GetLevel() - 60)); + energizeAmount -= 4 * std::max(0, std::min(15, unitCaster->GetLevel() - 60)); break; case 67490: // Runic Mana Injector (mana gain increased by 25% for engineers - 3.2.0 patch change) { if (Player* player = unitCaster->ToPlayer()) if (player->HasSkill(SKILL_ENGINEERING)) - AddPct(damage, 25); + AddPct(energizeAmount, 25); break; } default: break; } - unitCaster->EnergizeBySpell(unitTarget, m_spellInfo, damage, power); + unitCaster->EnergizeBySpell(unitTarget, m_spellInfo, energizeAmount, power); } void Spell::EffectEnergizePct() @@ -1636,7 +1635,7 @@ void Spell::EffectEnergizePct() if (!maxPower) return; - uint32 const gain = CalculatePct(maxPower, damage); + uint32 const gain = CalculatePct(maxPower, effectValue); unitCaster->EnergizeBySpell(unitTarget, m_spellInfo, gain, power); } @@ -1933,7 +1932,7 @@ void Spell::EffectSummonType() case 833: case 1161: case 713: - numSummons = (damage > 0) ? damage : 1; + numSummons = std::max(GetEffectValueAsInt(), 1); break; default: numSummons = 1; @@ -1979,10 +1978,10 @@ void Spell::EffectSummonType() if (!summon || !summon->IsTotem()) return; - if (damage) // if not spell info, DB values used + if (int32 health = GetEffectValueAsInt()) // if not spell info, DB values used { - summon->SetMaxHealth(damage); - summon->SetHealth(damage); + summon->SetMaxHealth(health); + summon->SetHealth(health); } break; } @@ -2061,7 +2060,7 @@ void Spell::EffectSummonType() // The spell that this effect will trigger. It has SPELL_AURA_CONTROL_VEHICLE uint32 spellId = VEHICLE_SPELL_RIDE_HARDCODED; - int32 basePoints = effectInfo->CalcValue(); + SpellEffectValue basePoints = effectInfo->CalcValue(); if (basePoints > MAX_VEHICLE_SEATS) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(basePoints, GetCastDifficulty()); @@ -2153,9 +2152,11 @@ void Spell::EffectDispel() size_t remaining = dispelList.size(); + int32 dispelAmount = GetEffectValueAsInt(); + // Ok if exist some buffs for dispel try dispel it DispelChargesList successList; - successList.reserve(damage); + successList.reserve(dispelAmount); WorldPackets::Spells::DispelFailed dispelFailed; dispelFailed.CasterGUID = m_caster->GetGUID(); @@ -2163,7 +2164,7 @@ void Spell::EffectDispel() dispelFailed.SpellID = m_spellInfo->Id; // dispel N = damage buffs (or while exist buffs for dispel) - for (int32 count = 0; count < damage && remaining > 0;) + for (int32 count = 0; count < dispelAmount && remaining > 0;) { // Random select buff for dispel auto itr = dispelList.begin(); @@ -2257,7 +2258,7 @@ void Spell::EffectDistract() if (unitTarget->HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING)) return; - unitTarget->GetMotionMaster()->MoveDistract(damage * IN_MILLISECONDS, unitTarget->GetAbsoluteAngle(destTarget)); + unitTarget->GetMotionMaster()->MoveDistract(GetEffectValueAsInt() * IN_MILLISECONDS, unitTarget->GetAbsoluteAngle(destTarget)); } void Spell::EffectPickPocket() @@ -2370,7 +2371,8 @@ void Spell::EffectLearnSkill() if (!playerTarget) return; - if (damage < 1) + uint16 skillTier = GetEffectValueAsInt(); + if (skillTier < 1) return; uint32 skillid = effectInfo->MiscValue; @@ -2383,12 +2385,12 @@ void Spell::EffectLearnSkill() return; uint16 skillval = std::max(1, playerTarget->GetPureSkillValue(skillid)); - uint16 maxSkillVal = tier->GetValueForTierIndex(damage - 1); + uint16 maxSkillVal = tier->GetValueForTierIndex(skillTier - 1); if (rcEntry->Flags & SKILL_FLAG_ALWAYS_MAX_VALUE) skillval = maxSkillVal; - playerTarget->SetSkill(skillid, damage, skillval, maxSkillVal); + playerTarget->SetSkill(skillid, skillTier, skillval, maxSkillVal); } void Spell::EffectPlayMovie() @@ -2438,7 +2440,7 @@ void Spell::EffectEnchantItemPerm() player->DestroyItemCount(itemTarget, count, true); unitTarget = player; // and add a scroll - damage = 1; + effectValue = 1.0; DoCreateItem(effectInfo->ItemType, m_spellInfo->HasAttribute(SPELL_ATTR0_IS_TRADESKILL) ? ItemContext::Trade_Skill : ItemContext::NONE); itemTarget = nullptr; m_targets.SetItemTarget(nullptr); @@ -2714,7 +2716,7 @@ void Spell::EffectSummonPet() Optional petSlot; if (!petentry) - petSlot = PetSaveMode(damage); + petSlot = PetSaveMode(GetEffectValueAsInt()); float x, y, z; owner->GetClosePoint(x, y, z, owner->GetCombatReach()); @@ -2845,8 +2847,8 @@ void Spell::EffectWeaponDmg() // some spell specific modifiers float totalDamagePercentMod = 1.0f; // applied to final bonus+weapon damage - int32 fixed_bonus = 0; - int32 spell_bonus = 0; // bonus specific for spell + SpellEffectValue fixed_bonus = 0; + SpellEffectValue spell_bonus = 0; // bonus specific for spell switch (m_spellInfo->SpellFamilyName) { @@ -2901,12 +2903,12 @@ void Spell::EffectWeaponDmg() float weapon_total_pct = unitCaster->GetPctModifierValue(unitMod, TOTAL_PCT); if (fixed_bonus) - fixed_bonus = int32(fixed_bonus * weapon_total_pct); + fixed_bonus = fixed_bonus * weapon_total_pct; if (spell_bonus) - spell_bonus = int32(spell_bonus * weapon_total_pct); + spell_bonus = spell_bonus * weapon_total_pct; } - int32 weaponDamage = unitCaster->CalculateDamage(m_attackType, normalized, addPctMods); + SpellEffectValue weaponDamage = unitCaster->CalculateDamage(m_attackType, normalized, addPctMods); Mechanics mechanic = MECHANIC_NONE; // Sequence is important @@ -2925,7 +2927,7 @@ void Spell::EffectWeaponDmg() weaponDamage += fixed_bonus; break; case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: - weaponDamage = int32(weaponDamage * weaponDamagePercentMod); + weaponDamage = weaponDamage * weaponDamagePercentMod; break; default: continue; // not weapon damage effect, just skip @@ -2936,10 +2938,10 @@ void Spell::EffectWeaponDmg() } weaponDamage += spell_bonus; - weaponDamage = int32(weaponDamage * totalDamagePercentMod); + weaponDamage = weaponDamage * totalDamagePercentMod; // prevent negative damage - weaponDamage = std::max(weaponDamage, 0); + weaponDamage = std::max(std::round(weaponDamage), 0.0); // Add melee damage bonuses (also check for negative) weaponDamage = unitCaster->MeleeDamageBonusDone(unitTarget, weaponDamage, m_attackType, SPELL_DIRECT_DAMAGE, m_spellInfo, effectInfo, mechanic, m_spellSchoolMask, this); @@ -2961,7 +2963,7 @@ void Spell::EffectThreat() if (!unitTarget->CanHaveThreatList()) return; - unitTarget->GetThreatManager().AddThreat(unitCaster, float(damage), m_spellInfo, true); + unitTarget->GetThreatManager().AddThreat(unitCaster, effectValue, m_spellInfo, true); } void Spell::EffectHealMaxHealth() @@ -2979,7 +2981,7 @@ void Spell::EffectHealMaxHealth() int32 addhealth = 0; // damage == 0 - heal for caster max health - if (damage == 0) + if (GetEffectValueAsInt() == 0) addhealth = unitCaster->GetMaxHealth(); else addhealth = unitTarget->GetMaxHealth() - unitTarget->GetHealth(); @@ -3183,7 +3185,7 @@ void Spell::EffectScriptEffect() return; // Delete item from inventory at death - m_caster->ToPlayer()->DestroyItemCount(damage, 5, true); + m_caster->ToPlayer()->DestroyItemCount(GetEffectValueAsInt(), 5, true); return; } @@ -3200,7 +3202,7 @@ void Spell::EffectScriptEffect() { /// @todo a hack, range = 11, should after some time cast, otherwise too far unitCaster->CastSpell(parent, 62496, this); - unitTarget->CastSpell(parent, damage, CastSpellExtraArgs() + unitTarget->CastSpell(parent, GetEffectValueAsInt(), CastSpellExtraArgs() .SetTriggeringSpell(this)); // DIFFICULTY_NONE, so effect always valid } } @@ -3471,7 +3473,7 @@ void Spell::EffectEnchantHeldItem() uint32 enchant_id = effectInfo->MiscValue; int32 duration = m_spellInfo->GetDuration(); //Try duration index first .. if (!duration) - duration = damage;//+1; //Base points after .. + duration = GetEffectValueAsInt();//+1; //Base points after .. if (!duration) duration = 10 * IN_MILLISECONDS; //10 seconds for enchants which don't have listed duration @@ -3524,7 +3526,7 @@ void Spell::EffectInebriate() Player* player = unitTarget->ToPlayer(); uint8 currentDrunkValue = player->GetDrunkValue(); - uint8 drunkValue = std::clamp(damage + currentDrunkValue, 0, 100); + uint8 drunkValue = std::clamp(GetEffectValueAsInt() + currentDrunkValue, 0, 100); if (currentDrunkValue == 100 && currentDrunkValue == drunkValue) if (roll_chance_f(25.0f)) player->CastSpell(player, 67468, CastSpellExtraArgs() @@ -3669,8 +3671,8 @@ void Spell::EffectResurrect() if (player->IsResurrectRequested()) // already have one active request return; - uint32 health = player->CountPctFromMaxHealth(damage); - uint32 mana = CalculatePct(player->GetMaxPower(POWER_MANA), damage); + uint32 health = player->CountPctFromMaxHealth(effectValue); + uint32 mana = CalculatePct(player->GetMaxPower(POWER_MANA), effectValue); ExecuteLogEffectResurrect(SpellEffectName(effectInfo->Effect), player); @@ -3686,9 +3688,11 @@ void Spell::EffectAddExtraAttacks() if (!unitTarget || !unitTarget->IsAlive()) return; - unitTarget->AddExtraAttacks(damage); + int32 extraAttacks = GetEffectValueAsInt(); - ExecuteLogEffectExtraAttacks(SpellEffectName(effectInfo->Effect), unitTarget, damage); + unitTarget->AddExtraAttacks(extraAttacks); + + ExecuteLogEffectExtraAttacks(SpellEffectName(effectInfo->Effect), unitTarget, extraAttacks); } void Spell::EffectParry() @@ -3740,7 +3744,7 @@ void Spell::EffectReputation() Player* player = unitTarget->ToPlayer(); - int32 repChange = damage; + int32 repChange = GetEffectValueAsInt(); uint32 factionId = effectInfo->MiscValue; @@ -3831,17 +3835,17 @@ void Spell::EffectSelfResurrect() uint32 mana = 0; // flat case - if (damage < 0) + if (effectValue < 0) { - health = uint32(-damage); + health = uint32(-GetEffectValueAsInt()); mana = effectInfo->MiscValue; } // percent case else { - health = player->CountPctFromMaxHealth(damage); + health = player->CountPctFromMaxHealth(effectValue); if (player->GetMaxPower(POWER_MANA) > 0) - mana = CalculatePct(player->GetMaxPower(POWER_MANA), damage); + mana = CalculatePct(player->GetMaxPower(POWER_MANA), effectValue); } player->ResurrectPlayer(0.0f); @@ -4044,7 +4048,7 @@ void Spell::EffectKnockBack() float ratio = 0.1f; float speedXY = float(effectInfo->MiscValue) * ratio; - float speedZ = float(damage) * ratio; + float speedZ = effectValue * ratio; if (std::abs(speedXY) < 0.01f && std::abs(speedZ) < 0.01f) return; @@ -4074,7 +4078,7 @@ void Spell::EffectLeapBack() return; float speedxy = effectInfo->MiscValue / 10.f; - float speedz = damage / 10.f; + float speedz = effectValue / 10.f; // Disengage unitTarget->KnockbackFrom(unitTarget->GetPosition(), speedxy, speedz, effectInfo->PositionFacing); @@ -4221,7 +4225,7 @@ void Spell::EffectChangeRaidMarker() float x, y, z; destTarget->GetPosition(x, y, z); - group->AddRaidMarker(damage, player->GetMapId(), x, y, z); + group->AddRaidMarker(GetEffectValueAsInt(), player->GetMapId(), x, y, z); } void Spell::EffectDispelMechanic() @@ -4264,7 +4268,7 @@ void Spell::EffectResurrectPet() if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; - if (damage < 0) + if (effectValue < 0) return; Player* player = m_caster->ToPlayer(); @@ -4310,7 +4314,7 @@ void Spell::EffectResurrectPet() pet->RemoveUnitFlag(UNIT_FLAG_SKINNABLE); pet->setDeathState(ALIVE); pet->ClearUnitState(UNIT_STATE_ALL_ERASABLE); - pet->SetHealth(pet->CountPctFromMaxHealth(damage)); + pet->SetHealth(pet->CountPctFromMaxHealth(effectValue)); // Reset things for when the AI to takes over CharmInfo *ci = pet->GetCharmInfo(); @@ -4361,7 +4365,7 @@ void Spell::EffectDestroyAllTotems() } } - ApplyPct(mana, damage); + ApplyPct(mana, effectValue); if (mana) { @@ -4385,7 +4389,7 @@ void Spell::EffectDurabilityDamage() // -1 means all player equipped items and -2 all items if (slot < 0) { - unitTarget->ToPlayer()->DurabilityPointsLossAll(damage, (slot < -1)); + unitTarget->ToPlayer()->DurabilityPointsLossAll(GetEffectValueAsInt(), (slot < -1)); ExecuteLogEffectDurabilityDamage(SpellEffectName(effectInfo->Effect), unitTarget, -1, -1); return; } @@ -4396,7 +4400,7 @@ void Spell::EffectDurabilityDamage() if (Item* item = unitTarget->ToPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) { - unitTarget->ToPlayer()->DurabilityPointsLoss(item, damage); + unitTarget->ToPlayer()->DurabilityPointsLoss(item, GetEffectValueAsInt()); ExecuteLogEffectDurabilityDamage(SpellEffectName(effectInfo->Effect), unitTarget, item->GetEntry(), slot); } } @@ -4415,7 +4419,7 @@ void Spell::EffectDurabilityDamagePCT() // Possibly its mean -1 all player equipped items and -2 all items if (slot < 0) { - unitTarget->ToPlayer()->DurabilityLossAll(float(damage) / 100.0f, (slot < -1)); + unitTarget->ToPlayer()->DurabilityLossAll(effectValue / 100.0, (slot < -1)); return; } @@ -4423,11 +4427,11 @@ void Spell::EffectDurabilityDamagePCT() if (slot >= INVENTORY_SLOT_BAG_END) return; - if (damage <= 0) + if (effectValue <= 0) return; if (Item* item = unitTarget->ToPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) - unitTarget->ToPlayer()->DurabilityLoss(item, float(damage) / 100.0f); + unitTarget->ToPlayer()->DurabilityLoss(item, effectValue / 100.0); } void Spell::EffectModifyThreatPercent() @@ -4439,7 +4443,7 @@ void Spell::EffectModifyThreatPercent() if (!unitCaster || !unitTarget) return; - unitTarget->GetThreatManager().ModifyThreatByPercent(unitCaster, damage); + unitTarget->GetThreatManager().ModifyThreatByPercent(unitCaster, effectValue); } void Spell::EffectTransmitted() @@ -4639,11 +4643,12 @@ void Spell::EffectSkill() if (!playerTarget) return; - if (damage < 1) + uint16 skillStep = GetEffectValueAsInt(); + if (skillStep < 1) return; uint32 skillid = effectInfo->MiscValue; - if (playerTarget->GetSkillStep(skillid) >= damage) + if (playerTarget->GetSkillStep(skillid) >= skillStep) return; SkillRaceClassInfoEntry const* rcEntry = sDB2Manager.GetSkillRaceClassInfo(skillid, playerTarget->GetRace(), playerTarget->GetClass()); @@ -4655,12 +4660,12 @@ void Spell::EffectSkill() return; uint16 skillval = std::max(1, playerTarget->GetPureSkillValue(skillid)); - uint16 maxSkillVal = tier->GetValueForTierIndex(damage - 1); + uint16 maxSkillVal = tier->GetValueForTierIndex(skillStep - 1); if (rcEntry->Flags & SKILL_FLAG_ALWAYS_MAX_VALUE) skillval = maxSkillVal; - playerTarget->SetSkill(skillid, damage, skillval, maxSkillVal); + playerTarget->SetSkill(skillid, skillStep, skillval, maxSkillVal); } void Spell::EffectSpiritHeal() @@ -4758,9 +4763,11 @@ void Spell::EffectStealBeneficialBuff() size_t remaining = stealList.size(); + int32 stealAmount = GetEffectValueAsInt(); + // Ok if exist some buffs for dispel try dispel it std::vector> successList; - successList.reserve(damage); + successList.reserve(stealAmount); WorldPackets::Spells::DispelFailed dispelFailed; dispelFailed.CasterGUID = m_caster->GetGUID(); @@ -4768,7 +4775,7 @@ void Spell::EffectStealBeneficialBuff() dispelFailed.SpellID = m_spellInfo->Id; // dispel N = damage buffs (or while exist buffs for dispel) - for (int32 count = 0; count < damage && remaining > 0;) + for (int32 count = 0; count < stealAmount && remaining > 0;) { // Random select buff for dispel DispelChargesList::iterator itr = stealList.begin(); @@ -4959,7 +4966,7 @@ void Spell::EffectRedirectThreat() return; if (unitTarget) - unitCaster->GetThreatManager().RegisterRedirectThreat(m_spellInfo->Id, unitTarget->GetGUID(), uint32(damage)); + unitCaster->GetThreatManager().RegisterRedirectThreat(m_spellInfo->Id, unitTarget->GetGUID(), effectValue); } void Spell::EffectGameObjectDamage() @@ -4974,7 +4981,7 @@ void Spell::EffectGameObjectDamage() FactionTemplateEntry const* targetFaction = sFactionTemplateStore.LookupEntry(gameObjTarget->GetFaction()); // Do not allow to damage GO's of friendly factions (ie: Wintergrasp Walls/Ulduar Storm Beacons) if (!targetFaction || (casterFaction && !casterFaction->IsFriendlyTo(targetFaction))) - gameObjTarget->ModifyHealth(-damage, m_caster, GetSpellInfo()->Id); + gameObjTarget->ModifyHealth(-GetEffectValueAsInt(), m_caster, GetSpellInfo()->Id); } void Spell::EffectGameObjectRepair() @@ -4985,7 +4992,7 @@ void Spell::EffectGameObjectRepair() if (!gameObjTarget) return; - gameObjTarget->ModifyHealth(damage, m_caster); + gameObjTarget->ModifyHealth(GetEffectValueAsInt(), m_caster); } void Spell::EffectGameObjectSetDestructionState() @@ -5157,7 +5164,7 @@ void Spell::EffectDamageFromMaxHealthPCT() if (!unitTarget) return; - m_damage += unitTarget->CountPctFromMaxHealth(damage); + m_damage += unitTarget->CountPctFromMaxHealth(effectValue); } void Spell::EffectGiveCurrency() @@ -5171,7 +5178,7 @@ void Spell::EffectGiveCurrency() if (!sCurrencyTypesStore.LookupEntry(effectInfo->MiscValue)) return; - unitTarget->ToPlayer()->ModifyCurrency(effectInfo->MiscValue, damage, CurrencyGainSource::Spell, CurrencyDestroyReason::Spell); + unitTarget->ToPlayer()->ModifyCurrency(effectInfo->MiscValue, GetEffectValueAsInt(), CurrencyGainSource::Spell, CurrencyDestroyReason::Spell); } void Spell::EffectCastButtons() @@ -5283,11 +5290,11 @@ void Spell::EffectIncreaseCurrencyCap() if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (damage <= 0) + if (effectValue <= 0) return; if (Player* player = unitTarget->ToPlayer()) - player->IncreaseCurrencyCap(effectInfo->MiscValue, damage); + player->IncreaseCurrencyCap(effectInfo->MiscValue, GetEffectValueAsInt()); } void Spell::EffectSummonRaFFriend() @@ -5309,7 +5316,7 @@ void Spell::EffectUnlockGuildVaultTab() // Safety checks done in Spell::CheckCast Player* caster = m_caster->ToPlayer(); if (Guild* guild = caster->GetGuild()) - guild->HandleBuyBankTab(caster->GetSession(), damage - 1); // Bank tabs start at zero internally + guild->HandleBuyBankTab(caster->GetSession(), GetEffectValueAsInt() - 1); // Bank tabs start at zero internally } void Spell::EffectSummonPersonalGameObject() @@ -5382,8 +5389,8 @@ void Spell::EffectResurrectWithAura() if (target->IsResurrectRequested()) // already have one active request return; - uint32 health = target->CountPctFromMaxHealth(damage); - uint32 mana = CalculatePct(target->GetMaxPower(POWER_MANA), damage); + uint32 health = target->CountPctFromMaxHealth(effectValue); + uint32 mana = CalculatePct(target->GetMaxPower(POWER_MANA), effectValue); uint32 resurrectAura = 0; if (sSpellMgr->GetSpellInfo(effectInfo->TriggerSpell, DIFFICULTY_NONE)) resurrectAura = effectInfo->TriggerSpell; @@ -5563,7 +5570,7 @@ void Spell::EffectGrantBattlePetLevel() if (!unitTarget || !unitTarget->IsCreature()) return; - playerCaster->GetSession()->GetBattlePetMgr()->GrantBattlePetLevel(unitTarget->GetBattlePetCompanionGUID(), damage); + playerCaster->GetSession()->GetBattlePetMgr()->GrantBattlePetLevel(unitTarget->GetBattlePetCompanionGUID(), GetEffectValueAsInt()); } void Spell::EffectGiveExperience() @@ -5589,7 +5596,7 @@ void Spell::EffectGiveRestedExperience() return; // effect value is number of resting hours - playerTarget->GetRestMgr().AddRestBonus(REST_TYPE_XP, damage * HOUR * playerTarget->GetRestMgr().CalcExtraPerSec(REST_TYPE_XP, 0.125f)); + playerTarget->GetRestMgr().AddRestBonus(REST_TYPE_XP, effectValue * float(HOUR) * playerTarget->GetRestMgr().CalcExtraPerSec(REST_TYPE_XP, 0.125f)); } void Spell::EffectHealBattlePetPct() @@ -5601,7 +5608,7 @@ void Spell::EffectHealBattlePetPct() return; if (BattlePets::BattlePetMgr* battlePetMgr = unitTarget->ToPlayer()->GetSession()->GetBattlePetMgr()) - battlePetMgr->HealBattlePetsPct(damage); + battlePetMgr->HealBattlePetsPct(GetEffectValueAsInt()); } void Spell::EffectEnableBattlePets() @@ -5629,10 +5636,7 @@ void Spell::EffectChangeBattlePetQuality() if (!unitTarget || !unitTarget->IsCreature()) return; - auto qualityItr = std::lower_bound(sBattlePetBreedQualityStore.begin(), sBattlePetBreedQualityStore.end(), damage, [](BattlePetBreedQualityEntry const* a1, int32 selector) - { - return a1->MaxQualityRoll < selector; - }); + auto qualityItr = std::ranges::lower_bound(sBattlePetBreedQualityStore, GetEffectValueAsInt(), {}, &BattlePetBreedQualityEntry::MaxQualityRoll); BattlePets::BattlePetBreedQuality quality = BattlePets::BattlePetBreedQuality::Poor; if (qualityItr != sBattlePetBreedQualityStore.end()) @@ -5761,7 +5765,7 @@ void Spell::EffectGiveArtifactPower() if (Aura* artifactAura = playerCaster->GetAura(ARTIFACTS_ALL_WEAPONS_GENERAL_WEAPON_EQUIPPED_PASSIVE)) if (Item* artifact = playerCaster->GetItemByGuid(artifactAura->GetCastItemGUID())) - artifact->GiveArtifactXp(damage, m_CastItem, uint32(effectInfo->MiscValue)); + artifact->GiveArtifactXp(uint64(effectValue), m_CastItem, uint32(effectInfo->MiscValue)); } void Spell::EffectGiveArtifactPowerNoBonus() @@ -5774,7 +5778,7 @@ void Spell::EffectGiveArtifactPowerNoBonus() if (Aura* artifactAura = unitTarget->GetAura(ARTIFACTS_ALL_WEAPONS_GENERAL_WEAPON_EQUIPPED_PASSIVE)) if (Item* artifact = unitTarget->ToPlayer()->GetItemByGuid(artifactAura->GetCastItemGUID())) - artifact->GiveArtifactXp(damage, m_CastItem, 0); + artifact->GiveArtifactXp(uint64(effectValue), m_CastItem, 0); } void Spell::EffectPlaySceneScriptPackage() @@ -5862,12 +5866,14 @@ void Spell::EffectGiveHonor() if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; + int32 honor = GetEffectValueAsInt(); + WorldPackets::Combat::PvPCredit packet; - packet.Honor = damage; - packet.OriginalHonor = damage; + packet.Honor = honor; + packet.OriginalHonor = honor; Player* playerTarget = unitTarget->ToPlayer(); - playerTarget->AddHonorXP(damage); + playerTarget->AddHonorXP(honor); playerTarget->SendDirectMessage(packet.Write()); } @@ -6094,7 +6100,7 @@ void Spell::EffectGrantBattlePetExperience() if (!unitTarget || !unitTarget->IsCreature()) return; - playerCaster->GetSession()->GetBattlePetMgr()->GrantBattlePetExperience(unitTarget->GetBattlePetCompanionGUID(), damage, BattlePets::BattlePetXpSource::SpellEffect); + playerCaster->GetSession()->GetBattlePetMgr()->GrantBattlePetExperience(unitTarget->GetBattlePetCompanionGUID(), GetEffectValueAsInt(), BattlePets::BattlePetXpSource::SpellEffect); } void Spell::EffectLearnTransmogIllusion() @@ -6125,10 +6131,10 @@ void Spell::EffectModifyAuraStacks() switch (effectInfo->MiscValue) { case 0: - targetAura->ModStackAmount(damage); + targetAura->ModStackAmount(GetEffectValueAsInt()); break; case 1: - targetAura->SetStackAmount(damage); + targetAura->SetStackAmount(GetEffectValueAsInt()); break; default: break; @@ -6140,7 +6146,7 @@ void Spell::EffectModifyCooldown() if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - unitTarget->GetSpellHistory()->ModifyCooldown(effectInfo->TriggerSpell, Milliseconds(damage)); + unitTarget->GetSpellHistory()->ModifyCooldown(effectInfo->TriggerSpell, Milliseconds(GetEffectValueAsInt())); } void Spell::EffectModifyCooldowns() @@ -6159,7 +6165,7 @@ void Spell::EffectModifyCooldowns() return false; return (spellOnCooldown->SpellFamilyFlags[bitIndex / 32] & 1u << (bitIndex % 32)) != 0; - }, Milliseconds(damage)); + }, Milliseconds(GetEffectValueAsInt())); } void Spell::EffectModifyCooldownsByCategory() @@ -6170,7 +6176,7 @@ void Spell::EffectModifyCooldownsByCategory() unitTarget->GetSpellHistory()->ModifyCoooldowns([this](SpellHistory::CooldownEntry const& cooldown) { return sSpellMgr->AssertSpellInfo(cooldown.SpellId, DIFFICULTY_NONE)->CategoryId == uint32(effectInfo->MiscValue); - }, Milliseconds(damage)); + }, Milliseconds(GetEffectValueAsInt())); } void Spell::EffectModifySpellCharges() @@ -6178,7 +6184,7 @@ void Spell::EffectModifySpellCharges() if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - for (int32 i = 0; i < damage; ++i) + for (int32 i = 0; i < GetEffectValueAsInt(); ++i) unitTarget->GetSpellHistory()->RestoreCharge(effectInfo->MiscValue); } @@ -6240,7 +6246,7 @@ void Spell::EffectChangeActiveCombatTraitConfig() if (!traitConfig) return; - target->UpdateTraitConfig(std::move(*traitConfig), damage, false); + target->UpdateTraitConfig(std::move(*traitConfig), GetEffectValueAsInt(), false); } void Spell::EffectTeleportGraveyard() @@ -6300,7 +6306,7 @@ void Spell::EffectSetPlayerDataElementAccount() if (!target) return; - target->SetDataElementAccount(effectInfo->MiscValue, int64(damage)); + target->SetDataElementAccount(effectInfo->MiscValue, int64(GetEffectValueAsInt())); } void Spell::EffectSetPlayerDataElementCharacter() @@ -6312,7 +6318,7 @@ void Spell::EffectSetPlayerDataElementCharacter() if (!target) return; - target->SetDataElementCharacter(effectInfo->MiscValue, int64(damage)); + target->SetDataElementCharacter(effectInfo->MiscValue, int64(GetEffectValueAsInt())); } void Spell::EffectSetPlayerDataFlagAccount() @@ -6324,7 +6330,7 @@ void Spell::EffectSetPlayerDataFlagAccount() if (!target) return; - target->SetDataFlagAccount(effectInfo->MiscValue, damage != 0); + target->SetDataFlagAccount(effectInfo->MiscValue, GetEffectValueAsInt() != 0); } void Spell::EffectSetPlayerDataFlagCharacter() @@ -6336,7 +6342,7 @@ void Spell::EffectSetPlayerDataFlagCharacter() if (!target) return; - target->SetDataFlagCharacter(effectInfo->MiscValue, damage != 0); + target->SetDataFlagCharacter(effectInfo->MiscValue, GetEffectValueAsInt() != 0); } void Spell::EffectEquipTransmogOutfit() diff --git a/src/server/game/Spells/SpellHistory.cpp b/src/server/game/Spells/SpellHistory.cpp index 6589cb8b2e..c2140544dc 100644 --- a/src/server/game/Spells/SpellHistory.cpp +++ b/src/server/game/Spells/SpellHistory.cpp @@ -456,7 +456,7 @@ void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spel { auto calcRecoveryRate = [&](AuraEffect const* modRecoveryRate) { - float rate = 100.0f / (std::max(modRecoveryRate->GetAmount(), -99.0f) + 100.0f); + double rate = 100.0 / (std::max(modRecoveryRate->GetAmount(), -99.0) + 100.0); if (baseCooldown <= 1h && !spellInfo->HasAttribute(SPELL_ATTR6_IGNORE_FOR_MOD_TIME_RATE) && !modRecoveryRate->GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes::IgnoreDuringCooldownTimeRateCalculation)) @@ -465,7 +465,7 @@ void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spel return rate; }; - float recoveryRate = 1.0f; + double recoveryRate = 1.0; for (AuraEffect const* modRecoveryRate : _owner->GetAuraEffectsByType(SPELL_AURA_MOD_RECOVERY_RATE)) if (modRecoveryRate->IsAffectingSpell(spellInfo)) recoveryRate *= calcRecoveryRate(modRecoveryRate); @@ -474,7 +474,7 @@ void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spel if (spellInfo->HasLabel(modRecoveryRate->GetMiscValue()) || (modRecoveryRate->GetMiscValueB() && spellInfo->HasLabel(modRecoveryRate->GetMiscValueB()))) recoveryRate *= calcRecoveryRate(modRecoveryRate); - if (recoveryRate > 0.0f) + if (recoveryRate > 0.0) { cooldown = Duration(int64(cooldown.count() * recoveryRate)); categoryCooldown = Duration(int64(categoryCooldown.count() * recoveryRate)); @@ -1002,36 +1002,35 @@ int32 SpellHistory::GetChargeRecoveryTime(uint32 chargeCategoryId) const if (!chargeCategoryEntry) return 0; - int32 recoveryTime = chargeCategoryEntry->ChargeRecoveryTime; + SpellEffectValue recoveryTime = chargeCategoryEntry->ChargeRecoveryTime; recoveryTime += _owner->GetTotalAuraModifierByMiscValue(SPELL_AURA_CHARGE_RECOVERY_MOD, chargeCategoryId); for (AuraEffect const* modRecoveryRate : _owner->GetAuraEffectsByType(SPELL_AURA_MOD_CHARGE_RECOVERY_BY_TYPE_MASK)) if (modRecoveryRate->GetMiscValue() & chargeCategoryEntry->TypeMask) recoveryTime += modRecoveryRate->GetAmount(); - float recoveryTimeF = float(recoveryTime); - recoveryTimeF *= _owner->GetTotalAuraMultiplierByMiscValue(SPELL_AURA_CHARGE_RECOVERY_MULTIPLIER, chargeCategoryId); + recoveryTime *= _owner->GetTotalAuraMultiplierByMiscValue(SPELL_AURA_CHARGE_RECOVERY_MULTIPLIER, chargeCategoryId); if (_owner->HasAuraType(SPELL_AURA_CHARGE_RECOVERY_AFFECTED_BY_HASTE)) - recoveryTimeF *= _owner->m_unitData->ModSpellHaste; + recoveryTime *= _owner->m_unitData->ModSpellHaste; if (_owner->HasAuraTypeWithMiscvalue(SPELL_AURA_CHARGE_RECOVERY_AFFECTED_BY_HASTE_REGEN, chargeCategoryId)) - recoveryTimeF *= _owner->m_unitData->ModHasteRegen; + recoveryTime *= _owner->m_unitData->ModHasteRegen; for (AuraEffect const* modRecoveryRate : _owner->GetAuraEffectsByType(SPELL_AURA_MOD_CHARGE_RECOVERY_RATE)) if (modRecoveryRate->GetMiscValue() == int32(chargeCategoryId)) - recoveryTimeF *= 100.0f / (std::max(modRecoveryRate->GetAmount(), -99.0f) + 100.0f); + recoveryTime *= 100.0 / (std::max(modRecoveryRate->GetAmount(), -99.0) + 100.0); for (AuraEffect const* modRecoveryRate : _owner->GetAuraEffectsByType(SPELL_AURA_MOD_CHARGE_RECOVERY_RATE_BY_TYPE_MASK)) if (modRecoveryRate->GetMiscValue() & chargeCategoryEntry->TypeMask) - recoveryTimeF *= 100.0f / (std::max(modRecoveryRate->GetAmount(), -99.0f) + 100.0f); + recoveryTime *= 100.0 / (std::max(modRecoveryRate->GetAmount(), -99.0) + 100.0); if (Milliseconds(chargeCategoryEntry->ChargeRecoveryTime) <= 1h && !(chargeCategoryEntry->GetFlags().HasFlag(SpellCategoryFlags::IgnoreForModTimeRate)) && !(chargeCategoryEntry->GetFlags().HasFlag(SpellCategoryFlags::CooldownInDays))) - recoveryTimeF *= *_owner->m_unitData->ModTimeRate; + recoveryTime *= *_owner->m_unitData->ModTimeRate; - return int32(std::floor(recoveryTimeF)); + return int32(std::floor(recoveryTime)); } bool SpellHistory::HasGlobalCooldown(SpellInfo const* spellInfo) const diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 36d122984f..05b90335d9 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -512,7 +512,12 @@ uint32 SpellEffectInfo::GetPeriodicTickCount() const return totalTicks; } -int32 SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, int32 const* bp /*= nullptr*/, Unit const* target /*= nullptr*/, float* variance /*= nullptr*/, uint32 castItemId /*= 0*/, int32 itemLevel /*= -1*/) const +int32 SpellEffectInfo::CalcValueAsInt(WorldObject const* caster /*= nullptr*/, SpellEffectValue const* basePoints /*= nullptr*/, Unit const* target /*= nullptr*/, float* variance /*= nullptr*/, uint32 castItemId /*= 0*/, int32 itemLevel /*= -1*/) const +{ + return int32(CalcValue(caster, basePoints, target, variance, castItemId, itemLevel)); +} + +SpellEffectValue SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, SpellEffectValue const* bp /*= nullptr*/, Unit const* target /*= nullptr*/, float* variance /*= nullptr*/, uint32 castItemId /*= 0*/, int32 itemLevel /*= -1*/) const { SpellEffectValue basePoints = CalcBaseValue(caster, target, castItemId, itemLevel); SpellEffectValue value = bp ? *bp : basePoints; @@ -598,7 +603,59 @@ int32 SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, int32 if (caster) value = caster->ApplyEffectModifiers(_spellInfo, EffectIndex, value); - return int32(round(value)); + switch (Effect) + { + case SPELL_EFFECT_SCHOOL_DAMAGE: + case SPELL_EFFECT_ENVIRONMENTAL_DAMAGE: + case SPELL_EFFECT_HEALTH_LEECH: + case SPELL_EFFECT_HEAL: + case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: + case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: + case SPELL_EFFECT_WEAPON_DAMAGE: + case SPELL_EFFECT_HEAL_MAX_HEALTH: + case SPELL_EFFECT_HEAL_MECHANICAL: + case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: + case SPELL_EFFECT_POWER_DRAIN: + case SPELL_EFFECT_ENERGIZE: + case SPELL_EFFECT_POWER_BURN: + value = std::round(value); + break; + case SPELL_EFFECT_APPLY_AURA: + case SPELL_EFFECT_PERSISTENT_AREA_AURA: + case SPELL_EFFECT_APPLY_AREA_AURA_PARTY: + case SPELL_EFFECT_APPLY_AREA_AURA_RAID: + case SPELL_EFFECT_APPLY_AREA_AURA_PET: + case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND: + case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY: + case SPELL_EFFECT_APPLY_AREA_AURA_OWNER: + case SPELL_EFFECT_APPLY_AURA_ON_PET: + case SPELL_EFFECT_APPLY_AREA_AURA_SUMMONS: + switch (ApplyAuraName) + { + case SPELL_AURA_PERIODIC_DAMAGE: + case SPELL_AURA_PERIODIC_HEAL: + case SPELL_AURA_PERIODIC_LEECH: + case SPELL_AURA_PERIODIC_HEALTH_FUNNEL: + case SPELL_AURA_PERIODIC_WEAPON_PERCENT_DAMAGE: + case SPELL_AURA_DAMAGE_SHIELD: + case SPELL_AURA_PROC_TRIGGER_DAMAGE: + case SPELL_AURA_OBS_MOD_HEALTH: + case SPELL_AURA_OBS_MOD_POWER: + case SPELL_AURA_PERIODIC_ENERGIZE: + case SPELL_AURA_PERIODIC_MANA_LEECH: + case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: + case SPELL_AURA_POWER_BURN: + value = std::round(value); + break; + default: + break; + } + break; + default: + return false; + } + + return std::clamp(value, MinValue, MaxValue); } SpellEffectValue SpellEffectInfo::CalcBaseValue(WorldObject const* caster, Unit const* target, uint32 itemId, int32 itemLevel) const @@ -658,7 +715,10 @@ SpellEffectValue SpellEffectInfo::CalcBaseValue(WorldObject const* caster, Unit if (value > 0.0f && value < 1.0f) value = 1.0f; - return round(value); + if (!_spellInfo->HasAttribute(SPELL_ATTR12_USE_FLOAT_VALUES_FOR_SCALING_AMOUNTS)) + value = round(value); + + return value; } else { @@ -681,10 +741,12 @@ SpellEffectValue SpellEffectInfo::CalcBaseValue(WorldObject const* caster, Unit else if (caster && caster->IsUnit()) level = caster->ToUnit()->GetLevel(); - value = sDB2Manager.EvaluateExpectedStat(stat, level, expansion, 0, CLASS_NONE, 0) * BasePoints / 100.0f; + value = sDB2Manager.EvaluateExpectedStat(stat, level, expansion, 0, CLASS_NONE, 0) * value / 100.0f; + if (!_spellInfo->HasAttribute(SPELL_ATTR12_USE_FLOAT_VALUES_FOR_SCALING_AMOUNTS)) + value = round(value); } - return round(value); + return value; } } @@ -4582,7 +4644,7 @@ bool _isPositiveEffectImpl(SpellInfo const* spellInfo, SpellEffectInfo const& ef //We need scaling level info for some auras that compute bp 0 or positive but should be debuffs float bpScalePerLevel = effect.RealPointsPerLevel; - int32 bp = effect.CalcValue(); + SpellEffectValue bp = effect.CalcValue(); switch (spellInfo->SpellFamilyName) { case SPELLFAMILY_GENERIC: diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index aedf82f9e9..aeb4f58bd1 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -263,7 +263,11 @@ public: uint32 GetPeriodicTickCount() const; - int32 CalcValue(WorldObject const* caster = nullptr, int32 const* basePoints = nullptr, Unit const* target = nullptr, float* variance = nullptr, uint32 castItemId = 0, int32 itemLevel = -1) const; + static constexpr SpellEffectValue MinValue = -2000000000.0; + static constexpr SpellEffectValue MaxValue = 2000000000.0; + + int32 CalcValueAsInt(WorldObject const* caster = nullptr, SpellEffectValue const* basePoints = nullptr, Unit const* target = nullptr, float* variance = nullptr, uint32 castItemId = 0, int32 itemLevel = -1) const; + SpellEffectValue CalcValue(WorldObject const* caster = nullptr, SpellEffectValue const* basePoints = nullptr, Unit const* target = nullptr, float* variance = nullptr, uint32 castItemId = 0, int32 itemLevel = -1) const; SpellEffectValue CalcBaseValue(WorldObject const* caster, Unit const* target, uint32 itemId, int32 itemLevel) const; float CalcValueMultiplier(WorldObject* caster, Spell* spell = nullptr) const; float CalcDamageMultiplier(WorldObject* caster, Spell* spell = nullptr) const; diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 4188177476..ce8d545b5f 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -410,7 +410,7 @@ void SpellMgr::GetSetOfSpellsInSpellGroup(SpellGroup group_id, std::set& } } -bool SpellMgr::AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, uint32 auraType, int32 amount, std::map& groups) const +bool SpellMgr::AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, AuraType auraType, SpellEffectValue amount, std::map& groups) const { uint32 spellId = spellInfo->GetFirstRankSpell()->Id; auto spellGroupBounds = GetSpellSpellGroupMapBounds(spellId); @@ -422,7 +422,7 @@ bool SpellMgr::AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, uin if (found != mSpellSameEffectStack.end()) { // check auraTypes - if (!found->second.count(auraType)) + if (!found->second.contains(auraType)) continue; // Put the highest amount in the map @@ -431,7 +431,7 @@ bool SpellMgr::AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, uin groups.emplace(group, amount); else { - int32 curr_amount = groups[group]; + SpellEffectValue curr_amount = groupItr->second; // Take absolute value because this also counts for the highest negative aura if (std::abs(curr_amount) < std::abs(amount)) groupItr->second = amount; @@ -975,7 +975,7 @@ void SpellMgr::LoadSpellLearnSkills() { case SPELL_EFFECT_SKILL: dbc_node.skill = uint16(spellEffectInfo.MiscValue); - dbc_node.step = uint16(spellEffectInfo.CalcValue()); + dbc_node.step = uint16(spellEffectInfo.CalcValueAsInt()); dbc_node.value = 0; dbc_node.maxvalue = 0; break; @@ -1858,7 +1858,7 @@ void SpellMgr::LoadSpellProcs() break; // proc auras with another aura reducing hit chance (eg 63767) only proc on missed attack case SPELL_AURA_MOD_HIT_CHANCE: - if (spellEffectInfo.CalcValue() <= -100) + if (spellEffectInfo.CalcValueAsInt() <= -100) procEntry.HitMask = PROC_HIT_MISS; break; case SPELL_AURA_PROC_TRIGGER_SPELL: @@ -2101,7 +2101,7 @@ void SpellMgr::LoadSpellLinked() { for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) { - if (spellEffectInfo.CalcValue() == abs(effect)) + if (spellEffectInfo.CalcValueAsInt() == abs(effect)) TC_LOG_ERROR("sql.sql", "The spell {} Effect: {} listed in `spell_linked_spell` has same bp{} like effect (possible hack).", abs(trigger), abs(effect), uint32(spellEffectInfo.EffectIndex)); } } @@ -3192,7 +3192,7 @@ void SpellMgr::LoadSpellInfoCustomAttributes() default: { // No value and not interrupt cast or crowd control without SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY flag - if (!spellEffectInfo.CalcValue() && !((spellEffectInfo.Effect == SPELL_EFFECT_INTERRUPT_CAST || spellInfoMutable->HasAttribute(SPELL_ATTR0_CU_AURA_CC)) && !spellInfoMutable->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES))) + if (!spellEffectInfo.CalcValueAsInt() && !((spellEffectInfo.Effect == SPELL_EFFECT_INTERRUPT_CAST || spellInfoMutable->HasAttribute(SPELL_ATTR0_CU_AURA_CC)) && !spellInfoMutable->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES))) break; // Sindragosa Frost Breath diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index 30cea7a5f1..c9e954b25e 100644 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -439,7 +439,7 @@ class TC_GAME_API PetAura public: PetAura() : removeOnChangePet(false), damage(0) { } - PetAura(uint32 petEntry, uint32 aura, bool _removeOnChangePet, int _damage) : + PetAura(uint32 petEntry, uint32 aura, bool _removeOnChangePet, SpellEffectValue _damage) : removeOnChangePet(_removeOnChangePet), damage(_damage) { auras[petEntry] = aura; @@ -466,7 +466,7 @@ class TC_GAME_API PetAura return removeOnChangePet; } - int32 GetDamage() const + SpellEffectValue GetDamage() const { return damage; } @@ -474,7 +474,7 @@ class TC_GAME_API PetAura private: PetAuraMap auras; bool removeOnChangePet; - int32 damage; + SpellEffectValue damage; }; typedef std::map SpellPetAuraMap; @@ -697,7 +697,7 @@ class TC_GAME_API SpellMgr void GetSetOfSpellsInSpellGroup(SpellGroup group_id, std::set& foundSpells, std::set& usedGroups) const; // Spell Group Stack Rules table - bool AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, uint32 auraType, int32 amount, std::map& groups) const; + bool AddSameEffectStackRuleSpellGroups(SpellInfo const* spellInfo, AuraType auraType, SpellEffectValue amount, std::map& groups) const; SpellGroupStackRule CheckSpellGroupStackRules(SpellInfo const* spellInfo1, SpellInfo const* spellInfo2) const; SpellGroupStackRule GetSpellGroupStackRule(SpellGroup groupid) const; diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp index 0a1edb7ab5..0e26eff614 100644 --- a/src/server/game/Spells/SpellScript.cpp +++ b/src/server/game/Spells/SpellScript.cpp @@ -719,7 +719,12 @@ SpellEffectInfo const& SpellScript::GetEffectInfo() const return *m_spell->effectInfo; } -int32 SpellScript::GetEffectValue() const +int32 SpellScript::GetEffectValueAsInt() const +{ + return static_cast(GetEffectValue()); +} + +SpellEffectValue SpellScript::GetEffectValue() const { if (!IsInEffectHook()) { @@ -727,10 +732,10 @@ int32 SpellScript::GetEffectValue() const return 0; } - return m_spell->damage; + return m_spell->effectValue; } -void SpellScript::SetEffectValue(int32 value) +void SpellScript::SetEffectValue(SpellEffectValue value) { if (!IsInEffectHook()) { @@ -738,7 +743,7 @@ void SpellScript::SetEffectValue(int32 value) return; } - m_spell->damage = value; + m_spell->effectValue = std::clamp(value, SpellEffectInfo::MinValue, SpellEffectInfo::MaxValue); } float SpellScript::GetEffectVariance() const diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index e3f818628b..2ae439a378 100644 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -55,6 +55,8 @@ struct SpellValue; enum Difficulty : int16; enum class ItemContext : uint8; +using SpellEffectValue = double; + #define SPELL_EFFECT_ANY ((uint16)-1) #define SPELL_AURA_ANY ((uint16)-1) @@ -940,8 +942,9 @@ public: // method available only in EffectHandler method SpellEffectInfo const& GetEffectInfo() const; - int32 GetEffectValue() const; - void SetEffectValue(int32 value); + int32 GetEffectValueAsInt() const; + SpellEffectValue GetEffectValue() const; + void SetEffectValue(SpellEffectValue value); float GetEffectVariance() const; void SetEffectVariance(float variance); @@ -1191,7 +1194,7 @@ public: class EffectCalcAmountHandler final : public EffectBase { public: - using ScriptFuncInvoker = AuraScript::ScriptFuncInvoker; + using ScriptFuncInvoker = AuraScript::ScriptFuncInvoker; template explicit EffectCalcAmountHandler(ScriptFunc handler, uint8 effIndex, uint16 auraType) @@ -1203,17 +1206,17 @@ public: static_assert(ScriptFuncInvoker::Alignment >= alignof(ScriptFunc)); if constexpr (std::is_member_function_pointer_v) - static_assert(std::is_invocable_r_v, - R""(EffectCalcAmountHandler signature must be "void CalcAmount(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated)")""); + static_assert(std::is_invocable_r_v, + R""(EffectCalcAmountHandler signature must be "void CalcAmount(AuraEffect const* aurEff, SpellEffectValue& amount, bool& canBeRecalculated)")""); else - static_assert(std::is_invocable_r_v, - R""(EffectCalcAmountHandler signature must be "static void CalcAmount(your_script_class& script, AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated)")""); + static_assert(std::is_invocable_r_v, + R""(EffectCalcAmountHandler signature must be "static void CalcAmount(your_script_class& script, AuraEffect const* aurEff, SpellEffectValue& amount, bool& canBeRecalculated)")""); new (_invoker.ImplStorage.data()) ScriptFuncInvoker::Impl{ .Func = handler }; _invoker.Thunk = &ScriptFuncInvoker::Impl::Invoke; } - void Call(AuraScript* auraScript, AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated) const + void Call(AuraScript* auraScript, AuraEffect const* aurEff, SpellEffectValue& amount, bool& canBeRecalculated) const { return _invoker.Thunk(*auraScript, aurEff, amount, canBeRecalculated, _invoker.ImplStorage); } diff --git a/src/server/scripts/Argus/AntorusTheBurningThrone/boss_garothi_worldbreaker.cpp b/src/server/scripts/Argus/AntorusTheBurningThrone/boss_garothi_worldbreaker.cpp index 65e07c5a47..ce64017a19 100644 --- a/src/server/scripts/Argus/AntorusTheBurningThrone/boss_garothi_worldbreaker.cpp +++ b/src/server/scripts/Argus/AntorusTheBurningThrone/boss_garothi_worldbreaker.cpp @@ -598,13 +598,13 @@ class spell_garothi_fel_bombardment_periodic : public AuraScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandlePeriodic(AuraEffect const* aurEff) { if (Unit* caster = GetCaster()) - caster->CastSpell(GetTarget(), uint32(aurEff->GetSpellEffectInfo().CalcValue(caster)), true); + caster->CastSpell(GetTarget(), uint32(aurEff->GetSpellEffectInfo().CalcValueAsInt(caster)), true); } void Register() override @@ -651,7 +651,7 @@ class spell_garothi_searing_barrage_selector : public SpellScript void HandleHit(SpellEffIndex /*effIndex*/) { - uint32 spellId = GetEffectValue() == SPELL_SEARING_BARRAGE_DUMMY_ANNIHILATOR ? SPELL_SEARING_BARRAGE_DAMAGE_ANNIHILATOR : SPELL_SEARING_BARRAGE_DAMAGE_DECIMATOR; + uint32 spellId = GetEffectValueAsInt() == SPELL_SEARING_BARRAGE_DUMMY_ANNIHILATOR ? SPELL_SEARING_BARRAGE_DAMAGE_ANNIHILATOR : SPELL_SEARING_BARRAGE_DAMAGE_DECIMATOR; if (Unit* caster = GetCaster()) caster->CastSpell(GetHitUnit(), spellId, true); } @@ -739,13 +739,13 @@ class spell_garothi_annihilation_selector : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleHit(SpellEffIndex /*effIndex*/) { if (Unit* caster = GetCaster()) - caster->CastSpell(GetHitUnit(), uint32(GetEffectInfo().CalcValue(caster)), true); + caster->CastSpell(GetHitUnit(), uint32(GetEffectInfo().CalcValueAsInt(caster)), true); } void Register() override diff --git a/src/server/scripts/Battlegrounds/DalaranSewers/arena_dalaran_sewers.cpp b/src/server/scripts/Battlegrounds/DalaranSewers/arena_dalaran_sewers.cpp index 24b16f3b90..175bedee0c 100644 --- a/src/server/scripts/Battlegrounds/DalaranSewers/arena_dalaran_sewers.cpp +++ b/src/server/scripts/Battlegrounds/DalaranSewers/arena_dalaran_sewers.cpp @@ -262,13 +262,13 @@ class spell_arena_dalaran_sewers_pipe_flush_knockback_search_trigger : public Sp bool Validate(SpellInfo const* spellInfo) override { return ValidateSpellInfo({ - static_cast(spellInfo->GetEffect(EFFECT_0).CalcValue()) + static_cast(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleDummy(SpellEffIndex /*effIndex*/) const { - GetCaster()->CastSpell(nullptr, GetSpellInfo()->GetEffect(EFFECT_0).CalcValue(), CastSpellExtraArgsInit + GetCaster()->CastSpell(nullptr, GetSpellInfo()->GetEffect(EFFECT_0).CalcValueAsInt(), CastSpellExtraArgsInit { .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR }); diff --git a/src/server/scripts/Battlegrounds/SeethingShore/battleground_seething_shore.cpp b/src/server/scripts/Battlegrounds/SeethingShore/battleground_seething_shore.cpp index f6810ecd7a..7e3f5413b9 100644 --- a/src/server/scripts/Battlegrounds/SeethingShore/battleground_seething_shore.cpp +++ b/src/server/scripts/Battlegrounds/SeethingShore/battleground_seething_shore.cpp @@ -609,7 +609,7 @@ class spell_bg_seething_shore_parachute : public SpellScript return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo( { - static_cast(spellInfo->GetEffect(EFFECT_0).CalcValue()), + static_cast(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()), SeethingShore::Spells::AchievementTrackerCreditClaimJumper, SeethingShore::Spells::AchievementTrackerDeathFromAbove }); @@ -623,7 +623,7 @@ class spell_bg_seething_shore_parachute : public SpellScript args.TriggerFlags = TRIGGERED_FULL_MASK; args.OriginalCastId = GetSpell()->m_castId; - player->CastSpell(player, static_cast(GetEffectInfo().CalcValue(player)), args); + player->CastSpell(player, static_cast(GetEffectInfo().CalcValueAsInt(player)), args); player->CastSpell(player, SeethingShore::Spells::AchievementTrackerCreditClaimJumper, true); player->CastSpell(player, SeethingShore::Spells::AchievementTrackerDeathFromAbove, true); } diff --git a/src/server/scripts/BrokenIsles/TrialOfValor/boss_guarm.cpp b/src/server/scripts/BrokenIsles/TrialOfValor/boss_guarm.cpp index fa5b8a08fb..19f81696db 100644 --- a/src/server/scripts/BrokenIsles/TrialOfValor/boss_guarm.cpp +++ b/src/server/scripts/BrokenIsles/TrialOfValor/boss_guarm.cpp @@ -418,7 +418,7 @@ class spell_lick_selector_guarm : public SpellScript void HandleHitTarget(SpellEffIndex /*effIndex*/) { - GetCaster()->CastSpell(GetHitUnit(), GetEffectValue(), true); + GetCaster()->CastSpell(GetHitUnit(), GetEffectValueAsInt(), true); } void Register() override @@ -728,7 +728,7 @@ class spell_volatile_foam_selector : public SpellScript void HandleHitTarget(SpellEffIndex /*effIndex*/) { - GetCaster()->CastSpell(GetHitUnit(), GetEffectValue(), true); + GetCaster()->CastSpell(GetHitUnit(), GetEffectValueAsInt(), true); } void Register() override @@ -769,7 +769,7 @@ class spell_volatile_foam_aura : public AuraScript { return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo( { - (uint32)spellInfo->GetEffect(EFFECT_0).CalcValue(), // SpellIdOnDispel + (uint32)spellInfo->GetEffect(EFFECT_0).CalcValueAsInt(), // SpellIdOnDispel SpellIdOnExpire }); } @@ -782,7 +782,7 @@ class spell_volatile_foam_aura : public AuraScript if (removeMode == AURA_REMOVE_BY_EXPIRE) target->CastSpell(target, SpellIdOnExpire); else if (removeMode == AURA_REMOVE_BY_ENEMY_SPELL) - target->CastSpell(nullptr, GetSpellInfo()->GetEffect(EFFECT_0).CalcValue()); + target->CastSpell(nullptr, GetSpellInfo()->GetEffect(EFFECT_0).CalcValueAsInt()); } void Register() override diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 063d0699f1..46e8a7ad18 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -1005,7 +1005,7 @@ public: for (auto const& pair : redirectInfo) { Unit* unit = ObjectAccessor::GetUnit(*target, pair.first); - handler->PSendSysMessage(" |-- %02u%% to %s", pair.second, unit ? unit->GetName().c_str() : pair.first.ToString().c_str()); + handler->PSendSysMessage(" |-- % 2.1f%% to %s", pair.second, unit ? unit->GetName().c_str() : pair.first.ToString().c_str()); } } } @@ -1025,7 +1025,7 @@ public: for (auto const& innerPair : outerPair.second) // (guid, pct) { Unit* unit = ObjectAccessor::GetUnit(*target, innerPair.first); - handler->PSendSysMessage(" |-- %02u%% to %s", innerPair.second, unit ? unit->GetName().c_str() : innerPair.first.ToString().c_str()); + handler->PSendSysMessage(" |-- % 2.1f%% to %s", innerPair.second, unit ? unit->GetName().c_str() : innerPair.first.ToString().c_str()); } } } diff --git a/src/server/scripts/EasternKingdoms/BaradinHold/boss_argaloth.cpp b/src/server/scripts/EasternKingdoms/BaradinHold/boss_argaloth.cpp index ac6ddaffef..4d684391a5 100644 --- a/src/server/scripts/EasternKingdoms/BaradinHold/boss_argaloth.cpp +++ b/src/server/scripts/EasternKingdoms/BaradinHold/boss_argaloth.cpp @@ -150,7 +150,7 @@ class spell_argaloth_consuming_darkness : public AuraScript { if (AuraEffect* aurEff = GetEffect(EFFECT_0)) { - int32 damage = aurEff->GetAmount() + CalculatePct(aurEff->GetAmount(), 10); + SpellEffectValue damage = aurEff->GetAmount() + CalculatePct(aurEff->GetAmount(), 10); aurEff->SetAmount(damage); } } diff --git a/src/server/scripts/EasternKingdoms/BaradinHold/boss_occuthar.cpp b/src/server/scripts/EasternKingdoms/BaradinHold/boss_occuthar.cpp index 6d4b0e31a8..332a333759 100644 --- a/src/server/scripts/EasternKingdoms/BaradinHold/boss_occuthar.cpp +++ b/src/server/scripts/EasternKingdoms/BaradinHold/boss_occuthar.cpp @@ -248,7 +248,7 @@ class spell_occuthar_eyes_of_occuthar : public SpellScriptLoader { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } bool Load() override @@ -266,7 +266,7 @@ class spell_occuthar_eyes_of_occuthar : public SpellScriptLoader void HandleScript(SpellEffIndex /*effIndex*/) { - GetHitUnit()->CastSpell(GetCaster(), GetEffectValue(), true); + GetHitUnit()->CastSpell(GetCaster(), GetEffectValueAsInt(), true); } void Register() override diff --git a/src/server/scripts/EasternKingdoms/Gilneas/gilneas_chapter_1.cpp b/src/server/scripts/EasternKingdoms/Gilneas/gilneas_chapter_1.cpp index a249d16a0f..2584514277 100644 --- a/src/server/scripts/EasternKingdoms/Gilneas/gilneas_chapter_1.cpp +++ b/src/server/scripts/EasternKingdoms/Gilneas/gilneas_chapter_1.cpp @@ -147,14 +147,14 @@ class spell_gilneas_knocking : public SpellScript { return ValidateSpellInfo( { - uint32(spellInfo->GetEffect(EFFECT_1).CalcValue()), - uint32(spellInfo->GetEffect(EFFECT_2).CalcValue()) + uint32(spellInfo->GetEffect(EFFECT_1).CalcValueAsInt()), + uint32(spellInfo->GetEffect(EFFECT_2).CalcValueAsInt()) }); } void HandleEffect() { - GetCaster()->CastSpell(GetCaster(), GetEffectInfo(RAND(EFFECT_1, EFFECT_2)).CalcValue(), true); + GetCaster()->CastSpell(GetCaster(), GetEffectInfo(RAND(EFFECT_1, EFFECT_2)).CalcValueAsInt(), true); } void Register() override diff --git a/src/server/scripts/EasternKingdoms/ReturnToKarazhan/boss_maiden_of_virtue_rtk.cpp b/src/server/scripts/EasternKingdoms/ReturnToKarazhan/boss_maiden_of_virtue_rtk.cpp index 2d0d9f9519..a8bfc08f7c 100644 --- a/src/server/scripts/EasternKingdoms/ReturnToKarazhan/boss_maiden_of_virtue_rtk.cpp +++ b/src/server/scripts/EasternKingdoms/ReturnToKarazhan/boss_maiden_of_virtue_rtk.cpp @@ -222,7 +222,7 @@ class spell_maiden_of_virtue_rtk_sacred_ground : public AuraScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandlePeriodic(AuraEffect const* /*aurEff*/) const @@ -230,7 +230,7 @@ class spell_maiden_of_virtue_rtk_sacred_ground : public AuraScript if (!GetCaster()) return; - GetCaster()->CastSpell(GetTarget(), GetEffectInfo(EFFECT_0).CalcValue(), TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR); + GetCaster()->CastSpell(GetTarget(), GetEffectInfo(EFFECT_0).CalcValueAsInt(), TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR); } void Register() override diff --git a/src/server/scripts/EasternKingdoms/ReturnToKarazhan/boss_shade_of_medivh.cpp b/src/server/scripts/EasternKingdoms/ReturnToKarazhan/boss_shade_of_medivh.cpp index c2d31a6b5f..73a7e8bf1b 100644 --- a/src/server/scripts/EasternKingdoms/ReturnToKarazhan/boss_shade_of_medivh.cpp +++ b/src/server/scripts/EasternKingdoms/ReturnToKarazhan/boss_shade_of_medivh.cpp @@ -679,7 +679,7 @@ class spell_shade_of_medivh_arcane_bolt_selector : public SpellScript { void HandleScript(SpellEffIndex /*effIndex*/) const { - GetCaster()->CastSpell(GetHitUnit(), GetEffectValue(), CastSpellExtraArgsInit{ + GetCaster()->CastSpell(GetHitUnit(), GetEffectValueAsInt(), CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringSpell = GetSpell(), }); diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp index ff1cacd5e0..e16af7b56d 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp @@ -614,7 +614,7 @@ class spell_death_knight_devour_humanoid : public SpellScript { void HandleScriptEffect(SpellEffIndex /* effIndex */) { - GetHitUnit()->CastSpell(GetCaster(), GetEffectValue(), true); + GetHitUnit()->CastSpell(GetCaster(), GetEffectValueAsInt(), true); } void Register() override diff --git a/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp b/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp index 9536ae4db6..ac5f9c535d 100644 --- a/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp +++ b/src/server/scripts/EasternKingdoms/ShadowfangKeep/shadowfang_keep.cpp @@ -31,7 +31,7 @@ class spell_shadowfang_keep_haunting_spirits : public AuraScript void HandleDummyTick(AuraEffect const* aurEff) { - GetTarget()->CastSpell(nullptr, aurEff->GetAmount(), true); + GetTarget()->CastSpell(nullptr, aurEff->GetAmountAsInt(), true); } void HandleUpdatePeriodic(AuraEffect* aurEff) diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index 68717bdb57..31b0d012c5 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -601,12 +601,12 @@ class spell_kalecgos_tap_check : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleDummy(SpellEffIndex /*effIndex*/) { - GetHitUnit()->CastSpell(GetCaster(), GetEffectInfo().CalcValue(), true); + GetHitUnit()->CastSpell(GetCaster(), GetEffectInfo().CalcValueAsInt(), true); } void Register() override diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp index 9dce483983..0381aaff7b 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp @@ -415,7 +415,7 @@ class spell_mandokir_decapitate : public SpellScript { Unit* caster = GetCaster(); if (Player* target = GetHitPlayer()) - caster->CastSpell(target, uint32(GetEffectValue()), true); + caster->CastSpell(target, uint32(GetEffectValueAsInt()), true); } void Register() override @@ -442,7 +442,7 @@ class spell_mandokir_bloodletting : public AuraScript CastSpellExtraArgs args; args.TriggerFlags = TRIGGERED_FULL_MASK; - args.AddSpellMod(SPELLVALUE_BASE_POINT0, std::max(7500, target->CountPctFromCurHealth(aurEff->GetAmount()))); + args.AddSpellMod(SPELLVALUE_BASE_POINT0, std::max(7500, CalculatePct(target->GetHealth(), aurEff->GetAmount()))); caster->CastSpell(target, SPELL_BLOODLETTING_DAMAGE, args); target->CastSpell(caster, SPELL_BLOODLETTING_HEAL, args); @@ -460,7 +460,7 @@ class spell_mandokir_spirit_vengeance_cancel : public SpellScript void HandleScript(SpellEffIndex /*effIndex*/) { if (Player* target = GetHitPlayer()) - target->RemoveAura(uint32(GetEffectValue())); + target->RemoveAura(uint32(GetEffectValueAsInt())); } void Register() override @@ -553,7 +553,7 @@ class spell_mandokir_ohgan_orders : public SpellScript { Unit* caster = GetCaster(); if (Unit* target = GetHitUnit()) - caster->CastSpell(target, uint32(GetEffectValue()), true); + caster->CastSpell(target, uint32(GetEffectValueAsInt()), true); } void Register() override diff --git a/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp b/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp index 7177fb2ec0..b2ea568a23 100644 --- a/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp +++ b/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp @@ -353,13 +353,13 @@ class spell_stormwind_harbor_to_boralus_transition : public AuraScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_1).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_1).CalcValueAsInt()) }); } void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { if (Unit* caster = GetCaster()) - caster->CastSpell(caster, aurEff->GetAmount(), false); + caster->CastSpell(caster, aurEff->GetAmountAsInt(), false); } void Register() override diff --git a/src/server/scripts/Events/love_is_in_the_air.cpp b/src/server/scripts/Events/love_is_in_the_air.cpp index 10a5448c43..986c9664be 100644 --- a/src/server/scripts/Events/love_is_in_the_air.cpp +++ b/src/server/scripts/Events/love_is_in_the_air.cpp @@ -152,12 +152,12 @@ class spell_love_is_in_the_air_fragrant_air_analysis : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { - GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValue())); + GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValueAsInt())); } void Register() override @@ -171,12 +171,12 @@ class spell_love_is_in_the_air_heavily_perfumed : public AuraScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - GetTarget()->CastSpell(GetTarget(), uint32(GetEffectInfo(EFFECT_0).CalcValue())); + GetTarget()->CastSpell(GetTarget(), uint32(GetEffectInfo(EFFECT_0).CalcValueAsInt())); } void Register() override @@ -241,7 +241,7 @@ class spell_love_is_in_the_air_service_uniform : public AuraScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) @@ -258,7 +258,7 @@ class spell_love_is_in_the_air_service_uniform : public AuraScript void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - GetTarget()->RemoveAurasDueToSpell(uint32(GetEffectInfo(EFFECT_0).CalcValue())); + GetTarget()->RemoveAurasDueToSpell(uint32(GetEffectInfo(EFFECT_0).CalcValueAsInt())); } void Register() override @@ -300,14 +300,14 @@ class spell_love_is_in_the_air_perfume_cologne_immune : public SpellScript { return ValidateSpellInfo( { - uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()), - uint32(spellInfo->GetEffect(EFFECT_1).CalcValue()) + uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()), + uint32(spellInfo->GetEffect(EFFECT_1).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { - GetCaster()->RemoveAurasDueToSpell(uint32(GetEffectValue())); + GetCaster()->RemoveAurasDueToSpell(uint32(GetEffectValueAsInt())); } void Register() override diff --git a/src/server/scripts/Events/pilgrims_bounty.cpp b/src/server/scripts/Events/pilgrims_bounty.cpp index 9d0b8f7ad5..c3dbd4fc47 100644 --- a/src/server/scripts/Events/pilgrims_bounty.cpp +++ b/src/server/scripts/Events/pilgrims_bounty.cpp @@ -87,7 +87,7 @@ class spell_pilgrims_bounty_feast_on : public SpellScript bool Validate(SpellInfo const* spellInfo) override { return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) - && ValidateSpellEffect({ { uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()), EFFECT_0 } }); + && ValidateSpellEffect({ { uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()), EFFECT_0 } }); } void HandleDummy(SpellEffIndex /*effIndex*/) @@ -125,10 +125,10 @@ class spell_pilgrims_bounty_feast_on : public SpellScript .SetOriginalCaster(player->GetGUID())); } - if (Aura* aura = caster->GetAura(GetEffectValue())) + if (Aura* aura = caster->GetAura(GetEffectValueAsInt())) { if (aura->GetStackAmount() == 1) - caster->RemoveAurasDueToSpell(aura->GetSpellInfo()->GetEffect(EFFECT_0).CalcValue()); + caster->RemoveAurasDueToSpell(aura->GetSpellInfo()->GetEffect(EFFECT_0).CalcValueAsInt()); aura->ModStackAmount(-1); } } @@ -411,14 +411,14 @@ private: void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { Unit* target = GetTarget(); - target->CastSpell(target, uint32(aurEff->GetAmount()), true); + target->CastSpell(target, uint32(aurEff->GetAmountAsInt()), true); HandlePlate(target, true); } void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { Unit* target = GetTarget(); - target->RemoveAurasDueToSpell(aurEff->GetAmount()); + target->RemoveAurasDueToSpell(aurEff->GetAmountAsInt()); HandlePlate(target, false); } diff --git a/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp b/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp index 9b5ebec95f..245759b8c3 100644 --- a/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp +++ b/src/server/scripts/Kalimdor/BlackfathomDeeps/blackfathom_deeps.cpp @@ -208,7 +208,7 @@ public: void HandleScript(SpellEffIndex /*effIndex*/) { if (Unit* hitUnit = GetHitUnit()) - GetCaster()->CastSpell(hitUnit, uint32(GetEffectValue()), true); + GetCaster()->CastSpell(hitUnit, uint32(GetEffectValueAsInt()), true); } void Register() override diff --git a/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp b/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp index 64668e887e..d5b9ee9243 100644 --- a/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp +++ b/src/server/scripts/Kalimdor/Firelands/boss_baleroc.cpp @@ -409,13 +409,13 @@ class spell_baleroc_decimating_strike : public SpellScript bool Validate(SpellInfo const* spellInfo) override { return ValidateSpellEffect({ { spellInfo->Id, EFFECT_2 } }) - && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_2).CalcValue()) }); + && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_2).CalcValueAsInt()) }); } void ChangeDamage() { int32 healthPctDmg = GetHitUnit()->CountPctFromMaxHealth(GetEffectInfo(EFFECT_0).CalcValue(GetCaster())); - int32 flatDmg = GetEffectInfo(EFFECT_2).CalcValue(GetCaster()); + int32 flatDmg = GetEffectInfo(EFFECT_2).CalcValueAsInt(GetCaster()); SetHitDamage(healthPctDmg < flatDmg ? flatDmg : healthPctDmg); } @@ -779,7 +779,7 @@ class spell_baleroc_vital_flame : public AuraScript } stacks = GetCaster()->GetAuraCount(SPELL_VITAL_SPARK); - int32 healingPct = sSpellMgr->AssertSpellInfo(SPELL_VITAL_SPARK, GetCastDifficulty())->GetEffect(EFFECT_0).CalcValue(GetCaster()) * stacks; + SpellEffectValue healingPct = sSpellMgr->AssertSpellInfo(SPELL_VITAL_SPARK, GetCastDifficulty())->GetEffect(EFFECT_0).CalcValue(GetCaster()) * stacks; if (GetAura()->GetEffect(EFFECT_0)->GetAmount() < healingPct) GetAura()->GetEffect(EFFECT_0)->SetAmount(healingPct); diff --git a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_temple_guardian_anhuur.cpp b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_temple_guardian_anhuur.cpp index 764cd43494..5bcbf61ddf 100644 --- a/src/server/scripts/Kalimdor/HallsOfOrigination/boss_temple_guardian_anhuur.cpp +++ b/src/server/scripts/Kalimdor/HallsOfOrigination/boss_temple_guardian_anhuur.cpp @@ -287,7 +287,7 @@ class spell_anhuur_disable_beacon_beams : public SpellScript { void HandleScript(SpellEffIndex /*effIndex*/) { - GetHitUnit()->RemoveAurasDueToSpell(GetEffectValue()); + GetHitUnit()->RemoveAurasDueToSpell(GetEffectValueAsInt()); } void Notify(SpellEffIndex /*index*/) diff --git a/src/server/scripts/Kalimdor/RagefireChasm/boss_dark_shaman_koranthal.cpp b/src/server/scripts/Kalimdor/RagefireChasm/boss_dark_shaman_koranthal.cpp index beba0fa6b2..ac7c7ad32a 100644 --- a/src/server/scripts/Kalimdor/RagefireChasm/boss_dark_shaman_koranthal.cpp +++ b/src/server/scripts/Kalimdor/RagefireChasm/boss_dark_shaman_koranthal.cpp @@ -126,7 +126,7 @@ class spell_dark_shaman_koranthal_shadow_storm : public SpellScript { void HandleScript(SpellEffIndex /*effIndex*/) const { - GetCaster()->CastSpell(GetHitUnit(), GetEffectValue(), true); + GetCaster()->CastSpell(GetHitUnit(), GetEffectValueAsInt(), true); } void Register() override diff --git a/src/server/scripts/Kalimdor/zone_dustwallow_marsh.cpp b/src/server/scripts/Kalimdor/zone_dustwallow_marsh.cpp index 41c617f230..554245cb6c 100644 --- a/src/server/scripts/Kalimdor/zone_dustwallow_marsh.cpp +++ b/src/server/scripts/Kalimdor/zone_dustwallow_marsh.cpp @@ -38,7 +38,7 @@ class spell_ooze_zap : public SpellScript SpellCastResult CheckRequirement() { - if (!GetCaster()->HasAura(GetEffectInfo(EFFECT_1).CalcValue())) + if (!GetCaster()->HasAura(GetEffectInfo(EFFECT_1).CalcValueAsInt())) return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; // This is actually correct if (!GetExplTargetUnit()) @@ -51,7 +51,7 @@ class spell_ooze_zap : public SpellScript { PreventHitDefaultEffect(effIndex); if (GetHitUnit()) - GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true); + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -95,7 +95,7 @@ class spell_energize_aoe : public SpellScript { for (std::list::iterator itr = targets.begin(); itr != targets.end();) { - if ((*itr)->GetTypeId() == TYPEID_PLAYER && (*itr)->ToPlayer()->GetQuestStatus(GetEffectInfo(EFFECT_1).CalcValue()) == QUEST_STATUS_INCOMPLETE) + if ((*itr)->GetTypeId() == TYPEID_PLAYER && (*itr)->ToPlayer()->GetQuestStatus(GetEffectInfo(EFFECT_1).CalcValueAsInt()) == QUEST_STATUS_INCOMPLETE) ++itr; else targets.erase(itr++); @@ -106,7 +106,7 @@ class spell_energize_aoe : public SpellScript void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt()), true); } void Register() override diff --git a/src/server/scripts/KhazAlgar/TheStoneVault/boss_edna.cpp b/src/server/scripts/KhazAlgar/TheStoneVault/boss_edna.cpp index dd087c8ffc..a58a70b31b 100644 --- a/src/server/scripts/KhazAlgar/TheStoneVault/boss_edna.cpp +++ b/src/server/scripts/KhazAlgar/TheStoneVault/boss_edna.cpp @@ -474,7 +474,7 @@ class spell_edna_refracting_beam_selector : public SpellScript void FilterTargets(std::list& targets) const { SpellInfo const* spell = sSpellMgr->GetSpellInfo(SPELL_REFRACTING_BEAM_DAMAGE, GetCastDifficulty()); - uint32 maxTargets = spell->GetEffect(EFFECT_3).CalcValue(GetCaster()); + uint32 maxTargets = spell->GetEffect(EFFECT_3).CalcValueAsInt(GetCaster()); if (targets.size() > maxTargets) targets.resize(maxTargets); diff --git a/src/server/scripts/KulTiras/ShrineOfTheStorm/boss_lord_stormsong.cpp b/src/server/scripts/KulTiras/ShrineOfTheStorm/boss_lord_stormsong.cpp index 6b69fda548..683f206f23 100644 --- a/src/server/scripts/KulTiras/ShrineOfTheStorm/boss_lord_stormsong.cpp +++ b/src/server/scripts/KulTiras/ShrineOfTheStorm/boss_lord_stormsong.cpp @@ -472,12 +472,12 @@ class spell_lord_stormsong_surrender_to_the_void : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleDummy(SpellEffIndex /* effIndex */) const { - GetHitUnit()->m_Events.AddEvent([hitUnit = GetHitUnit(), casterGUID = GetCaster()->GetGUID(), spellId = GetEffectValue()]() + GetHitUnit()->m_Events.AddEvent([hitUnit = GetHitUnit(), casterGUID = GetCaster()->GetGUID(), spellId = GetEffectValueAsInt()]() { if (Unit* caster = ObjectAccessor::GetUnit(*hitUnit, casterGUID)) hitUnit->CastSpell(caster, uint32(spellId), TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR); @@ -495,13 +495,13 @@ class spell_lord_stormsong_disciple_of_the_vol_zith : public AuraScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandlePeriodic(AuraEffect const* /*aurEff*/) const { Unit* target = GetTarget(); - target->CastSpell(target, GetEffectInfo(EFFECT_0).CalcValue(), TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR); + target->CastSpell(target, GetEffectInfo(EFFECT_0).CalcValueAsInt(), TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR); } void Register() override diff --git a/src/server/scripts/KulTiras/ShrineOfTheStorm/boss_tidesage_council.cpp b/src/server/scripts/KulTiras/ShrineOfTheStorm/boss_tidesage_council.cpp index 131aba7bcd..b036ff896b 100644 --- a/src/server/scripts/KulTiras/ShrineOfTheStorm/boss_tidesage_council.cpp +++ b/src/server/scripts/KulTiras/ShrineOfTheStorm/boss_tidesage_council.cpp @@ -351,12 +351,12 @@ class spell_tidesage_council_ward_selector : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleHitTarget(SpellEffIndex /*effIndex*/) const { - GetCaster()->CastSpell(GetHitUnit()->GetPosition(), GetEffectValue(), CastSpellExtraArgsInit{ + GetCaster()->CastSpell(GetHitUnit()->GetPosition(), GetEffectValueAsInt(), CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringSpell = GetSpell() }); diff --git a/src/server/scripts/KulTiras/WaycrestManor/boss_heartsbane_triad.cpp b/src/server/scripts/KulTiras/WaycrestManor/boss_heartsbane_triad.cpp index 8e8e206668..b311343983 100644 --- a/src/server/scripts/KulTiras/WaycrestManor/boss_heartsbane_triad.cpp +++ b/src/server/scripts/KulTiras/WaycrestManor/boss_heartsbane_triad.cpp @@ -676,7 +676,7 @@ class spell_heartsbane_triad_jagged_nettles : public AuraScript { if (aurEff->GetTickNumber() > 1) { - if (GetTarget()->GetHealthPct() >= float(GetEffectInfo(EFFECT_2).CalcValue(GetCaster()))) + if (GetTarget()->GetHealthPct() >= GetEffectInfo(EFFECT_2).CalcValue(GetCaster())) Remove(); } } diff --git a/src/server/scripts/KulTiras/WaycrestManor/boss_soulbound_goliath.cpp b/src/server/scripts/KulTiras/WaycrestManor/boss_soulbound_goliath.cpp index d08fe51c8a..980daec93c 100644 --- a/src/server/scripts/KulTiras/WaycrestManor/boss_soulbound_goliath.cpp +++ b/src/server/scripts/KulTiras/WaycrestManor/boss_soulbound_goliath.cpp @@ -278,7 +278,7 @@ class spell_soulbound_goliath_soul_thorns_remove_stun : public SpellScript if (TempSummon* target = GetHitUnit()->ToTempSummon()) { if (Unit* summoner = target->GetSummonerUnit()) - summoner->RemoveAurasDueToSpell(GetEffectValue()); + summoner->RemoveAurasDueToSpell(GetEffectValueAsInt()); } } diff --git a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/ahnkahet.cpp b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/ahnkahet.cpp index c6ab0f90be..9d69d02bef 100644 --- a/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/ahnkahet.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/Ahnkahet/ahnkahet.cpp @@ -86,20 +86,20 @@ class spell_ahnkahet_yogg_saron_whisper : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return sBroadcastTextStore.HasRecord(uint32(spellInfo->GetEffect(EFFECT_0).CalcValue())) && - sSoundKitStore.HasRecord(uint32(spellInfo->GetEffect(EFFECT_1).CalcValue())); + return sBroadcastTextStore.HasRecord(uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt())) && + sSoundKitStore.HasRecord(uint32(spellInfo->GetEffect(EFFECT_1).CalcValueAsInt())); } void HandleScript(SpellEffIndex /*effIndex*/) { if (Player* player = GetHitPlayer()) - GetCaster()->Unit::Whisper(uint32(GetEffectValue()), player, false); + GetCaster()->Unit::Whisper(uint32(GetEffectValueAsInt()), player, false); } void HandleDummy(SpellEffIndex /*effIndex*/) { if (Player* player = GetHitPlayer()) - player->PlayDistanceSound(uint32(GetEffectValue()), player); + player->PlayDistanceSound(uint32(GetEffectValueAsInt()), player); } void Register() override diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp index 67117eb675..5b5af02855 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp @@ -1704,8 +1704,8 @@ class spell_halion_clear_debuffs : public SpellScriptLoader void HandleScript(SpellEffIndex /*effIndex*/) { - if (GetHitUnit()->HasAura(GetEffectInfo().CalcValue())) - GetHitUnit()->RemoveAurasDueToSpell(GetEffectInfo().CalcValue()); + if (GetHitUnit()->HasAura(GetEffectInfo().CalcValueAsInt())) + GetHitUnit()->RemoveAurasDueToSpell(GetEffectInfo().CalcValueAsInt()); } void Register() override diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_saviana_ragefire.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_saviana_ragefire.cpp index d6fe5c2a01..a8b667572b 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_saviana_ragefire.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_saviana_ragefire.cpp @@ -241,7 +241,7 @@ class spell_saviana_conflagration_throwback : public SpellScript void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt()), true); GetHitUnit()->GetMotionMaster()->MovePoint(POINT_LAND, SavianaRagefireFlyInPos); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp index a42e87a133..43ef561e70 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_black_knight.cpp @@ -384,12 +384,12 @@ class spell_black_knight_ghoul_explode : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { - GetHitUnit()->CastSpell(GetHitUnit(), uint32(GetEffectInfo(EFFECT_0).CalcValue())); + GetHitUnit()->CastSpell(GetHitUnit(), uint32(GetEffectInfo(EFFECT_0).CalcValueAsInt())); } void Register() override @@ -404,12 +404,12 @@ class spell_black_knight_ghoul_explode_risen_ghoul : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_1).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_1).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { - GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValue())); + GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt())); } void Register() override diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp index 08c75cc716..d157c8ce2e 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp @@ -855,7 +855,7 @@ class spell_anubarak_leeching_swarm : public AuraScript Unit* caster = GetCaster(); if (Unit* target = GetTarget()) { - int32 lifeLeeched = target->CountPctFromCurHealth(aurEff->GetAmount()); + SpellEffectValue lifeLeeched = target->CountPctFromCurHealth(aurEff->GetAmount()); if (lifeLeeched < 250) lifeLeeched = 250; CastSpellExtraArgs args(TRIGGERED_FULL_MASK); diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp index c6a4c1a939..752879f7ad 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_lord_jaraxxus.cpp @@ -487,7 +487,7 @@ class spell_mistress_kiss_area : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void FilterTargets(std::list& targets) @@ -508,7 +508,7 @@ class spell_mistress_kiss_area : public SpellScript void HandleScript(SpellEffIndex /*effIndex*/) { - GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true); + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -523,12 +523,12 @@ class spell_fel_streak_visual : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { - GetCaster()->CastSpell(GetHitUnit(), static_cast(GetEffectValue()), true); + GetCaster()->CastSpell(GetHitUnit(), static_cast(GetEffectValueAsInt()), true); } void Register() override diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp index f744fe1c8f..89151a737e 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp @@ -1150,7 +1150,7 @@ class spell_jormungars_paralytic_toxin : public AuraScript GetTarget()->RemoveAurasDueToSpell(SPELL_PARALYSIS); } - void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated) + void CalculateAmount(AuraEffect const* aurEff, SpellEffectValue& amount, bool& canBeRecalculated) { if (!canBeRecalculated) amount = aurEff->GetAmount(); @@ -1162,7 +1162,7 @@ class spell_jormungars_paralytic_toxin : public AuraScript { if (AuraEffect* slowEff = GetEffect(EFFECT_0)) { - int32 newAmount = slowEff->GetAmount() - 10; + SpellEffectValue newAmount = slowEff->GetAmount() - 10; if (newAmount < -100) newAmount = -100; slowEff->ChangeAmount(newAmount); @@ -1270,12 +1270,12 @@ class spell_icehowl_arctic_breath : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScriptEffect(SpellEffIndex /*effIndex*/) { - uint32 spellId = GetEffectInfo().CalcValue(); + uint32 spellId = GetEffectInfo().CalcValueAsInt(); GetCaster()->CastSpell(GetHitUnit(), spellId, true); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp index 98607db6f3..408bb22c1b 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_twin_valkyr.cpp @@ -750,7 +750,7 @@ private: // Twin Vortex part uint32 lightVortex = SPELL_LIGHT_VORTEX_DAMAGE; uint32 darkVortex = SPELL_DARK_VORTEX_DAMAGE; - int32 stacksCount = dmgInfo.GetSpellInfo()->GetEffect(EFFECT_0).CalcValue() / 1000 - 1; + int32 stacksCount = dmgInfo.GetSpellInfo()->GetEffect(EFFECT_0).CalcValueAsInt() / 1000 - 1; if (lightVortex && darkVortex && stacksCount) { diff --git a/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp b/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp index f38e1dcf69..c0042273ef 100644 --- a/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp +++ b/src/server/scripts/Northrend/DraktharonKeep/boss_trollgore.cpp @@ -255,13 +255,13 @@ class spell_trollgore_invader_taunt : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleTaunt(SpellEffIndex /*effIndex*/) { if (Unit* target = GetHitUnit()) - target->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + target->CastSpell(GetCaster(), uint32(GetEffectValueAsInt()), true); } void Register() override diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp index a5db42cf2d..86d5c33c26 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp @@ -262,7 +262,7 @@ class spell_bronjahm_consume_soul : public SpellScript void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetHitUnit()->CastSpell(GetHitUnit(), GetEffectValue(), true); + GetHitUnit()->CastSpell(GetHitUnit(), GetEffectValueAsInt(), true); } void Register() override diff --git a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_marwyn.cpp b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_marwyn.cpp index 0660da6176..35c2d3df93 100644 --- a/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_marwyn.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/HallsOfReflection/boss_marwyn.cpp @@ -145,7 +145,7 @@ class spell_marwyn_shared_suffering : public SpellScriptLoader if (Unit* caster = GetCaster()) { - int32 remainingDamage = aurEff->GetAmount() * aurEff->GetRemainingTicks(); + SpellEffectValue remainingDamage = aurEff->GetAmount() * aurEff->GetRemainingTicks(); if (remainingDamage > 0) { CastSpellExtraArgs args(TRIGGERED_FULL_MASK); diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp index 531f88a88e..22e2a9339b 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp @@ -600,7 +600,7 @@ class spell_krick_pursuit : public SpellScript ick->AI()->Talk(SAY_ICK_CHASE_1, target); ick->AddAura(GetSpellInfo()->Id, target); ick->AI()->DoAction(ACTION_STORE_OLD_TARGET); - ick->GetThreatManager().AddThreat(target, float(GetEffectValue()), GetSpellInfo(), true, true); + ick->GetThreatManager().AddThreat(target, GetEffectValue(), GetSpellInfo(), true, true); ick->GetThreatManager().FixateTarget(target); } } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp index 0ca2b57d1e..6ace8aa4ed 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp @@ -1092,7 +1092,7 @@ class spell_taldaram_glittering_sparks : public SpellScript void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -1108,7 +1108,7 @@ class spell_taldaram_summon_flame_ball : public SpellScript void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -1290,7 +1290,7 @@ class spell_blood_council_shadow_prison_damage : public SpellScript { if (Aura const* aur = victim->GetAura(GetSpellInfo()->Id)) if (AuraEffect const* eff = aur->GetEffect(EFFECT_1)) - flatMod += eff->GetAmount(); + flatMod += eff->GetAmountAsInt(); } void Register() override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp index 48d42b6aa4..44b30bcaff 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp @@ -676,9 +676,9 @@ class spell_blood_queen_pact_of_the_darkfallen_dmg : public AuraScript void PeriodicTick(AuraEffect const* aurEff) { SpellInfo const* damageSpell = sSpellMgr->AssertSpellInfo(SPELL_PACT_OF_THE_DARKFALLEN_DAMAGE, GetCastDifficulty()); - int32 damage = damageSpell->GetEffect(EFFECT_0).CalcValue(); + SpellEffectValue damage = damageSpell->GetEffect(EFFECT_0).CalcValue(); float multiplier = 0.3375f + 0.1f * uint32(aurEff->GetTickNumber()/10); // do not convert to 0.01f - we need tick number/10 as INT (damage increases every 10 ticks) - damage = int32(damage * multiplier); + damage = damage * multiplier; CastSpellExtraArgs args(TRIGGERED_FULL_MASK); args.AddSpellBP0(damage); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp index 762eafebd8..5256c0ec08 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp @@ -1025,9 +1025,9 @@ class spell_deathbringer_blood_power : public SpellScript class spell_deathbringer_blood_power_aura : public AuraScript { - void RecalculateHook(AuraEffect const* /*aurEffect*/, int32& amount, bool& canBeRecalculated) + void RecalculateHook(AuraEffect const* /*aurEffect*/, SpellEffectValue& amount, bool& canBeRecalculated) { - amount = int32(GetUnitOwner()->GetPower(POWER_ENERGY)); + amount = GetUnitOwner()->GetPower(POWER_ENERGY); canBeRecalculated = true; } @@ -1146,7 +1146,7 @@ private: void HandleForceCast(SpellEffIndex /*effIndex*/) { - GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), TRIGGERED_FULL_MASK); + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt()), TRIGGERED_FULL_MASK); } void Register() override @@ -1190,7 +1190,7 @@ class spell_deathbringer_remove_marks : public SpellScript void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValue())); + GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValueAsInt())); } void Register() override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp index f7e8cdcbc3..360fa08de2 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp @@ -353,7 +353,7 @@ class spell_festergut_pungent_blight : public SpellScript void HandleScript(SpellEffIndex /*effIndex*/) { - GetCaster()->RemoveAurasDueToSpell(uint32(GetEffectValue())); + GetCaster()->RemoveAurasDueToSpell(uint32(GetEffectValueAsInt())); GetCaster()->ToCreature()->AI()->Talk(EMOTE_PUNGENT_BLIGHT); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp index 9c50461a49..cc50c66ae6 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp @@ -1999,7 +1999,7 @@ class spell_igb_burning_pitch_selector : public SpellScript void HandleDummy(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), TRIGGERED_NONE); + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt()), TRIGGERED_NONE); } void Register() override @@ -2017,7 +2017,7 @@ class spell_igb_burning_pitch : public SpellScript PreventHitDefaultEffect(effIndex); CastSpellExtraArgs args(TRIGGERED_FULL_MASK); args.AddSpellBP0(8000); - GetCaster()->CastSpell(nullptr, GetEffectValue(), args); + GetCaster()->CastSpell(nullptr, GetEffectValueAsInt(), args); GetHitUnit()->CastSpell(GetHitUnit(), SPELL_BURNING_PITCH, TRIGGERED_FULL_MASK); } @@ -2043,7 +2043,7 @@ class spell_igb_rocket_artillery : public SpellScript void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), TRIGGERED_NONE); + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt()), TRIGGERED_NONE); } void Register() override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp index 9de7dea952..c1a4ea1327 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp @@ -498,7 +498,7 @@ class spell_marrowgar_coldflame : public SpellScript void HandleScriptEffect(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true); + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -515,7 +515,7 @@ class spell_marrowgar_coldflame_bonestorm : public SpellScript { PreventHitDefaultEffect(effIndex); for (uint8 i = 0; i < 4; ++i) - GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue() + i), true); + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt() + i), true); } void Register() override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index b29b5a7e02..bf63b468e1 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -975,7 +975,7 @@ class spell_putricide_unstable_experiment : public SpellScript break; } - GetCaster()->CastSpell(target, uint32(GetEffectInfo(SpellEffIndex(stage)).CalcValue()), true); + GetCaster()->CastSpell(target, uint32(GetEffectInfo(SpellEffIndex(stage)).CalcValueAsInt()), true); } void Register() override @@ -1037,7 +1037,7 @@ class spell_putricide_choking_gas_bomb : public SpellScript if (spellEffectInfo.EffectIndex == skipIndex) continue; - uint32 spellId = uint32(spellEffectInfo.CalcValue()); + uint32 spellId = uint32(spellEffectInfo.CalcValueAsInt()); GetCaster()->CastSpell(GetCaster(), spellId, CastSpellExtraArgs(TRIGGERED_FULL_MASK) .SetOriginalCaster(GetCaster()->GetGUID())); } @@ -1129,7 +1129,7 @@ class spell_putricide_eat_ooze : public SpellScript if (!target) return; - if (Aura* grow = target->GetAura(uint32(GetEffectValue()))) + if (Aura* grow = target->GetAura(uint32(GetEffectValueAsInt()))) { if (grow->GetStackAmount() < 3) { @@ -1162,13 +1162,13 @@ class spell_putricide_mutated_plague : public AuraScript uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell; SpellInfo const* spell = sSpellMgr->AssertSpellInfo(triggerSpell, GetCastDifficulty()); - int32 damage = spell->GetEffect(EFFECT_0).CalcValue(caster); + SpellEffectValue damage = spell->GetEffect(EFFECT_0).CalcValue(caster); float multiplier = 2.0f; if (GetTarget()->GetMap()->Is25ManRaid()) multiplier = 3.0f; - damage *= int32(pow(multiplier, GetStackAmount())); - damage = int32(damage * 1.5f); + damage *= std::pow(multiplier, GetStackAmount()); + damage = damage * 1.5f; CastSpellExtraArgs args(aurEff); args.OriginalCaster = GetCasterGUID(); @@ -1178,13 +1178,13 @@ class spell_putricide_mutated_plague : public AuraScript void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { - uint32 healSpell = uint32(aurEff->GetSpellEffectInfo().CalcValue()); + uint32 healSpell = uint32(aurEff->GetSpellEffectInfo().CalcValueAsInt()); SpellInfo const* healSpellInfo = sSpellMgr->GetSpellInfo(healSpell, GetCastDifficulty()); if (!healSpellInfo) return; - int32 heal = healSpellInfo->GetEffect(EFFECT_0).CalcValue() * GetStackAmount(); + SpellEffectValue heal = healSpellInfo->GetEffect(EFFECT_0).CalcValue() * GetStackAmount(); CastSpellExtraArgs args(TRIGGERED_FULL_MASK); args.SetOriginalCaster(GetCasterGUID()); args.AddSpellBP0(heal); @@ -1372,11 +1372,11 @@ class spell_putricide_clear_aura_effect_value : public SpellScript { PreventHitDefaultEffect(effIndex); Unit* target = GetHitUnit(); - uint32 auraId = GetEffectValue(); + uint32 auraId = GetEffectValueAsInt(); target->RemoveAurasDueToSpell(auraId); if (m_scriptSpellId == SPELL_TEAR_GAS_CANCEL && GetSpellInfo()->GetEffects().size() >= EFFECT_1) { - uint32 auraId2 = GetSpellInfo()->GetEffect(EFFECT_1).CalcValue(); + uint32 auraId2 = GetSpellInfo()->GetEffect(EFFECT_1).CalcValueAsInt(); target->RemoveAurasDueToSpell(auraId2); } } @@ -1393,9 +1393,9 @@ class spell_stinky_precious_decimate : public SpellScript { void HandleScript(SpellEffIndex /*effIndex*/) { - if (GetHitUnit()->GetHealthPct() > float(GetEffectValue())) + if (GetHitUnit()->GetHealthPct() > GetEffectValue()) { - uint32 newHealth = GetHitUnit()->GetMaxHealth() * uint32(GetEffectValue()) / 100; + uint64 newHealth = GetHitUnit()->CountPctFromMaxHealth(GetEffectValue()); GetHitUnit()->SetHealth(newHealth); } } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp index 081cfce1ce..d1c6e27889 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp @@ -419,7 +419,7 @@ class spell_rotface_ooze_flood : public SpellScript return; triggers.sort(Trinity::ObjectDistanceOrderPred(GetHitUnit())); - GetHitUnit()->CastSpell(triggers.back(), uint32(GetEffectValue()), CastSpellExtraArgs(TRIGGERED_FULL_MASK) + GetHitUnit()->CastSpell(triggers.back(), uint32(GetEffectValueAsInt()), CastSpellExtraArgs(TRIGGERED_FULL_MASK) .SetOriginalCaster(GetOriginalCaster() ? GetOriginalCaster()->GetGUID() : ObjectGuid::Empty)); } @@ -478,13 +478,13 @@ class spell_rotface_mutated_infection_aura : public AuraScript bool Validate(SpellInfo const* spellInfo) override { return ValidateSpellEffect({ { spellInfo->Id, EFFECT_2 } }) - && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_2).CalcValue()) }); + && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_2).CalcValueAsInt()) }); } void HandleEffectRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { Unit* target = GetTarget(); - target->CastSpell(target, uint32(GetEffectInfo(EFFECT_2).CalcValue()), CastSpellExtraArgs(TRIGGERED_FULL_MASK) + target->CastSpell(target, uint32(GetEffectInfo(EFFECT_2).CalcValueAsInt()), CastSpellExtraArgs(TRIGGERED_FULL_MASK) .SetTriggeringAura(aurEff) .SetOriginalCaster(GetCasterGUID())); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index 659f216fc1..c5abd0dece 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -1058,7 +1058,7 @@ class spell_sindragosa_s_fury : public SpellScript uint32 minResistFactor = uint32((resistance / (resistance + 510.0f)) * 10.0f) * 2; uint32 randomResist = urand(0, (9 - minResistFactor) * 100) / 100 + minResistFactor; - uint32 damage = (uint32(GetEffectValue() / _targetCount) * randomResist) / 10; + uint32 damage = (uint32(GetEffectValueAsInt() / _targetCount) * randomResist) / 10; SpellNonMeleeDamage damageInfo(GetCaster(), GetHitUnit(), GetSpellInfo(), GetSpell()->m_SpellVisual, GetSpellInfo()->SchoolMask); damageInfo.damage = damage; @@ -1378,7 +1378,7 @@ class spell_frostwarden_handler_order_whelp : public SpellScript if (unitList.empty()) return; - Trinity::Containers::SelectRandomContainerElement(unitList)->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true); + Trinity::Containers::SelectRandomContainerElement(unitList)->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -1394,7 +1394,7 @@ class spell_frostwarden_handler_focus_fire : public SpellScript void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetCaster()->GetThreatManager().AddThreat(GetHitUnit(), float(GetEffectValue()), GetSpellInfo(), true, true); + GetCaster()->GetThreatManager().AddThreat(GetHitUnit(), GetEffectValue(), GetSpellInfo(), true, true); GetCaster()->GetAI()->SetData(DATA_WHELP_MARKER, 1); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index fd860851d2..3d0b5bf80b 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -1944,7 +1944,7 @@ class spell_the_lich_king_infest : public AuraScript if (aurEff->GetTickNumber() == 1) return; - aurEff->SetAmount(int32(aurEff->GetAmount() * 1.15f)); + aurEff->SetAmount(aurEff->GetAmount() * 1.15); } void Register() override @@ -2091,7 +2091,7 @@ private: AfterEffectApply += AuraEffectRemoveFn(spell_the_lich_king_necrotic_plague_jump_aura::AfterDispel, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE, AURA_EFFECT_HANDLE_REAPPLY); } - int32 _lastAmount; + SpellEffectValue _lastAmount; }; // 73530 - Shadow Trap (Visual) @@ -2188,7 +2188,7 @@ class spell_the_lich_king_raging_spirit : public SpellScript void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetHitUnit()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true); + GetHitUnit()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -2337,7 +2337,7 @@ class spell_the_lich_king_cast_back_to_caster : public SpellScript { void HandleScript(SpellEffIndex /*effIndex*/) { - GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -2517,12 +2517,12 @@ class spell_the_lich_king_lights_favor : public AuraScript effect->RecalculateAmount(caster); } - void CalculateBonus(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + void CalculateBonus(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) { canBeRecalculated = true; amount = 0; if (Unit* caster = GetCaster()) - amount = int32(caster->GetHealthPct()); + amount = caster->GetHealthPct(); } void Register() override @@ -2659,7 +2659,7 @@ class spell_the_lich_king_summon_spirit_bomb : public SpellScript void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetHitUnit()->CastSpell(nullptr, uint32(GetEffectValue()), true); + GetHitUnit()->CastSpell(nullptr, uint32(GetEffectValueAsInt()), true); } void Register() override @@ -2710,7 +2710,7 @@ class spell_the_lich_king_jump_remove_aura : public SpellScript void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValue())); + GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValueAsInt())); } void Register() override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp index bac72097dc..8c4ea66cb2 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp @@ -1440,12 +1440,12 @@ class spell_icc_harvest_blight_specimen : public SpellScript void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValue())); + GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValueAsInt())); } void HandleQuestComplete(SpellEffIndex /*effIndex*/) { - GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValue())); + GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValueAsInt())); } void Register() override diff --git a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp index 182f71a016..4479fc4bef 100644 --- a/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp +++ b/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp @@ -1916,7 +1916,7 @@ class spell_wyrmrest_skytalon_ride_red_dragon_buddy_trigger : public SpellScript void HandleScript(SpellEffIndex /*effIndex*/) { if (Unit* target = GetHitUnit()) - target->CastSpell(GetCaster(), GetEffectValue(), true); + target->CastSpell(GetCaster(), GetEffectValueAsInt(), true); } void Register() override diff --git a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp index 6232a72848..ea160f3249 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp @@ -442,7 +442,7 @@ class spell_oculus_shock_lance : public SpellScript { if (AuraEffect const* shockCharges = victim->GetAuraEffect(SPELL_AMBER_SHOCK_CHARGE, EFFECT_0, GetCaster()->GetGUID())) { - flatMod += shockCharges->GetAmount(); + flatMod += shockCharges->GetAmountAsInt(); shockCharges->GetBase()->Remove(AURA_REMOVE_BY_ENEMY_SPELL); } } @@ -493,7 +493,7 @@ class spell_oculus_temporal_rift : public AuraScript if (!damageInfo || !damageInfo->GetDamage()) return; - int32 amount = aurEff->GetAmount() + damageInfo->GetDamage(); + SpellEffectValue amount = aurEff->GetAmount() + damageInfo->GetDamage(); if (amount >= 15000) { if (Unit* caster = GetCaster()) @@ -501,7 +501,7 @@ class spell_oculus_temporal_rift : public AuraScript amount -= 15000; } - const_cast(aurEff)->SetAmount(amount); + aurEff->SetAmount(amount); } void Register() override @@ -527,10 +527,10 @@ class spell_oculus_touch_the_nightmare : public SpellScript // 50344 - Dream Funnel class spell_oculus_dream_funnel : public AuraScript { - void HandleEffectCalcAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + void HandleEffectCalcAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) { if (Unit* caster = GetCaster()) - amount = int32(caster->CountPctFromMaxHealth(5)); + amount = caster->CountPctFromMaxHealth(5); canBeRecalculated = false; } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp index 73daed2768..f5332de037 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp @@ -1717,7 +1717,7 @@ class spell_vehicle_throw_passenger : public SpellScriptLoader { Spell* baseSpell = GetSpell(); SpellCastTargets targets = baseSpell->m_targets; - int32 damage = GetEffectValue(); + int32 damage = GetEffectValueAsInt(); if (targets.HasTraj()) if (Vehicle* vehicle = GetCaster()->GetVehicleKit()) if (Unit* passenger = vehicle->GetPassenger(damage - 1)) diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp index 37cec2e31c..ca4c457bba 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp @@ -1561,19 +1561,19 @@ class spell_freya_attuned_to_nature_dose_reduction : public SpellScriptLoader switch (GetSpellInfo()->Id) { case SPELL_ATTUNED_TO_NATURE_2_DOSE_REDUCTION: - if (target->HasAura(GetEffectValue())) + if (target->HasAura(GetEffectValueAsInt())) for (uint8 n = 0; n < 2; ++n) - target->RemoveAuraFromStack(GetEffectValue()); + target->RemoveAuraFromStack(GetEffectValueAsInt()); break; case SPELL_ATTUNED_TO_NATURE_10_DOSE_REDUCTION: - if (target->HasAura(GetEffectValue())) + if (target->HasAura(GetEffectValueAsInt())) for (uint8 n = 0; n < 10; ++n) - target->RemoveAuraFromStack(GetEffectValue()); + target->RemoveAuraFromStack(GetEffectValueAsInt()); break; case SPELL_ATTUNED_TO_NATURE_25_DOSE_REDUCTION: - if (target->HasAura(GetEffectValue())) + if (target->HasAura(GetEffectValueAsInt())) for (uint8 n = 0; n < 25; ++n) - target->RemoveAuraFromStack(GetEffectValue()); + target->RemoveAuraFromStack(GetEffectValueAsInt()); break; default: break; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp index c65f7113b7..cea4a754d8 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp @@ -526,7 +526,7 @@ class spell_general_vezax_saronite_vapors : public SpellScriptLoader { if (Unit* caster = GetCaster()) { - int32 mana = int32(aurEff->GetAmount() * std::pow(2.0f, GetStackAmount())); // mana restore - bp * 2^stackamount + SpellEffectValue mana = aurEff->GetAmount() * std::pow(2.0f, GetStackAmount()); // mana restore - bp * 2^stackamount CastSpellExtraArgs args1(TRIGGERED_FULL_MASK), args2(TRIGGERED_FULL_MASK); args1.AddSpellBP0(mana); args2.AddSpellBP0(mana * 2); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp index db6bfa7b2f..0179cfc747 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp @@ -339,7 +339,7 @@ class spell_ulduar_rubble_summon : public SpellScriptLoader return; ObjectGuid originalCaster = caster->GetInstanceScript() ? caster->GetInstanceScript()->GetGuidData(DATA_KOLOGARN) : ObjectGuid::Empty; - uint32 spellId = GetEffectValue(); + uint32 spellId = GetEffectValueAsInt(); for (uint8 i = 0; i < 5; ++i) caster->CastSpell(caster, spellId, CastSpellExtraArgs(TRIGGERED_FULL_MASK) .SetOriginalCaster(originalCaster)); @@ -460,7 +460,7 @@ class spell_ulduar_cancel_stone_grip : public SpellScriptLoader if (target->GetMap()->Is25ManRaid()) effectIndexToCancel = EFFECT_1; - target->RemoveAura(GetEffectInfo(effectIndexToCancel).CalcValue()); + target->RemoveAura(GetEffectInfo(effectIndexToCancel).CalcValueAsInt()); } void Register() override @@ -558,7 +558,7 @@ class spell_ulduar_stone_grip : public SpellScriptLoader { void OnRemoveStun(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { - GetUnitOwner()->RemoveAurasDueToSpell(aurEff->GetAmount()); + GetUnitOwner()->RemoveAurasDueToSpell(aurEff->GetAmountAsInt()); } void OnRemoveVehicle(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp index 08708ff647..6531825c3f 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp @@ -951,7 +951,7 @@ struct npc_thorim_trashAI : public ScriptedAI /// returns heal amount of the given spell including hots static uint32 GetTotalHeal(SpellInfo const* spellInfo, Unit const* caster) { - uint32 heal = 0; + SpellEffectValue heal = 0; for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) { if (spellEffectInfo.IsEffect(SPELL_EFFECT_HEAL)) @@ -960,18 +960,18 @@ struct npc_thorim_trashAI : public ScriptedAI if (spellEffectInfo.IsEffect(SPELL_EFFECT_APPLY_AURA) && spellEffectInfo.IsAura(SPELL_AURA_PERIODIC_HEAL)) heal += spellEffectInfo.GetPeriodicTickCount() * spellEffectInfo.CalcValue(caster); } - return heal; + return static_cast(heal); } /// returns remaining heal amount on given target static uint32 GetRemainingHealOn(Unit* target) { - uint32 heal = 0; + SpellEffectValue heal = 0; Unit::AuraEffectList const& auras = target->GetAuraEffectsByType(SPELL_AURA_PERIODIC_HEAL); for (AuraEffect const* aurEff : auras) heal += aurEff->GetAmount() * aurEff->GetRemainingTicks(); - return heal; + return static_cast(heal); } class MostHPMissingInRange diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp index fb38edf3c9..ce86c65b1b 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp @@ -700,7 +700,7 @@ class spell_xt002_searing_light_spawn_life_spark : public AuraScript void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { if (Unit* xt002 = GetCaster()) - if (xt002->HasAura(aurEff->GetAmount())) // Heartbreak aura indicating hard mode + if (xt002->HasAura(aurEff->GetAmountAsInt())) // Heartbreak aura indicating hard mode xt002->CastSpell(GetOwner(), SPELL_SUMMON_LIFE_SPARK, true); } @@ -721,7 +721,7 @@ class spell_xt002_gravity_bomb_aura : public AuraScript void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { if (Unit* xt002 = GetCaster()) - if (xt002->HasAura(aurEff->GetAmount())) // Heartbreak aura indicating hard mode + if (xt002->HasAura(aurEff->GetAmountAsInt())) // Heartbreak aura indicating hard mode xt002->CastSpell(GetOwner(), SPELL_SUMMON_VOID_ZONE, true); } @@ -732,7 +732,7 @@ class spell_xt002_gravity_bomb_aura : public AuraScript if (!xt002) return; - if (aurEff->GetAmount() >= int32(owner->GetHealth())) + if (aurEff->GetAmount() >= static_cast(owner->GetHealth())) xt002->GetAI()->SetData(DATA_GRAVITY_BOMB_CASUALTY, 1); } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp index fabd012123..86c12476aa 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yogg_saron.cpp @@ -1967,7 +1967,7 @@ class spell_yogg_saron_target_selectors : public SpellScriptLoader // 63744, void HandleScript(SpellEffIndex /*effIndex*/) { if (Unit* target = GetHitUnit()) - GetCaster()->CastSpell(target, uint32(GetEffectValue())); + GetCaster()->CastSpell(target, uint32(GetEffectValueAsInt())); } void Register() override @@ -2186,7 +2186,7 @@ class spell_yogg_saron_brain_link : public SpellScriptLoader // 63802 if (!linked) return; - GetTarget()->CastSpell(linked, (GetTarget()->GetDistance(linked) > (float)aurEff->GetAmount()) ? SPELL_BRAIN_LINK_DAMAGE : SPELL_BRAIN_LINK_NO_DAMAGE, true); + GetTarget()->CastSpell(linked, (GetTarget()->GetDistance(linked) > aurEff->GetAmount()) ? SPELL_BRAIN_LINK_DAMAGE : SPELL_BRAIN_LINK_NO_DAMAGE, true); } void Register() override @@ -2311,7 +2311,7 @@ class spell_yogg_saron_empowering_shadows_range_check : public SpellScriptLoader void HandleScript(SpellEffIndex /*effIndex*/) { if (Unit* target = GetHitUnit()) - target->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + target->CastSpell(GetCaster(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -2410,7 +2410,7 @@ class spell_yogg_saron_lunge : public SpellScriptLoader // 64131 else target->CastSpell(target, SPELL_SQUEEZE_10, true); - target->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + target->CastSpell(GetCaster(), uint32(GetEffectValueAsInt()), true); } } @@ -2569,7 +2569,7 @@ class spell_yogg_saron_shattered_illusion : public SpellScriptLoader // 65238 void HandleScript(SpellEffIndex /*effIndex*/) { if (Unit* target = GetHitUnit()) - target->RemoveAurasDueToSpell(uint32(GetEffectValue())); + target->RemoveAurasDueToSpell(uint32(GetEffectValueAsInt())); } void Register() override @@ -2638,7 +2638,7 @@ class spell_yogg_saron_cancel_illusion_room_aura : public SpellScriptLoader / if (Unit* target = GetHitUnit()) { target->CastSpell(target, SPELL_TELEPORT_BACK_TO_MAIN_ROOM); - target->RemoveAurasDueToSpell(uint32(GetEffectValue())); + target->RemoveAurasDueToSpell(uint32(GetEffectValueAsInt())); } } @@ -2664,7 +2664,7 @@ class spell_yogg_saron_nondescript : public SpellScriptLoader // 64010, 6401 { void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { - GetTarget()->CastSpell(GetTarget(), uint32(aurEff->GetAmount()), true); + GetTarget()->CastSpell(GetTarget(), uint32(aurEff->GetAmountAsInt()), true); } void Register() override @@ -2770,7 +2770,7 @@ class spell_yogg_saron_induce_madness : public SpellScriptLoader // 64059 { target->CastSpell(target, SPELL_TELEPORT_BACK_TO_MAIN_ROOM); target->RemoveAurasDueToSpell(SPELL_SANITY, ObjectGuid::Empty, 0, AURA_REMOVE_BY_ENEMY_SPELL); - target->RemoveAurasDueToSpell(uint32(GetEffectValue())); + target->RemoveAurasDueToSpell(uint32(GetEffectValueAsInt())); } } @@ -2917,7 +2917,7 @@ class spell_yogg_saron_insane_periodic : public SpellScriptLoader // 64555 void HandleScript(SpellEffIndex /*effIndex*/) { if (Unit* target = GetHitUnit()) - GetCaster()->CastSpell(target, uint32(GetEffectValue()), true); + GetCaster()->CastSpell(target, uint32(GetEffectValueAsInt()), true); } void Register() override diff --git a/src/server/scripts/Northrend/zone_borean_tundra.cpp b/src/server/scripts/Northrend/zone_borean_tundra.cpp index b4ac065ce1..8ae4c0e724 100644 --- a/src/server/scripts/Northrend/zone_borean_tundra.cpp +++ b/src/server/scripts/Northrend/zone_borean_tundra.cpp @@ -1397,12 +1397,12 @@ class spell_borean_tundra_nerubar_web_random_unit_not_on_quest : public SpellScr { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { - GetHitUnit()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true); + GetHitUnit()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -1466,12 +1466,12 @@ class spell_borean_tundra_dispel_freed_soldier_debuff : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { - if (Aura* aura = GetHitUnit()->GetAura(uint32(GetEffectValue()))) + if (Aura* aura = GetHitUnit()->GetAura(uint32(GetEffectValueAsInt()))) aura->ModStackAmount(-1); } diff --git a/src/server/scripts/Northrend/zone_dragonblight.cpp b/src/server/scripts/Northrend/zone_dragonblight.cpp index fd99ee345f..29ed9e473d 100644 --- a/src/server/scripts/Northrend/zone_dragonblight.cpp +++ b/src/server/scripts/Northrend/zone_dragonblight.cpp @@ -615,14 +615,14 @@ class spell_dragonblight_moti_hourglass_cast_see_invis_on_master : public SpellS { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { if (TempSummon* casterSummon = GetCaster()->ToTempSummon()) if (Unit* summoner = casterSummon->GetSummonerUnit()) - summoner->CastSpell(summoner, uint32(GetEffectValue())); + summoner->CastSpell(summoner, uint32(GetEffectValueAsInt())); } void Register() override @@ -911,12 +911,12 @@ class spell_dragonblight_fill_blood_unholy_frost_gem : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { - GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValue())); + GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt())); } void Register() override @@ -930,18 +930,18 @@ class spell_dragonblight_corrosive_spit : public AuraScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void AfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - if (GetTarget()->HasAura(GetEffectInfo(EFFECT_0).CalcValue())) + if (GetTarget()->HasAura(GetEffectInfo(EFFECT_0).CalcValueAsInt())) GetAura()->Remove(); } void PeriodicTick(AuraEffect const* /*aurEff*/) { - if (GetTarget()->HasAura(GetEffectInfo(EFFECT_0).CalcValue())) + if (GetTarget()->HasAura(GetEffectInfo(EFFECT_0).CalcValueAsInt())) { PreventDefaultAction(); GetAura()->Remove(); diff --git a/src/server/scripts/Northrend/zone_howling_fjord.cpp b/src/server/scripts/Northrend/zone_howling_fjord.cpp index 2bfb9902ba..5f748c5f27 100644 --- a/src/server/scripts/Northrend/zone_howling_fjord.cpp +++ b/src/server/scripts/Northrend/zone_howling_fjord.cpp @@ -449,14 +449,14 @@ class spell_fjord_the_cleansing_on_death_cast_on_master : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { if (TempSummon* casterSummon = GetCaster()->ToTempSummon()) if (Unit* summoner = casterSummon->GetSummonerUnit()) - summoner->CastSpell(summoner, uint32(GetEffectValue())); + summoner->CastSpell(summoner, uint32(GetEffectValueAsInt())); } void Register() override @@ -500,12 +500,12 @@ class spell_fjord_the_way_to_his_heart_reverse_cast : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { - GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -519,14 +519,14 @@ class spell_fjord_the_way_to_his_heart_quest_complete : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { if (TempSummon* casterSummon = GetCaster()->ToTempSummon()) if (Unit* summoner = casterSummon->GetSummonerUnit()) - summoner->CastSpell(summoner, uint32(GetEffectValue()), true); + summoner->CastSpell(summoner, uint32(GetEffectValueAsInt()), true); } void Register() override diff --git a/src/server/scripts/Northrend/zone_icecrown.cpp b/src/server/scripts/Northrend/zone_icecrown.cpp index a043f399dd..01c72169f5 100644 --- a/src/server/scripts/Northrend/zone_icecrown.cpp +++ b/src/server/scripts/Northrend/zone_icecrown.cpp @@ -733,13 +733,13 @@ class spell_icecrown_the_ocular_on_death : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { if (Player* target = GetHitPlayer()) - target->CastSpell(target, uint32(GetEffectValue())); + target->CastSpell(target, uint32(GetEffectValueAsInt())); } void Register() override @@ -905,12 +905,12 @@ class spell_icecrown_summon_freed_crusader : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { - GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt()), true); } void Register() override diff --git a/src/server/scripts/Northrend/zone_sholazar_basin.cpp b/src/server/scripts/Northrend/zone_sholazar_basin.cpp index 3cddb45f98..565b503ef0 100644 --- a/src/server/scripts/Northrend/zone_sholazar_basin.cpp +++ b/src/server/scripts/Northrend/zone_sholazar_basin.cpp @@ -628,14 +628,14 @@ class spell_sholazar_take_sputum_sample : public SpellScript { return ValidateSpellEffect({ { spellInfo->Id, EFFECT_1 } }) && ValidateSpellInfo( { - uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()), - uint32(spellInfo->GetEffect(EFFECT_1).CalcValue()) + uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()), + uint32(spellInfo->GetEffect(EFFECT_1).CalcValueAsInt()) }); } SpellCastResult CheckCast() { - if (!GetCaster()->HasAura(uint32(GetEffectInfo(EFFECT_1).CalcValue()))) + if (!GetCaster()->HasAura(uint32(GetEffectInfo(EFFECT_1).CalcValueAsInt()))) return SPELL_FAILED_CASTER_AURASTATE; return SPELL_CAST_OK; @@ -643,7 +643,7 @@ class spell_sholazar_take_sputum_sample : public SpellScript void HandleDummy(SpellEffIndex /*effIndex*/) { - GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValue())); + GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt())); } void Register() override @@ -762,7 +762,7 @@ class spell_sholazar_flight_to_sholazar : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return sBroadcastTextStore.LookupEntry(uint32(spellInfo->GetEffect(EFFECT_0).CalcValue())); + return sBroadcastTextStore.LookupEntry(uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt())); } void HandleScript(SpellEffIndex /*effIndex*/) @@ -770,7 +770,7 @@ class spell_sholazar_flight_to_sholazar : public SpellScript // 51076 (triggers 51071) is Area Aura - Party and applies on player too (no aura in sniffs on player) // That makes both player and creature say if (Creature* caster = GetCaster()->ToCreature()) - caster->Unit::Say(uint32(GetEffectValue()), caster); + caster->Unit::Say(uint32(GetEffectValueAsInt()), caster); } void Register() override diff --git a/src/server/scripts/Northrend/zone_storm_peaks.cpp b/src/server/scripts/Northrend/zone_storm_peaks.cpp index 5009c75858..8aa1cdf037 100644 --- a/src/server/scripts/Northrend/zone_storm_peaks.cpp +++ b/src/server/scripts/Northrend/zone_storm_peaks.cpp @@ -971,7 +971,7 @@ class spell_grab_on : public SpellScript void HandleScript(SpellEffIndex /*effIndex*/) { if (Aura* grip = GetCaster()->GetAura(SPELL_GRIP, GetCaster()->GetGUID())) - grip->ModStackAmount(GetEffectValue(), AURA_REMOVE_BY_DEFAULT, false); + grip->ModStackAmount(GetEffectValueAsInt(), AURA_REMOVE_BY_DEFAULT, false); } void Register() override @@ -1002,12 +1002,12 @@ class spell_low_health_trigger : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { - GetHitUnit()->CastSpell(nullptr, GetEffectValue(), true); + GetHitUnit()->CastSpell(nullptr, GetEffectValueAsInt(), true); } void Register() override @@ -1022,7 +1022,7 @@ class spell_jaws_of_death_claw_swipe_pct_damage : public SpellScript { void HandleDamage(SpellEffIndex /*effIndex*/) { - SetEffectValue(static_cast(GetHitUnit()->CountPctFromMaxHealth(GetEffectValue()))); + SetEffectValue(static_cast(GetHitUnit()->CountPctFromMaxHealth(GetEffectValue()))); } void Register() override @@ -1053,7 +1053,7 @@ class spell_claw_swipe_check : public AuraScript } } - GetTarget()->CastSpell(nullptr, aurEff->GetAmount(), false); + GetTarget()->CastSpell(nullptr, aurEff->GetAmountAsInt(), false); } void Register() override @@ -1073,11 +1073,11 @@ class spell_fatal_strike : public SpellScript void HandleDummy(SpellEffIndex /*effIndex*/) { - int32 chance = 0; + SpellEffectValue chance = 0; if (AuraEffect const* aurEff = GetCaster()->GetAuraEffect(SPELL_PRY_JAWS_OPEN, EFFECT_0)) chance = aurEff->GetAmount(); - if (!roll_chance_i(chance)) + if (!roll_chance_f(chance)) { GetCaster()->GetAI()->DoAction(ACTION_FATAL_STRIKE_MISS); return; @@ -1120,12 +1120,12 @@ class spell_storm_peaks_remove_collapsing_cave_aura : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { - GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValue())); + GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValueAsInt())); } void Register() override diff --git a/src/server/scripts/Northrend/zone_wintergrasp.cpp b/src/server/scripts/Northrend/zone_wintergrasp.cpp index 7f222b21e7..3f30c548c6 100644 --- a/src/server/scripts/Northrend/zone_wintergrasp.cpp +++ b/src/server/scripts/Northrend/zone_wintergrasp.cpp @@ -366,7 +366,7 @@ class spell_wintergrasp_force_building : public SpellScript void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetHitUnit()->CastSpell(GetHitUnit(), GetEffectValue(), false); + GetHitUnit()->CastSpell(GetHitUnit(), GetEffectValueAsInt(), false); } void Register() override @@ -465,7 +465,7 @@ class spell_wintergrasp_tenacity_refresh : public AuraScript { if (!ValidateSpellEffect({ { spellInfo->Id, EFFECT_2 } })) return false; - uint32 triggeredSpellId = spellInfo->GetEffect(EFFECT_2).CalcValue(); + uint32 triggeredSpellId = spellInfo->GetEffect(EFFECT_2).CalcValueAsInt(); return !triggeredSpellId || ValidateSpellInfo({ triggeredSpellId }); } @@ -473,9 +473,9 @@ class spell_wintergrasp_tenacity_refresh : public AuraScript { PreventDefaultAction(); - if (uint32 triggeredSpellId = aurEff->GetSpellEffectInfo().CalcValue()) + if (uint32 triggeredSpellId = aurEff->GetSpellEffectInfo().CalcValueAsInt()) { - int32 bp = 0; + SpellEffectValue bp = 0; if (AuraEffect const* healEffect = GetEffect(EFFECT_0)) bp = healEffect->GetAmount(); @@ -491,7 +491,7 @@ class spell_wintergrasp_tenacity_refresh : public AuraScript void OnRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { - if (uint32 triggeredSpellId = aurEff->GetSpellEffectInfo().CalcValue()) + if (uint32 triggeredSpellId = aurEff->GetSpellEffectInfo().CalcValueAsInt()) GetTarget()->RemoveAurasDueToSpell(triggeredSpellId); } diff --git a/src/server/scripts/Northrend/zone_zuldrak.cpp b/src/server/scripts/Northrend/zone_zuldrak.cpp index fd750e96b8..13e5ee1d8e 100644 --- a/src/server/scripts/Northrend/zone_zuldrak.cpp +++ b/src/server/scripts/Northrend/zone_zuldrak.cpp @@ -868,12 +868,12 @@ class spell_zuldrak_chains_of_the_scourge : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_1).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_1).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { - GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue())); + GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt())); } void Register() override diff --git a/src/server/scripts/Outland/BlackTemple/black_temple.cpp b/src/server/scripts/Outland/BlackTemple/black_temple.cpp index b8cad82d8a..c2140e6c3a 100644 --- a/src/server/scripts/Outland/BlackTemple/black_temple.cpp +++ b/src/server/scripts/Outland/BlackTemple/black_temple.cpp @@ -256,7 +256,7 @@ class spell_illidari_nightlord_shadow_inferno : public AuraScript void OnPeriodic(AuraEffect const* aurEffect) { PreventDefaultAction(); - int32 bp = aurEffect->GetTickNumber() * aurEffect->GetAmount(); + SpellEffectValue bp = aurEffect->GetTickNumber() * aurEffect->GetAmount(); GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_SHADOW_INFERNO_DAMAGE, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellBP0(bp)); } diff --git a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp index 5af82e2019..09dae5b99e 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp @@ -740,7 +740,7 @@ class spell_reliquary_of_souls_aura_of_anger : public AuraScript { if (AuraEffect* aurEff1 = aurEff->GetBase()->GetEffect(EFFECT_1)) aurEff1->ChangeAmount(aurEff1->GetAmount() + 5); - aurEff->SetAmount(100 * aurEff->GetTickNumber()); + aurEff->SetAmount(100.0 * aurEff->GetTickNumber()); } void Register() override diff --git a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp index 6ba5bebf0d..a3c2499d8d 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_shade_of_akama.cpp @@ -1089,7 +1089,7 @@ class spell_shade_soul_channel : public AuraScript { void OnApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { - int32 const maxSlowEff = -99; + constexpr SpellEffectValue maxSlowEff = -99; if (aurEff->GetAmount() < maxSlowEff) if (AuraEffect* slowEff = GetEffect(EFFECT_0)) slowEff->ChangeAmount(maxSlowEff); diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp index 4ae564a5b3..d27633dfc2 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_astromancer.cpp @@ -487,7 +487,7 @@ class spell_astromancer_wrath_of_the_astromancer : public AuraScript return; Unit* target = GetUnitOwner(); - target->CastSpell(target, GetEffectInfo(EFFECT_1).CalcValue(), false); + target->CastSpell(target, GetEffectInfo(EFFECT_1).CalcValueAsInt(), false); } void Register() override diff --git a/src/server/scripts/Outland/boss_doomlord_kazzak.cpp b/src/server/scripts/Outland/boss_doomlord_kazzak.cpp index 769f441e04..25b207a7cd 100644 --- a/src/server/scripts/Outland/boss_doomlord_kazzak.cpp +++ b/src/server/scripts/Outland/boss_doomlord_kazzak.cpp @@ -169,7 +169,7 @@ class spell_mark_of_kazzak : public AuraScript return ValidateSpellInfo({ SPELL_MARK_OF_KAZZAK_DAMAGE }); } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* owner = GetUnitOwner()) amount = CalculatePct(owner->GetPower(POWER_MANA), 5); diff --git a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp index b61e5cf87b..3b0dfa345b 100644 --- a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp +++ b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp @@ -1622,7 +1622,7 @@ class spell_shadowmoon_quest_credit_crazed_colossus : public SpellScript { return ValidateSpellInfo( { - uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()), + uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()), SPELL_KILL_CREDIT_CRAZED_COLOSSUS }); } @@ -1630,7 +1630,7 @@ class spell_shadowmoon_quest_credit_crazed_colossus : public SpellScript void HandleScript(SpellEffIndex /*effIndex*/) { Unit* target = GetHitUnit(); - if (target->HasAura(uint32(GetEffectValue()))) + if (target->HasAura(uint32(GetEffectValueAsInt()))) target->CastSpell(target, SPELL_KILL_CREDIT_CRAZED_COLOSSUS); } diff --git a/src/server/scripts/Pandaria/zone_the_wandering_isle.cpp b/src/server/scripts/Pandaria/zone_the_wandering_isle.cpp index e97abce2bf..e6aaa54308 100644 --- a/src/server/scripts/Pandaria/zone_the_wandering_isle.cpp +++ b/src/server/scripts/Pandaria/zone_the_wandering_isle.cpp @@ -639,7 +639,7 @@ class spell_force_summoner_to_ride_vehicle : public SpellScript { void HandleScript(SpellEffIndex /*effIndex*/) const { - GetHitUnit()->CastSpell(GetCaster(), GetEffectValue(), TRIGGERED_FULL_MASK); + GetHitUnit()->CastSpell(GetCaster(), GetEffectValueAsInt(), TRIGGERED_FULL_MASK); } void Register() override diff --git a/src/server/scripts/Pet/pet_generic.cpp b/src/server/scripts/Pet/pet_generic.cpp index b35dfeade3..069458df89 100644 --- a/src/server/scripts/Pet/pet_generic.cpp +++ b/src/server/scripts/Pet/pet_generic.cpp @@ -265,12 +265,12 @@ class spell_pet_gen_lich_pet_focus : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleScript(SpellEffIndex /*effIndex*/) { - GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue())); + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt())); } void Register() override diff --git a/src/server/scripts/Shadowlands/SepulcherOfTheFirstOnes/boss_anduin_wrynn.cpp b/src/server/scripts/Shadowlands/SepulcherOfTheFirstOnes/boss_anduin_wrynn.cpp index fe5996968e..73183afb1a 100644 --- a/src/server/scripts/Shadowlands/SepulcherOfTheFirstOnes/boss_anduin_wrynn.cpp +++ b/src/server/scripts/Shadowlands/SepulcherOfTheFirstOnes/boss_anduin_wrynn.cpp @@ -2185,7 +2185,7 @@ class spell_anduin_wrynn_progression_aura : public AuraScript return ValidateSpellInfo({ SPELL_ANDUIN_PROGRESSION_AURA, SPELL_ANDUIN_KNEEL_POSE }); } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) { amount = -1; canBeRecalculated = true; @@ -2379,7 +2379,7 @@ struct at_anduin_wrynn_befouled_barrier : AreaTriggerAI void OnInitialize() override { if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_BEFOULED_BARRIER_DEBUFF, at->GetMap()->GetDifficultyID())) - _absorbRequired = spellInfo->GetEffect(EFFECT_0).CalcValue(at->GetCaster()); + _absorbRequired = spellInfo->GetEffect(EFFECT_0).CalcValueAsInt(at->GetCaster()); at->SetTimeToTargetScale(30000); @@ -2609,7 +2609,7 @@ class spell_anduin_wrynn_befouled_barrier_absorb : public AuraScript void OnHealAbsorb(AuraEffect* /*aurEff*/, HealInfo const& healInfo, uint32& absorbAmount) const { - absorbAmount = CalculatePct(healInfo.GetHeal(), GetEffectInfo(EFFECT_2).CalcValue()); + absorbAmount = CalculatePct(healInfo.GetHeal(), GetEffectInfo(EFFECT_2).CalcValueAsInt()); Unit* caster = GetCaster(); if (!caster) @@ -3150,7 +3150,7 @@ class spell_anduin_wrynn_soul_despawn : public SpellScript // 368913 - Force of Will class spell_anduin_wrynn_force_of_will : public AuraScript { - void RecalculateHook(AuraEffect const* /*aurEffect*/, int32& amount, bool& canBeRecalculated) const + void RecalculateHook(AuraEffect const* /*aurEffect*/, SpellEffectValue& amount, bool& canBeRecalculated) const { Unit* caster = GetCaster(); if (!caster) @@ -3162,7 +3162,7 @@ class spell_anduin_wrynn_force_of_will : public AuraScript canBeRecalculated = false; } - void RecalculateHookDamageTaken(AuraEffect const* /*aurEffect*/, int32& amount, bool& canBeRecalculated) const + void RecalculateHookDamageTaken(AuraEffect const* /*aurEffect*/, SpellEffectValue& amount, bool& canBeRecalculated) const { Unit* caster = GetCaster(); if (!caster) diff --git a/src/server/scripts/Shadowlands/Torghast/spell_torghast.cpp b/src/server/scripts/Shadowlands/Torghast/spell_torghast.cpp index 198f8cc2d0..996dd032a5 100644 --- a/src/server/scripts/Shadowlands/Torghast/spell_torghast.cpp +++ b/src/server/scripts/Shadowlands/Torghast/spell_torghast.cpp @@ -197,7 +197,7 @@ class spell_torghast_uncontrolled_darkness_proc : public AuraScript if (caster->HasAura(SPELL_UNCONTROLLED_DARKNESS_BUFF)) { - if (++script->KillCounter >= uncontrolledDarkness->GetSpellInfo()->GetEffect(EFFECT_1).CalcValue()) + if (++script->KillCounter >= uncontrolledDarkness->GetSpellInfo()->GetEffect(EFFECT_1).CalcValueAsInt()) { caster->RemoveAura(SPELL_UNCONTROLLED_DARKNESS_BUFF); script->KillCounter = 0; @@ -205,7 +205,7 @@ class spell_torghast_uncontrolled_darkness_proc : public AuraScript } else { - if (++script->KillCounter >= uncontrolledDarkness->GetSpellInfo()->GetEffect(EFFECT_0).CalcValue()) + if (++script->KillCounter >= uncontrolledDarkness->GetSpellInfo()->GetEffect(EFFECT_0).CalcValueAsInt()) { caster->CastSpell(caster, SPELL_UNCONTROLLED_DARKNESS_BUFF, true); script->KillCounter = 0; diff --git a/src/server/scripts/Spells/spell_azerite.cpp b/src/server/scripts/Spells/spell_azerite.cpp index a7b14f2985..2f60bdb9e1 100644 --- a/src/server/scripts/Spells/spell_azerite.cpp +++ b/src/server/scripts/Spells/spell_azerite.cpp @@ -32,7 +32,7 @@ class spell_azerite_gen_aura_calc_from_2nd_effect_triggered_spell : public AuraS return ValidateSpellEffect({ { spellInfo->Id, EFFECT_1 } }) && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_1).TriggerSpell }); } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) { if (Unit* caster = GetCaster()) { @@ -467,7 +467,7 @@ class spell_item_echoing_blades_damage : public SpellScript void CalculateDamage(SpellEffectInfo const& /*spellEffectInfo*/, Unit const* /*victim*/, int32& damage, int32& /*flatMod*/, float& /*pctMod*/) const { if (AuraEffect const* trait = GetCaster()->GetAuraEffect(SPELL_ECHOING_BLADES_TRAIT, EFFECT_2)) - damage = trait->GetAmount() * 2; + damage = trait->GetAmountAsInt() * 2; } void ForceCritical(Unit const* /*victim*/, float& critChance) @@ -604,7 +604,7 @@ class spell_item_corruption_grasping_tendrils : public AuraScript return GetUnitOwner()->IsPlayer(); } - void CalcAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + void CalcAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) { Player* player = GetUnitOwner()->ToPlayer(); amount = std::clamp(10.0f + player->GetRatingBonusValue(CR_CORRUPTION) - player->GetRatingBonusValue(CR_CORRUPTION_RESISTANCE), 0.0f, 99.0f); diff --git a/src/server/scripts/Spells/spell_dh.cpp b/src/server/scripts/Spells/spell_dh.cpp index 522ae2aabf..b0f240e1ae 100644 --- a/src/server/scripts/Spells/spell_dh.cpp +++ b/src/server/scripts/Spells/spell_dh.cpp @@ -409,7 +409,7 @@ class spell_dh_chaos_theory : public SpellScript if (!min || !max) return; - int32 critChance = irand(min->GetAmount(), max->GetAmount()); + SpellEffectValue critChance = frand(min->GetAmount(), max->GetAmount()); caster->CastSpell(caster, SPELL_DH_CHAOS_THEORY_CRIT, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, critChance } } @@ -611,7 +611,7 @@ class spell_dh_consume_soul_vengeance_lesser : public SpellScript if (!shearPassive || !shearPassive->HasEffect(EFFECT_1) || !shearPassive->HasEffect(EFFECT_2)) return; - flatMod += std::max(CalculatePct(uint64(damageTakenTracker->CalculateAmount(GetCaster())), shearPassive->GetEffect(EFFECT_1)->GetAmount()), + flatMod += std::max(CalculatePct(damageTakenTracker->CalculateAmount(GetCaster()), shearPassive->GetEffect(EFFECT_1)->GetAmount()), victim->CountPctFromMaxHealth(shearPassive->GetEffect(EFFECT_2)->GetAmount())); } @@ -624,7 +624,7 @@ class spell_dh_consume_soul_vengeance_lesser : public SpellScript // 320413 - Critical Chaos class spell_dh_critical_chaos : public AuraScript { - void CalcAmount(AuraEffect const* /*aurEff*/, int32& amount, bool const& /*canBeRecalculated*/) const + void CalcAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool const& /*canBeRecalculated*/) const { if (AuraEffect const* amountHolder = GetEffect(EFFECT_1)) { @@ -659,7 +659,7 @@ class spell_dh_cycle_of_binding : public AuraScript void HandleEffectProc(AuraEffect const* aurEff, ProcEventInfo const& /*eventInfo*/) const { SpellHistory* history = GetTarget()->GetSpellHistory(); - SpellHistory::Duration amount = Seconds(-aurEff->GetAmount()); + SpellHistory::Duration amount = duration_cast(FloatSeconds(-aurEff->GetAmount())); for (uint32 spellId : SigilSpellsIds) history->ModifyCooldown(spellId, amount); @@ -691,7 +691,7 @@ class spell_dh_cycle_of_hatred : public SpellScript // First calculate cooldown then add another stack uint32 cycleOfHatredStack = caster->GetAuraCount(SPELL_DH_CYCLE_OF_HATRED_COOLDOWN_REDUCTION); AuraEffect const* cycleOfHatred = caster->GetAuraEffect(SPELL_DH_CYCLE_OF_HATRED_TALENT, EFFECT_0); - caster->GetSpellHistory()->ModifyCooldown(GetSpellInfo(), -Milliseconds(cycleOfHatred->GetAmount() * cycleOfHatredStack)); + caster->GetSpellHistory()->ModifyCooldown(GetSpellInfo(), -Milliseconds(static_cast(cycleOfHatred->GetAmount() * cycleOfHatredStack))); CastSpellExtraArgs args; args.SetTriggerFlags(TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR); @@ -783,10 +783,10 @@ class spell_dh_darkglare_boon : public AuraScript SpellHistory::Duration cooldown, categoryCooldown; SpellHistory::GetCooldownDurations(GetSpellInfo(), 0, &cooldown, nullptr, &categoryCooldown); - int32 reductionPct = irand(darkglareBoon->GetEffect(EFFECT_0)->GetAmount(), darkglareBoon->GetEffect(EFFECT_1)->GetAmount()); + SpellEffectValue reductionPct = frand(darkglareBoon->GetEffect(EFFECT_0)->GetAmount(), darkglareBoon->GetEffect(EFFECT_1)->GetAmount()); SpellHistory::Duration cooldownReduction(CalculatePct(std::max(cooldown, categoryCooldown).count(), reductionPct)); - int32 energizeValue = irand(darkglareBoon->GetEffect(EFFECT_2)->GetAmount(), darkglareBoon->GetEffect(EFFECT_3)->GetAmount()); + SpellEffectValue energizeValue = frand(darkglareBoon->GetEffect(EFFECT_2)->GetAmount(), darkglareBoon->GetEffect(EFFECT_3)->GetAmount()); target->GetSpellHistory()->ModifyCooldown(SPELL_DH_FEL_DEVASTATION, -cooldownReduction); @@ -810,7 +810,7 @@ class spell_dh_darkness : public AuraScript return ValidateSpellEffect({ { spellInfo->Id, EFFECT_1 } }); } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { // Set absorbtion amount to unlimited amount = -1; @@ -819,7 +819,7 @@ class spell_dh_darkness : public AuraScript void Absorb(AuraEffect const* /*aurEff*/, DamageInfo& dmgInfo, uint32& absorbAmount) const { if (AuraEffect const* chanceEffect = GetEffect(EFFECT_1)) - if (roll_chance_i(chanceEffect->GetAmount())) + if (roll_chance_f(chanceEffect->GetAmount())) absorbAmount = dmgInfo.GetDamage(); } @@ -924,7 +924,7 @@ class spell_dh_demonic : public SpellScript if (!demonic) return; - int32 duration = demonic->GetAmount() + GetSpell()->GetChannelDuration(); + int32 duration = demonic->GetAmountAsInt() + GetSpell()->GetChannelDuration(); if (Aura* aura = caster->GetAura(_transformSpellId)) { @@ -1126,7 +1126,7 @@ public: bool Load() override { - _maxFragmentsToCreate = sSpellMgr->AssertSpellInfo(_primarySpellId, GetCastDifficulty())->GetEffect(EFFECT_2).CalcValue(GetCaster()); + _maxFragmentsToCreate = sSpellMgr->AssertSpellInfo(_primarySpellId, GetCastDifficulty())->GetEffect(EFFECT_2).CalcValueAsInt(GetCaster()); _fragmentsToCreate = _maxFragmentsToCreate; return true; } @@ -1517,7 +1517,7 @@ struct at_dh_inner_demon : AreaTriggerAI // 388118 - Know Your Enemy class spell_dh_know_your_enemy : public AuraScript { - void CalcAmount(AuraEffect const* /*aurEff*/, int32& amount, bool const& /*canBeRecalculated*/) const + void CalcAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool const& /*canBeRecalculated*/) const { if (AuraEffect const* amountHolder = GetEffect(EFFECT_1)) { @@ -1924,7 +1924,7 @@ class spell_dh_shattered_destiny : public AuraScript return false; _furySpent += procSpell->GetPowerTypeCostAmount(POWER_FURY).value_or(0); - return _furySpent >= GetEffect(EFFECT_1)->GetAmount(); + return _furySpent >= GetEffect(EFFECT_1)->GetAmountAsInt(); } void HandleProc(ProcEventInfo const& /*eventInfo*/) @@ -1933,8 +1933,8 @@ class spell_dh_shattered_destiny : public AuraScript if (!metamorphosis) return; - int32 requiredFuryAmount = GetEffect(EFFECT_1)->GetAmount(); - metamorphosis->SetDuration(metamorphosis->GetDuration() + _furySpent / requiredFuryAmount * GetEffect(EFFECT_0)->GetAmount()); + int32 requiredFuryAmount = GetEffect(EFFECT_1)->GetAmountAsInt(); + metamorphosis->SetDuration(metamorphosis->GetDuration() + _furySpent / requiredFuryAmount * GetEffect(EFFECT_0)->GetAmountAsInt()); _furySpent %= requiredFuryAmount; } @@ -2010,7 +2010,7 @@ class spell_dh_shattered_souls_devourer : public AuraScript static bool CheckProc(AuraScript const&, AuraEffect const* aurEff, ProcEventInfo const& /*eventInfo*/) { - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } static void HandleProc(AuraScript const&, AuraEffect const* /*aurEff*/, ProcEventInfo const& eventInfo) @@ -2162,7 +2162,7 @@ class spell_dh_soul_carver : public SpellScript void HandleSoulFragments(SpellEffIndex /*effIndex*/) const { - spell_dh_shattered_souls_base_lesser::CreateFragments(GetHitUnit(), GetCaster(), GetEffectInfo(EFFECT_2).CalcValue(GetCaster())); + spell_dh_shattered_souls_base_lesser::CreateFragments(GetHitUnit(), GetCaster(), GetEffectInfo(EFFECT_2).CalcValueAsInt(GetCaster())); } void Register() override @@ -2181,7 +2181,7 @@ class spell_dh_soul_carver_aura : public AuraScript void HandleEffectPeriodic(AuraEffect const* /*aurEff*/) const { if (Unit* caster = GetCaster()) - spell_dh_shattered_souls_base_lesser::CreateFragments(GetTarget(), caster, GetEffectInfo(EFFECT_3).CalcValue(caster)); + spell_dh_shattered_souls_base_lesser::CreateFragments(GetTarget(), caster, GetEffectInfo(EFFECT_3).CalcValueAsInt(caster)); } void Register() override @@ -2204,7 +2204,7 @@ class spell_dh_soul_fragments_damage_taken_tracker : public AuraScript if (!seconds) return false; - _damagePerSecond.resize(seconds->GetAmount()); + _damagePerSecond.resize(seconds->GetAmountAsInt()); return !_damagePerSecond.empty(); } @@ -2220,10 +2220,10 @@ class spell_dh_soul_fragments_damage_taken_tracker : public AuraScript _damagePerSecond[0] = 0; } - void HandleCalcAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + void HandleCalcAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) { canBeRecalculated = true; - amount = int32(std::reduce(_damagePerSecond.begin(), _damagePerSecond.end(), 0u)); + amount = std::reduce(_damagePerSecond.begin(), _damagePerSecond.end(), 0u); } void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo const& eventInfo) @@ -2259,11 +2259,11 @@ class spell_dh_soulmonger : public AuraScript static void HandleEffectProc(AuraScript const&, AuraEffect const* aurEff, ProcEventInfo const& eventInfo) { Unit* target = eventInfo.GetActionTarget(); - int32 amount = eventInfo.GetHealInfo()->GetHeal(); + SpellEffectValue amount = eventInfo.GetHealInfo()->GetHeal(); if (AuraEffect const* existingAbsorb = target->GetAuraEffect(SPELL_DH_SOULMONGER_ABSORB, EFFECT_0)) amount += existingAbsorb->GetAmount(); - amount = std::min(amount, int32(target->CountPctFromMaxHealth(aurEff->GetAmount()))); + amount = std::min(amount, SpellEffectValue(target->CountPctFromMaxHealth(aurEff->GetAmount()))); target->CastSpell(target, SPELL_DH_SOULMONGER_ABSORB, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, @@ -2307,7 +2307,7 @@ class spell_dh_soul_furnace_conduit : public AuraScript { void CalculateSpellMod(AuraEffect const* aurEff, SpellModifier*& spellMod) { - if (aurEff->GetAmount() == 10) + if (aurEff->GetAmountAsInt() == 10) { if (!spellMod) { @@ -2328,7 +2328,7 @@ class spell_dh_soul_sigils : public AuraScript { void HandleOnProc(AuraEffect const* aurEff, ProcEventInfo const& eventInfo) const { - spell_dh_shattered_souls_base_lesser::CreateFragments(eventInfo.GetActionTarget(), eventInfo.GetActor(), aurEff->GetAmount()); + spell_dh_shattered_souls_base_lesser::CreateFragments(eventInfo.GetActionTarget(), eventInfo.GetActor(), aurEff->GetAmountAsInt()); } void Register() override diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp index 608640fda0..02cf1e4101 100644 --- a/src/server/scripts/Spells/spell_dk.cpp +++ b/src/server/scripts/Spells/spell_dk.cpp @@ -169,7 +169,7 @@ public: return true; } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { amount = CalculatePct(maxHealth, absorbPct); @@ -185,7 +185,7 @@ public: absorbedAmount += absorbAmount; CastSpellExtraArgs args(aurEff); - args.AddSpellMod(SPELLVALUE_BASE_POINT0, CalculatePct(absorbAmount, 2 * absorbAmount * 100 / maxHealth)); + args.AddSpellMod(SPELLVALUE_BASE_POINT0, CalculatePct(absorbAmount, UI64LIT(2) * absorbAmount * 100 / maxHealth)); GetTarget()->CastSpell(GetTarget(), SPELL_DK_RUNIC_POWER_ENERGIZE, args); } @@ -196,8 +196,8 @@ public: } private: - int32 absorbPct; - int32 maxHealth; + SpellEffectValue absorbPct; + uint64 maxHealth; uint32 absorbedAmount; }; @@ -218,7 +218,7 @@ public: void HandleHitTarget(SpellEffIndex /*effIndex*/) const { Unit* caster = GetCaster(); - for (int32 i = 0; i < GetEffectValue(); ++i) + for (int32 i = 0; i < GetEffectValueAsInt(); ++i) caster->CastSpell(caster, SPELL_DK_BONE_SHIELD, CastSpellExtraArgs() .SetTriggerFlags(TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR) .SetTriggeringSpell(GetSpell())); @@ -385,7 +385,7 @@ class spell_dk_blood_bond_periodic : public AuraScript Unit* owner = GetTarget()->GetOwner(); Unit* target = GetTarget(); SpellInfo const* bloodBondTalent = sSpellMgr->AssertSpellInfo(SPELL_DK_BLOOD_BOND_TALENT, GetCastDifficulty()); - if (owner->GetHealthPct() >= bloodBondTalent->GetEffect(EFFECT_0).CalcValue(owner)) + if (owner->GetHealthPct() >= bloodBondTalent->GetEffect(EFFECT_0).CalcValueAsInt(owner)) return; CastSpellExtraArgs args; @@ -559,7 +559,7 @@ class spell_dk_dark_simulacrum_buff : public AuraScript { bool CheckProc(AuraEffect const* aurEff, ProcEventInfo const& eventInfo) const { - return uint32(aurEff->GetAmount()) == eventInfo.GetSpellInfo()->Id; + return uint32(aurEff->GetAmountAsInt()) == eventInfo.GetSpellInfo()->Id; } void Register() override @@ -623,7 +623,7 @@ class spell_dk_death_gate : public SpellScript { PreventHitDefaultEffect(effIndex); if (Unit* target = GetHitUnit()) - target->CastSpell(target, GetEffectValue(), false); + target->CastSpell(target, GetEffectValueAsInt(), false); } void Register() override @@ -680,10 +680,10 @@ class spell_dk_death_pact : public AuraScript return ValidateSpellEffect({ { spellInfo->Id, EFFECT_2 } }); } - void HandleCalcAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void HandleCalcAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* caster = GetCaster()) - amount = int32(caster->CountPctFromMaxHealth(GetEffectInfo(EFFECT_2).CalcValue(caster))); + amount = caster->CountPctFromMaxHealth(GetEffectInfo(EFFECT_2).CalcValue(caster)); } void Register() override @@ -716,9 +716,9 @@ class spell_dk_death_strike : public SpellScript if (AuraEffect* enabler = caster->GetAuraEffect(SPELL_DK_DEATH_STRIKE_ENABLER, EFFECT_0, GetCaster()->GetGUID())) { // Heals you for 25% of all damage taken in the last 5 sec, - int32 heal = CalculatePct(enabler->CalculateAmount(GetCaster()), GetEffectInfo(EFFECT_1).CalcValue(GetCaster())); + SpellEffectValue heal = CalculatePct(enabler->CalculateAmount(GetCaster()), GetEffectInfo(EFFECT_1).CalcValue(GetCaster())); // minimum 7.0% of maximum health. - int32 pctOfMaxHealth = CalculatePct(GetEffectInfo(EFFECT_2).CalcValue(GetCaster()), caster->GetMaxHealth()); + SpellEffectValue pctOfMaxHealth = CalculatePct(GetEffectInfo(EFFECT_2).CalcValue(GetCaster()), caster->GetMaxHealth()); heal = std::max(heal, pctOfMaxHealth); caster->CastSpell(caster, SPELL_DK_DEATH_STRIKE_HEAL, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_BASE_POINT0, heal)); @@ -761,10 +761,10 @@ class spell_dk_death_strike_enabler : public AuraScript _damagePerSecond[0] = 0; } - void HandleCalcAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + void HandleCalcAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) { canBeRecalculated = true; - amount = int32(std::accumulate(_damagePerSecond.begin(), _damagePerSecond.end(), 0u)); + amount = std::accumulate(_damagePerSecond.begin(), _damagePerSecond.end(), 0u); } void HandleProc(AuraEffect* /*aurEff*/, ProcEventInfo& eventInfo) @@ -794,7 +794,7 @@ class spell_dk_festering_strike : public SpellScript void HandleScriptEffect(SpellEffIndex /*effIndex*/) { - GetCaster()->CastSpell(GetHitUnit(), SPELL_DK_FESTERING_WOUND, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_AURA_STACK, GetEffectValue())); + GetCaster()->CastSpell(GetHitUnit(), SPELL_DK_FESTERING_WOUND, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_AURA_STACK, GetEffectValueAsInt())); } void Register() override @@ -808,7 +808,7 @@ class spell_dk_frost_fever_proc : public AuraScript { bool CheckProc(AuraEffect const* aurEff, ProcEventInfo const& /*eventInfo*/) const { - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } void Register() override @@ -1003,13 +1003,13 @@ class spell_dk_improved_death_strike : public AuraScript && ValidateSpellEffect({ { spellInfo->Id, EFFECT_4 } }); } - void CalcHealIncrease(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) const + void CalcHealIncrease(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) const { if (GetUnitOwner()->HasAura(SPELL_DK_BLOOD)) amount = GetEffectInfo(EFFECT_3).CalcValue(GetCaster()); } - void CalcPowerCostReduction(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) const + void CalcPowerCostReduction(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) const { if (GetUnitOwner()->HasAura(SPELL_DK_BLOOD)) amount = GetEffectInfo(EFFECT_4).CalcValue(GetCaster()); @@ -1079,7 +1079,7 @@ class spell_dk_obliteration : public AuraScript target->CastSpell(target, SPELL_DK_KILLING_MACHINE_PROC, aurEff); if (AuraEffect const* oblitaration = target->GetAuraEffect(SPELL_DK_OBLITERATION, EFFECT_1)) - if (roll_chance_i(oblitaration->GetAmount())) + if (roll_chance_f(oblitaration->GetAmount())) target->CastSpell(target, SPELL_DK_OBLITERATION_RUNE_ENERGIZE, aurEff); } @@ -1258,7 +1258,7 @@ class spell_dk_rime : public AuraScript bool CheckProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo) { - float chance = static_cast(GetSpellInfo()->GetEffect(EFFECT_1).CalcValue(GetTarget())); + SpellEffectValue chance = GetSpellInfo()->GetEffect(EFFECT_1).CalcValue(GetTarget()); if (eventInfo.GetSpellInfo()->Id == SPELL_DK_FROST_SCYTHE) chance /= 2.f; @@ -1291,7 +1291,7 @@ public: if (!caster) return; - if (!_healthLimitEffectIndex || target->GetHealthPct() < float(GetEffectInfo(*_healthLimitEffectIndex).CalcValue(caster))) + if (!_healthLimitEffectIndex || target->GetHealthPct() < GetEffectInfo(*_healthLimitEffectIndex).CalcValue(caster)) caster->CastSpell(target, SPELL_DK_SOUL_REAPER_DAMAGE, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringAura = aurEff @@ -1421,7 +1421,7 @@ class spell_dk_t20_2p_rune_empowered : public AuraScript // 55233 - Vampiric Blood class spell_dk_vampiric_blood : public AuraScript { - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { amount = GetUnitOwner()->CountPctFromMaxHealth(amount); } @@ -1485,7 +1485,7 @@ struct at_dk_death_and_decay : AreaTriggerAI if (Aura* deathAndDecay = unit->GetAura(SPELL_DK_DEATH_AND_DECAY_INCREASE_TARGETS)) { if (AuraEffect* const cleavingStrikes = unit->GetAuraEffect(SPELL_DK_CLEAVING_STRIKES, EFFECT_3)) - deathAndDecay->SetDuration(cleavingStrikes->GetAmount()); + deathAndDecay->SetDuration(cleavingStrikes->GetAmountAsInt()); } unit->RemoveAurasDueToSpell(SPELL_DK_SANGUINE_GROUND); diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index 5e3e0b81fa..7f17e73a3d 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -258,9 +258,9 @@ class spell_dru_astral_smolder : public AuraScript PreventDefaultAction(); SpellEffectInfo const& astralSmolderDmg = sSpellMgr->AssertSpellInfo(SPELL_DRUID_ASTRAL_SMOLDER_DAMAGE, GetCastDifficulty())->GetEffect(EFFECT_0); - int32 pct = aurEff->GetAmount(); + SpellEffectValue pct = aurEff->GetAmount(); - int32 amount = int32(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), pct) / astralSmolderDmg.GetPeriodicTickCount()); + SpellEffectValue amount = CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), pct) / astralSmolderDmg.GetPeriodicTickCount(); CastSpellExtraArgs args(aurEff); args.AddSpellMod(SPELLVALUE_BASE_POINT0, amount); @@ -490,7 +490,7 @@ class spell_dru_cultivation : public AuraScript // 1850 - Dash class spell_dru_dash : public AuraScript { - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { // do not set speed if not in cat form if (GetUnitOwner()->GetShapeshiftForm() != FORM_CAT_FORM) @@ -585,7 +585,7 @@ class spell_dru_eclipse_aura : public AuraScript return; uint32 spellId = GetSpellInfo()->Id == SPELL_DRUID_ECLIPSE_SOLAR_AURA ? SPELL_DRUID_ECLIPSE_LUNAR_SPELL_CNT : SPELL_DRUID_ECLIPSE_SOLAR_SPELL_CNT; - spell_dru_eclipse_common::SetSpellCount(GetTarget(), spellId, auraEffDummy->GetAmount()); + spell_dru_eclipse_common::SetSpellCount(GetTarget(), spellId, auraEffDummy->GetAmountAsInt()); } void Register() override @@ -641,7 +641,7 @@ class spell_dru_eclipse_dummy : public AuraScript void HandleApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { // counters are applied with a delay - GetTarget()->m_Events.AddEventAtOffset(new InitializeEclipseCountersEvent(GetTarget(), aurEff->GetAmount()), 1s); + GetTarget()->m_Events.AddEventAtOffset(new InitializeEclipseCountersEvent(GetTarget(), aurEff->GetAmountAsInt()), 1s); } void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) @@ -711,8 +711,8 @@ class spell_dru_eclipse_ooc : public AuraScript if (!owner->IsInCombat() && (!owner->HasAura(SPELL_DRUID_ECLIPSE_SOLAR_SPELL_CNT) || !owner->HasAura(SPELL_DRUID_ECLIPSE_LUNAR_SPELL_CNT))) { // Restore 2 stacks to each spell when out of combat - spell_dru_eclipse_common::SetSpellCount(owner, SPELL_DRUID_ECLIPSE_SOLAR_SPELL_CNT, auraEffDummy->GetAmount()); - spell_dru_eclipse_common::SetSpellCount(owner, SPELL_DRUID_ECLIPSE_LUNAR_SPELL_CNT, auraEffDummy->GetAmount()); + spell_dru_eclipse_common::SetSpellCount(owner, SPELL_DRUID_ECLIPSE_SOLAR_SPELL_CNT, auraEffDummy->GetAmountAsInt()); + spell_dru_eclipse_common::SetSpellCount(owner, SPELL_DRUID_ECLIPSE_LUNAR_SPELL_CNT, auraEffDummy->GetAmountAsInt()); } } @@ -837,7 +837,7 @@ class spell_dru_elunes_favored_proc : public AuraScript if (!elunesFavored) return; - int32 heal = CalculatePct(_arcaneDamage, elunesFavored->GetAmount()); + SpellEffectValue heal = CalculatePct(_arcaneDamage, elunesFavored->GetAmount()); caster->CastSpell(caster, SPELL_DRUID_ELUNES_FAVORED_HEAL, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, @@ -868,7 +868,7 @@ class spell_dru_embrace_of_the_dream : public AuraScript bool CheckProc(AuraEffect const* /*aurEff*/, ProcEventInfo const& /*eventInfo*/) const { - return roll_chance_i(GetEffectInfo(EFFECT_2).CalcValue(GetCaster())); + return roll_chance_f(GetEffectInfo(EFFECT_2).CalcValue(GetCaster())); } void HandleProc(AuraEffect const* aurEff, ProcEventInfo const& eventInfo) const @@ -986,7 +986,7 @@ class spell_dru_ferocious_bite : public SpellScript void HandleHitTargetBurn(SpellEffIndex /*effIndex*/) { - int32 newValue = int32(float(GetEffectValue()) * _damageMultiplier); + SpellEffectValue newValue = GetEffectValue() * _damageMultiplier; SetEffectValue(newValue); } @@ -1000,16 +1000,16 @@ class spell_dru_ferocious_bite : public SpellScript { Unit* caster = GetCaster(); - int32 maxExtraConsumedPower = GetEffectValue(); + SpellEffectValue maxExtraConsumedPower = GetEffectValue(); if (AuraEffect* auraEffect = caster->GetAuraEffect(SPELL_DRUID_INCARNATION_KING_OF_THE_JUNGLE, EFFECT_1)) { - float multiplier = 1.0f + float(auraEffect->GetAmount()) / 100.0f; - maxExtraConsumedPower = int32(float(maxExtraConsumedPower) * multiplier); + SpellEffectValue multiplier = 1.0 + auraEffect->GetAmount() / 100.0; + maxExtraConsumedPower = maxExtraConsumedPower * multiplier; SetEffectValue(maxExtraConsumedPower); } - _damageMultiplier = std::min(caster->GetPower(POWER_ENERGY), maxExtraConsumedPower) / maxExtraConsumedPower; + _damageMultiplier = std::min(caster->GetPower(POWER_ENERGY), maxExtraConsumedPower) / maxExtraConsumedPower; } void Register() override @@ -1061,7 +1061,7 @@ class spell_dru_flower_walk_heal : public SpellScript void FilterTargets(std::list& targets) { Unit* caster = GetCaster(); - int32 maxTargets = GetEffectInfo(EFFECT_1).CalcValue(caster); + int32 maxTargets = GetEffectInfo(EFFECT_1).CalcValueAsInt(caster); if (targets.size() > 1) targets.remove(caster); @@ -1168,7 +1168,7 @@ class spell_dru_galactic_guardian : public AuraScript static bool CheckEffectProc(AuraScript const&, AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) { - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } static void HandleProc(AuraScript const&, AuraEffect const* /*aurEff*/, ProcEventInfo const& eventInfo) @@ -1294,7 +1294,7 @@ class spell_dru_gore : public AuraScript bool CheckEffectProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) { - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } void HandleProc(AuraEffect* /*aurEff*/, ProcEventInfo& /*procInfo*/) @@ -1320,7 +1320,7 @@ class spell_dru_guardian_of_elune_healing : public AuraScript return ValidateSpellEffect({ { SPELL_DRUID_GUARDIAN_OF_ELUNE_AURA, EFFECT_1 } }); } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) { canBeRecalculated = false; @@ -1604,7 +1604,7 @@ class spell_dru_luxuriant_soil : public AuraScript static bool CheckProc(AuraScript const&, AuraEffect const* aurEff, ProcEventInfo const& /*eventInfo*/) { - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo const& eventInfo) const @@ -1701,7 +1701,7 @@ class spell_dru_matted_fur_absorb : public AuraScript static void CalculateAmount(AuraScript const&, AuraEffect const* /*aurEff*/, Unit const* victim, int32& baseAbsorb, int32& /*flatMod*/, float& /*pctMod*/) { if (AuraEffect const* passiveEffect = victim->GetAuraEffect(SPELL_DRUID_MATTED_FUR, EFFECT_0)) - baseAbsorb = static_cast(victim->GetTotalAttackPowerValue(BASE_ATTACK) * 0.0125f * passiveEffect->GetAmount()); + baseAbsorb = static_cast(victim->GetTotalAttackPowerValue(BASE_ATTACK) * 0.0125 * passiveEffect->GetAmount()); } void Register() override @@ -1746,7 +1746,7 @@ class spell_dru_moonless_night : public AuraScript { Unit* caster = eventInfo.GetActor(); Unit* target = eventInfo.GetActionTarget(); - int32 damage = CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount()); + SpellEffectValue damage = CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount()); caster->CastSpell(target, SPELL_DRUID_MOONLESS_NIGHT_DAMAGE, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, @@ -1774,7 +1774,7 @@ public: static void Trigger(Unit* caster, AuraEffect const* naturesGraceEffect) { caster->CastSpell(caster, SPELL_DRUID_DREAMSTATE, CastSpellExtraArgsInit{ - .SpellValueOverrides = { { SPELLVALUE_AURA_STACK, naturesGraceEffect->GetAmount() } } + .SpellValueOverrides = { { SPELLVALUE_AURA_STACK, naturesGraceEffect->GetAmountAsInt() } } }); } @@ -1879,7 +1879,7 @@ class spell_dru_omen_of_clarity_restoration : public AuraScript { bool CheckProc(AuraEffect const* aurEff, ProcEventInfo const& /*eventInfo*/) const { - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } void Register() override @@ -1921,7 +1921,7 @@ class spell_dru_power_of_the_archdruid : public AuraScript AuraEffect const* powerOfTheArchdruidEffect = druid->GetAuraEffect(SPELL_DRUID_POWER_OF_THE_ARCHDRUID, EFFECT_0); // max. targets is SPELL_DRUID_POWER_OF_THE_ARCHDRUID's EFFECT_0 BasePoints. - int32 maxTargets = powerOfTheArchdruidEffect->GetAmount(); + int32 maxTargets = powerOfTheArchdruidEffect->GetAmountAsInt(); Trinity::Containers::RandomResize(targetList, maxTargets); @@ -1960,7 +1960,7 @@ class spell_dru_pulverize : public SpellScript if (!bleedAura) return; - int32 stacksToRemove = GetEffectInfo(EFFECT_2).CalcValue(caster); + int32 stacksToRemove = GetEffectInfo(EFFECT_2).CalcValueAsInt(caster); bleedAura->ModStackAmount(-stacksToRemove); target->RemoveAurasDueToSpell(SPELL_DRUID_THRASH_PULVERIZE_TRIGGER); @@ -2001,7 +2001,7 @@ class spell_dru_pulverize_thrash : public SpellScript if (!bleedAura) return; - int32 thresholdStacks = sSpellMgr->AssertSpellInfo(SPELL_DRUID_PULVERIZE, GetCastDifficulty())->GetEffect(EFFECT_2).CalcValue(caster); + int32 thresholdStacks = sSpellMgr->AssertSpellInfo(SPELL_DRUID_PULVERIZE, GetCastDifficulty())->GetEffect(EFFECT_2).CalcValueAsInt(caster); if (bleedAura->GetStackAmount() >= thresholdStacks) caster->CastSpell(target, SPELL_DRUID_THRASH_PULVERIZE_TRIGGER, CastSpellExtraArgs().SetTriggeringSpell(GetSpell())); } @@ -2091,7 +2091,7 @@ class spell_dru_rip : public AuraScript return caster && caster->GetTypeId() == TYPEID_PLAYER; } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) { canBeRecalculated = false; @@ -2107,7 +2107,7 @@ class spell_dru_rip : public AuraScript else if (AuraEffect const* auraEffIdolOfWorship = caster->GetAuraEffect(SPELL_DRUID_IDOL_OF_WORSHIP, EFFECT_0)) amount += cp * auraEffIdolOfWorship->GetAmount(); - amount += int32(CalculatePct(caster->GetTotalAttackPowerValue(BASE_ATTACK), cp)); + amount += CalculatePct(caster->GetTotalAttackPowerValue(BASE_ATTACK), cp); } } @@ -2210,7 +2210,7 @@ class spell_dru_shooting_stars : public AuraScript { uint32 spellId = SPELL_DRUID_SHOOTING_STARS_DAMAGE; AuraEffect const* crashingStarTalent = caster->GetAuraEffect(SPELL_DRUID_CRASHING_STAR_TALENT, EFFECT_0); - if (crashingStarTalent && roll_chance_i(crashingStarTalent->GetAmount())) + if (crashingStarTalent && roll_chance_f(crashingStarTalent->GetAmount())) spellId = SPELL_DRUID_CRASHING_STAR_DAMAGE; caster->CastSpell(target, spellId, CastSpellExtraArgsInit{ @@ -2295,7 +2295,7 @@ class spell_dru_starfall_dummy : public SpellScript if (caster->HasUnitState(UNIT_STATE_CONTROLLED)) return; - caster->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true); + caster->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -2339,7 +2339,7 @@ class spell_dru_sudden_ambush : public AuraScript if (!comboPoints) return false; - return roll_chance_i(*comboPoints * aurEff->GetAmount()); + return roll_chance_f(*comboPoints * aurEff->GetAmount()); } void Register() override @@ -2395,7 +2395,7 @@ class spell_dru_swift_flight_passive : public AuraScript return GetCaster()->GetTypeId() == TYPEID_PLAYER; } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Player* caster = GetCaster()->ToPlayer()) if (caster->GetSkillValue(SKILL_RIDING) >= 375) @@ -2448,7 +2448,7 @@ class spell_dru_t3_8p_bonus : public AuraScript if (!manaCost) return; - int32 amount = CalculatePct(*manaCost, aurEff->GetAmount()); + SpellEffectValue amount = CalculatePct(*manaCost, aurEff->GetAmount()); CastSpellExtraArgs args(aurEff); args.AddSpellBP0(amount); caster->CastSpell(nullptr, SPELL_DRUID_EXHILARATE, args); @@ -2502,7 +2502,7 @@ class spell_dru_t10_balance_4p_bonus : public AuraScript Unit* target = eventInfo.GetProcTarget(); SpellEffectInfo const& spellEffect = sSpellMgr->AssertSpellInfo(SPELL_DRUID_LANGUISH, GetCastDifficulty())->GetEffect(EFFECT_0); - int32 amount = CalculatePct(static_cast(damageInfo->GetDamage()), aurEff->GetAmount()); + SpellEffectValue amount = CalculatePct(static_cast(damageInfo->GetDamage()), aurEff->GetAmount()); amount /= spellEffect.GetPeriodicTickCount(); @@ -2608,7 +2608,7 @@ class spell_dru_thorns_of_iron_damage : public SpellScript Unit* caster = GetCaster(); int32 noTargets = GetUnitTargetCountForEffect(effIndex); - int32 pct = GetTriggeringSpell()->GetEffect(effIndex).CalcValue(caster); + SpellEffectValue pct = GetTriggeringSpell()->GetEffect(effIndex).CalcValue(caster); int32 damage = CalculatePct(caster->GetArmor(), pct) / noTargets; SetHitDamage(damage); @@ -2837,7 +2837,7 @@ class spell_dru_tiger_dash_aura : public AuraScript { if (AuraEffect* effRunSpeed = GetEffect(EFFECT_0)) { - int32 reduction = aurEff->GetAmount(); + SpellEffectValue reduction = aurEff->GetAmount(); effRunSpeed->ChangeAmount(effRunSpeed->GetAmount() - reduction); } } @@ -3003,7 +3003,7 @@ class spell_dru_ursocs_fury : public AuraScript return; Unit* caster = eventInfo.GetActor(); - int32 amount = CalculatePct(damageInfo->GetDamage(), aurEff->GetAmount()); + SpellEffectValue amount = CalculatePct(damageInfo->GetDamage(), aurEff->GetAmount()); caster->CastSpell(caster, SPELL_DRUID_URSOCS_FURY_SHIELD, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, @@ -3028,10 +3028,10 @@ class spell_dru_wild_growth : public SpellScript void FilterTargets(std::list& targets) const { Unit* caster = GetCaster(); - int32 maxTargets = GetEffectInfo(EFFECT_1).CalcValue(caster); + int32 maxTargets = GetEffectInfo(EFFECT_1).CalcValueAsInt(caster); if (AuraEffect const* treeOfLife = caster->GetAuraEffect(SPELL_DRUID_TREE_OF_LIFE, EFFECT_2)) - maxTargets += treeOfLife->GetAmount(); + maxTargets += treeOfLife->GetAmountAsInt(); // Note: Wild Growth became a smart heal which prioritizes players and their pets in their group before any unit outside their group. Trinity::SelectRandomInjuredTargets(targets, maxTargets, true, caster); @@ -3057,16 +3057,16 @@ class spell_dru_wild_growth_aura : public AuraScript return; // calculate from base damage, not from aurEff->GetAmount() (already modified) - float damage = caster->CalculateSpellDamage(GetUnitOwner(), aurEff->GetSpellEffectInfo()); + SpellEffectValue damage = aurEff->GetSpellEffectInfo().CalcValue(caster, nullptr, GetUnitOwner()); // Wild Growth = first tick gains a 6% bonus, reduced by 2% each tick float reduction = 2.f; if (AuraEffect* bonus = caster->GetAuraEffect(SPELL_DRUID_RESTORATION_T10_2P_BONUS, EFFECT_0)) reduction -= CalculatePct(reduction, bonus->GetAmount()); - reduction *= (aurEff->GetTickNumber() - 1); + reduction *= aurEff->GetTickNumber() - 1; AddPct(damage, 6.f - reduction); - aurEff->SetAmount(int32(damage)); + aurEff->SetAmount(damage); } void Register() override @@ -3089,7 +3089,7 @@ class spell_dru_yseras_gift : public AuraScript void HandleEffectPeriodic(AuraEffect const* aurEff) { - int32 healAmount = int32(GetTarget()->CountPctFromMaxHealth(aurEff->GetAmount())); + SpellEffectValue healAmount = GetTarget()->CountPctFromMaxHealth(aurEff->GetAmount()); if (!GetTarget()->IsFullHealth()) GetTarget()->CastSpell(GetTarget(), SPELL_DRUID_YSERAS_GIFT_HEAL_SELF, CastSpellExtraArgs(aurEff).AddSpellBP0(healAmount)); diff --git a/src/server/scripts/Spells/spell_evoker.cpp b/src/server/scripts/Spells/spell_evoker.cpp index 48c8229c6c..f05e76d547 100644 --- a/src/server/scripts/Spells/spell_evoker.cpp +++ b/src/server/scripts/Spells/spell_evoker.cpp @@ -97,7 +97,7 @@ class spell_evo_azure_strike : public SpellScript void FilterTargets(std::list& targets) { targets.remove(GetExplTargetUnit()); - Trinity::Containers::RandomResize(targets, GetEffectInfo(EFFECT_0).CalcValue(GetCaster()) - 1); + Trinity::Containers::RandomResize(targets, GetEffectInfo(EFFECT_0).CalcValueAsInt(GetCaster()) - 1); targets.push_back(GetExplTargetUnit()); } @@ -168,7 +168,7 @@ class spell_evo_burnout : public AuraScript static bool CheckProc(AuraScript const&, AuraEffect const* aurEff, ProcEventInfo const& /*eventInfo*/) { - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } static void HandleProc(AuraScript const&, AuraEffect const* /*aurEff*/, ProcEventInfo const& eventInfo) @@ -229,7 +229,7 @@ class spell_evo_causality_disintegrate : public AuraScript { if (AuraEffect const* causality = GetCaster()->GetAuraEffect(SPELL_EVOKER_CAUSALITY, EFFECT_0)) for (uint32 spell : CausalityAffectedEmpowerSpells) - GetCaster()->GetSpellHistory()->ModifyCooldown(spell, Milliseconds(causality->GetAmount())); + GetCaster()->GetSpellHistory()->ModifyCooldown(spell, Milliseconds(causality->GetAmountAsInt())); } void Register() override @@ -259,7 +259,7 @@ class spell_evo_causality_pyre : public SpellScript if (!causality) return; - Milliseconds cooldownReduction = Milliseconds(std::min(GetUnitTargetCountForEffect(EFFECT_0), TargetLimit) * causality->GetAmount()); + Milliseconds cooldownReduction = Milliseconds(std::min(GetUnitTargetCountForEffect(EFFECT_0), TargetLimit) * causality->GetAmountAsInt()); for (uint32 spell : CausalityAffectedEmpowerSpells) GetCaster()->GetSpellHistory()->ModifyCooldown(spell, cooldownReduction); } @@ -307,7 +307,7 @@ class spell_evo_emerald_blossom_heal : public SpellScript void FilterTargets(std::list& targets) const { - uint32 const maxTargets = uint32(GetSpellInfo()->GetEffect(EFFECT_1).CalcValue(GetCaster())); + uint32 const maxTargets = uint32(GetSpellInfo()->GetEffect(EFFECT_1).CalcValueAsInt(GetCaster())); Trinity::SelectRandomInjuredTargets(targets, maxTargets, true); } @@ -332,7 +332,7 @@ public: bool Load() override { AuraEffect const* aurEff = GetCaster()->GetAuraEffect(_talentAuraId, EFFECT_0); - return aurEff && roll_chance_i(aurEff->GetAmount()); + return aurEff && roll_chance_f(aurEff->GetAmount()); } void HandleEssenceBurst() const @@ -368,7 +368,7 @@ public: void OnComplete(int32 completedStageCount) const { - int32 dotTicks = 10 - (completedStageCount - 1) * 3; + SpellEffectValue dotTicks = 10 - (completedStageCount - 1) * 3; if (AuraEffect const* blastFurnace = GetCaster()->GetAuraEffect(SPELL_EVOKER_BLAST_FURNACE, EFFECT_0)) dotTicks += blastFurnace->GetAmount() / 2; diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 358a6df294..93362920e7 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -60,7 +60,7 @@ class spell_gen_absorb0_hitlimit1 : public AuraScript bool Load() override { // Max absorb stored in 1 dummy effect - limit = GetSpellInfo()->GetEffect(EFFECT_1).CalcValue(); + limit = GetSpellInfo()->GetEffect(EFFECT_1).CalcValueAsInt(); return true; } @@ -269,7 +269,7 @@ class spell_gen_arena_drink : public AuraScript isPeriodic = false; } - void CalcAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalcAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { AuraEffect* regen = GetAura()->GetEffect(EFFECT_0); if (!regen) @@ -715,18 +715,18 @@ class spell_gen_burning_depths_necrolyte_image : public AuraScript bool Validate(SpellInfo const* spellInfo) override { return ValidateSpellEffect({ { spellInfo->Id, EFFECT_2 } }) - && ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_2).CalcValue()) }); + && ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_2).CalcValueAsInt()) }); } void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { if (Unit* caster = GetCaster()) - caster->CastSpell(GetTarget(), uint32(GetEffectInfo(EFFECT_2).CalcValue())); + caster->CastSpell(GetTarget(), uint32(GetEffectInfo(EFFECT_2).CalcValueAsInt())); } void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - GetTarget()->RemoveAurasDueToSpell(uint32(GetEffectInfo(EFFECT_2).CalcValue()), GetCasterGUID()); + GetTarget()->RemoveAurasDueToSpell(uint32(GetEffectInfo(EFFECT_2).CalcValueAsInt()), GetCasterGUID()); } void Register() override @@ -786,7 +786,7 @@ class spell_gen_chains_of_ice : public AuraScript if (!slow) return; - int32 newAmount = std::min(slow->GetAmount() + aurEff->GetAmount(), 0); + SpellEffectValue newAmount = std::min(slow->GetAmount() + aurEff->GetAmount(), 0.0); slow->ChangeAmount(newAmount); } @@ -851,7 +851,7 @@ class spell_gen_clone : public SpellScript void HandleScriptEffect(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -886,7 +886,7 @@ class spell_gen_clone_weapon : public SpellScript void HandleScriptEffect(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true); + GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -1027,7 +1027,7 @@ class spell_gen_consumption : public SpellScript void CalculateDamage(SpellEffectInfo const& /*spellEffectInfo*/, Unit const* /*victim*/, int32& damage, int32& /*flatMod*/, float& /*pctMod*/) const { if (SpellInfo const* createdBySpell = sSpellMgr->GetSpellInfo(GetCaster()->m_unitData->CreatedBySpell, GetCastDifficulty())) - damage = createdBySpell->GetEffect(EFFECT_1).CalcValue(); + damage = createdBySpell->GetEffect(EFFECT_1).CalcValueAsInt(); } void Register() override @@ -1896,14 +1896,14 @@ class spell_gen_gift_of_naaru : public AuraScript return ValidateSpellEffect({ { spellInfo->Id, EFFECT_1 } }); } - void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* aurEff, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (!GetCaster() || !aurEff->GetTotalTicks()) return; - float healPct = GetEffectInfo(EFFECT_1).CalcValue() / 100.0f; - float heal = healPct * GetCaster()->GetMaxHealth(); - int32 healTick = std::floor(heal / aurEff->GetTotalTicks()); + SpellEffectValue healPct = GetEffectInfo(EFFECT_1).CalcValue() / 100.0; + SpellEffectValue heal = healPct * GetCaster()->GetMaxHealth(); + SpellEffectValue healTick = std::floor(heal / aurEff->GetTotalTicks()); amount += healTick; } @@ -2064,9 +2064,9 @@ class spell_gen_increase_stats_buff : public SpellScript void HandleDummy(SpellEffIndex /*effIndex*/) { if (GetHitUnit()->IsInRaidWith(GetCaster())) - GetCaster()->CastSpell(GetCaster(), GetEffectValue() + 1, true); // raid buff + GetCaster()->CastSpell(GetCaster(), GetEffectValueAsInt() + 1, true); // raid buff else - GetCaster()->CastSpell(GetHitUnit(), GetEffectValue(), true); // single-target buff + GetCaster()->CastSpell(GetHitUnit(), GetEffectValueAsInt(), true); // single-target buff } void Register() override @@ -2479,8 +2479,8 @@ class spell_gen_oracle_wolvar_reputation : public SpellScript void HandleDummy(SpellEffIndex /*effIndex*/) { Player* player = GetCaster()->ToPlayer(); - uint32 factionId = GetEffectInfo().CalcValue(); - int32 repChange = GetEffectInfo(EFFECT_1).CalcValue(); + uint32 factionId = GetEffectInfo().CalcValueAsInt(); + int32 repChange = GetEffectInfo(EFFECT_1).CalcValueAsInt(); FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId); if (!factionEntry) @@ -2590,14 +2590,14 @@ class spell_gen_player_say : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return sBroadcastTextStore.HasRecord(uint32(spellInfo->GetEffect(EFFECT_0).CalcValue())); + return sBroadcastTextStore.HasRecord(uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt())); } void HandleScript(SpellEffIndex /*effIndex*/) { // Note: target here is always player; caster here is gameobject, creature or player (self cast) if (Unit* target = GetHitUnit()) - target->Unit::Say(uint32(GetEffectValue()), target); + target->Unit::Say(uint32(GetEffectValueAsInt()), target); } void Register() override @@ -2614,7 +2614,7 @@ class spell_gen_proc_below_pct_damaged : public AuraScript if (!damageInfo || !damageInfo->GetDamage()) return false; - int32 pct = GetSpellInfo()->GetEffect(EFFECT_0).CalcValue(); + SpellEffectValue pct = GetSpellInfo()->GetEffect(EFFECT_0).CalcValue(); if (eventInfo.GetActionTarget()->HealthBelowPctDamaged(pct, damageInfo->GetDamage())) return true; @@ -3014,7 +3014,7 @@ class spell_gen_replenishment_aura : public AuraScript return GetUnitOwner()->GetPowerType() == POWER_MANA; } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { switch (GetSpellInfo()->Id) { @@ -3074,7 +3074,7 @@ class spell_gen_running_wild_aura : public AuraScript target->Mount(DISPLAYID_HIDDEN_MOUNT, 0, 0); // cast speed aura - if (MountCapabilityEntry const* mountCapability = sMountCapabilityStore.LookupEntry(aurEff->GetAmount())) + if (MountCapabilityEntry const* mountCapability = sMountCapabilityStore.LookupEntry(aurEff->GetAmountAsInt())) target->CastSpell(target, mountCapability->ModSpellAuraID, TRIGGERED_FULL_MASK); } @@ -3246,7 +3246,7 @@ class spell_gen_throw_shield : public SpellScript void HandleScriptEffect(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true); + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -3550,22 +3550,22 @@ class spell_gen_vehicle_scaling : public AuraScript return GetCaster() && GetCaster()->GetTypeId() == TYPEID_PLAYER; } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { Unit* caster = GetCaster(); float factor; - uint16 baseItemLevel; + float baseItemLevel; /// @todo Reserach coeffs for different vehicles switch (GetId()) { case SPELL_GEAR_SCALING: factor = 1.0f; - baseItemLevel = 205; + baseItemLevel = 205.0f; break; default: factor = 1.0f; - baseItemLevel = 170; + baseItemLevel = 170.0f; break; } @@ -3573,7 +3573,7 @@ class spell_gen_vehicle_scaling : public AuraScript if (avgILvl < baseItemLevel) return; /// @todo Research possibility of scaling down - amount = uint16((avgILvl - baseItemLevel) * factor); + amount = (avgILvl - baseItemLevel) * factor; } void Register() override @@ -3648,14 +3648,14 @@ class spell_gen_whisper_to_controller : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return sBroadcastTextStore.HasRecord(uint32(spellInfo->GetEffect(EFFECT_0).CalcValue())); + return sBroadcastTextStore.HasRecord(uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt())); } void HandleScript(SpellEffIndex /*effIndex*/) { if (TempSummon* casterSummon = GetCaster()->ToTempSummon()) if (Player* target = casterSummon->GetSummonerUnit()->ToPlayer()) - casterSummon->Unit::Whisper(uint32(GetEffectValue()), target, false); + casterSummon->Unit::Whisper(uint32(GetEffectValueAsInt()), target, false); } void Register() override @@ -3721,7 +3721,7 @@ class spell_gen_eject_passenger : public SpellScript { if (!ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } })) return false; - if (spellInfo->GetEffect(EFFECT_0).CalcValue() < 1) + if (spellInfo->GetEffect(EFFECT_0).CalcValueAsInt() < 1) return false; return true; } @@ -3730,7 +3730,7 @@ class spell_gen_eject_passenger : public SpellScript { if (Vehicle* vehicle = GetHitUnit()->GetVehicleKit()) { - if (Unit* passenger = vehicle->GetPassenger(GetEffectValue() - 1)) + if (Unit* passenger = vehicle->GetPassenger(GetEffectValueAsInt() - 1)) passenger->ExitVehicle(); } } @@ -3946,7 +3946,7 @@ class spell_gen_mixology_bonus : public AuraScript bonus = value; } - void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* aurEff, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (GetCaster()->HasAura(SPELL_MIXOLOGY) && GetCaster()->HasSpell(GetEffectInfo(EFFECT_0).TriggerSpell)) { @@ -4375,7 +4375,7 @@ class spell_freezing_circle : public SpellScript if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, GetCastDifficulty())) if (!spellInfo->GetEffects().empty()) - SetHitDamage(spellInfo->GetEffect(EFFECT_0).CalcValue()); + SetHitDamage(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()); } void Register() override @@ -4420,7 +4420,7 @@ class spell_gen_cannon_blast : public SpellScript } void HandleScript(SpellEffIndex /*effIndex*/) { - int32 bp = GetEffectValue(); + SpellEffectValue bp = GetEffectValue(); Unit* target = GetHitUnit(); CastSpellExtraArgs args(TRIGGERED_FULL_MASK); args.AddSpellBP0(bp); @@ -4468,7 +4468,7 @@ class spell_gen_anetheron_summon_towering_infernal : public SpellScript { void HandleDummy(SpellEffIndex /* effIndex */) { - GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true); + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -4536,7 +4536,7 @@ class spell_gen_azgalor_rain_of_fire_hellfire_citadel : public SpellScript { void HandleDummy(SpellEffIndex /* effIndex */) { - GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValue()), true); + GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt()), true); } void Register() override @@ -4617,7 +4617,7 @@ class spell_gen_boost_2_0_paladin_priest_watch_for_shield : public AuraScript // 282559 - Enlisted class spell_gen_war_mode_enlisted : public AuraScript { - void CalcWarModeBonus(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalcWarModeBonus(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { Player* target = GetUnitOwner()->ToPlayer(); if (!target) @@ -4931,7 +4931,7 @@ class spell_gen_reverse_cast_target_to_caster_triggered: public SpellScript { void HandleScript(SpellEffIndex effIndex) { - GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->GetEffect(effIndex).CalcValue(), true); + GetHitUnit()->CastSpell(GetCaster(), GetSpellInfo()->GetEffect(effIndex).CalcValueAsInt(), true); } void Register() override @@ -5232,7 +5232,7 @@ enum MajorHealingCooldownSpell namespace MajorPlayerHealingCooldownHelpers { -float GetBonusMultiplier(Unit const* unit, uint32 spellId) +SpellEffectValue GetBonusMultiplier(Unit const* unit, uint32 spellId) { // Note: if caster is not in a raid setting, is in PvP or while in arena combat with 5 or less allied players. if (!unit->GetMap()->IsRaid() || !unit->GetMap()->IsBattleground()) @@ -5275,7 +5275,7 @@ float GetBonusMultiplier(Unit const* unit, uint32 spellId) return sSpellMgr->AssertSpellInfo(bonusSpellId, DIFFICULTY_NONE)->GetEffect(effIndex).CalcValue(unit); } - return 0.0f; + return 0.0; } } @@ -5584,7 +5584,7 @@ class spell_gen_no_npc_damage_below_override : public AuraScript public: spell_gen_no_npc_damage_below_override(float healthPct) : _healthPct(healthPct) {} - static void CalculateAmount(AuraScript const&, AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + static void CalculateAmount(AuraScript const&, AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { amount = -1; } diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 46e0ea7d61..22e4c4da78 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -335,7 +335,7 @@ class spell_hun_cobra_sting : public AuraScript bool RollProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*procInfo*/) { - return roll_chance_i(GetEffect(EFFECT_1)->GetAmount()); + return roll_chance_f(GetEffect(EFFECT_1)->GetAmount()); } void Register() override @@ -360,7 +360,7 @@ class spell_hun_concussive_shot : public SpellScript if (Aura* concussiveShot = GetHitUnit()->GetAura(SPELL_HUNTER_CONCUSSIVE_SHOT, caster->GetGUID())) { SpellInfo const* steadyShot = sSpellMgr->AssertSpellInfo(SPELL_HUNTER_STEADY_SHOT, GetCastDifficulty()); - Milliseconds extraDuration = Seconds(steadyShot->GetEffect(EFFECT_2).CalcValue(caster) / 10); + Milliseconds extraDuration = duration_cast(FloatSeconds(steadyShot->GetEffect(EFFECT_2).CalcValue(caster) / 10)); Milliseconds newDuration = Milliseconds(concussiveShot->GetDuration()) + extraDuration; concussiveShot->SetDuration(newDuration.count()); concussiveShot->SetMaxDuration(newDuration.count()); @@ -481,8 +481,8 @@ class spell_hun_hunting_party : public AuraScript void HandleProc(AuraEffect* aurEff, ProcEventInfo& /*eventInfo*/) { PreventDefaultAction(); - GetTarget()->GetSpellHistory()->ModifyCooldown(SPELL_HUNTER_EXHILARATION, -Seconds(aurEff->GetAmount())); - GetTarget()->GetSpellHistory()->ModifyCooldown(SPELL_HUNTER_EXHILARATION_PET, -Seconds(aurEff->GetAmount())); + GetTarget()->GetSpellHistory()->ModifyCooldown(SPELL_HUNTER_EXHILARATION, duration_cast(FloatSeconds(-aurEff->GetAmount()))); + GetTarget()->GetSpellHistory()->ModifyCooldown(SPELL_HUNTER_EXHILARATION_PET, duration_cast(FloatSeconds(-aurEff->GetAmount()))); } void Register() override @@ -639,7 +639,7 @@ class spell_hun_lock_and_load : public AuraScript static bool CheckProc(AuraScript const&, AuraEffect const* aurEff, ProcEventInfo const& /*eventInfo*/) { - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } static void HandleProc(AuraScript const&, AuraEffect const* /*aurEff*/, ProcEventInfo const& eventInfo) @@ -697,7 +697,7 @@ class spell_hun_master_marksman : public AuraScript static void HandleProc(AuraScript const&, AuraEffect const* aurEff, ProcEventInfo const& eventInfo) { uint32 ticks = sSpellMgr->AssertSpellInfo(SPELL_HUNTER_MASTER_MARKSMAN, DIFFICULTY_NONE)->GetEffect(EFFECT_0).GetPeriodicTickCount(); - int32 damage = CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount()) / ticks; + SpellEffectValue damage = CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount()) / ticks; eventInfo.GetActor()->CastSpell(eventInfo.GetActionTarget(), SPELL_HUNTER_MASTER_MARKSMAN, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, @@ -717,7 +717,7 @@ class spell_hun_masters_call : public SpellScript bool Validate(SpellInfo const* spellInfo) override { return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) - && ValidateSpellInfo({ SPELL_HUNTER_MASTERS_CALL_TRIGGERED, uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + && ValidateSpellInfo({ SPELL_HUNTER_MASTERS_CALL_TRIGGERED, uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } bool Load() override @@ -760,7 +760,7 @@ class spell_hun_masters_call : public SpellScript void HandleDummy(SpellEffIndex /*effIndex*/) { - GetCaster()->ToPlayer()->GetPet()->CastSpell(GetHitUnit(), GetEffectValue(), true); + GetCaster()->ToPlayer()->GetPet()->CastSpell(GetHitUnit(), GetEffectValueAsInt(), true); } void HandleScriptEffect(SpellEffIndex /*effIndex*/) @@ -850,7 +850,7 @@ class spell_hun_multi_shot : public SpellScript // 459783 - Penetrating Shots class spell_hun_penetrating_shots : public AuraScript { - void CalcAmount(AuraEffect const* /*aurEff*/, int32& amount, bool const& /*canBeRecalculated*/) const + void CalcAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool const& /*canBeRecalculated*/) const { if (AuraEffect const* amountHolder = GetEffect(EFFECT_1)) { @@ -1008,7 +1008,7 @@ class spell_hun_rejuvenating_wind : public AuraScript Unit* caster = GetTarget(); uint32 ticks = sSpellMgr->AssertSpellInfo(SPELL_HUNTER_REJUVENATING_WIND_HEAL, DIFFICULTY_NONE)->GetEffect(EFFECT_0).GetPeriodicTickCount(); - int32 heal = CalculatePct(caster->GetMaxHealth(), aurEff->GetAmount()) / ticks; + SpellEffectValue heal = CalculatePct(caster->GetMaxHealth(), aurEff->GetAmount()) / ticks; caster->CastSpell(caster, SPELL_HUNTER_REJUVENATING_WIND_HEAL, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, @@ -1120,7 +1120,7 @@ class spell_hun_scrappy : public AuraScript void HandleEffectProc(AuraEffect const* aurEff, ProcEventInfo const& /*eventInfo*/) const { for (uint32 spellId : AffectedSpellIds) - GetTarget()->GetSpellHistory()->ModifyCooldown(spellId, -Milliseconds(aurEff->GetAmount())); + GetTarget()->GetSpellHistory()->ModifyCooldown(spellId, -Milliseconds(aurEff->GetAmountAsInt())); } void Register() override @@ -1139,7 +1139,7 @@ class spell_hun_shrapnel_shot : public AuraScript void HandleProc(ProcEventInfo const& /*eventInfo*/) const { - if (!roll_chance_i(GetEffect(EFFECT_0)->GetAmount())) + if (!roll_chance_f(GetEffect(EFFECT_0)->GetAmount())) return; GetCaster()->CastSpell(GetCaster(), SPELL_HUNTER_LOCK_AND_LOAD, CastSpellExtraArgsInit{ @@ -1174,7 +1174,7 @@ class spell_hun_steady_shot : public SpellScript }); if (GetCaster()->HasAura(SPELL_HUNTER_MARKSMANSHIP_HUNTER_AURA)) - GetCaster()->GetSpellHistory()->ModifyCooldown(SPELL_HUNTER_AIMED_SHOT, Milliseconds(-GetEffectInfo(EFFECT_1).CalcValue())); + GetCaster()->GetSpellHistory()->ModifyCooldown(SPELL_HUNTER_AIMED_SHOT, Milliseconds(-GetEffectInfo(EFFECT_1).CalcValueAsInt())); } void Register() override @@ -1406,7 +1406,7 @@ class spell_hun_t29_2p_marksmanship_bonus : public AuraScript Unit* caster = eventInfo.GetActor(); uint32 ticks = sSpellMgr->AssertSpellInfo(SPELL_HUNTER_T29_2P_MARKSMANSHIP_DAMAGE, DIFFICULTY_NONE)->GetEffect(EFFECT_0).GetPeriodicTickCount(); - uint32 damage = CalculatePct(eventInfo.GetDamageInfo()->GetOriginalDamage(), aurEff->GetAmount()) / ticks; + SpellEffectValue damage = CalculatePct(eventInfo.GetDamageInfo()->GetOriginalDamage(), aurEff->GetAmount()) / ticks; caster->CastSpell(eventInfo.GetActionTarget(), SPELL_HUNTER_T29_2P_MARKSMANSHIP_DAMAGE, CastSpellExtraArgs(aurEff) .SetTriggeringSpell(eventInfo.GetProcSpell()) @@ -1444,7 +1444,7 @@ class spell_hun_wilderness_medicine : public AuraScript void OnPeriodic(AuraEffect const* aurEff) const { if (Unit* caster = GetCaster()) - if (roll_chance_i(_dispelChance)) + if (roll_chance_f(_dispelChance)) caster->CastSpell(GetTarget(), SPELL_HUNTER_WILDERNESS_MEDICINE_DISPEL, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringAura = aurEff @@ -1456,7 +1456,7 @@ class spell_hun_wilderness_medicine : public AuraScript OnEffectPeriodic += AuraEffectPeriodicFn(spell_hun_wilderness_medicine::OnPeriodic, EFFECT_0, SPELL_AURA_OBS_MOD_HEALTH); } - int32 _dispelChance = 0; + SpellEffectValue _dispelChance = 0; }; void AddSC_hunter_spell_scripts() diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 5c627e283a..5c23fb8c5e 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -334,7 +334,7 @@ class spell_item_anger_capacitor : public SpellScriptLoader // 26400 - Arcane Shroud class spell_item_arcane_shroud : public AuraScript { - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { int32 diff = GetUnitOwner()->GetLevel() - 60; if (diff > 0) @@ -504,11 +504,11 @@ class spell_item_blessing_of_ancient_kings : public AuraScript if (!healInfo || !healInfo->GetHeal()) return; - int32 absorb = int32(CalculatePct(healInfo->GetHeal(), 15.0f)); + SpellEffectValue absorb = CalculatePct(healInfo->GetHeal(), 15.0f); if (AuraEffect* protEff = eventInfo.GetProcTarget()->GetAuraEffect(SPELL_PROTECTION_OF_ANCIENT_KINGS, EFFECT_0, eventInfo.GetActor()->GetGUID())) { // The shield can grow to a maximum size of 20,000 damage absorbtion - protEff->SetAmount(std::min(protEff->GetAmount() + absorb, 20000)); + protEff->SetAmount(std::min(protEff->GetAmount() + absorb, 20000.0)); // Refresh and return to prevent replacing the aura protEff->GetBase()->RefreshDuration(); @@ -1355,7 +1355,7 @@ class spell_item_crystal_spire_of_karabor : public AuraScript bool CheckProc(ProcEventInfo& eventInfo) { - int32 pct = GetSpellInfo()->GetEffect(EFFECT_0).CalcValue(); + SpellEffectValue pct = GetSpellInfo()->GetEffect(EFFECT_0).CalcValue(); if (HealInfo* healInfo = eventInfo.GetHealInfo()) if (Unit* healTarget = healInfo->GetTarget()) if (healTarget->GetHealth() - healInfo->GetEffectiveHeal() <= healTarget->CountPctFromMaxHealth(pct)) @@ -1692,7 +1692,7 @@ class spell_item_persistent_shield : public AuraScript { Unit* caster = eventInfo.GetActor(); Unit* target = eventInfo.GetProcTarget(); - int32 bp0 = CalculatePct(eventInfo.GetHealInfo()->GetHeal(), 15); + SpellEffectValue bp0 = CalculatePct(eventInfo.GetHealInfo()->GetHeal(), 15); // Scarab Brooch does not replace stronger shields if (AuraEffect const* shield = target->GetAuraEffect(SPELL_PERSISTENT_SHIELD_TRIGGERED, EFFECT_0, caster->GetGUID())) @@ -2331,7 +2331,7 @@ class spell_item_swift_hand_justice_dummy : public AuraScript // 28862 - The Eye of Diminution class spell_item_the_eye_of_diminution : public AuraScript { - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { int32 diff = GetUnitOwner()->GetLevel() - 60; if (diff > 0) @@ -3561,7 +3561,7 @@ public: Aura* dummy = caster->GetAura(_stackSpell); // retrieve aura //dont do anything if it's not the right amount of stacks; - if (!dummy || dummy->GetStackAmount() < aurEff->GetAmount()) + if (!dummy || dummy->GetStackAmount() < aurEff->GetAmountAsInt()) return; // if right amount, remove the aura and cast real trigger @@ -3941,7 +3941,7 @@ class spell_item_artifical_stamina : public AuraScript return GetOwner()->GetTypeId() == TYPEID_PLAYER; } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Item* artifact = GetOwner()->ToPlayer()->GetItemByGuid(GetAura()->GetCastItemGUID())) amount = GetEffectInfo(EFFECT_1).BasePoints * artifact->GetTotalPurchasedArtifactPowers() / 100; @@ -3965,7 +3965,7 @@ class spell_item_artifical_damage : public AuraScript return GetOwner()->GetTypeId() == TYPEID_PLAYER; } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Item* artifact = GetOwner()->ToPlayer()->GetItemByGuid(GetAura()->GetCastItemGUID())) amount = GetSpellInfo()->GetEffect(EFFECT_1).BasePoints * artifact->GetTotalPurchasedArtifactPowers() / 100; @@ -4548,7 +4548,7 @@ class spell_item_grips_of_forsaken_sanity : public AuraScript bool CheckHealth(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo) { - return eventInfo.GetActor()->GetHealthPct() >= float(GetEffectInfo(EFFECT_1).CalcValue()); + return eventInfo.GetActor()->GetHealthPct() >= GetEffectInfo(EFFECT_1).CalcValue(); } void Register() override diff --git a/src/server/scripts/Spells/spell_mage.cpp b/src/server/scripts/Spells/spell_mage.cpp index 6876418dac..c7b1656bf7 100644 --- a/src/server/scripts/Spells/spell_mage.cpp +++ b/src/server/scripts/Spells/spell_mage.cpp @@ -293,7 +293,7 @@ class spell_mage_arcane_explosion : public SpellScript if (!requiredTargets) return false; - return GetUnitTargetCountForEffect(EFFECT_1) >= requiredTargets->GetAmount() && roll_chance_i(triggerChance->GetAmount()); + return GetUnitTargetCountForEffect(EFFECT_1) >= requiredTargets->GetAmount() && roll_chance_f(triggerChance->GetAmount()); }(); if (!procTriggered) @@ -315,11 +315,11 @@ class spell_mage_blazing_barrier : public AuraScript return ValidateSpellInfo({ SPELL_MAGE_BLAZING_BARRIER_TRIGGER }); } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) { canBeRecalculated = false; if (Unit* caster = GetCaster()) - amount = int32(caster->SpellBaseHealingBonusDone(GetSpellInfo()->GetSchoolMask()) * 7.0f); + amount = caster->SpellBaseHealingBonusDone(GetSpellInfo()->GetSchoolMask()) * 7.0f; } void HandleProc(AuraEffect* /*aurEff*/, ProcEventInfo& eventInfo) @@ -647,22 +647,22 @@ class spell_mage_ethereal_blink_triggered : public SpellScript if (!reductionEffect) return; - Seconds reduction = Seconds(reductionEffect->GetAmount()) * targets.size(); + FloatSeconds reduction = FloatSeconds(reductionEffect->GetAmount()) * targets.size(); if (AuraEffect const* cap = GetCaster()->GetAuraEffect(SPELL_MAGE_ETHEREAL_BLINK, EFFECT_3)) - if (reduction > Seconds(cap->GetAmount())) - reduction = Seconds(cap->GetAmount()); + if (reduction > FloatSeconds(cap->GetAmount())) + reduction = FloatSeconds(cap->GetAmount()); if (reduction > 0s) { - GetCaster()->GetSpellHistory()->ModifyCooldown(SPELL_MAGE_BLINK, -reduction); - GetCaster()->GetSpellHistory()->ModifyCooldown(SPELL_MAGE_SHIMMER, -reduction); + GetCaster()->GetSpellHistory()->ModifyCooldown(SPELL_MAGE_BLINK, -duration_cast(reduction)); + GetCaster()->GetSpellHistory()->ModifyCooldown(SPELL_MAGE_SHIMMER, -duration_cast(reduction)); } } void TriggerSlow(SpellEffIndex /*effIndex*/) { - int32 effectivenessPct = 100; + SpellEffectValue effectivenessPct = 100; if (AuraEffect const* effectivenessEffect = GetCaster()->GetAuraEffect(SPELL_MAGE_ETHEREAL_BLINK, EFFECT_1)) effectivenessPct = effectivenessEffect->GetAmount(); @@ -688,7 +688,7 @@ class spell_mage_feel_the_burn : public AuraScript return ValidateSpellInfo({ SPELL_MAGE_FEEL_THE_BURN }); } - void CalcAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + void CalcAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) { if (Unit* caster = GetCaster()) if (AuraEffect const* valueHolder = caster->GetAuraEffect(SPELL_MAGE_FEEL_THE_BURN, EFFECT_0)) @@ -733,13 +733,13 @@ class spell_mage_fingers_of_frost : public AuraScript bool CheckFrostboltProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) { return eventInfo.GetSpellInfo() && eventInfo.GetSpellInfo()->IsAffected(SPELLFAMILY_MAGE, flag128(0, 0x2000000, 0, 0)) - && roll_chance_i(aurEff->GetAmount()); + && roll_chance_f(aurEff->GetAmount()); } bool CheckFrozenOrbProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) { return eventInfo.GetSpellInfo() && eventInfo.GetSpellInfo()->IsAffected(SPELLFAMILY_MAGE, flag128(0, 0, 0x80, 0)) - && roll_chance_i(aurEff->GetAmount()); + && roll_chance_f(aurEff->GetAmount()); } void Trigger(AuraEffect* aurEff, ProcEventInfo& eventInfo) @@ -843,10 +843,10 @@ class spell_mage_flame_on : public AuraScript && ValidateSpellEffect({ { spellInfo->Id, EFFECT_2 } }); } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) { canBeRecalculated = false; - amount = -GetPctOf(GetEffectInfo(EFFECT_2).CalcValue() * IN_MILLISECONDS, sSpellCategoryStore.AssertEntry(sSpellMgr->AssertSpellInfo(SPELL_MAGE_FIRE_BLAST, DIFFICULTY_NONE)->ChargeCategoryId)->ChargeRecoveryTime); + amount = -GetPctOf(GetEffectInfo(EFFECT_2).CalcValue() * int32(IN_MILLISECONDS), sSpellCategoryStore.AssertEntry(sSpellMgr->AssertSpellInfo(SPELL_MAGE_FIRE_BLAST, DIFFICULTY_NONE)->ChargeCategoryId)->ChargeRecoveryTime); } void Register() override @@ -946,7 +946,7 @@ class spell_mage_flurry : public SpellScript void EffectHit(SpellEffIndex /*effIndex*/) const { - GetCaster()->m_Events.AddEventAtOffset(new FlurryEvent(GetCaster(), GetHitUnit()->GetGUID(), GetSpell()->m_castId, GetEffectValue() - 1), randtime(300ms, 400ms)); + GetCaster()->m_Events.AddEventAtOffset(new FlurryEvent(GetCaster(), GetHitUnit()->GetGUID(), GetSpell()->m_castId, GetEffectValueAsInt() - 1), randtime(300ms, 400ms)); } void Register() override @@ -1156,7 +1156,7 @@ class spell_mage_ice_barrier : public AuraScript }); } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) const + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) const { canBeRecalculated = false; amount = CalculatePct(GetUnitOwner()->GetMaxHealth(), GetEffectInfo(EFFECT_1).CalcValue()); @@ -1243,7 +1243,7 @@ class spell_mage_ice_lance : public SpellScript if (Aura const* thermalVoid = caster->GetAura(SPELL_MAGE_THERMAL_VOID)) if (!thermalVoid->GetSpellInfo()->GetEffects().empty()) if (Aura* icyVeins = caster->GetAura(SPELL_MAGE_ICY_VEINS)) - icyVeins->SetDuration(icyVeins->GetDuration() + thermalVoid->GetSpellInfo()->GetEffect(EFFECT_0).CalcValue(caster) * IN_MILLISECONDS); + icyVeins->SetDuration(icyVeins->GetDuration() + thermalVoid->GetSpellInfo()->GetEffect(EFFECT_0).CalcValueAsInt(caster) * IN_MILLISECONDS); // Chain Reaction if (caster->HasAura(SPELL_MAGE_CHAIN_REACTION_DUMMY)) @@ -1307,12 +1307,12 @@ class spell_mage_ignite : public AuraScript PreventDefaultAction(); SpellEffectInfo const& igniteDot = sSpellMgr->AssertSpellInfo(SPELL_MAGE_IGNITE, GetCastDifficulty())->GetEffect(EFFECT_0); - int32 pct = aurEff->GetAmount(); + SpellEffectValue pct = aurEff->GetAmount(); if (spell_mage_hot_streak_ignite_marker::IsActive(eventInfo.GetProcSpell())) pct *= 2; - int32 amount = int32(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), pct) / igniteDot.GetPeriodicTickCount()); + SpellEffectValue amount = CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), pct) / igniteDot.GetPeriodicTickCount(); CastSpellExtraArgs args(aurEff); args.AddSpellMod(SPELLVALUE_BASE_POINT0, amount); @@ -1379,7 +1379,7 @@ class spell_mage_improved_combustion : public AuraScript return GetUnitOwner()->HasAura(SPELL_MAGE_IMPROVED_COMBUSTION); } - void CalcAmount(AuraEffect const* /*aurEff*/, int32& amount, bool const& /*canBeRecalculated*/) const + void CalcAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool const& /*canBeRecalculated*/) const { if (AuraEffect const* amountHolder = GetEffect(EFFECT_2)) { @@ -1665,11 +1665,11 @@ class spell_mage_prismatic_barrier : public AuraScript return ValidateSpellEffect({ { spellInfo->Id, EFFECT_5 } }); } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) { canBeRecalculated = false; if (Unit* caster = GetCaster()) - amount = int32(CalculatePct(caster->GetMaxHealth(), GetEffectInfo(EFFECT_5).CalcValue(caster))); + amount = CalculatePct(caster->GetMaxHealth(), GetEffectInfo(EFFECT_5).CalcValue(caster)); } void Register() override @@ -1978,7 +1978,7 @@ class spell_mage_supernova : public SpellScript { if (GetExplTargetUnit() == GetHitUnit()) { - uint32 damage = GetHitDamage(); + int32 damage = GetHitDamage(); AddPct(damage, GetEffectInfo(EFFECT_0).CalcValue()); SetHitDamage(damage); } @@ -2002,7 +2002,7 @@ class spell_mage_tempest_barrier : public AuraScript { PreventDefaultAction(); Unit* target = GetTarget(); - int32 amount = CalculatePct(target->GetMaxHealth(), aurEff->GetAmount()); + SpellEffectValue amount = CalculatePct(target->GetMaxHealth(), aurEff->GetAmount()); target->CastSpell(target, SPELL_MAGE_TEMPEST_BARRIER_ABSORB, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringAura = aurEff, @@ -2031,7 +2031,7 @@ class spell_mage_touch_of_the_magi_aura : public AuraScript { if (damageInfo->GetAttacker() == GetCaster() && damageInfo->GetVictim() == GetTarget()) { - uint32 extra = CalculatePct(damageInfo->GetDamage(), 25); + SpellEffectValue extra = CalculatePct(damageInfo->GetDamage(), 25); if (extra > 0) aurEff->ChangeAmount(aurEff->GetAmount() + extra); } @@ -2040,7 +2040,7 @@ class spell_mage_touch_of_the_magi_aura : public AuraScript void AfterRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { - int32 amount = aurEff->GetAmount(); + SpellEffectValue amount = aurEff->GetAmount(); if (!amount || GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE) return; @@ -2087,7 +2087,7 @@ class spell_mage_wildfire_crit : public AuraScript return ValidateSpellEffect({ { SPELL_MAGE_WILDFIRE_TALENT, _effIndex } }); } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) const + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) const { Unit* caster = GetCaster(); if (!caster) diff --git a/src/server/scripts/Spells/spell_monk.cpp b/src/server/scripts/Spells/spell_monk.cpp index a29af634d3..c6a6f76fc0 100644 --- a/src/server/scripts/Spells/spell_monk.cpp +++ b/src/server/scripts/Spells/spell_monk.cpp @@ -85,7 +85,7 @@ class spell_monk_burst_of_life : public AuraScript void AfterRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) const { AuraRemoveMode removeMode = GetTargetApplication()->GetRemoveMode(); - if (removeMode != AURA_REMOVE_BY_EXPIRE && (removeMode != AURA_REMOVE_BY_ENEMY_SPELL || aurEff->GetAmount())) + if (removeMode != AURA_REMOVE_BY_EXPIRE && (removeMode != AURA_REMOVE_BY_ENEMY_SPELL || aurEff->GetAmountAsInt())) return; Unit* caster = GetCaster(); @@ -98,7 +98,7 @@ class spell_monk_burst_of_life : public AuraScript caster->CastSpell(GetTarget(), SPELL_MONK_BURST_OF_LIFE_HEAL, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, - .SpellValueOverrides = { { SPELLVALUE_MAX_TARGETS, burstOfLife->GetAmount() } } + .SpellValueOverrides = { { SPELLVALUE_MAX_TARGETS, burstOfLife->GetAmountAsInt() } } }); } @@ -223,7 +223,7 @@ class spell_monk_life_cocoon : public SpellScript void CalculateAbsorb(SpellEffIndex /*effIndex*/) { - int32 absorb = GetCaster()->CountPctFromMaxHealth(GetEffectValue()); + SpellEffectValue absorb = GetCaster()->CountPctFromMaxHealth(GetEffectValue()); if (Player* player = GetCaster()->ToPlayer()) AddPct(absorb, player->GetRatingBonusValue(CR_VERSATILITY_HEALING_DONE)); @@ -285,7 +285,7 @@ class spell_monk_open_palm_strikes : public AuraScript bool CheckProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*procInfo*/) { AuraEffect const* talent = GetTarget()->GetAuraEffect(SPELL_MONK_OPEN_PALM_STRIKES_TALENT, EFFECT_1); - return talent && roll_chance_i(talent->GetAmount()); + return talent && roll_chance_f(talent->GetAmount()); } void Register() override @@ -465,14 +465,14 @@ class spell_monk_roll : public SpellScript // 109131 - Roll (backward) class spell_monk_roll_aura : public AuraScript { - void CalcMovementAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalcMovementAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { - amount += 100; + amount += 100.0; } - void CalcImmunityAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalcImmunityAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { - amount -= 100; + amount -= 100.0; } void ChangeRunBackSpeed(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) @@ -596,7 +596,7 @@ class spell_monk_stagger : public AuraScript if (!effect) return; - Absorb(dmgInfo, float(effect->GetAmount()) / 100.0f); + Absorb(dmgInfo, effect->GetAmount() / 100.0); } void Absorb(DamageInfo& dmgInfo, float multiplier) @@ -639,7 +639,7 @@ class spell_monk_stagger : public AuraScript } private: - void AddAndRefreshStagger(float amount) + void AddAndRefreshStagger(float amount) const { Unit* target = GetTarget(); if (Aura* auraStagger = FindExistingStaggerEffect(target)) @@ -648,7 +648,7 @@ private: if (!effStaggerRemaining) return; - float newAmount = effStaggerRemaining->GetAmount() + amount; + SpellEffectValue newAmount = effStaggerRemaining->GetAmount() + amount; uint32 spellId = GetStaggerSpellId(target, newAmount); if (spellId == effStaggerRemaining->GetSpellInfo()->Id) { @@ -666,18 +666,18 @@ private: AddNewStagger(target, GetStaggerSpellId(target, amount), amount); } - uint32 GetStaggerSpellId(Unit* unit, float amount) + static uint32 GetStaggerSpellId(Unit const* unit, SpellEffectValue amount) { - const float StaggerHeavy = 0.6f; - const float StaggerModerate = 0.3f; + constexpr double StaggerHeavy = 0.6; + constexpr double StaggerModerate = 0.3; - float staggerPct = amount / float(unit->GetMaxHealth()); + double staggerPct = amount / SpellEffectValue(unit->GetMaxHealth()); return (staggerPct >= StaggerHeavy) ? SPELL_MONK_STAGGER_HEAVY : (staggerPct >= StaggerModerate) ? SPELL_MONK_STAGGER_MODERATE : SPELL_MONK_STAGGER_LIGHT; } - void AddNewStagger(Unit* unit, uint32 staggerSpellId, float staggerAmount) + static void AddNewStagger(Unit* unit, uint32 staggerSpellId, SpellEffectValue staggerAmount) { // We only set the total stagger amount. The amount per tick will be set by the stagger spell script unit->CastSpell(unit, staggerSpellId, CastSpellExtraArgs(SPELLVALUE_BASE_POINT1, staggerAmount).SetTriggerFlags(TRIGGERED_FULL_MASK)); @@ -697,11 +697,11 @@ class spell_monk_stagger_damage_aura : public AuraScript // Update our light/medium/heavy stagger with the correct stagger amount left if (Aura* auraStagger = FindExistingStaggerEffect(GetTarget())) { - if (AuraEffect* auraEff = auraStagger->GetEffect(AuraStaggerEffectTotal)) + if (AuraEffect* totalEffect = auraStagger->GetEffect(AuraStaggerEffectTotal)) { - float total = float(auraEff->GetAmount()); - float tickDamage = float(aurEff->GetAmount()); - auraEff->ChangeAmount(total - tickDamage); + SpellEffectValue total = totalEffect->GetAmount(); + SpellEffectValue tickDamage = aurEff->GetAmount(); + totalEffect->ChangeAmount(total - tickDamage); } } } @@ -730,8 +730,8 @@ class spell_monk_stagger_debuff_aura : public AuraScript void OnReapply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) { // Calculate damage per tick - float total = float(aurEff->GetAmount()); - float perTick = total * _period / float(GetDuration()); // should be same as GetMaxDuration() TODO: verify + SpellEffectValue total = aurEff->GetAmount(); + SpellEffectValue perTick = total * _period / float(GetDuration()); // should be same as GetMaxDuration() TODO: verify // Set amount on effect for tooltip AuraEffect* effInfo = GetAura()->GetEffect(AuraStaggerEffectTick); @@ -760,7 +760,7 @@ class spell_monk_stagger_debuff_aura : public AuraScript private: float _period = 0.0f; - void CastOrChangeTickDamage(float tickDamage) + void CastOrChangeTickDamage(SpellEffectValue tickDamage) { Unit* unit = GetTarget(); Aura* auraDamage = unit->GetAura(SPELL_MONK_STAGGER_DAMAGE_AURA); diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index 07568cb557..58685b5081 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -179,7 +179,7 @@ class spell_pal_ardent_defender : public AuraScript { PreventDefaultAction(); - int32 targetHealthPercent = GetEffectInfo(EFFECT_1).CalcValue(GetTarget()); + SpellEffectValue targetHealthPercent = GetEffectInfo(EFFECT_1).CalcValue(GetTarget()); uint64 targetHealth = int32(GetTarget()->CountPctFromMaxHealth(targetHealthPercent)); if (GetTarget()->HealthBelowPct(targetHealthPercent)) { @@ -215,7 +215,7 @@ class spell_pal_art_of_war : public AuraScript bool CheckProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) { - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } void HandleProc(AuraEffect* /*aurEff*/, ProcEventInfo& /*eventInfo*/) @@ -297,14 +297,14 @@ class spell_pal_awakening : public AuraScript bool CheckProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) { - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } void HandleProc(AuraEffect* /*aurEff*/, ProcEventInfo& eventInfo) { Milliseconds extraDuration = 0ms; if (AuraEffect const* durationEffect = GetEffect(EFFECT_1)) - extraDuration = Seconds(durationEffect->GetAmount()); + extraDuration = duration_cast(FloatSeconds(durationEffect->GetAmount())); if (Aura* avengingWrath = GetTarget()->GetAura(SPELL_PALADIN_AVENGING_WRATH)) { @@ -479,7 +479,7 @@ class spell_pal_crusader_might : public AuraScript void HandleEffectProc(AuraEffect* aurEff, ProcEventInfo& /*eventInfo*/) { - GetTarget()->GetSpellHistory()->ModifyCooldown(SPELL_PALADIN_HOLY_SHOCK, Milliseconds(aurEff->GetAmount())); + GetTarget()->GetSpellHistory()->ModifyCooldown(SPELL_PALADIN_HOLY_SHOCK, Milliseconds(aurEff->GetAmountAsInt())); } void Register() override @@ -558,7 +558,7 @@ class spell_pal_divine_purpose : public AuraScript if (!procSpell->HasPowerTypeCost(POWER_HOLY_POWER)) return false; - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } void HandleProc(AuraEffect* /*aurEff*/, ProcEventInfo& eventInfo) @@ -779,7 +779,7 @@ class spell_pal_execution_sentence_aura : public AuraScript void AfterRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/) const { - int32 amount = aurEff->GetAmount(); + SpellEffectValue amount = aurEff->GetAmount(); if (!amount || GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE) return; @@ -827,7 +827,7 @@ class spell_pal_final_verdict : public SpellScript void HandleDummy(SpellEffIndex /*effIndex*/) const { - if (!roll_chance_i(GetEffectValue())) + if (!roll_chance_f(GetEffectValue())) return; Unit* caster = GetCaster(); @@ -1382,7 +1382,7 @@ class spell_pal_light_s_beacon : public AuraScript if (!healInfo || !healInfo->GetHeal()) return; - uint32 heal = CalculatePct(healInfo->GetHeal(), aurEff->GetAmount()); + SpellEffectValue heal = CalculatePct(healInfo->GetHeal(), aurEff->GetAmount()); Unit::AuraList const& auras = GetCaster()->GetSingleCastAuras(); for (Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) @@ -1489,7 +1489,7 @@ class spell_pal_righteous_protector : public AuraScript void HandleEffectProc(AuraEffect* aurEff, ProcEventInfo& /*eventInfo*/) { - int32 value = aurEff->GetAmount() * 100 * _baseHolyPowerCost->Amount; + int32 value = aurEff->GetAmountAsInt() * 100 * _baseHolyPowerCost->Amount; GetTarget()->GetSpellHistory()->ModifyCooldown(SPELL_PALADIN_AVENGING_WRATH, Milliseconds(-value)); GetTarget()->GetSpellHistory()->ModifyCooldown(SPELL_PALADIN_GUARDIAN_OF_ANCIENT_KINGS, Milliseconds(-value)); @@ -1567,7 +1567,7 @@ class spell_pal_shield_of_vengeance : public AuraScript return ValidateSpellInfo({ SPELL_PALADIN_SHIELD_OF_VENGEANCE_DAMAGE }) && ValidateSpellEffect({ { spellInfo->Id, EFFECT_1 } }); } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { amount = CalculatePct(GetUnitOwner()->GetMaxHealth(), GetEffectInfo(EFFECT_1).CalcValue()); if (Player const* player = GetUnitOwner()->ToPlayer()) @@ -1588,7 +1588,7 @@ class spell_pal_shield_of_vengeance : public AuraScript OnEffectRemove += AuraEffectApplyFn(spell_pal_shield_of_vengeance::HandleRemove, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB, AURA_EFFECT_HANDLE_REAL); } - int32 _initialAmount = 0; + SpellEffectValue _initialAmount = 0; }; // 469304 - Steed of Liberty @@ -1605,7 +1605,7 @@ class spell_pal_steed_of_liberty : public AuraScript target->CastSpell(target, SPELL_PALADIN_BLESSING_OF_FREEDOM, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringAura = aurEff, - .SpellValueOverrides = { { SPELLVALUE_DURATION, aurEff->GetAmount() } } + .SpellValueOverrides = { { SPELLVALUE_DURATION, aurEff->GetAmountAsInt() } } }); } @@ -1709,7 +1709,7 @@ class spell_pal_t8_2p_bonus : public AuraScript Unit* target = eventInfo.GetProcTarget(); SpellEffectInfo const& hotEffect = sSpellMgr->AssertSpellInfo(SPELL_PALADIN_HOLY_MENDING, GetCastDifficulty())->GetEffect(EFFECT_0); - int32 amount = CalculatePct(static_cast(healInfo->GetHeal()), aurEff->GetAmount()); + SpellEffectValue amount = CalculatePct(static_cast(healInfo->GetHeal()), aurEff->GetAmount()); amount /= hotEffect.GetPeriodicTickCount(); @@ -1739,7 +1739,7 @@ class spell_pal_t30_2p_protection_bonus : public AuraScript Unit* caster = procInfo.GetActor(); uint32 ticks = sSpellMgr->AssertSpellInfo(SPELL_PALADIN_T30_2P_HEARTFIRE_DAMAGE, DIFFICULTY_NONE)->GetEffect(EFFECT_0).GetPeriodicTickCount(); - uint32 damage = CalculatePct(procInfo.GetDamageInfo()->GetOriginalDamage(), aurEff->GetAmount()) / ticks; + SpellEffectValue damage = CalculatePct(procInfo.GetDamageInfo()->GetOriginalDamage(), aurEff->GetAmount()) / ticks; caster->CastSpell(procInfo.GetActionTarget(), SPELL_PALADIN_T30_2P_HEARTFIRE_DAMAGE, CastSpellExtraArgs(aurEff) .SetTriggeringSpell(procInfo.GetProcSpell()) @@ -1815,7 +1815,7 @@ class spell_pal_zeal : public AuraScript void HandleEffectProc(AuraEffect* aurEff, ProcEventInfo& /*procInfo*/) { Unit* target = GetTarget(); - target->CastSpell(target, SPELL_PALADIN_ZEAL_AURA, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_AURA_STACK, aurEff->GetAmount())); + target->CastSpell(target, SPELL_PALADIN_ZEAL_AURA, CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_AURA_STACK, aurEff->GetAmountAsInt())); PreventDefaultAction(); } diff --git a/src/server/scripts/Spells/spell_pet.cpp b/src/server/scripts/Spells/spell_pet.cpp index c7d5ebb7ff..179a070367 100644 --- a/src/server/scripts/Spells/spell_pet.cpp +++ b/src/server/scripts/Spells/spell_pet.cpp @@ -100,7 +100,7 @@ class spell_gen_pet_calculate : public SpellScriptLoader return true; } - void CalculateAmountCritSpell(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountCritSpell(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) { @@ -113,11 +113,11 @@ class spell_gen_pet_calculate : public SpellScriptLoader // Increase crit spell from spell crit ratings CritSpell += owner->GetRatingBonusValue(CR_CRIT_SPELL); - amount += int32(CritSpell); + amount += CritSpell; } } - void CalculateAmountCritMelee(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountCritMelee(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) { @@ -130,11 +130,11 @@ class spell_gen_pet_calculate : public SpellScriptLoader // Increase crit melee from melee crit ratings CritMelee += owner->GetRatingBonusValue(CR_CRIT_MELEE); - amount += int32(CritMelee); + amount += CritMelee; } } - void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) { @@ -145,11 +145,11 @@ class spell_gen_pet_calculate : public SpellScriptLoader // Increase hit melee from meele hit ratings HitMelee += owner->GetRatingBonusValue(CR_HIT_MELEE); - amount += int32(HitMelee); + amount += HitMelee; } } - void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) { @@ -160,11 +160,11 @@ class spell_gen_pet_calculate : public SpellScriptLoader // Increase hit spell from spell hit ratings HitSpell += owner->GetRatingBonusValue(CR_HIT_SPELL); - amount += int32(HitSpell); + amount += HitSpell; } } - void CalculateAmountExpertise(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountExpertise(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) { @@ -175,7 +175,7 @@ class spell_gen_pet_calculate : public SpellScriptLoader // Increase Expertise from Expertise ratings Expertise += owner->GetRatingBonusValue(CR_EXPERTISE); - amount += int32(Expertise); + amount += Expertise; } } @@ -235,7 +235,7 @@ public: return true; } - void CalculateStaminaAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateStaminaAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) if (pet->IsPet()) @@ -289,7 +289,7 @@ public: } } - void CalculateAttackPowerAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAttackPowerAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) if (pet->IsPet()) @@ -317,7 +317,7 @@ public: } } - void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) if (pet->IsPet()) @@ -376,7 +376,7 @@ public: return true; } - void CalculateIntellectAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateIntellectAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) if (pet->IsPet()) @@ -427,7 +427,7 @@ public: } } - void CalculateArmorAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateArmorAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) if (pet->IsPet()) @@ -438,7 +438,7 @@ public: } } - void CalculateFireResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateFireResistanceAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) if (pet->IsPet()) @@ -482,7 +482,7 @@ public: return true; } - void CalculateFrostResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateFrostResistanceAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) if (pet->IsPet()) @@ -493,7 +493,7 @@ public: } } - void CalculateArcaneResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateArcaneResistanceAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) if (pet->IsPet()) @@ -504,7 +504,7 @@ public: } } - void CalculateNatureResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateNatureResistanceAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) if (pet->IsPet()) @@ -543,7 +543,7 @@ public: return true; } - void CalculateShadowResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateShadowResistanceAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) if (pet->IsPet()) @@ -580,7 +580,7 @@ public: return true; } - void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) { @@ -591,11 +591,11 @@ public: // Increase hit spell from spell hit ratings HitMelee += owner->GetRatingBonusValue(CR_HIT_SPELL); - amount += int32(HitMelee); + amount += HitMelee; } } - void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) { @@ -606,11 +606,11 @@ public: // Increase hit spell from spell hit ratings HitSpell += owner->GetRatingBonusValue(CR_HIT_SPELL); - amount += int32(HitSpell); + amount += HitSpell; } } - void CalculateAmountExpertise(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountExpertise(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) { @@ -621,7 +621,7 @@ public: // Increase hit spell from spell hit ratings Expertise += owner->GetRatingBonusValue(CR_HIT_SPELL); - amount += int32(Expertise); + amount += Expertise; } } @@ -653,7 +653,7 @@ public: return true; } - void CalculateAmountCritSpell(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountCritSpell(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) { @@ -673,7 +673,7 @@ public: } } - void CalculateAmountCritMelee(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountCritMelee(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) { @@ -720,7 +720,7 @@ public: return true; } - void CalculateAmountDamageDone(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountDamageDone(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (!GetCaster() || !GetCaster()->GetOwner()) return; @@ -769,7 +769,7 @@ public: return true; } - void CalculateAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) if (pet->IsPet()) @@ -804,7 +804,7 @@ public: return true; } - void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) { @@ -815,11 +815,11 @@ public: // Increase hit melee from meele hit ratings HitMelee += owner->GetRatingBonusValue(CR_HIT_MELEE); - amount += int32(HitMelee); + amount += HitMelee; } } - void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Player* owner = GetCaster()->GetOwner()->ToPlayer()) { @@ -830,7 +830,7 @@ public: // Increase hit spell from spell hit ratings HitSpell += owner->GetRatingBonusValue(CR_HIT_SPELL); - amount += int32(HitSpell); + amount += HitSpell; } } @@ -861,7 +861,7 @@ public: } private: - void CalculateStaminaAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateStaminaAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) if (pet->IsPet()) @@ -897,7 +897,7 @@ public: _tempHealth = pet->GetHealth(); } - void CalculateAttackPowerAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAttackPowerAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) { @@ -927,7 +927,7 @@ public: } } - void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) { @@ -990,7 +990,7 @@ public: return true; } - void CalculateFrostResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateFrostResistanceAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) { @@ -1006,7 +1006,7 @@ public: } } - void CalculateFireResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateFireResistanceAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) { @@ -1022,7 +1022,7 @@ public: } } - void CalculateNatureResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateNatureResistanceAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) { @@ -1066,7 +1066,7 @@ public: return true; } - void CalculateShadowResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateShadowResistanceAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) { @@ -1082,7 +1082,7 @@ public: } } - void CalculateArcaneResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateArcaneResistanceAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) { @@ -1098,7 +1098,7 @@ public: } } - void CalculateArmorAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateArmorAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) { @@ -1142,7 +1142,7 @@ public: return true; } - void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (!GetCaster() || !GetCaster()->GetOwner()) return; @@ -1155,11 +1155,11 @@ public: // Increase hit melee from meele hit ratings HitMelee += owner->GetRatingBonusValue(CR_HIT_MELEE); - amount += int32(HitMelee); + amount += HitMelee; } } - void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (!GetCaster() || !GetCaster()->GetOwner()) return; @@ -1172,11 +1172,11 @@ public: // Increase hit spell from spell hit ratings HitSpell += owner->GetRatingBonusValue(CR_HIT_SPELL); - amount += int32(HitSpell); + amount += HitSpell; } } - void CalculateAmountExpertise(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountExpertise(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (!GetCaster() || !GetCaster()->GetOwner()) return; @@ -1189,7 +1189,7 @@ public: // Increase Expertise from Expertise ratings Expertise += owner->GetRatingBonusValue(CR_EXPERTISE); - amount += int32(Expertise); + amount += Expertise; } } @@ -1221,7 +1221,7 @@ public: return true; } - void CalculateAmountCritSpell(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountCritSpell(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (!GetCaster() || !GetCaster()->GetOwner()) return; @@ -1240,7 +1240,7 @@ public: } } - void CalculateAmountCritMelee(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountCritMelee(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (!GetCaster() || !GetCaster()->GetOwner()) return; @@ -1286,7 +1286,7 @@ public: return true; } - void CalculateAmountDamageDone(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountDamageDone(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (!GetCaster() || !GetCaster()->GetOwner()) return; @@ -1324,7 +1324,7 @@ public: return true; } - void CalculateAmountDamageDone(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountDamageDone(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (!GetCaster() || !GetCaster()->GetOwner()) return; @@ -1363,7 +1363,7 @@ public: return true; } - void CalculateAvoidanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAvoidanceAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) { @@ -1405,7 +1405,7 @@ public: return true; } - void CalculateStaminaAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateStaminaAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) { @@ -1433,7 +1433,7 @@ public: _tempHealth = pet->GetHealth(); } - void CalculateStrengthAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateStrengthAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) { @@ -1480,7 +1480,7 @@ public: return true; } - void CalculateAmountMeleeHaste(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountMeleeHaste(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (!GetCaster() || !GetCaster()->GetOwner()) return; @@ -1491,7 +1491,7 @@ public: // Increase hit from SPELL_AURA_MOD_HIT_CHANCE HasteMelee += (1-owner->m_modAttackSpeedPct[BASE_ATTACK])*100; - amount += int32(HasteMelee); + amount += HasteMelee; } } @@ -1521,7 +1521,7 @@ public: return true; } - void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (!GetCaster() || !GetCaster()->GetOwner()) return; @@ -1534,11 +1534,11 @@ public: // Increase hit melee from meele hit ratings HitMelee += owner->GetRatingBonusValue(CR_HIT_MELEE); - amount += int32(HitMelee); + amount += HitMelee; } } - void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (!GetCaster() || !GetCaster()->GetOwner()) return; @@ -1551,7 +1551,7 @@ public: // Increase hit spell from spell hit ratings HitSpell += owner->GetRatingBonusValue(CR_HIT_SPELL); - amount += int32(HitSpell); + amount += HitSpell; } } @@ -1582,7 +1582,7 @@ public: return true; } - void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (Unit* pet = GetUnitOwner()) { @@ -1597,7 +1597,7 @@ public: } } - void CalculateAmountMeleeHaste(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/) + void CalculateAmountMeleeHaste(AuraEffect const* /* aurEff */, SpellEffectValue& amount, bool& /*canBeRecalculated*/) { if (!GetCaster() || !GetCaster()->GetOwner()) return; @@ -1608,7 +1608,7 @@ public: // Increase hit from SPELL_AURA_MOD_HIT_CHANCE HasteMelee += (1-owner->m_modAttackSpeedPct[BASE_ATTACK])*100; - amount += int32(HasteMelee); + amount += HasteMelee; } } diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index 36731e11a4..2ee0f40046 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -353,7 +353,7 @@ class spell_pri_angelic_bulwark : public AuraScript if (!caster) return; - int32 absorb = caster->CountPctFromMaxHealth(GetEffect(EFFECT_1)->GetAmount()); + SpellEffectValue absorb = caster->CountPctFromMaxHealth(GetEffect(EFFECT_1)->GetAmount()); caster->CastSpell(caster, SPELL_PRIEST_ANGELIC_BULWARK_BUFF, CastSpellExtraArgsInit { @@ -447,7 +447,7 @@ class spell_pri_answered_prayers : public AuraScript { Milliseconds extraDuration = 0ms; if (AuraEffect const* durationEffect = GetEffect(EFFECT_1)) - extraDuration = Seconds(durationEffect->GetAmount()); + extraDuration = duration_cast(FloatSeconds(durationEffect->GetAmount())); Unit* target = eventInfo.GetActor(); @@ -462,7 +462,7 @@ class spell_pri_answered_prayers : public AuraScript answeredPrayers->ModStackAmount(1); // Note: if current stacks match max. stacks, trigger Apotheosis. - if (answeredPrayers->GetStackAmount() != aurEff->GetAmount()) + if (answeredPrayers->GetStackAmount() != aurEff->GetAmountAsInt()) return; answeredPrayers->Remove(); @@ -630,11 +630,11 @@ public: void UpdateSinsOfTheManyValue() const { // Note: the damage dimish starts at the 6th application as of 10.0.5. - constexpr std::array damageByStack = { 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 17.5f, 15.0f, 12.5f, 10.0f, 7.5f, 5.5f, 4.0f, 2.5f, 2.0f, 1.5f, 1.25f, 1.0f, 0.75f, 0.63f, 0.5f }; + static constexpr std::array DamageByStack = { 20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 17.5f, 15.0f, 12.5f, 10.0f, 7.5f, 5.5f, 4.0f, 2.5f, 2.0f, 1.5f, 1.25f, 1.0f, 0.75f, 0.63f, 0.5f }; for (SpellEffIndex effectIndex : { EFFECT_0, EFFECT_1, EFFECT_2 }) if (AuraEffect* sinOfTheMany = GetUnitOwner()->GetAuraEffect(SPELL_PRIEST_SINS_OF_THE_MANY, effectIndex)) - sinOfTheMany->ChangeAmount(damageByStack[std::min(_appliedAtonements.size(), damageByStack.size() - 1)]); + sinOfTheMany->ChangeAmount(DamageByStack[std::min(_appliedAtonements.size(), DamageByStack.size() - 1)]); } void UpdateTrinityEffect() const @@ -714,7 +714,7 @@ class spell_pri_atonement_effect : public SpellScript case SPELL_PRIEST_POWER_WORD_SHIELD: if (AuraEffect const* indemnity = caster->GetAuraEffect(SPELL_PRIEST_INDEMNITY, EFFECT_0)) args.AddSpellMod(SPELLVALUE_DURATION, - (Seconds(indemnity->GetAmount()) + (FloatSeconds(indemnity->GetAmount()) + Milliseconds(Aura::CalcMaxDuration(sSpellMgr->AssertSpellInfo(_effectSpellId, GetCastDifficulty()), caster, &GetSpell()->GetPowerCost()))).count()); break; @@ -838,7 +838,7 @@ class spell_pri_benediction : public SpellScript void HandleEffectHitTarget(SpellEffIndex /*effIndex*/) const { if (AuraEffect const* benediction = GetCaster()->GetAuraEffect(SPELL_PRIEST_BENEDICTION, EFFECT_0)) - if (roll_chance_i(benediction->GetAmount())) + if (roll_chance_f(benediction->GetAmount())) GetCaster()->CastSpell(GetHitUnit(), SPELL_PRIEST_RENEW, TRIGGERED_IGNORE_GCD | TRIGGERED_IGNORE_CAST_IN_PROGRESS); } @@ -869,7 +869,7 @@ class spell_pri_binding_heals : public AuraScript .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringSpell = eventInfo.GetProcSpell(), .TriggeringAura = aurEff, - .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, int32(CalculatePct(eventInfo.GetHealInfo()->GetHeal(), aurEff->GetAmount())) } } + .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, SpellEffectValue(CalculatePct(eventInfo.GetHealInfo()->GetHeal(), aurEff->GetAmount())) } } }); } @@ -924,7 +924,7 @@ class spell_pri_burning_vehemence : public AuraScript .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringSpell = eventInfo.GetProcSpell(), .TriggeringAura = aurEff, - .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, int32(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount())) } } + .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, SpellEffectValue(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount())) } } }); } @@ -945,7 +945,7 @@ class spell_pri_circle_of_healing : public SpellScript void FilterTargets(std::list& targets) const { // Note: we must remove one since target is always chosen. - uint32 const maxTargets = uint32(GetSpellInfo()->GetEffect(EFFECT_1).CalcValue(GetCaster()) - 1); + uint32 const maxTargets = uint32(GetSpellInfo()->GetEffect(EFFECT_1).CalcValueAsInt(GetCaster()) - 1); Trinity::SelectRandomInjuredTargets(targets, maxTargets, true); @@ -1024,7 +1024,7 @@ class spell_pri_dark_indulgence : public SpellScript if (!aurEff) return; - if (roll_chance_i(aurEff->GetAmount())) + if (roll_chance_f(aurEff->GetAmount())) GetCaster()->CastSpell(GetCaster(), SPELL_PRIEST_POWER_OF_THE_DARK_SIDE, true); } @@ -1040,7 +1040,7 @@ class spell_pri_deaths_torment : public AuraScript public: struct Data { - int32 DamagePct = 0; + SpellEffectValue DamagePct = 0; int32 BacklashPct = 10; // for some weird reason its 10% for backlash, not 15% int32 EnergizePct = 25; // for some weird reason its 25% for energize, not 15% }; @@ -1061,8 +1061,8 @@ public: Unit* caster = eventInfo.GetActor(); Unit* target = eventInfo.GetActionTarget(); - int32 maxHits = GetEffect(EFFECT_0)->GetAmount(); - int32 effectiveness = GetEffect(EFFECT_1)->GetAmount(); + int32 maxHits = GetEffect(EFFECT_0)->GetAmountAsInt(); + SpellEffectValue effectiveness = GetEffect(EFFECT_1)->GetAmount(); for (int32 i = 1; i <= maxHits; ++i) { @@ -1108,8 +1108,8 @@ class spell_pri_dispersing_light : public AuraScript .TriggeringAura = aurEff, .SpellValueOverrides = { - { SPELLVALUE_BASE_POINT0, int32(CalculatePct(healInfo->GetHeal(), aurEff->GetAmount())) }, - { SPELLVALUE_MAX_TARGETS, GetEffectInfo(EFFECT_1).CalcValue(caster) } + { SPELLVALUE_BASE_POINT0, SpellEffectValue(CalculatePct(healInfo->GetHeal(), aurEff->GetAmount())) }, + { SPELLVALUE_MAX_TARGETS, GetEffectInfo(EFFECT_1).CalcValueAsInt(caster) } }, .CustomArg = TriggerArgs{ .TargetToExclude = target->GetGUID() } }); @@ -1357,7 +1357,7 @@ class spell_pri_divine_service : public SpellScript { if (AuraEffect const* divineServiceEffect = GetCaster()->GetAuraEffect(SPELL_PRIEST_DIVINE_SERVICE, EFFECT_0)) if (Aura const* prayerOfMending = victim->GetAura(SPELL_PRIEST_PRAYER_OF_MENDING_AURA, GetCaster()->GetGUID())) - AddPct(pctMod, int32(divineServiceEffect->GetAmount() * prayerOfMending->GetStackAmount())); + AddPct(pctMod, divineServiceEffect->GetAmount() * prayerOfMending->GetStackAmount()); } void Register() override @@ -1531,7 +1531,7 @@ class spell_pri_divine_word : public AuraScript .TriggeringSpell = procInfo.GetProcSpell() }); spell_pri_holy_words_base::ModifyCooldown(caster, procInfo.GetSpellInfo(), - Seconds(-GetSpellInfo()->GetEffect(EFFECT_1).CalcValue(caster))); + Seconds(-GetSpellInfo()->GetEffect(EFFECT_1).CalcValueAsInt(caster))); break; case SPELL_PRIEST_HOLY_WORD_SANCTIFY: GetCaster()->CastSpell(*procInfo.GetProcSpell()->m_targets.GetDst(), SPELL_PRIEST_DIVINE_WORD_SANCTUARY_AREATRIGGER, CastSpellExtraArgsInit{ @@ -1587,7 +1587,7 @@ class spell_pri_divine_word_sanctuary_heal : public SpellScript void FilterTargets(std::list& targets) const { - int32 maxTargets = GetEffectInfo(EFFECT_1).CalcValue(GetCaster()); + int32 maxTargets = GetEffectInfo(EFFECT_1).CalcValueAsInt(GetCaster()); Trinity::SelectRandomInjuredTargets(targets, maxTargets, true); } @@ -1643,7 +1643,7 @@ class spell_pri_empowered_renew : public AuraScript void HandleProc(AuraEffect const* aurEff, ProcEventInfo const& eventInfo) const { spell_pri_holy_words_base::ModifyCooldown(eventInfo.GetActor(), sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_SANCTIFY, GetCastDifficulty()), - Milliseconds(-aurEff->GetAmount())); + Milliseconds(-aurEff->GetAmountAsInt())); } void Register() override @@ -1691,7 +1691,7 @@ class spell_pri_empyreal_blaze : public AuraScript .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringSpell = eventInfo.GetProcSpell(), .TriggeringAura = aurEff, - .SpellValueOverrides = { { SPELLVALUE_AURA_STACK, aurEff->GetAmount() } } + .SpellValueOverrides = { { SPELLVALUE_AURA_STACK, aurEff->GetAmountAsInt() } } }); } @@ -1933,7 +1933,7 @@ class spell_pri_epiphany : public AuraScript static bool CheckProc(AuraScript const&, AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) { - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } void HandleOnProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) const @@ -1983,7 +1983,7 @@ class spell_pri_eternal_sanctity : public AuraScript static void HandleEffectProc(AuraScript const&, AuraEffect const* aurEff, ProcEventInfo const& eventInfo) { if (Aura* apotheosisAura = eventInfo.GetActor()->GetAura(SPELL_PRIEST_APOTHEOSIS)) - apotheosisAura->SetDuration(apotheosisAura->GetDuration() + aurEff->GetAmount()); + apotheosisAura->SetDuration(apotheosisAura->GetDuration() + aurEff->GetAmountAsInt()); } void Register() override @@ -1999,7 +1999,7 @@ class spell_pri_evangelism : public SpellScript public: struct TriggerArgs { - int32 EffectivenessPct = 100; + SpellEffectValue EffectivenessPct = 100.0; }; bool Validate(SpellInfo const* /*spellInfo*/) override @@ -2009,7 +2009,7 @@ public: void HandleCast() const { - GetSpell()->SetSpellValue({ SPELLVALUE_AURA_STACK, GetEffectInfo(EFFECT_0).CalcValue(GetCaster()) }); + GetSpell()->SetSpellValue({ SPELLVALUE_AURA_STACK, GetEffectInfo(EFFECT_0).CalcValueAsInt(GetCaster()) }); } void HandleDummy(SpellEffIndex /*effIndex*/) const @@ -2065,13 +2065,13 @@ class spell_pri_expiation : public SpellScript Aura* swPainAura = swPainAuraEffect->GetBase(); int32 debuffDuration = swPainAura->GetDuration(); - int32 consumeDuration = std::min(debuffDuration, expiationConsume->GetAmount() * IN_MILLISECONDS); + int32 consumeDuration = std::min(debuffDuration, expiationConsume->GetAmountAsInt() * IN_MILLISECONDS); if (consumeDuration == 0) return; float ticksConsumed = static_cast(consumeDuration) / swPainAuraEffect->GetPeriod(); - float damagePerTick = swPainAuraEffect->CalculateEstimatedAmount(caster, swPainAuraEffect->GetAmount()).value_or(swPainAuraEffect->GetAmount()); - int32 totalDamage = static_cast(damagePerTick * ticksConsumed); + SpellEffectValue damagePerTick = swPainAuraEffect->CalculateEstimatedAmount(caster, swPainAuraEffect->GetAmount()).value_or(swPainAuraEffect->GetAmount()); + SpellEffectValue totalDamage = static_cast(damagePerTick * ticksConsumed); swPainAura->SetDuration(debuffDuration - consumeDuration); @@ -2130,7 +2130,7 @@ class spell_pri_from_darkness_comes_light : public AuraScript // 47788 - Guardian Spirit class spell_pri_guardian_spirit : public AuraScript { - uint32 healPct = 0; + SpellEffectValue healPct = 0.0; bool Validate(SpellInfo const* spellInfo) override { @@ -2143,7 +2143,7 @@ class spell_pri_guardian_spirit : public AuraScript return true; } - static void CalculateAmount(AuraScript const&, AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/) + static void CalculateAmount(AuraScript const&, AuraEffect const* /*aurEff*/, SpellEffectValue & amount, bool & /*canBeRecalculated*/) { // Set absorbtion amount to unlimited amount = -1; @@ -2155,7 +2155,7 @@ class spell_pri_guardian_spirit : public AuraScript if (dmgInfo.GetDamage() < target->GetHealth()) return; - int32 healAmount = int32(target->CountPctFromMaxHealth(healPct)); + SpellEffectValue healAmount = SpellEffectValue(target->CountPctFromMaxHealth(healPct)); // remove the aura now, we don't want 40% healing bonus Remove(AURA_REMOVE_BY_ENEMY_SPELL); CastSpellExtraArgs args(TRIGGERED_FULL_MASK); @@ -2190,7 +2190,7 @@ class spell_pri_harsh_discipline : public SpellScript { Unit* caster = GetCaster(); SpellInfo const* penanceChannel = sSpellMgr->AssertSpellInfo(SPELL_PRIEST_PENANCE_CHANNEL_DAMAGE, GetCastDifficulty()); - int32 additionalBolts = sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HARSH_DISCIPLINE, GetCastDifficulty())->GetEffect(EFFECT_1).CalcValue(caster); + SpellEffectValue additionalBolts = sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HARSH_DISCIPLINE, GetCastDifficulty())->GetEffect(EFFECT_1).CalcValue(caster); // do the calc here float channelDuration = penanceChannel->GetDuration(); @@ -2200,16 +2200,16 @@ class spell_pri_harsh_discipline : public SpellScript if (caster->HasAura(SPELL_PRIEST_CASTIGATION)) baseBolts += 1.0f; - float basePeriod = channelDuration / baseBolts; + SpellEffectValue basePeriod = channelDuration / baseBolts; - float totalBolts = baseBolts + additionalBolts; - float newPeriod = channelDuration / totalBolts; - float pctDiff = GetPctOf(newPeriod - basePeriod, basePeriod); + SpellEffectValue totalBolts = baseBolts + additionalBolts; + SpellEffectValue newPeriod = channelDuration / totalBolts; + SpellEffectValue pctDiff = GetPctOf(newPeriod - basePeriod, basePeriod); caster->CastSpell(caster, SPELL_PRIEST_HARSH_DISCIPLINE_AURA, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .SpellValueOverrides = { - { SPELLVALUE_BASE_POINT0, static_cast(std::floor(pctDiff)) }, + { SPELLVALUE_BASE_POINT0, std::floor(pctDiff) }, { SPELLVALUE_BASE_POINT1, additionalBolts } } }); @@ -2240,8 +2240,8 @@ class spell_pri_heavens_wrath : public AuraScript if (!caster) return; - int32 cdReduction = aurEff->GetAmount(); - caster->GetSpellHistory()->ModifyCooldown(SPELL_PRIEST_ULTIMATE_PENITENCE, Seconds(-cdReduction), true); + SpellHistory::Duration cdReduction = -duration_cast(FloatSeconds(aurEff->GetAmount())); + caster->GetSpellHistory()->ModifyCooldown(SPELL_PRIEST_ULTIMATE_PENITENCE, cdReduction, true); } void Register() override @@ -2447,7 +2447,7 @@ class spell_pri_holy_words : public AuraScript case SPELL_PRIEST_FLASH_HEAL: // reduce Holy Word: Serenity cd by 6 seconds targetSpellId = SPELL_PRIEST_HOLY_WORD_SERENITY; cdReductionEffIndex = EFFECT_1; - // cdReduction = sSpellMgr->GetSpellInfo(SPELL_PRIEST_HOLY_WORD_SERENITY, GetCastDifficulty())->GetEffect(EFFECT_1)->CalcValue(player); + // cdReduction = sSpellMgr->GetSpellInfo(SPELL_PRIEST_HOLY_WORD_SERENITY, GetCastDifficulty())->GetEffect(EFFECT_1)->CalcValueAsInt(player); break; case SPELL_PRIEST_PRAYER_OF_HEALING: // reduce Holy Word: Sanctify cd by 6 seconds targetSpellId = SPELL_PRIEST_HOLY_WORD_SANCTIFY; @@ -2467,7 +2467,7 @@ class spell_pri_holy_words : public AuraScript } SpellInfo const* targetSpellInfo = sSpellMgr->AssertSpellInfo(targetSpellId, GetCastDifficulty()); - int32 cdReduction = targetSpellInfo->GetEffect(cdReductionEffIndex).CalcValue(GetTarget()); + int32 cdReduction = targetSpellInfo->GetEffect(cdReductionEffIndex).CalcValueAsInt(GetTarget()); spell_pri_holy_words_base::ModifyCooldown(GetTarget(), targetSpellInfo, Seconds(-cdReduction)); } @@ -2538,9 +2538,9 @@ class spell_pri_holy_word_salvation : public SpellScript args.TriggerFlags = TRIGGERED_FULL_MASK; // amount of Prayer of Mending is SPELL_PRIEST_HOLY_WORD_SALVATION's EFFECT_1. - args.AddSpellMod(SPELLVALUE_AURA_STACK, GetEffectValue()); + args.AddSpellMod(SPELLVALUE_AURA_STACK, GetEffectValueAsInt()); - int32 basePoints = caster->SpellHealingBonusDone(target, _spellInfoHeal, _healEffectDummy->CalcValue(caster), HEAL, *_healEffectDummy); + int32 basePoints = caster->SpellHealingBonusDone(target, _spellInfoHeal, _healEffectDummy->CalcValueAsInt(caster), HEAL, *_healEffectDummy); args.AddSpellMod(SPELLVALUE_BASE_POINT0, basePoints); caster->CastSpell(target, SPELL_PRIEST_PRAYER_OF_MENDING_AURA, args); @@ -2575,7 +2575,7 @@ class spell_pri_holy_word_salvation_cooldown_reduction : public SpellScript void ReduceCooldown() const { // cooldown reduced by SPELL_PRIEST_HOLY_WORD_SALVATION's Seconds(EFFECT_2). - int32 cooldownReduction = sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_SALVATION, GetCastDifficulty())->GetEffect(EFFECT_2).CalcValue(GetCaster()); + int32 cooldownReduction = sSpellMgr->AssertSpellInfo(SPELL_PRIEST_HOLY_WORD_SALVATION, GetCastDifficulty())->GetEffect(EFFECT_2).CalcValueAsInt(GetCaster()); GetCaster()->GetSpellHistory()->ModifyCooldown(SPELL_PRIEST_HOLY_WORD_SALVATION, Seconds(-cooldownReduction), true); } @@ -2622,7 +2622,7 @@ class spell_pri_inescapable_torment : public SpellScript .TriggeringSpell = GetSpell() }); - int32 durationExtend = sSpellMgr->AssertSpellInfo(SPELL_PRIEST_INESCAPABLE_TORMENT, DIFFICULTY_NONE)->GetEffect(EFFECT_1).CalcValue(caster); + int32 durationExtend = sSpellMgr->AssertSpellInfo(SPELL_PRIEST_INESCAPABLE_TORMENT, DIFFICULTY_NONE)->GetEffect(EFFECT_1).CalcValueAsInt(caster); summon->ModifyTimer(Milliseconds(durationExtend)); } @@ -2718,7 +2718,7 @@ class spell_pri_lasting_words : public SpellScript caster->CastSpell(GetHitUnit(), SPELL_PRIEST_RENEW, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_GCD | TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD | TRIGGERED_IGNORE_POWER_COST | TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringSpell = GetSpell(), - .SpellValueOverrides = { { SPELLVALUE_DURATION, lastingWordsEff->GetAmount() } } + .SpellValueOverrides = { { SPELLVALUE_DURATION, lastingWordsEff->GetAmountAsInt() } } }); } @@ -2748,7 +2748,7 @@ class spell_pri_leap_of_faith_effect_trigger : public SpellScript SpellCastTargets targets; targets.SetDst(destPos); targets.SetUnitTarget(GetCaster()); - GetHitUnit()->CastSpell(std::move(targets), GetEffectValue(), GetCastDifficulty()); + GetHitUnit()->CastSpell(std::move(targets), GetEffectValueAsInt(), GetCastDifficulty()); } void Register() override @@ -2836,7 +2836,7 @@ class spell_pri_mental_decay : public AuraScript return; Unit* target = eventInfo.GetActionTarget(); - int32 durationExtend = aurEff->GetAmount() * IN_MILLISECONDS; + int32 durationExtend = aurEff->GetAmount() * int32(IN_MILLISECONDS); if (Aura* shadowWordPain = target->GetOwnedAura(SPELL_PRIEST_SHADOW_WORD_PAIN, caster->GetGUID())) { @@ -2896,7 +2896,7 @@ class spell_pri_mind_devourer : public SpellScript void HandleEffectHitTarget(SpellEffIndex /*effIndex*/) const { AuraEffect const* aurEff = GetCaster()->GetAuraEffect(SPELL_PRIEST_MIND_DEVOURER, EFFECT_0); - if (aurEff && roll_chance_i(aurEff->GetAmount())) + if (aurEff && roll_chance_f(aurEff->GetAmount())) GetCaster()->CastSpell(GetCaster(), SPELL_PRIEST_MIND_DEVOURER_AURA, GetSpell()); } @@ -2921,7 +2921,7 @@ class spell_pri_mind_devourer_buff_aura : public AuraScript } public: - float DamageIncrease = 0.0f; + SpellEffectValue DamageIncrease = 0.0; }; class spell_pri_mind_devourer_buff : public SpellScript @@ -2963,7 +2963,7 @@ class spell_pri_mind_devourer_buff : public SpellScript OnEffectHitTarget += SpellEffectFn(spell_pri_mind_devourer_buff::ModifyAuraValueAndRemoveBuff, EFFECT_1, SPELL_EFFECT_APPLY_AURA); } - float _damageIncrease = 0.0f; + SpellEffectValue _damageIncrease = 0.0; }; // 390686 - Painful Punishment @@ -2985,7 +2985,7 @@ class spell_pri_painful_punishment : public AuraScript if (!caster || !target) return; - int32 additionalDuration = aurEff->GetAmount(); + int32 additionalDuration = aurEff->GetAmountAsInt(); if (Aura* shadowWordPain = target->GetOwnedAura(SPELL_PRIEST_SHADOW_WORD_PAIN, caster->GetGUID())) shadowWordPain->SetDuration(shadowWordPain->GetDuration() + additionalDuration); @@ -3360,7 +3360,7 @@ class spell_pri_power_word_radiance : public SpellScript Unit* explTarget = GetExplTargetUnit(); // we must add one since explicit target is always chosen. - uint32 maxTargets = GetEffectInfo(EFFECT_2).CalcValue(caster) + 1; + uint32 maxTargets = GetEffectInfo(EFFECT_2).CalcValueAsInt(caster) + 1; Trinity::SortTargetsWithPriorityRules(targets, maxTargets, GetRadianceRules(caster, explTarget)); @@ -3507,7 +3507,7 @@ class spell_pri_divine_aegis : public AuraScript if (!caster) return; - int32 aegisAmount = CalculatePct(eventInfo.GetHealInfo()->GetHeal(), aurEff->GetAmount()); + SpellEffectValue aegisAmount = CalculatePct(eventInfo.GetHealInfo()->GetHeal(), aurEff->GetAmount()); CastSpellExtraArgs args(aurEff); args.SetTriggerFlags(TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR); @@ -3566,7 +3566,7 @@ class spell_pri_divine_procession : public AuraScript { if (atonement->GetDuration() < 30 * IN_MILLISECONDS) { - int32 newDuration = atonement->GetDuration() + aurEff->GetAmount(); + int32 newDuration = atonement->GetDuration() + aurEff->GetAmountAsInt(); atonement->SetDuration(newDuration); atonement->SetMaxDuration(newDuration); } @@ -3592,7 +3592,7 @@ class spell_pri_power_word_solace : public SpellScript { GetCaster()->CastSpell(GetCaster(), SPELL_PRIEST_POWER_WORD_SOLACE_ENERGIZE, CastSpellExtraArgs(TRIGGERED_IGNORE_CAST_IN_PROGRESS).SetTriggeringSpell(GetSpell()) - .AddSpellMod(SPELLVALUE_BASE_POINT0, GetEffectValue() / 100)); + .AddSpellMod(SPELLVALUE_BASE_POINT0, GetEffectValue() / 100.0)); } void Register() override @@ -3617,7 +3617,7 @@ public: return true; } - void CastPrayerOfMendingAura(Unit* caster, Unit* target, Unit* visualSender, uint8 stack, bool firstCast) const + void CastPrayerOfMendingAura(Unit* caster, Unit* target, Unit* visualSender, int32 stack, bool firstCast) const { CastSpellExtraArgs args; args.TriggerFlags = TRIGGERED_FULL_MASK; @@ -3625,7 +3625,7 @@ public: // Note: this line's purpose is to show the correct amount in Points field in SMSG_AURA_UPDATE. SpellEffectInfo const* healEffectDummy = &_spellInfoHeal->GetEffect(EFFECT_0); - uint32 basePoints = caster->SpellHealingBonusDone(target, _spellInfoHeal, healEffectDummy->CalcValue(caster), HEAL, *healEffectDummy); + uint32 basePoints = caster->SpellHealingBonusDone(target, _spellInfoHeal, healEffectDummy->CalcValueAsInt(caster), HEAL, *healEffectDummy); args.AddSpellMod(SPELLVALUE_BASE_POINT0, basePoints); // Note: Focused Mending talent. @@ -3660,7 +3660,7 @@ class spell_pri_prayer_of_mending_dummy : public spell_pri_prayer_of_mending_Spe Unit* target = GetHitUnit(); // Note: we need to increase BasePoints by 1 since it's 4 as default. Also HACKFIX, we shouldn't reduce it by 1 if the target has the aura already. - uint8 stackAmount = target->HasAura(SPELL_PRIEST_PRAYER_OF_MENDING_AURA, caster->GetGUID()) ? GetEffectValue() : GetEffectValue() + 1; + uint8 stackAmount = target->HasAura(SPELL_PRIEST_PRAYER_OF_MENDING_AURA, caster->GetGUID()) ? GetEffectValueAsInt() : GetEffectValueAsInt() + 1; CastPrayerOfMendingAura(caster, target, caster, stackAmount, true); @@ -3704,7 +3704,7 @@ class spell_pri_prayer_of_mending_aura : public AuraScript int32 newStackAmount = stackAmount - 1; if (AuraEffect* sayYourPrayers = caster->GetAuraEffect(SPELL_PRIEST_SAY_YOUR_PRAYERS, EFFECT_0)) - if (roll_chance_i(sayYourPrayers->GetAmount())) + if (roll_chance_f(sayYourPrayers->GetAmount())) ++newStackAmount; args.AddSpellMod(SPELLVALUE_BASE_POINT0, newStackAmount); @@ -3764,7 +3764,7 @@ class spell_pri_prayer_of_mending_jump : public spell_pri_prayer_of_mending_Spel void HandleJump(SpellEffIndex /*effIndex*/) const { if (Unit* origCaster = GetOriginalCaster()) - CastPrayerOfMendingAura(origCaster, GetHitUnit(), GetCaster(), GetEffectValue(), false); + CastPrayerOfMendingAura(origCaster, GetHitUnit(), GetCaster(), GetEffectValueAsInt(), false); } void Register() override @@ -3831,7 +3831,7 @@ class spell_pri_holy_10_1_class_set_2pc : public AuraScript static bool CheckProc(AuraScript const&, AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) { - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } void HandleProc(AuraEffect const* aurEff, ProcEventInfo const& eventInfo) const @@ -3869,7 +3869,7 @@ class spell_pri_holy_10_1_class_set_2pc_chooser : public spell_pri_prayer_of_men Unit* target = GetHitUnit(); // Note: we need to increase BasePoints by 1 since it's 4 as default. Also HACKFIX, we shouldn't reduce it by 1 if the target has the aura already. - uint8 stackAmount = target->HasAura(SPELL_PRIEST_PRAYER_OF_MENDING_AURA, caster->GetGUID()) ? GetEffectValue() : GetEffectValue() + 1; + uint8 stackAmount = target->HasAura(SPELL_PRIEST_PRAYER_OF_MENDING_AURA, caster->GetGUID()) ? GetEffectValueAsInt() : GetEffectValueAsInt() + 1; CastPrayerOfMendingAura(caster, target, caster, stackAmount, true); } @@ -3942,7 +3942,7 @@ class spell_pri_assured_safety : public spell_pri_prayer_of_mending_SpellScriptB { Unit* caster = GetCaster(); if (AuraEffect const* effect = caster->GetAuraEffect(SPELL_PRIEST_ASSURED_SAFETY, EFFECT_0)) - CastPrayerOfMendingAura(caster, GetHitUnit(), caster, effect->GetAmount(), false); + CastPrayerOfMendingAura(caster, GetHitUnit(), caster, effect->GetAmountAsInt(), false); } void Register() override @@ -3963,7 +3963,7 @@ class spell_pri_protector_of_the_frail : public SpellScript { Unit* caster = GetCaster(); - int32 cdReduction = sSpellMgr->AssertSpellInfo(SPELL_PRIEST_PROTECTOR_OF_THE_FRAIL, GetCastDifficulty())->GetEffect(EFFECT_1).CalcValue(caster); + int32 cdReduction = sSpellMgr->AssertSpellInfo(SPELL_PRIEST_PROTECTOR_OF_THE_FRAIL, GetCastDifficulty())->GetEffect(EFFECT_1).CalcValueAsInt(caster); caster->GetSpellHistory()->ModifyCooldown(SPELL_PRIEST_PAIN_SUPPRESSION, Milliseconds(cdReduction)); } @@ -4051,7 +4051,7 @@ class spell_pri_purge_the_wicked_dummy : public SpellScript // Note: Revel in Purity talent. if (caster->HasAura(SPELL_PRIEST_REVEL_IN_PURITY)) - spreadCount += sSpellMgr->AssertSpellInfo(SPELL_PRIEST_REVEL_IN_PURITY, DIFFICULTY_NONE)->GetEffect(EFFECT_1).CalcValue(GetCaster()); + spreadCount += sSpellMgr->AssertSpellInfo(SPELL_PRIEST_REVEL_IN_PURITY, DIFFICULTY_NONE)->GetEffect(EFFECT_1).CalcValueAsInt(GetCaster()); if (targets.size() > spreadCount) targets.resize(spreadCount); @@ -4194,10 +4194,10 @@ class spell_pri_sanctuary_absorb : public AuraScript if (!amountHolderEffect) return; - if (dmgInfo.GetDamage() >= uint32(amountHolderEffect->GetAmount())) + if (dmgInfo.GetDamage() >= uint32(amountHolderEffect->GetAmountAsInt())) { amountHolderEffect->GetBase()->Remove(AURA_REMOVE_BY_ENEMY_SPELL); - dmgInfo.AbsorbDamage(amountHolderEffect->GetAmount()); + dmgInfo.AbsorbDamage(amountHolderEffect->GetAmountAsInt()); } else { @@ -4222,7 +4222,7 @@ class spell_pri_searing_light : public AuraScript void HandleEffectProc(AuraEffect const* aurEff, ProcEventInfo const& eventInfo) const { - int32 dotDmg = CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount()); + SpellEffectValue dotDmg = CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount()); dotDmg /= sSpellMgr->AssertSpellInfo(SPELL_PRIEST_SEARING_LIGHT_DAMAGE, GetCastDifficulty())->GetEffect(EFFECT_0).GetPeriodicTickCount(); eventInfo.GetActor()->CastSpell(eventInfo.GetActionTarget(), SPELL_PRIEST_SEARING_LIGHT_DAMAGE, CastSpellExtraArgsInit{ @@ -4255,7 +4255,7 @@ class spell_pri_sanctuary_trigger : public SpellScript { if (Unit* target = GetHitUnit()) { - float absorbAmount = CalculatePct(caster->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW), sanctuaryEffect->GetAmount()); + SpellEffectValue absorbAmount = CalculatePct(caster->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW), sanctuaryEffect->GetAmount()); AddPct(absorbAmount, caster->GetRatingBonusValue(CR_VERSATILITY_DAMAGE_DONE)); caster->CastSpell(caster, SPELL_PRIEST_SANCTUARY_ABSORB, CastSpellExtraArgs() @@ -4419,7 +4419,7 @@ class spell_pri_shadow_mend_periodic_damage : public AuraScript void HandleProc(AuraEffect* aurEff, ProcEventInfo const& eventInfo) { - int32 newAmount = aurEff->GetAmount() - eventInfo.GetDamageInfo()->GetDamage(); + SpellEffectValue newAmount = aurEff->GetAmount() - eventInfo.GetDamageInfo()->GetDamage(); aurEff->ChangeAmount(newAmount); if (newAmount < 0) @@ -4641,7 +4641,7 @@ class spell_pri_surge_of_light : public AuraScript void HandleEffectProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/) const { - if (roll_chance_i(aurEff->GetAmount())) + if (roll_chance_f(aurEff->GetAmount())) GetTarget()->CastSpell(GetTarget(), SPELL_PRIEST_SURGE_OF_LIGHT_EFFECT, aurEff); } @@ -4722,7 +4722,7 @@ class spell_pri_t10_heal_2p_bonus : public AuraScript return; SpellEffectInfo const& hotEffect = sSpellMgr->AssertSpellInfo(SPELL_PRIEST_BLESSED_HEALING, GetCastDifficulty())->GetEffect(EFFECT_0); - int32 amount = CalculatePct(static_cast(healInfo->GetHeal()), aurEff->GetAmount()); + SpellEffectValue amount = CalculatePct(static_cast(healInfo->GetHeal()), aurEff->GetAmount()); amount /= hotEffect.GetPeriodicTickCount(); @@ -4781,7 +4781,7 @@ class spell_pri_trail_of_light : public AuraScript if (!caster->IsWithinDist(oldTarget, healSpellInfo->GetMaxRange(true, caster))) return; - uint32 healAmount = CalculatePct(eventInfo.GetHealInfo()->GetHeal(), aurEff->GetAmount()); + SpellEffectValue healAmount = CalculatePct(eventInfo.GetHealInfo()->GetHeal(), aurEff->GetAmount()); caster->CastSpell(oldTarget, SPELL_PRIEST_TRAIL_OF_LIGHT_HEAL, CastSpellExtraArgs(aurEff).AddSpellBP0(healAmount)); } @@ -4823,12 +4823,12 @@ class spell_pri_train_of_thought : public AuraScript void ReducePowerWordShieldCooldown(AuraEffect const* aurEff, ProcEventInfo const& /*eventInfo*/) const { - GetTarget()->GetSpellHistory()->ModifyCooldown(SPELL_PRIEST_POWER_WORD_SHIELD, Milliseconds(aurEff->GetAmount())); + GetTarget()->GetSpellHistory()->ModifyCooldown(SPELL_PRIEST_POWER_WORD_SHIELD, Milliseconds(aurEff->GetAmountAsInt())); } void ReducePenanceCooldown(AuraEffect const* aurEff, ProcEventInfo const& /*eventInfo*/) const { - GetTarget()->GetSpellHistory()->ModifyCooldown(SPELL_PRIEST_PENANCE, Milliseconds(aurEff->GetAmount())); + GetTarget()->GetSpellHistory()->ModifyCooldown(SPELL_PRIEST_PENANCE, Milliseconds(aurEff->GetAmountAsInt())); } void Register() override @@ -4877,7 +4877,7 @@ class spell_pri_twilight_equilibrium_shadow_word_pain : public AuraScript return ValidateSpellInfo({ SPELL_PRIEST_TWILIGHT_EQUILIBRIUM_SHADOW }); } - void OnApply(AuraEffect const* /*aurEff*/, int32& /*amount*/, bool& /*canBeRecalculated*/) + void OnApply(AuraEffect const* /*aurEff*/, SpellEffectValue& /*amount*/, bool& /*canBeRecalculated*/) { _damageMultiplier = 1.0f; if (Unit* caster = GetCaster()) @@ -4937,7 +4937,7 @@ class spell_pri_ultimate_penitence : public SpellScript .TriggeringSpell = GetSpell() }); - int32 preferHealing = 1; + SpellEffectValue preferHealing = 1; if (Unit const* target = GetExplTargetUnit(); target && !GetCaster()->IsFriendlyTo(target)) preferHealing = 0; @@ -4961,7 +4961,7 @@ class spell_pri_ultimate_penitence : public SpellScript // 421453 - Ultimate Penitence (Aura) class spell_pri_ultimate_penitence_aura : public AuraScript { - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) const + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) const { canBeRecalculated = false; Unit* caster = GetCaster(); @@ -4994,7 +4994,7 @@ class spell_pri_ultimate_penitence_channel : public AuraScript void HandlePeriodic(AuraEffect const* aurEff) const { - if (aurEff->GetAmount() == 1) // set by spell_pri_ultimate_penitence + if (aurEff->GetAmountAsInt() == 1) // set by spell_pri_ultimate_penitence (void)(TryHealing() || TryDealingDamage()); else (void)(TryDealingDamage() || TryHealing()); @@ -5160,8 +5160,8 @@ class spell_pri_vampiric_embrace : public AuraScript if (!damageInfo || !damageInfo->GetDamage()) return; - int32 selfHeal = int32(CalculatePct(damageInfo->GetDamage(), aurEff->GetAmount())); - int32 teamHeal = selfHeal / 2; + SpellEffectValue selfHeal = CalculatePct(damageInfo->GetDamage(), aurEff->GetAmount()); + SpellEffectValue teamHeal = selfHeal / 2; CastSpellExtraArgs args(aurEff); args.AddSpellMod(SPELLVALUE_BASE_POINT0, teamHeal); @@ -5255,8 +5255,8 @@ class spell_pri_voice_of_harmony : public AuraScript void HandleProc(AuraEffect const* aurEff, ProcEventInfo const& /*eventInfo*/) const { SpellInfo const* targetSpellInfo = sSpellMgr->AssertSpellInfo(TargetSpellId, GetCastDifficulty()); - int32 cdReduction = aurEff->GetAmount(); - spell_pri_holy_words_base::ModifyCooldown(GetTarget(), targetSpellInfo, Seconds(-cdReduction)); + Milliseconds cdReduction = -duration_cast(FloatSeconds(aurEff->GetAmount())); + spell_pri_holy_words_base::ModifyCooldown(GetTarget(), targetSpellInfo, cdReduction); } void Register() override @@ -5323,7 +5323,7 @@ class spell_pri_void_volley : public SpellScript .TriggeringSpell = GetSpell() }); - int32 bolts = target == GetExplTargetUnit() ? GetEffectValue() : GetEffectInfo(EFFECT_2).CalcValue(caster); + int32 bolts = target == GetExplTargetUnit() ? GetEffectValueAsInt() : GetEffectInfo(EFFECT_2).CalcValueAsInt(caster); if (bolts > 1) caster->m_Events.AddEventAtOffset(new BoltEvent(caster, target->GetGUID(), GetSpell()->m_originalCastId, bolts - 1), BoltEvent::Period); } diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index 2c2eff515e..47d05d207c 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -521,7 +521,7 @@ class spell_q12805_lifeblood_dummy : public SpellScript if (Creature* target = GetHitCreature()) { caster->KilledMonsterCredit(NPC_SHARD_KILL_CREDIT); - target->CastSpell(target, uint32(GetEffectValue()), true); + target->CastSpell(target, uint32(GetEffectValueAsInt()), true); target->DespawnOrUnsummon(2s); } } @@ -897,13 +897,13 @@ class spell_q13086_cannons_target : public SpellScript bool Validate(SpellInfo const* spellInfo) override { return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) - && ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + && ValidateSpellInfo({ static_cast(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleEffectDummy(SpellEffIndex /*effIndex*/) { if (WorldLocation const* pos = GetExplTargetDest()) - GetCaster()->CastSpell(pos->GetPosition(), GetEffectValue(), true); + GetCaster()->CastSpell(pos->GetPosition(), GetEffectValueAsInt(), true); } void Register() override @@ -1084,7 +1084,7 @@ class spell_q13264_q13276_q13288_q13289_assign_credit_to_master : public SpellSc { if (Unit* owner = target->GetOwner()) { - owner->CastSpell(owner, GetEffectValue(), true); + owner->CastSpell(owner, GetEffectValueAsInt(), true); } } } @@ -1299,7 +1299,7 @@ class spell_q12619_emblazon_runeblade_effect : public SpellScript { void HandleScript(SpellEffIndex /*effIndex*/) { - GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValue()), false); + GetCaster()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt()), false); } void Register() override @@ -1537,7 +1537,7 @@ class spell_q13665_q13790_bested_trigger : public SpellScript void HandleScript(SpellEffIndex /*effIndex*/) { Unit* target = GetHitUnit()->GetCharmerOrOwnerOrSelf(); - target->CastSpell(target, uint32(GetEffectValue()), true); + target->CastSpell(target, uint32(GetEffectValueAsInt()), true); } void Register() override @@ -1647,7 +1647,7 @@ class spell_q11896_weakness_to_lightning_46444 : public SpellScript { if (Unit* owner = target->GetOwner()) { - target->CastSpell(owner, GetEffectValue(), true); + target->CastSpell(owner, GetEffectValueAsInt(), true); } } } @@ -1772,8 +1772,8 @@ class spell_quest_portal_with_condition : public SpellScript bool Validate(SpellInfo const* spellInfo) override { return ValidateSpellEffect({ { spellInfo->Id, EFFECT_1 } }) - && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }) - && sObjectMgr->GetQuestTemplate(uint32(spellInfo->GetEffect(EFFECT_1).CalcValue())); + && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }) + && sObjectMgr->GetQuestTemplate(uint32(spellInfo->GetEffect(EFFECT_1).CalcValueAsInt())); } void HandleScriptEffect(SpellEffIndex /* effIndex */) @@ -1782,8 +1782,8 @@ class spell_quest_portal_with_condition : public SpellScript if (!target) return; - uint32 spellId = GetEffectInfo().CalcValue(); - uint32 questId = GetEffectInfo(EFFECT_1).CalcValue(); + uint32 spellId = GetEffectInfo().CalcValueAsInt(); + uint32 questId = GetEffectInfo(EFFECT_1).CalcValueAsInt(); // This probably should be a way to throw error in SpellCastResult if (target->IsActiveQuest(questId)) diff --git a/src/server/scripts/Spells/spell_rogue.cpp b/src/server/scripts/Spells/spell_rogue.cpp index 170ece98f6..1091052f5e 100644 --- a/src/server/scripts/Spells/spell_rogue.cpp +++ b/src/server/scripts/Spells/spell_rogue.cpp @@ -239,7 +239,7 @@ class spell_rog_backstab : public SpellScript if (hitUnit->isInBack(caster)) { float currDamage = float(GetHitDamage()); - float newDamage = AddPct(currDamage, float(GetEffectInfo(EFFECT_3).CalcValue(caster))); + float newDamage = AddPct(currDamage, GetEffectInfo(EFFECT_3).CalcValue(caster)); SetHitDamage(newDamage); } } @@ -365,7 +365,7 @@ class spell_rog_cloaked_in_shadows : public SpellScript if (!cloakedInShadows) return; - int32 amount = caster->CountPctFromMaxHealth(cloakedInShadows->GetAmount()); + SpellEffectValue amount = caster->CountPctFromMaxHealth(cloakedInShadows->GetAmount()); caster->CastSpell(caster, SPELL_ROGUE_CLOAKED_IN_SHADOWS_ABSORB, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, @@ -422,7 +422,7 @@ class spell_rog_deepening_shadows : public AuraScript void HandleProc(AuraEffect const* aurEff, ProcEventInfo const& procInfo) const { - Milliseconds amount = -Seconds(aurEff->GetAmount()) * *procInfo.GetProcSpell()->GetPowerTypeCostAmount(POWER_COMBO_POINTS); + Milliseconds amount = duration_cast(-FloatSeconds(aurEff->GetAmount()) * *procInfo.GetProcSpell()->GetPowerTypeCostAmount(POWER_COMBO_POINTS)); GetTarget()->GetSpellHistory()->ModifyChargeRecoveryTime(sSpellMgr->AssertSpellInfo(SPELL_ROGUE_SHADOW_DANCE, GetCastDifficulty())->ChargeCategoryId, amount / 10); } @@ -441,7 +441,7 @@ class spell_rog_envenom : public SpellScript pctMod *= GetSpell()->GetPowerTypeCostAmount(POWER_COMBO_POINTS).value_or(0); if (AuraEffect const* t5 = GetCaster()->GetAuraEffect(SPELL_ROGUE_T5_2P_SET_BONUS, EFFECT_0)) - flatMod += t5->GetAmount(); + flatMod += t5->GetAmountAsInt(); } void Register() override @@ -458,7 +458,7 @@ class spell_rog_eviscerate : public SpellScript pctMod *= GetSpell()->GetPowerTypeCostAmount(POWER_COMBO_POINTS).value_or(0); if (AuraEffect const* t5 = GetCaster()->GetAuraEffect(SPELL_ROGUE_T5_2P_SET_BONUS, EFFECT_0)) - flatMod += t5->GetAmount(); + flatMod += t5->GetAmountAsInt(); } void Register() override @@ -589,7 +589,7 @@ class spell_rog_improved_garrote_damage : public AuraScript }); } - void CalculateBonus(AuraEffect const* /*aurEff*/, int32& /*amount*/, bool& /*canBeRecalculated*/) + void CalculateBonus(AuraEffect const* /*aurEff*/, SpellEffectValue& /*amount*/, bool& /*canBeRecalculated*/) { _pctMod = 1.0f; Unit* caster = GetCaster(); @@ -973,11 +973,11 @@ class spell_rog_restless_blades : public AuraScript { if (Optional spentCP = GetFinishingMoveCPCost(procInfo.GetProcSpell())) { - int32 cdExtra = -(float(aurEff->GetAmount() * *spentCP) * 0.1f); + Milliseconds cdExtra = -duration_cast(FloatSeconds(aurEff->GetAmount() * *spentCP * 0.1)); SpellHistory* history = GetTarget()->GetSpellHistory(); for (uint32 spellId : Spells) - history->ModifyCooldown(spellId, Seconds(cdExtra), true); + history->ModifyCooldown(spellId, cdExtra, true); } } @@ -1086,7 +1086,7 @@ class spell_rog_ruthlessness : public AuraScript Unit* target = GetTarget(); if (Optional cost = GetFinishingMoveCPCost(procInfo.GetProcSpell())) - if (roll_chance_i(aurEff->GetSpellEffectInfo().PointsPerResource * (*cost))) + if (roll_chance_f(aurEff->GetSpellEffectInfo().PointsPerResource * *cost)) target->ModifyPower(POWER_COMBO_POINTS, 1); } @@ -1121,10 +1121,10 @@ class spell_rog_shadowstrike : public SpellScript if (caster->HasAura(SPELL_ROGUE_SLICE_AND_DICE)) if (Aura* premeditationPassive = caster->GetAura(SPELL_ROGUE_PREMEDITATION_PASSIVE)) if (AuraEffect const* auraEff = premeditationPassive->GetEffect(EFFECT_1)) - SetHitDamage(GetHitDamage() + auraEff->GetAmount()); + SetHitDamage(GetHitDamage() + auraEff->GetAmountAsInt()); // Grant 10 seconds of slice and dice - int32 duration = sSpellMgr->AssertSpellInfo(SPELL_ROGUE_PREMEDITATION_PASSIVE, DIFFICULTY_NONE)->GetEffect(EFFECT_0).CalcValue(GetCaster()); + int32 duration = sSpellMgr->AssertSpellInfo(SPELL_ROGUE_PREMEDITATION_PASSIVE, DIFFICULTY_NONE)->GetEffect(EFFECT_0).CalcValueAsInt(GetCaster()); CastSpellExtraArgs args; args.TriggerFlags = TRIGGERED_FULL_MASK; @@ -1236,7 +1236,7 @@ class spell_rog_shuriken_storm : public SpellScript GetCaster()->CastSpell(GetCaster(), SPELL_ROGUE_SHURIKEN_STORM_ENERGIZE, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringSpell = GetSpell(), - .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, static_cast(GetUnitTargetCountForEffect(effIndex)) } } + .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, static_cast(GetUnitTargetCountForEffect(effIndex)) } } }); } @@ -1280,7 +1280,7 @@ class spell_rog_sinister_strike : public SpellScript { int32 damagePerCombo = GetHitDamage(); if (AuraEffect const* t5 = GetCaster()->GetAuraEffect(SPELL_ROGUE_T5_2P_SET_BONUS, EFFECT_0)) - damagePerCombo += t5->GetAmount(); + damagePerCombo += t5->GetAmountAsInt(); int32 finalDamage = damagePerCombo; if (Optional comboPointCost = GetSpell()->GetPowerTypeCostAmount(POWER_COMBO_POINTS)) @@ -1552,7 +1552,7 @@ class spell_rog_venomous_wounds : public AuraScript { void HandleProc(AuraEffect* aurEff, ProcEventInfo& /*eventInfo*/) { - int32 extraEnergy = aurEff->GetAmount(); + int32 extraEnergy = aurEff->GetAmountAsInt(); GetTarget()->ModifyPower(POWER_ENERGY, extraEnergy); } diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp index 37ac7da248..ffabc6238f 100644 --- a/src/server/scripts/Spells/spell_shaman.cpp +++ b/src/server/scripts/Spells/spell_shaman.cpp @@ -233,7 +233,7 @@ class spell_sha_aftershock : public AuraScript { if (Spell const* procSpell = eventInfo.GetProcSpell()) if (Optional cost = procSpell->GetPowerTypeCostAmount(POWER_MAELSTROM)) - return cost > 0 && roll_chance_i(aurEff->GetAmount()); + return cost > 0 && roll_chance_f(aurEff->GetAmount()); return false; } @@ -245,7 +245,7 @@ class spell_sha_aftershock : public AuraScript .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringSpell = procSpell, .TriggeringAura = aurEff, - .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, *procSpell->GetPowerTypeCostAmount(POWER_MAELSTROM) } } + .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, static_cast(*procSpell->GetPowerTypeCostAmount(POWER_MAELSTROM)) } } }); } @@ -278,7 +278,7 @@ class spell_sha_ancestral_guidance : public AuraScript void HandleEffectProc(AuraEffect const* aurEff, ProcEventInfo const& eventInfo) { PreventDefaultAction(); - int32 bp0 = CalculatePct(int32(eventInfo.GetDamageInfo() ? eventInfo.GetDamageInfo()->GetDamage() : eventInfo.GetHealInfo()->GetHeal()), aurEff->GetAmount()); + SpellEffectValue bp0 = CalculatePct(eventInfo.GetDamageInfo() ? eventInfo.GetDamageInfo()->GetDamage() : eventInfo.GetHealInfo()->GetHeal(), aurEff->GetAmount()); if (!bp0) return; @@ -351,7 +351,7 @@ class spell_sha_artifact_gathering_storms : public SpellScript GetCaster()->CastSpell(GetCaster(), SPELL_SHAMAN_GATHERING_STORMS_BUFF, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_FULL_MASK, - .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, int32(gatheringStorms->GetAmount() * GetUnitTargetCountForEffect(effIndex)) } } + .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, gatheringStorms->GetAmount() * GetUnitTargetCountForEffect(effIndex) } } }); } @@ -400,7 +400,7 @@ class spell_sha_ascendance_restoration : public AuraScript } private: - int32 _healToDistribute = 0; + SpellEffectValue _healToDistribute = 0; }; // 390370 - Ashen Catalyst @@ -413,7 +413,7 @@ class spell_sha_ashen_catalyst : public AuraScript void ReduceLavaLashCooldown(AuraEffect const* aurEff, ProcEventInfo const& /*procInfo*/) const { - GetTarget()->GetSpellHistory()->ModifyCooldown(SPELL_SHAMAN_LAVA_LASH, -aurEff->GetAmount() * 100ms); + GetTarget()->GetSpellHistory()->ModifyCooldown(SPELL_SHAMAN_LAVA_LASH, -aurEff->GetAmountAsInt() * 100ms); } void Register() override @@ -437,7 +437,7 @@ class spell_sha_chain_lightning_crash_lightning : public SpellScript void HandleCooldownReduction(SpellEffIndex /*effIndex*/) const { - GetCaster()->GetSpellHistory()->ModifyCooldown(SPELL_SHAMAN_CRASH_LIGHTNING, Milliseconds(-GetEffectValue()) * GetUnitTargetCountForEffect(EFFECT_0)); + GetCaster()->GetSpellHistory()->ModifyCooldown(SPELL_SHAMAN_CRASH_LIGHTNING, Milliseconds(-GetEffectValueAsInt()) * GetUnitTargetCountForEffect(EFFECT_0)); } void HandleDamageBuff(SpellEffIndex effIndex) const @@ -477,7 +477,7 @@ class spell_sha_chain_lightning_energize : public SpellScript GetCaster()->CastSpell(GetCaster(), SPELL_SHAMAN_CHAIN_LIGHTNING_ENERGIZE, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringAura = energizeAmount, - .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, int32(energizeAmount->GetAmount() * GetUnitTargetCountForEffect(EFFECT_0)) } } + .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, energizeAmount->GetAmount() * GetUnitTargetCountForEffect(EFFECT_0) } } }); } @@ -507,7 +507,7 @@ class spell_sha_chain_lightning_overload : public SpellScript GetCaster()->CastSpell(GetCaster(), SPELL_SHAMAN_CHAIN_LIGHTNING_OVERLOAD_ENERGIZE, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringAura = energizeAmount, - .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, int32(energizeAmount->GetAmount() * GetUnitTargetCountForEffect(EFFECT_0)) } } + .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, energizeAmount->GetAmount() * GetUnitTargetCountForEffect(EFFECT_0) } } }); } @@ -669,7 +669,7 @@ class spell_sha_deeply_rooted_elements : public AuraScript Unit* target = eventInfo.GetActor(); - int32 duration = GetEffect(EFFECT_0)->GetAmount(); + int32 duration = GetEffect(EFFECT_0)->GetAmountAsInt(); if (Aura const* ascendanceAura = target->GetAura(_triggeredSpellId)) duration += ascendanceAura->GetDuration(); @@ -788,7 +788,7 @@ class spell_sha_downpour : public SpellScript void HandleCooldown() const { - SpellHistory::Duration cooldown = Milliseconds(GetSpellInfo()->RecoveryTime) + Seconds(GetEffectInfo(EFFECT_1).CalcValue() * _healedTargets); + SpellHistory::Duration cooldown = Milliseconds(GetSpellInfo()->RecoveryTime) + Seconds(GetEffectInfo(EFFECT_1).CalcValueAsInt() * _healedTargets); GetCaster()->GetSpellHistory()->StartCooldown(GetSpellInfo(), 0, GetSpell(), false, cooldown); } @@ -946,7 +946,7 @@ struct areatrigger_sha_earthquake : AreaTriggerAI caster->CastSpell(at->GetPosition(), SPELL_SHAMAN_EARTHQUAKE_TICK, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_FULL_MASK, .OriginalCaster = at->GetGUID(), - .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, int32(caster->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_NATURE) * 0.213f * _damageMultiplier) } } + .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, caster->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_NATURE) * 0.213 * _damageMultiplier } } }); _refreshTimer += _period; @@ -1016,7 +1016,7 @@ class spell_sha_earthquake_tick : public SpellScript { if (Unit* target = GetHitUnit()) { - if (roll_chance_i(GetEffectInfo(EFFECT_1).CalcValue())) + if (roll_chance_f(GetEffectInfo(EFFECT_1).CalcValue())) { std::vector areaTriggers = GetCaster()->GetAreaTriggers(SPELL_SHAMAN_EARTHQUAKE); auto itr = std::ranges::find(areaTriggers, GetSpell()->GetOriginalCasterGUID(), [](AreaTrigger const* at) { return at->GetGUID(); }); @@ -1110,7 +1110,7 @@ class spell_sha_elemental_weapons : public AuraScript if (owner->HasAura(SPELL_SHAMAN_WINDFURY_AURA)) ++enchatmentCount; - int32 valuePerStack = GetEffect(EFFECT_0)->GetAmount(); + SpellEffectValue valuePerStack = GetEffect(EFFECT_0)->GetAmount(); if (Aura* buff = owner->GetAura(SPELL_SHAMAN_ELEMENTAL_WEAPONS_BUFF)) { @@ -1462,7 +1462,7 @@ class spell_sha_ice_strike : public SpellScript void EnergizeMaelstrom(SpellEffIndex /*effIndex*/) const { - spell_sha_maelstrom_weapon_base::GenerateMaelstromWeapon(GetCaster(), GetEffectValue()); + spell_sha_maelstrom_weapon_base::GenerateMaelstromWeapon(GetCaster(), GetEffectValueAsInt()); } void Register() override @@ -1583,7 +1583,7 @@ class spell_sha_item_mana_surge : public AuraScript if (Optional manaCost = eventInfo.GetProcSpell()->GetPowerTypeCostAmount(POWER_MANA)) { - int32 mana = CalculatePct(*manaCost, 35); + SpellEffectValue mana = CalculatePct(*manaCost, 35); if (mana > 0) { GetTarget()->CastSpell(GetTarget(), SPELL_SHAMAN_ITEM_MANA_SURGE, CastSpellExtraArgsInit{ @@ -1667,7 +1667,7 @@ class spell_sha_item_t10_elemental_2p_bonus : public AuraScript { PreventDefaultAction(); if (Player* target = GetTarget()->ToPlayer()) - target->GetSpellHistory()->ModifyCooldown(SPELL_SHAMAN_ELEMENTAL_MASTERY, Milliseconds(-aurEff->GetAmount())); + target->GetSpellHistory()->ModifyCooldown(SPELL_SHAMAN_ELEMENTAL_MASTERY, Milliseconds(-aurEff->GetAmountAsInt())); } void Register() override @@ -1751,7 +1751,7 @@ class spell_sha_lava_crit_chance : public SpellScript return; if (victim->HasAura(SPELL_SHAMAN_FLAME_SHOCK, caster->GetGUID())) - if (victim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE) > -100) + if (victim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE) > -100.0f) chance = 100.f; } @@ -1810,19 +1810,19 @@ class spell_sha_lava_surge : public AuraScript Cell::VisitAllObjects(caster, worker, 100.0f); // Proc uptime is not supposed to scale with the number of applied flame shocks - _normalizedTicks += 1.0f / flameShocks; + _normalizedTicks += 1.0 / flameShocks; // first 6 ticks after last proc fail to prevent overwriting - if (_normalizedTicks < 6.0f) + if (_normalizedTicks < 6.0) return false; - float procChance = aurEff->GetAmount(); + SpellEffectValue procChance = aurEff->GetAmount(); if (AuraEffect const* igneousPotential = GetTarget()->GetAuraEffect(SPELL_SHAMAN_IGNEOUS_POTENTIAL, EFFECT_0)) procChance += igneousPotential->GetAmount(); - float missChance = std::max(100 - procChance, 0.0f) / 100.0f; + SpellEffectValue missChance = std::max(100 - procChance, 0.0) / 100.0; - procChance = (1.0f - std::pow(missChance, _normalizedTicks)) * 100.0f; + procChance = (1.0 - std::pow(missChance, _normalizedTicks)) * 100.0; return roll_chance_f(procChance); } @@ -1841,7 +1841,7 @@ class spell_sha_lava_surge : public AuraScript OnEffectProc += AuraEffectProcFn(spell_sha_lava_surge::HandleEffectProc, EFFECT_0, SPELL_AURA_DUMMY); } - float _normalizedTicks = 0.0f; + SpellEffectValue _normalizedTicks = 0.0; }; // 77762 - Lava Surge @@ -2150,14 +2150,14 @@ class spell_sha_mastery_elemental_overload : public AuraScript if (!GetTriggeredSpellId(spellInfo->Id)) return false; - float chance = aurEff->GetAmount(); // Mastery % amount + SpellEffectValue chance = aurEff->GetAmount(); // Mastery % amount if (spellInfo->Id == SPELL_SHAMAN_CHAIN_LIGHTNING) - chance /= 3.0f; + chance /= 3.0; if (Aura* stormkeeper = eventInfo.GetActor()->GetAura(SPELL_SHAMAN_STORMKEEPER)) if (eventInfo.GetProcSpell()->m_appliedMods.contains(stormkeeper)) - chance = 100.0f; + chance = 100.0; return roll_chance_f(chance); } @@ -2259,7 +2259,7 @@ class spell_sha_molten_assault : public SpellScript Cell::VisitAllObjects(lavaLashTarget, searcher, range + EXTRA_CELL_SEARCH_RADIUS); auto withoutFlameShockItr = std::partition(targets.begin(), targets.end(), Trinity::UnitAuraCheck(true, SPELL_SHAMAN_FLAME_SHOCK, GetCaster()->GetGUID())); - std::size_t flameShocksMissing = GetEffectValue() + 1 - std::ranges::distance(targets.begin(), withoutFlameShockItr); + std::size_t flameShocksMissing = GetEffectValueAsInt() + 1 - std::ranges::distance(targets.begin(), withoutFlameShockItr); if (flameShocksMissing) Trinity::Containers::RandomShuffle(withoutFlameShockItr, targets.end()); @@ -2269,7 +2269,7 @@ class spell_sha_molten_assault : public SpellScript args.SetTriggeringSpell(GetSpell()); // targets that already have flame shock are first in the list (and need to refresh it) - for (std::size_t i = 0; i < std::min(targets.size(), GetEffectValue() + 1); ++i) + for (std::size_t i = 0; i < std::min(targets.size(), GetEffectValueAsInt() + 1); ++i) caster->CastSpell(targets[i], SPELL_SHAMAN_FLAME_SHOCK, args); } @@ -2322,10 +2322,10 @@ class spell_sha_molten_thunder_sundering : public SpellScript if (!counterScript) return; - int32 procChance = chanceBaseEffect->GetAmount(); - procChance += std::min(targetLimitEffect->GetAmount(), GetUnitTargetCountForEffect(EFFECT_0)) * chancePerTargetEffect->GetAmount(); - procChance >>= counterScript->ProcCount; // Each consecutive reset reduces these chances by half - if (roll_chance_i(procChance)) + SpellEffectValue procChance = chanceBaseEffect->GetAmount(); + procChance += std::min(targetLimitEffect->GetAmount(), GetUnitTargetCountForEffect(EFFECT_0)) * chancePerTargetEffect->GetAmount(); + procChance *= std::pow(0.5, counterScript->ProcCount); // Each consecutive reset reduces these chances by half + if (roll_chance_f(procChance)) { shaman->CastSpell(shaman, SPELL_SHAMAN_MOLTEN_THUNDER_PROC, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, @@ -2442,7 +2442,7 @@ class spell_sha_primordial_wave : public SpellScript void EnergizeMaelstrom(SpellEffIndex /*effIndex*/) const { - spell_sha_maelstrom_weapon_base::GenerateMaelstromWeapon(GetCaster(), GetEffectValue()); + spell_sha_maelstrom_weapon_base::GenerateMaelstromWeapon(GetCaster(), GetEffectValueAsInt()); } void Register() override @@ -2542,7 +2542,7 @@ class spell_sha_stormblast_damage : public SpellScript { if (AuraEffect const* stormblast = GetCaster()->GetAuraEffect(SPELL_SHAMAN_STORMBLAST_TALENT, EFFECT_0)) { - int32 damage = CalculatePct(GetHitDamage(), stormblast->GetAmount()); + SpellEffectValue damage = CalculatePct(GetHitDamage(), stormblast->GetAmount()); // Not part of SpellFamilyFlags for mastery effect but known to be affected by it if (AuraEffect const* mastery = GetCaster()->GetAuraEffect(SPELL_SHAMAN_ENHANCED_ELEMENTS, EFFECT_0)) @@ -2593,11 +2593,11 @@ class StormflurryEvent : public BasicEvent public: struct Data { - int32 DamagePercent = 0; + SpellEffectValue DamagePercent = 0; }; - explicit StormflurryEvent(Unit* caster, Unit* target, ObjectGuid const& originalCastId, int32 damagePercent, - uint32 mainHandDamageSpellId, uint32 offHandDamageSpellId, int32 procChance) + explicit StormflurryEvent(Unit* caster, Unit* target, ObjectGuid const& originalCastId, SpellEffectValue damagePercent, + uint32 mainHandDamageSpellId, uint32 offHandDamageSpellId, SpellEffectValue procChance) : _caster(caster), _target(target), _originalCastId(originalCastId), _damagePercent(damagePercent), _mainHandDamageSpellId(mainHandDamageSpellId), _offHandDamageSpellId(offHandDamageSpellId), _procChance(procChance) { @@ -2618,7 +2618,7 @@ public: _caster->CastSpell(_target, _mainHandDamageSpellId, args); _caster->CastSpell(_target, _offHandDamageSpellId, args); - if (!roll_chance_i(_procChance)) + if (!roll_chance_f(_procChance)) return true; _caster->m_Events.AddEvent(this, Milliseconds(time) + 200ms); @@ -2629,10 +2629,10 @@ private: Unit* _caster; CastSpellTargetArg _target; ObjectGuid _originalCastId; - int32 _damagePercent; + SpellEffectValue _damagePercent; uint32 _mainHandDamageSpellId; uint32 _offHandDamageSpellId; - int32 _procChance; + SpellEffectValue _procChance; }; // 198367 Stormflurry @@ -2668,8 +2668,8 @@ public: if (!chanceEffect || !damageEffect) return; - int32 procChance = chanceEffect->GetAmount(); - if (!roll_chance_i(procChance)) + SpellEffectValue procChance = chanceEffect->GetAmount(); + if (!roll_chance_f(procChance)) return; caster->m_Events.AddEventAtOffset(new StormflurryEvent(caster, GetHitUnit(), GetSpell()->m_castId, damageEffect->GetAmount(), @@ -2780,7 +2780,7 @@ class spell_sha_swirling_maelstrom : public AuraScript void EnergizeMaelstrom(AuraEffect const* aurEff, ProcEventInfo const& /*eventInfo*/) const { - spell_sha_maelstrom_weapon_base::GenerateMaelstromWeapon(GetTarget(), aurEff->GetAmount()); + spell_sha_maelstrom_weapon_base::GenerateMaelstromWeapon(GetTarget(), aurEff->GetAmountAsInt()); } void Register() override @@ -2870,7 +2870,7 @@ class spell_sha_thorims_invocation_trigger : public SpellScript // Manually remove stacks - Maelstrom Weapon aura cannot proc from procs and free Lightning Bolt/Chain Lightning procs from Arc Discharge (455096) shoulnd't consume it if (Aura* maelstromWeaponVisibleAura = caster->GetAura(SPELL_SHAMAN_MAELSTROM_WEAPON_VISIBLE_AURA)) - spell_sha_maelstrom_weapon_base::ConsumeMaelstromWeapon(caster, maelstromWeaponVisibleAura, thorimsInvocation->GetAmount()); + spell_sha_maelstrom_weapon_base::ConsumeMaelstromWeapon(caster, maelstromWeaponVisibleAura, thorimsInvocation->GetAmountAsInt()); } void Register() override @@ -3001,7 +3001,7 @@ class spell_sha_t8_elemental_4p_bonus : public AuraScript return; SpellEffectInfo const& dotEffect = sSpellMgr->AssertSpellInfo(SPELL_SHAMAN_ELECTRIFIED, GetCastDifficulty())->GetEffect(EFFECT_0); - int32 amount = CalculatePct(static_cast(damageInfo->GetDamage()), aurEff->GetAmount()); + SpellEffectValue amount = CalculatePct(static_cast(damageInfo->GetDamage()), aurEff->GetAmount()); amount /= dotEffect.GetPeriodicTickCount(); @@ -3039,7 +3039,7 @@ class spell_sha_t9_elemental_4p_bonus : public AuraScript return; SpellEffectInfo const& dotEffect = sSpellMgr->AssertSpellInfo(SPELL_SHAMAN_LAVA_BURST_BONUS_DAMAGE, GetCastDifficulty())->GetEffect(EFFECT_0); - int32 amount = CalculatePct(static_cast(damageInfo->GetDamage()), aurEff->GetAmount()); + SpellEffectValue amount = CalculatePct(static_cast(damageInfo->GetDamage()), aurEff->GetAmount()); amount /= dotEffect.GetPeriodicTickCount(); @@ -3077,7 +3077,7 @@ class spell_sha_t10_elemental_4p_bonus : public AuraScript Aura* flameShockAura = flameShock->GetBase(); int32 maxDuration = flameShockAura->GetMaxDuration(); - int32 newDuration = flameShockAura->GetDuration() + aurEff->GetAmount() * IN_MILLISECONDS; + int32 newDuration = flameShockAura->GetDuration() + aurEff->GetAmountAsInt() * IN_MILLISECONDS; flameShockAura->SetDuration(newDuration); // is it blizzlike to change max duration for FS? @@ -3109,7 +3109,7 @@ class spell_sha_t10_restoration_4p_bonus : public AuraScript return; SpellEffectInfo const& dotEffect = sSpellMgr->AssertSpellInfo(SPELL_SHAMAN_CHAINED_HEAL, GetCastDifficulty())->GetEffect(EFFECT_0); - int32 amount = CalculatePct(static_cast(healInfo->GetHeal()), aurEff->GetAmount()); + SpellEffectValue amount = CalculatePct(static_cast(healInfo->GetHeal()), aurEff->GetAmount()); amount /= dotEffect.GetPeriodicTickCount(); @@ -3203,7 +3203,7 @@ class spell_sha_unrelenting_storms : public SpellScript int64 targetLimit = 0; if (AuraEffect const* limitEffect = unrelentingStorms->GetEffect(EFFECT_0)) - targetLimit = limitEffect->GetAmount(); + targetLimit = limitEffect->GetAmountAsInt(); if (GetUnitTargetCountForEffect(effIndex) > targetLimit) return; @@ -3215,7 +3215,7 @@ class spell_sha_unrelenting_storms : public SpellScript shaman->CastSpell(shaman, SPELL_SHAMAN_UNRELENTING_STORMS_REDUCTION, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, - .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, -int32(CalculatePct(cooldown.count(), reductionPctEffect->GetAmount())) } } + .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, SpellEffectValue(-CalculatePct(cooldown.count(), reductionPctEffect->GetAmount())) } } }); } @@ -3253,7 +3253,7 @@ class spell_sha_voltaic_blaze : public SpellScript void EnergizeMaelstrom(SpellEffIndex /*effIndex*/) const { - spell_sha_maelstrom_weapon_base::GenerateMaelstromWeapon(GetCaster(), GetEffectValue()); + spell_sha_maelstrom_weapon_base::GenerateMaelstromWeapon(GetCaster(), GetEffectValueAsInt()); } void Register() override @@ -3283,7 +3283,7 @@ class spell_sha_voltaic_blaze_talent : public AuraScript { static bool CheckProc(AuraScript const&, AuraEffect const* aurEff, ProcEventInfo const& /*eventInfo*/) { - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } static void HandleProc(AuraScript const&, AuraEffect const* /*aurEff*/, ProcEventInfo const& eventInfo) @@ -3370,7 +3370,7 @@ void WindfuryProcEvent::Trigger(Unit* shaman, Unit* target) } std::ptrdiff_t attacks = 2; - if (AuraEffect const* unrulyWinds = shaman->GetAuraEffect(SPELL_SHAMAN_UNRULY_WINDS, EFFECT_0); roll_chance_i(unrulyWinds->GetAmount())) + if (AuraEffect const* unrulyWinds = shaman->GetAuraEffect(SPELL_SHAMAN_UNRULY_WINDS, EFFECT_0); roll_chance_f(unrulyWinds->GetAmount())) ++attacks; shaman->m_Events.AddEventAtOffset(new WindfuryProcEvent(shaman, target, attacks), Sequence.front().Delay); diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index 589e862dd6..9dce0928d6 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -137,7 +137,7 @@ class spell_warl_absolute_corruption : public SpellScript if (Aura const* absoluteCorruption = GetCaster()->GetAura(SPELL_WARLOCK_ABSOLUTE_CORRUPTION)) { Milliseconds duration = GetHitUnit()->IsPvP() - ? Seconds(absoluteCorruption->GetSpellInfo()->GetEffect(EFFECT_0).CalcValue()) + ? Seconds(absoluteCorruption->GetSpellInfo()->GetEffect(EFFECT_0).CalcValueAsInt()) : Milliseconds(-1); GetHitAura()->SetMaxDuration(duration.count()); @@ -281,7 +281,7 @@ class spell_warl_burning_rush : public SpellScript { Unit* caster = GetCaster(); - if (caster->GetHealthPct() <= float(GetEffectInfo(EFFECT_1).CalcValue(caster))) + if (caster->GetHealthPct() <= GetEffectInfo(EFFECT_1).CalcValue(caster)) { SetCustomCastResultMessage(SPELL_CUSTOM_ERROR_YOU_DONT_HAVE_ENOUGH_HEALTH); return SPELL_FAILED_CUSTOM_ERROR; @@ -301,7 +301,7 @@ class spell_warl_burning_rush_aura : public AuraScript { void PeriodicTick(AuraEffect const* aurEff) { - if (GetTarget()->GetHealthPct() <= float(aurEff->GetAmount())) + if (GetTarget()->GetHealthPct() <= aurEff->GetAmount()) { PreventDefaultAction(); Remove(); @@ -467,7 +467,7 @@ class spell_warl_chaotic_energies : public AuraScript } // You take ${$s2/3}% reduced damage - float damageReductionPct = float(effect1->GetAmount()) / 3; + float damageReductionPct = effect1->GetAmount() / 3; // plus a random amount of up to ${$s2/3}% additional reduced damage damageReductionPct += frand(0.0f, damageReductionPct); @@ -534,13 +534,13 @@ class spell_warl_dark_pact : public AuraScript return ValidateSpellEffect({ { spellInfo->Id, EFFECT_1 }, { spellInfo->Id, EFFECT_2 } }); } - void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& canBeRecalculated) + void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated) { canBeRecalculated = false; if (Unit* caster = GetCaster()) { float extraAmount = caster->SpellBaseDamageBonusDone(GetSpellInfo()->GetSchoolMask()) * 2.5f; - int32 absorb = caster->CountPctFromCurHealth(GetEffectInfo(EFFECT_1).CalcValue(caster)); + uint64 absorb = caster->CountPctFromCurHealth(GetEffectInfo(EFFECT_1).CalcValue(caster)); caster->SetHealth(caster->GetHealth() - absorb); amount = CalculatePct(absorb, GetEffectInfo(EFFECT_2).CalcValue(caster)) + extraAmount; } @@ -912,7 +912,7 @@ class spell_warl_perpetual_unstability : public SpellScript { if (Aura const* unstableAfflictionAura = target->GetAura(GetSpellInfo()->Id, caster->GetGUID())) { - Milliseconds maxUnstableAfflictionDuration = Seconds(perpetualUnstability->GetAmount()); + FloatSeconds maxUnstableAfflictionDuration(perpetualUnstability->GetAmount()); if (Milliseconds(unstableAfflictionAura->GetDuration()) <= maxUnstableAfflictionDuration) caster->CastSpell(target, SPELL_WARLOCK_PERPETUAL_UNSTABILITY_DAMAGE, CastSpellExtraArgs() .SetTriggerFlags(TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR) @@ -1165,7 +1165,7 @@ class spell_warl_seed_of_corruption_dummy_aura : public AuraScript caster->CastSpell(GetTarget(), SPELL_WARLOCK_SEED_OF_CORRUPTION_DAMAGE, aurEff); } - void CalculateBuffer(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) const + void CalculateBuffer(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/) const { Unit* caster = GetCaster(); if (!caster) @@ -1192,7 +1192,7 @@ class spell_warl_seed_of_corruption_dummy_aura : public AuraScript // other seed explosions detonate this instantly, no matter what damage amount is if (!damageInfo->GetSpellInfo() || damageInfo->GetSpellInfo()->Id != SPELL_WARLOCK_SEED_OF_CORRUPTION_DAMAGE) { - int32 amount = aurEff->GetAmount() - damageInfo->GetDamage(); + SpellEffectValue amount = aurEff->GetAmount() - damageInfo->GetDamage(); if (amount > 0) { aurEff->SetAmount(amount); @@ -1235,10 +1235,10 @@ class spell_warl_seed_of_corruption_generic : public AuraScript if (!damageInfo || !damageInfo->GetDamage()) return; - int32 amount = aurEff->GetAmount() - damageInfo->GetDamage(); + SpellEffectValue amount = aurEff->GetAmount() - damageInfo->GetDamage(); if (amount > 0) { - const_cast(aurEff)->SetAmount(amount); + aurEff->SetAmount(amount); return; } @@ -1706,7 +1706,7 @@ class spell_warl_unstable_affliction : public AuraScript if (!removedEffect) return; - int32 damage = GetEffectInfo(EFFECT_0).CalcValue(caster, nullptr, GetUnitOwner()) / 100.0f * *removedEffect->CalculateEstimatedAmount(caster, removedEffect->GetAmount()); + SpellEffectValue damage = GetEffectInfo(EFFECT_0).CalcValue(caster, nullptr, GetUnitOwner()) / 100.0 * *removedEffect->CalculateEstimatedAmount(caster, removedEffect->GetAmount()); caster->CastSpell(dispelInfo->GetDispeller(), SPELL_WARLOCK_UNSTABLE_AFFLICTION_DAMAGE, CastSpellExtraArgs() .AddSpellMod(SPELLVALUE_BASE_POINT0, damage) .SetTriggerFlags(TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR)); @@ -1774,7 +1774,7 @@ class spell_warl_volatile_agony : public SpellScript { if (Aura const* agonyAura = target->GetAura(GetSpellInfo()->Id, caster->GetGUID())) { - Milliseconds maxAgonyDuration = Seconds(volatileAgony->GetAmount()); + FloatSeconds maxAgonyDuration(volatileAgony->GetAmount()); if (Milliseconds(agonyAura->GetDuration()) <= maxAgonyDuration) caster->CastSpell(target, SPELL_WARLOCK_VOLATILE_AGONY_DAMAGE, CastSpellExtraArgs() .SetTriggerFlags(TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR) diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp index edee2fc2c6..e7e7203ed4 100644 --- a/src/server/scripts/Spells/spell_warrior.cpp +++ b/src/server/scripts/Spells/spell_warrior.cpp @@ -166,7 +166,7 @@ class spell_warr_anger_management_proc : public AuraScript { static bool ValidateProc(AuraEffect const* aurEff, ProcEventInfo const& eventInfo, ChrSpecialization spec) { - if (aurEff->GetAmount() == 0) + if (aurEff->GetAmountAsInt() == 0) return false; Player const* player = eventInfo.GetActor()->ToPlayer(); @@ -222,7 +222,7 @@ class spell_warr_anger_management_proc : public AuraScript void HandleProc(AuraEffect const* aurEff, ProcEventInfo const& eventInfo, std::span spellIds) const { int32 rageCost = *eventInfo.GetProcSpell()->GetPowerTypeCostAmount(POWER_RAGE) / 10; // db values are 10x the actual rage cost - float multiplier = static_cast(rageCost) / static_cast(aurEff->GetAmount()); + SpellEffectValue multiplier = static_cast(rageCost) / aurEff->GetAmount(); Milliseconds cooldownMod = -duration_cast(multiplier * CooldownReduction); for (int32 spellId : spellIds) @@ -310,7 +310,7 @@ class spell_warr_bloodsurge : public AuraScript Trinity::UnitWorker worker(caster, work); Cell::VisitAllObjects(caster, worker, 50.0f); - float chance = std::sqrt(rends) * aurEff->GetAmount(); + SpellEffectValue chance = std::sqrt(rends) * aurEff->GetAmount(); if (!roll_chance_f(chance)) return; @@ -624,7 +624,7 @@ class spell_warr_deft_experience : public SpellScript Unit const* caster = GetCaster(); if (Aura* enrageAura = caster->GetAura(SPELL_WARRIOR_ENRAGE)) if (AuraEffect const* aurEff = caster->GetAuraEffect(SPELL_WARRIOR_DEFT_EXPERIENCE, EFFECT_1)) - enrageAura->SetDuration(enrageAura->GetDuration() + (aurEff->GetAmount() * (IsHitCrit() ? 2 : 1))); + enrageAura->SetDuration(enrageAura->GetDuration() + (aurEff->GetAmountAsInt() * (IsHitCrit() ? 2 : 1))); } void Register() override @@ -645,7 +645,7 @@ class spell_warr_devastator : public AuraScript { if (GetTarget()->GetSpellHistory()->HasCooldown(SPELL_WARRIOR_SHIELD_SLAM)) { - if (roll_chance_i(GetEffectInfo(EFFECT_1).CalcValue())) + if (roll_chance_f(GetEffectInfo(EFFECT_1).CalcValue())) { GetTarget()->GetSpellHistory()->ResetCooldown(SPELL_WARRIOR_SHIELD_SLAM, true); GetTarget()->CastSpell(GetTarget(), SPELL_WARRIOR_SHIELD_SLAM_MARKER, TRIGGERED_IGNORE_CAST_IN_PROGRESS); @@ -706,7 +706,7 @@ class spell_warr_enrage_proc : public AuraScript } } - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } void HandleProc(ProcEventInfo const& eventInfo) @@ -768,7 +768,7 @@ class spell_warr_execute : public SpellScript if (Aura* suddenDeathAura = GetCaster()->GetAura(SPELL_WARRIOR_SUDDEN_DEATH_BUFF)) if (GetSpell()->m_appliedMods.contains(suddenDeathAura)) if (AuraEffect const* suddenDeathTalentAura = GetCaster()->GetAuraEffect(SPELL_WARRIOR_SUDDEN_DEATH, EFFECT_0)) - return suddenDeathTalentAura->GetAmount() * 10; + return suddenDeathTalentAura->GetAmountAsInt() * 10; return {}; } @@ -797,7 +797,7 @@ class spell_warr_execute : public SpellScript .BaseRageCost = baseCost, .OptionalRageCost = optionalCost, .DamageRageSpent = GetSuddenDeathRageCost().value_or(rageSpent), - .RefundRage = CalculatePct(rageSpent, GetEffectInfo(EFFECT_1).CalcValue()) + .RefundRage = CalculatePct(rageSpent, GetEffectInfo(EFFECT_1).CalcValueAsInt()) } }); } @@ -924,7 +924,7 @@ class spell_warr_frothing_berserker : public AuraScript .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringSpell = procSpell, .TriggeringAura = aurEff, - .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, CalculatePct(spentRage, aurEff->GetAmount()) } } + .SpellValueOverrides = { { SPELLVALUE_BASE_POINT0, static_cast(CalculatePct(spentRage, aurEff->GetAmount())) } } }); } @@ -1193,15 +1193,15 @@ class spell_warr_improved_whirlwind : public SpellScript if (!caster) return; - int32 const ragePerTarget = GetEffectValue(); - int32 const baseRage = GetEffectInfo(EFFECT_0).CalcValue(); - int32 const maxRage = baseRage + (ragePerTarget * GetEffectInfo(EFFECT_2).CalcValue()); + int32 const ragePerTarget = GetEffectValueAsInt(); + int32 const baseRage = GetEffectInfo(EFFECT_0).CalcValueAsInt(); + int32 const maxRage = baseRage + (ragePerTarget * GetEffectInfo(EFFECT_2).CalcValueAsInt()); int32 const rageGained = std::min(baseRage + (targetsHit * ragePerTarget), maxRage); caster->CastSpell(nullptr, SPELL_WARRIOR_WHIRLWIND_ENERGIZE, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringSpell = GetSpell(), - .SpellValueOverrides = {{ SPELLVALUE_BASE_POINT0, rageGained * 10 } } + .SpellValueOverrides = {{ SPELLVALUE_BASE_POINT0, SpellEffectValue(rageGained * 10) } } }); ApplyWhirlwindCleaveAura(caster, GetCastDifficulty(), GetSpell()); @@ -1424,7 +1424,7 @@ class spell_warr_item_t10_prot_4p_bonus : public AuraScript PreventDefaultAction(); Unit* target = eventInfo.GetActionTarget(); - int32 bp0 = CalculatePct(target->GetMaxHealth(), GetEffectInfo(EFFECT_1).CalcValue()); + SpellEffectValue bp0 = CalculatePct(target->GetMaxHealth(), GetEffectInfo(EFFECT_1).CalcValue()); CastSpellExtraArgs args(TRIGGERED_FULL_MASK); args.AddSpellBP0(bp0); target->CastSpell(nullptr, SPELL_WARRIOR_STOICISM, args); @@ -1561,7 +1561,7 @@ protected: int64 const targetCount = GetUnitTargetCountForEffect(spellEffectInfo.EffectIndex); - if (targetCount < minTargetCount->GetAmount()) + if (targetCount < minTargetCount->GetAmountAsInt()) return; if (AuraEffect const* aurEff = meatCleaver->GetEffect(EFFECT_0)) @@ -1635,14 +1635,14 @@ class spell_warr_raging_blow_cooldown_reset : public SpellScript { // it is currently impossible to have Wrath and Fury without having Improved Raging Blow, but we will check it anyway Unit* caster = GetCaster(); - int32 value = 0; + SpellEffectValue value = 0; if (caster->HasAura(SPELL_WARRIOR_IMPROVED_RAGING_BLOW)) value = GetEffectValue(); if (AuraEffect const* auraEffect = caster->GetAuraEffect(SPELL_WARRIOR_WRATH_AND_FURY, EFFECT_0)) value += auraEffect->GetAmount(); - if (roll_chance_i(value)) + if (roll_chance_f(value)) { caster->CastSpell(nullptr, SPELL_WARRIOR_ALWAYS_ANGRY, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, @@ -1674,7 +1674,7 @@ class spell_warr_rallying_cry : public SpellScript void HandleScript(SpellEffIndex /*effIndex*/) { CastSpellExtraArgs args(TRIGGERED_FULL_MASK); - args.AddSpellMod(SPELLVALUE_BASE_POINT0, int32(GetHitUnit()->CountPctFromMaxHealth(GetEffectValue()))); + args.AddSpellMod(SPELLVALUE_BASE_POINT0, SpellEffectValue(GetHitUnit()->CountPctFromMaxHealth(GetEffectValue()))); GetCaster()->CastSpell(GetHitUnit(), SPELL_WARRIOR_RALLYING_CRY, args); } @@ -1746,8 +1746,8 @@ class spell_warr_rumbling_earth : public SpellScript if (!minTargetCount || !cooldownReduction) return; - if (GetUnitTargetCountForEffect(EFFECT_0) >= minTargetCount->GetAmount()) - GetCaster()->GetSpellHistory()->ModifyCooldown(GetSpellInfo()->Id, Seconds(-cooldownReduction->GetAmount())); + if (GetUnitTargetCountForEffect(EFFECT_0) >= minTargetCount->GetAmountAsInt()) + GetCaster()->GetSpellHistory()->ModifyCooldown(GetSpellInfo()->Id, -duration_cast(FloatSeconds(cooldownReduction->GetAmount()))); } void Register() override @@ -1873,7 +1873,7 @@ class spell_warr_strategist : public AuraScript static bool CheckProc(AuraScript const&, AuraEffect const* aurEff, ProcEventInfo const& /*procEvent*/) { - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } void HandleCooldown(AuraEffect const* /*aurEff*/, ProcEventInfo const& /*procEvent*/) const @@ -2000,7 +2000,7 @@ class spell_warr_tactician : public AuraScript if (!procSpell->CalcPowerCost(POWER_RAGE, false, eventInfo.GetActor(), SpellSchoolMask(procSpell->SchoolMask))) return false; - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } static void HandleProc(AuraScript const&, AuraEffect const* aurEff, ProcEventInfo const& eventInfo) @@ -2047,7 +2047,7 @@ class spell_warr_tenderize : public AuraScript target->CastSpell(nullptr, SPELL_WARRIOR_SLAUGHTERING_STRIKES_BUFF, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringSpell = eventInfo.GetProcSpell(), - .SpellValueOverrides = { { SPELLVALUE_AURA_STACK, aurEff->GetAmount() } } + .SpellValueOverrides = { { SPELLVALUE_AURA_STACK, aurEff->GetAmountAsInt() } } }); } @@ -2083,7 +2083,7 @@ class spell_warr_thunder_blast_aura : public AuraScript static bool CheckProc(AuraScript const&, AuraEffect const* aurEff, ProcEventInfo const& /*eventInfo*/) { - return roll_chance_i(aurEff->GetAmount()); + return roll_chance_f(aurEff->GetAmount()); } void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo const& /*eventInfo*/) const @@ -2193,7 +2193,7 @@ class spell_warr_trauma : public AuraScript { Unit* target = eventInfo.GetActionTarget(); //Get 25% of damage from the spell casted (Slam & Whirlwind) plus Remaining Damage from Aura - int32 damage = int32(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount()) / sSpellMgr->AssertSpellInfo(SPELL_WARRIOR_TRAUMA_EFFECT, GetCastDifficulty())->GetEffect(EFFECT_0).GetPeriodicTickCount()); + SpellEffectValue damage = CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetAmount()) / sSpellMgr->AssertSpellInfo(SPELL_WARRIOR_TRAUMA_EFFECT, GetCastDifficulty())->GetEffect(EFFECT_0).GetPeriodicTickCount(); CastSpellExtraArgs args(TRIGGERED_FULL_MASK); args.AddSpellMod(SPELLVALUE_BASE_POINT0, damage); GetCaster()->CastSpell(target, SPELL_WARRIOR_TRAUMA_EFFECT, args); @@ -2240,7 +2240,7 @@ class spell_warr_unbridled_ferocity : public AuraScript void HandleProc(ProcEventInfo& /*eventInfo*/) const { - int32 durationMs = GetEffect(EFFECT_1)->GetAmount(); + int32 durationMs = GetEffect(EFFECT_1)->GetAmountAsInt(); GetTarget()->CastSpell(nullptr, SPELL_WARRIOR_RECKLESSNESS, CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR | TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD, @@ -2250,7 +2250,7 @@ class spell_warr_unbridled_ferocity : public AuraScript bool CheckProc(ProcEventInfo& /*eventInfo*/) const { - return roll_chance_i(GetEffect(EFFECT_0)->GetAmount()); + return roll_chance_f(GetEffect(EFFECT_0)->GetAmount()); } void Register() override diff --git a/src/server/scripts/World/areatrigger_scripts.cpp b/src/server/scripts/World/areatrigger_scripts.cpp index 45cfcd40ce..407262b888 100644 --- a/src/server/scripts/World/areatrigger_scripts.cpp +++ b/src/server/scripts/World/areatrigger_scripts.cpp @@ -519,7 +519,7 @@ struct at_abyssal_portal_harbinger : AreaTriggerAI void OnCreate(Spell const* creatingSpell) override { if (Unit* caster = at->GetCaster()) - _remainingSummons = creatingSpell->GetSpellInfo()->GetEffect(EFFECT_0).CalcValue(caster); + _remainingSummons = creatingSpell->GetSpellInfo()->GetEffect(EFFECT_0).CalcValueAsInt(caster); _scheduler.Schedule(500ms, [this](TaskContext task) { diff --git a/src/server/scripts/Zandalar/AtalDazar/boss_priestess_alun_za.cpp b/src/server/scripts/Zandalar/AtalDazar/boss_priestess_alun_za.cpp index 24153b4f79..6f6533c104 100644 --- a/src/server/scripts/Zandalar/AtalDazar/boss_priestess_alun_za.cpp +++ b/src/server/scripts/Zandalar/AtalDazar/boss_priestess_alun_za.cpp @@ -401,7 +401,7 @@ class spell_priestess_alun_za_energy_regen : public AuraScript { void OnPeriodic(AuraEffect const* aurEff) const { - GetTarget()->ModifyPower(POWER_ENERGY, aurEff->GetAmount() / 10); + GetTarget()->ModifyPower(POWER_ENERGY, aurEff->GetAmountAsInt() / 10); } void Register() override @@ -415,7 +415,7 @@ class spell_priestess_alun_za_agitate : public SpellScript { void HandleScript(SpellEffIndex /*effIndex*/) const { - GetCaster()->CastSpell(GetHitUnit(), GetEffectValue(), CastSpellExtraArgsInit{ + GetCaster()->CastSpell(GetHitUnit(), GetEffectValueAsInt(), CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringSpell = GetSpell(), }); @@ -442,7 +442,7 @@ class spell_priestess_alun_za_molten_gold : public AuraScript return; Unit* target = GetTarget(); - target->CastSpell(target, aurEff->GetAmount(), CastSpellExtraArgsInit{ + target->CastSpell(target, aurEff->GetAmountAsInt(), CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringAura = aurEff }); @@ -580,7 +580,7 @@ class spell_priestess_alun_za_transfusion_heal : public SpellScript { void HandleHitTarget(SpellEffIndex /*effIndex*/) { - SetEffectValue(GetEffectValue() / 100); + SetEffectValue(GetEffectValue() / 100.0); } void Register() override @@ -594,7 +594,7 @@ class spell_priestess_alun_za_transfusion_damage : public SpellScript { void HandleHitTarget(SpellEffIndex /*effIndex*/) { - SetEffectValue(GetEffectValue() / 100); + SetEffectValue(GetEffectValue() / 100.0); } void Register() override diff --git a/src/server/scripts/Zandalar/AtalDazar/boss_volkaal.cpp b/src/server/scripts/Zandalar/AtalDazar/boss_volkaal.cpp index e09a06c665..ff9abd0922 100644 --- a/src/server/scripts/Zandalar/AtalDazar/boss_volkaal.cpp +++ b/src/server/scripts/Zandalar/AtalDazar/boss_volkaal.cpp @@ -267,7 +267,7 @@ class spell_volkaal_lingering_nausea : public AuraScript Unit* target = GetTarget(); if (Unit* caster = GetCaster()) - caster->CastSpell(target, aurEff->GetAmount(), CastSpellExtraArgsInit{ + caster->CastSpell(target, aurEff->GetAmountAsInt(), CastSpellExtraArgsInit{ .TriggerFlags = TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_DONT_REPORT_CAST_ERROR, .TriggeringAura = aurEff }); diff --git a/src/server/scripts/Zandalar/Underrot/boss_elder_leaxa.cpp b/src/server/scripts/Zandalar/Underrot/boss_elder_leaxa.cpp index a22a79be16..3e45f91446 100644 --- a/src/server/scripts/Zandalar/Underrot/boss_elder_leaxa.cpp +++ b/src/server/scripts/Zandalar/Underrot/boss_elder_leaxa.cpp @@ -212,13 +212,13 @@ class spell_sanguine_feast_selector : public SpellScript { bool Validate(SpellInfo const* spellInfo) override { - return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValue()) }); + return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) }); } void HandleHit(SpellEffIndex /*effIndex*/) { Unit* caster = GetCaster(); - caster->CastSpell(GetHitUnit(), uint32(GetEffectInfo().CalcValue(caster))); + caster->CastSpell(GetHitUnit(), uint32(GetEffectInfo().CalcValueAsInt(caster))); } void Register() override