diff --git a/src/server/game/Entities/Creature/TemporarySummon.cpp b/src/server/game/Entities/Creature/TemporarySummon.cpp index 68e2bf6d3c..a0a52ac8da 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.cpp +++ b/src/server/game/Entities/Creature/TemporarySummon.cpp @@ -24,6 +24,7 @@ #include "ObjectAccessor.h" #include "Pet.h" #include "Player.h" +#include "Stats.h" TempSummon::TempSummon(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject) : Creature(isWorldObject), m_Properties(properties), m_type(TEMPSUMMON_MANUAL_DESPAWN), diff --git a/src/server/game/Entities/Creature/TemporarySummon.h b/src/server/game/Entities/Creature/TemporarySummon.h index 8385dd150c..60f0d1316c 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.h +++ b/src/server/game/Entities/Creature/TemporarySummon.h @@ -131,7 +131,7 @@ class TC_GAME_API Guardian : public Minion void SetBonusDamage(int32 damage); protected: int32 m_bonusSpellDamage; - float m_statFromOwner[AsUnderlyingType(StatType::Max)]; + float m_statFromOwner[5]; }; class TC_GAME_API Puppet : public Minion diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index f1b97dee40..7f7854f006 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -102,6 +102,7 @@ #include "SpellHistory.h" #include "SpellMgr.h" #include "SpellPackets.h" +#include "Stats.h" #include "StringConvert.h" #include "TerrainMgr.h" #include "TicketMgr.h" diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index c745d02bc3..46a1fbde1f 100644 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -26,6 +26,7 @@ #include "SpellAuraEffects.h" #include "SpellAuras.h" #include "SpellMgr.h" +#include "Stats.h" #include "World.h" #include #include diff --git a/src/server/game/Entities/Unit/Stats.cpp b/src/server/game/Entities/Unit/Stats.cpp index 69693011f5..3bfe9fb875 100644 --- a/src/server/game/Entities/Unit/Stats.cpp +++ b/src/server/game/Entities/Unit/Stats.cpp @@ -75,7 +75,7 @@ void Stats::RemoveBaseStatModifier(StatType statType, int32 value) /// @param statType The stat which multiplier value will be updated void Stats::UpdateBaseStatMultiplier(StatType statType) { - if (statType == StatType::AllStats) + if (statType == StatType::AllStats || statType == StatType::AllStats2) { for (StatType stat : AllStats) { @@ -84,13 +84,6 @@ void Stats::UpdateBaseStatMultiplier(StatType statType) updateStat(stat); } } - else if (statType == StatType::PrimaryStat) - { - StatType primaryStat = GetPrimaryStat(); - float multiplier = getAuraMultiplierForStatType(SPELL_AURA_MOD_PERCENT_STAT, primaryStat); - _basePctMultipliers[AsUnderlyingType(primaryStat)] = multiplier; - updateStat(primaryStat); - } else { float multiplier = getAuraMultiplierForStatType(SPELL_AURA_MOD_PERCENT_STAT, statType); @@ -104,7 +97,7 @@ void Stats::UpdateBaseStatMultiplier(StatType statType) /// @param statType The stat which modifier value will be updated void Stats::UpdateTotalStatModifier(StatType statType) { - if (statType == StatType::AllStats) + if (statType == StatType::AllStats || statType == StatType::AllStats2) { for (StatType stat : AllStats) { @@ -113,13 +106,6 @@ void Stats::UpdateTotalStatModifier(StatType statType) updateStat(stat); } } - else if (statType == StatType::PrimaryStat) - { - StatType primaryStat = GetPrimaryStat(); - int32 modifier = getAuraModifierForStatType(SPELL_AURA_MOD_STAT, primaryStat); - _totalModifiers[AsUnderlyingType(primaryStat)] = modifier; - updateStat(primaryStat); - } else { int32 modifier = getAuraModifierForStatType(SPELL_AURA_MOD_STAT, statType); @@ -133,7 +119,7 @@ void Stats::UpdateTotalStatModifier(StatType statType) /// @param statType The stat which multiplier value will be updated void Stats::UpdateTotalStatMultiplier(StatType statType) { - if (statType == StatType::AllStats) + if (statType == StatType::AllStats || statType == StatType::AllStats2) { for (StatType stat : AllStats) { @@ -142,13 +128,6 @@ void Stats::UpdateTotalStatMultiplier(StatType statType) updateStat(stat); } } - else if (statType == StatType::PrimaryStat) - { - StatType primaryStat = GetPrimaryStat(); - float multiplier = getAuraMultiplierForStatType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, primaryStat); - _totalPctMultipliers[AsUnderlyingType(primaryStat)] = multiplier; - updateStat(primaryStat); - } else { float multiplier = getAuraMultiplierForStatType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, statType); @@ -238,7 +217,7 @@ void Stats::updateStat(StatType statType) if (flatStatValue < baseTotalValue) posStatValue += baseTotalValue - flatStatValue; else - negStatValue += flatStatValue - baseTotalValue; + negStatValue += baseTotalValue - flatStatValue; // ==== Calculate the total value (Total value buff auras) int32 totalModifier = _totalModifiers[AsUnderlyingType(statType)]; @@ -255,7 +234,7 @@ void Stats::updateStat(StatType statType) if (totalValue < statValue) posStatValue += statValue - totalValue; else - negStatValue += totalValue - statValue; + negStatValue += statValue - totalValue; // ==== Apply the stats _owner->SetInt32Value(UNIT_FIELD_STAT0 + AsUnderlyingType(statType), statValue); @@ -302,10 +281,7 @@ float Stats::getAuraMultiplierForStatType(AuraType auraType, StatType statType) float multiplier = _owner->GetTotalAuraMultiplier(auraType, [&](AuraEffect const* aurEff) { StatType auraStatType = static_cast(aurEff->GetMiscValue()); - if (auraStatType == StatType::AllStats || auraStatType == statType) - return true; - - if (auraStatType == StatType::PrimaryStat && statType == GetPrimaryStat()) + if (auraStatType == StatType::AllStats || auraStatType == StatType::AllStats2 || auraStatType == statType) return true; return false; @@ -319,10 +295,7 @@ int32 Stats::getAuraModifierForStatType(AuraType auraType, StatType statType) co int32 modifier = _owner->GetTotalAuraModifier(auraType, [&](AuraEffect const* aurEff) { StatType auraStatType = static_cast(aurEff->GetMiscValue()); - if (auraStatType == StatType::AllStats || auraStatType == statType) - return true; - - if (auraStatType == StatType::PrimaryStat && statType == GetPrimaryStat()) + if (auraStatType == StatType::AllStats || auraStatType == StatType::AllStats2 || auraStatType == statType) return true; return false; diff --git a/src/server/game/Entities/Unit/Stats.h b/src/server/game/Entities/Unit/Stats.h index ad0d8e5a0c..690486f615 100644 --- a/src/server/game/Entities/Unit/Stats.h +++ b/src/server/game/Entities/Unit/Stats.h @@ -27,7 +27,7 @@ enum AuraType : uint32; enum class StatType : int8 { - PrimaryStat = -2, + AllStats2 = -2, // There is only one spell using this and it also states that it increases all stats AllStats = -1, Strength = 0, Agility = 1, diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 03a7237e55..411082eb3e 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -13629,8 +13629,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) fieldBuffer << uint32(m_floatValues[index] < 0 ? 0 : m_floatValues[index]); } // there are some float values which may be negative or can't get negative due to other checks - else if ((index >= UNIT_FIELD_NEGSTAT0 && index <= UNIT_FIELD_NEGSTAT4) || - (index >= UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + 6)) || + else if ((index >= UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + 6)) || (index >= UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + 6))) { fieldBuffer << uint32(m_floatValues[index]); diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 9051744742..437ebcfa01 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -22,7 +22,6 @@ #include "Object.h" #include "SpellAuraDefines.h" #include "SpellDefines.h" -#include "Stats.h" #include "ThreatManager.h" #include "Timer.h" #include "UnitDefines.h" @@ -105,6 +104,8 @@ enum ProcFlagsSpellType : uint32; enum ZLiquidStatus : uint32; enum CharmType : uint8; +enum class StatType : int8; + namespace Movement { class ExtraMovementStatusElement; diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index f1b81dbe99..8aefc1dc2a 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -3570,7 +3570,7 @@ void AuraEffect::HandleAuraModStat(AuraApplication const* aurApp, uint8 mode, bo return; StatType stat = static_cast(GetMiscValue()); - if (stat < StatType::PrimaryStat || stat >= StatType::Max) + if (stat < StatType::AllStats2 || stat >= StatType::Max) { TC_LOG_ERROR("spells", "WARNING: Spell %u effect %u has an unsupported misc value (%i) for SPELL_AURA_MOD_STAT ", GetId(), GetEffIndex(), GetMiscValue()); return; @@ -3586,7 +3586,7 @@ void AuraEffect::HandleModPercentStat(AuraApplication const* aurApp, uint8 mode, return; StatType stat = static_cast(GetMiscValue()); - if (stat < StatType::PrimaryStat || stat >= StatType::Max) + if (stat < StatType::AllStats2 || stat >= StatType::Max) { TC_LOG_ERROR("spells", "WARNING: Spell %u effect %u has an unsupported misc value (%i) for SPELL_AURA_MOD_PERCENT_STAT ", GetId(), GetEffIndex(), GetMiscValue()); return; @@ -3676,7 +3676,7 @@ void AuraEffect::HandleModTotalPercentStat(AuraApplication const* aurApp, uint8 return; StatType stat = static_cast(GetMiscValue()); - if (stat < StatType::PrimaryStat || stat >= StatType::Max) + if (stat < StatType::AllStats2 || stat >= StatType::Max) { TC_LOG_ERROR("spells", "WARNING: Spell %u effect %u has an unsupported misc value (%i) for SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE ", GetId(), GetEffIndex(), GetMiscValue()); return; diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index d82bb8d918..c9b322772f 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -22,10 +22,10 @@ * Scriptnames of files in this file should be prefixed with "spell_gen_" */ -#include "ScriptMgr.h" #include "Battleground.h" #include "CellImpl.h" #include "Containers.h" +#include "CreatureAIImpl.h" #include "DBCStores.h" #include "GameTime.h" #include "GridNotifiersImpl.h" @@ -36,13 +36,14 @@ #include "ObjectAccessor.h" #include "Pet.h" #include "ReputationMgr.h" +#include "ScriptMgr.h" #include "SkillDiscovery.h" #include "SpellAuraEffects.h" #include "SpellHistory.h" #include "SpellMgr.h" #include "SpellScript.h" +#include "Stats.h" #include "Vehicle.h" -#include "CreatureAIImpl.h" namespace Spells::Generic { diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 1c53e2acd4..e9fc9a889a 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -21,20 +21,21 @@ * Scriptnames of files in this file should be prefixed with "spell_item_". */ -#include "ScriptMgr.h" #include "Battleground.h" -#include "CreatureAIImpl.h" #include "Containers.h" +#include "CreatureAIImpl.h" #include "DBCStores.h" #include "Map.h" #include "ObjectMgr.h" #include "Player.h" +#include "ScriptMgr.h" #include "ScriptedCreature.h" #include "SkillDiscovery.h" #include "SpellAuraEffects.h" #include "SpellHistory.h" #include "SpellMgr.h" #include "SpellScript.h" +#include "Stats.h" namespace Spells::Items { diff --git a/src/server/scripts/Spells/spell_pet.cpp b/src/server/scripts/Spells/spell_pet.cpp index 7bc8f90e54..bd70bc96f2 100644 --- a/src/server/scripts/Spells/spell_pet.cpp +++ b/src/server/scripts/Spells/spell_pet.cpp @@ -21,13 +21,14 @@ * Scriptnames of files in this file should be prefixed with "spell_dk_". */ -#include "ScriptMgr.h" #include "ObjectMgr.h" #include "Pet.h" #include "Player.h" +#include "ScriptMgr.h" #include "SpellAuraEffects.h" #include "SpellMgr.h" #include "SpellScript.h" +#include "Stats.h" #include "Unit.h" namespace Spells::Pets diff --git a/src/server/scripts/Spells/spell_shaman.cpp b/src/server/scripts/Spells/spell_shaman.cpp index 055ecc2ba9..5593ec0323 100644 --- a/src/server/scripts/Spells/spell_shaman.cpp +++ b/src/server/scripts/Spells/spell_shaman.cpp @@ -21,14 +21,15 @@ * Scriptnames of files in this file should be prefixed with "spell_sha_". */ -#include "ScriptMgr.h" -#include "Player.h" #include "GridNotifiers.h" #include "Item.h" +#include "Player.h" +#include "ScriptMgr.h" #include "SpellAuraEffects.h" #include "SpellHistory.h" #include "SpellMgr.h" #include "SpellScript.h" +#include "Stats.h" #include "TemporarySummon.h" #include "Unit.h"