diff options
Diffstat (limited to 'src/server/game/Entities/Unit')
| -rw-r--r-- | src/server/game/Entities/Unit/StatSystem.cpp | 93 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 165 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 38 |
3 files changed, 148 insertions, 148 deletions
diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index 7e0d38c9875..6d940a91582 100644 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -160,9 +160,9 @@ void Player::ApplySpellPowerBonus(int32 amount, bool apply) apply = _ModifyUInt32(apply, m_baseSpellPower, amount); // For speed just update for client - ApplyModUInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, amount, apply); + ApplyModUInt32Value(ACTIVE_PLAYER_FIELD_MOD_HEALING_DONE_POS, amount, apply); for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) - ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, amount, apply); + ApplyModUInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, amount, apply); if (HasAuraType(SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT)) { @@ -176,18 +176,18 @@ void Player::UpdateSpellDamageAndHealingBonus() // Magic damage modifiers implemented in Unit::SpellDamageBonusDone // This information for client side use only // Get healing bonus for all schools - SetStatInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, SpellBaseHealingBonusDone(SPELL_SCHOOL_MASK_ALL)); + SetStatInt32Value(ACTIVE_PLAYER_FIELD_MOD_HEALING_DONE_POS, SpellBaseHealingBonusDone(SPELL_SCHOOL_MASK_ALL)); // Get damage bonus for all schools Unit::AuraEffectList const& modDamageAuras = GetAuraEffectsByType(SPELL_AURA_MOD_DAMAGE_DONE); for (uint16 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) { - SetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i, std::accumulate(modDamageAuras.begin(), modDamageAuras.end(), 0, [i](int32 negativeMod, AuraEffect const* aurEff) + SetInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i, std::accumulate(modDamageAuras.begin(), modDamageAuras.end(), 0, [i](int32 negativeMod, AuraEffect const* aurEff) { if (aurEff->GetAmount() < 0 && aurEff->GetMiscValue() & (1 << i)) negativeMod += aurEff->GetAmount(); return negativeMod; })); - SetStatInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, SpellBaseDamageBonusDone(SpellSchoolMask(1 << i)) - GetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i)); + SetStatInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, SpellBaseDamageBonusDone(SpellSchoolMask(1 << i)) - GetInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i)); } if (HasAuraType(SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT)) @@ -231,7 +231,7 @@ bool Player::UpdateAllStats() void Player::ApplySpellPenetrationBonus(int32 amount, bool apply) { - ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, -amount, apply); + ApplyModInt32Value(ACTIVE_PLAYER_FIELD_MOD_TARGET_RESISTANCE, -amount, apply); m_spellPenetrationItemMod += apply ? amount : -amount; } @@ -239,8 +239,7 @@ void Player::UpdateResistances(uint32 school) { if (school > SPELL_SCHOOL_NORMAL) { - float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school)); - SetResistance(SpellSchools(school), int32(value)); + Unit::UpdateResistances(school); Pet* pet = GetPet(); if (pet) @@ -255,6 +254,7 @@ void Player::UpdateArmor() UnitMods unitMod = UNIT_MOD_ARMOR; float value = GetModifierValue(unitMod, BASE_VALUE); // base armor (from items) + float baseValue = value; value *= GetModifierValue(unitMod, BASE_PCT); // armor percent from items value += GetModifierValue(unitMod, TOTAL_VALUE); @@ -268,7 +268,7 @@ void Player::UpdateArmor() value *= GetModifierValue(unitMod, TOTAL_PCT); - SetArmor(int32(value)); + SetArmor(int32(baseValue), int32(value - baseValue)); Pet* pet = GetPet(); if (pet) @@ -360,11 +360,11 @@ void Player::UpdateAttackPowerAndDamage(bool ranged) } else { - int32 minSpellPower = GetInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS); + int32 minSpellPower = GetInt32Value(ACTIVE_PLAYER_FIELD_MOD_HEALING_DONE_POS); for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) - minSpellPower = std::min(minSpellPower, GetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i)); + minSpellPower = std::min(minSpellPower, GetInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i)); - val2 = CalculatePct(float(minSpellPower), GetFloatValue(PLAYER_FIELD_OVERRIDE_AP_BY_SPELL_POWER_PERCENT)); + val2 = CalculatePct(float(minSpellPower), GetFloatValue(ACTIVE_PLAYER_FIELD_OVERRIDE_AP_BY_SPELL_POWER_PERCENT)); } SetModifierValue(unitMod, BASE_VALUE, val2); @@ -488,7 +488,7 @@ void Player::UpdateBlockPercentage() value = value < 0.0f ? 0.0f : value; } - SetStatFloatValue(PLAYER_BLOCK_PERCENTAGE, value); + SetStatFloatValue(ACTIVE_PLAYER_FIELD_BLOCK_PERCENTAGE, value); } void Player::UpdateCritPercentage(WeaponAttackType attType) @@ -501,18 +501,18 @@ void Player::UpdateCritPercentage(WeaponAttackType attType) { case OFF_ATTACK: modGroup = OFFHAND_CRIT_PERCENTAGE; - index = PLAYER_OFFHAND_CRIT_PERCENTAGE; + index = ACTIVE_PLAYER_FIELD_OFFHAND_CRIT_PERCENTAGE; cr = CR_CRIT_MELEE; break; case RANGED_ATTACK: modGroup = RANGED_CRIT_PERCENTAGE; - index = PLAYER_RANGED_CRIT_PERCENTAGE; + index = ACTIVE_PLAYER_FIELD_RANGED_CRIT_PERCENTAGE; cr = CR_CRIT_RANGED; break; case BASE_ATTACK: default: modGroup = CRIT_PERCENTAGE; - index = PLAYER_CRIT_PERCENTAGE; + index = ACTIVE_PLAYER_FIELD_CRIT_PERCENTAGE; cr = CR_CRIT_MELEE; break; } @@ -545,13 +545,13 @@ void Player::UpdateMastery() { if (!CanUseMastery()) { - SetFloatValue(PLAYER_MASTERY, 0.0f); + SetFloatValue(ACTIVE_PLAYER_FIELD_MASTERY, 0.0f); return; } float value = GetTotalAuraModifier(SPELL_AURA_MASTERY); value += GetRatingBonusValue(CR_MASTERY); - SetFloatValue(PLAYER_MASTERY, value); + SetFloatValue(ACTIVE_PLAYER_FIELD_MASTERY, value); ChrSpecializationEntry const* chrSpec = sChrSpecializationStore.LookupEntry(GetUInt32Value(PLAYER_FIELD_CURRENT_SPEC_ID)); if (!chrSpec) @@ -579,7 +579,7 @@ void Player::UpdateMastery() void Player::UpdateVersatilityDamageDone() { // No proof that CR_VERSATILITY_DAMAGE_DONE is allways = PLAYER_VERSATILITY - SetUInt32Value(PLAYER_VERSATILITY, GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + CR_VERSATILITY_DAMAGE_DONE)); + SetUInt32Value(ACTIVE_PLAYER_FIELD_VERSATILITY, GetUInt32Value(ACTIVE_PLAYER_FIELD_COMBAT_RATING + CR_VERSATILITY_DAMAGE_DONE)); if (getClass() == CLASS_HUNTER) UpdateDamagePhysical(RANGED_ATTACK); @@ -596,7 +596,7 @@ void Player::UpdateHealingDonePercentMod() for (AuraEffect const* auraEffect : GetAuraEffectsByType(SPELL_AURA_MOD_HEALING_DONE_PERCENT)) AddPct(value, auraEffect->GetAmount()); - SetStatFloatValue(PLAYER_FIELD_MOD_HEALING_DONE_PCT, value); + SetStatFloatValue(ACTIVE_PLAYER_FIELD_MOD_HEALING_DONE_PCT, value); } const float m_diminishing_k[MAX_CLASSES] = @@ -651,7 +651,7 @@ void Player::UpdateParryPercentage() value = value < 0.0f ? 0.0f : value; } - SetStatFloatValue(PLAYER_PARRY_PERCENTAGE, value); + SetStatFloatValue(ACTIVE_PLAYER_FIELD_PARRY_PERCENTAGE, value); } void Player::UpdateDodgePercentage() @@ -686,7 +686,7 @@ void Player::UpdateDodgePercentage() value = value > sWorld->getFloatConfig(CONFIG_STATS_LIMITS_DODGE) ? sWorld->getFloatConfig(CONFIG_STATS_LIMITS_DODGE) : value; value = value < 0.0f ? 0.0f : value; - SetStatFloatValue(PLAYER_DODGE_PERCENTAGE, value); + SetStatFloatValue(ACTIVE_PLAYER_FIELD_DODGE_PERCENTAGE, value); } void Player::UpdateSpellCritChance() @@ -700,13 +700,13 @@ void Player::UpdateSpellCritChance() crit += GetRatingBonusValue(CR_CRIT_SPELL); // Store crit value - SetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1, crit); + SetFloatValue(ACTIVE_PLAYER_FIELD_SPELL_CRIT_PERCENTAGE1, crit); } void Player::UpdateArmorPenetration(int32 amount) { // Store Rating Value - SetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + CR_ARMOR_PENETRATION, amount); + SetUInt32Value(ACTIVE_PLAYER_FIELD_COMBAT_RATING + CR_ARMOR_PENETRATION, amount); } void Player::UpdateMeleeHitChances() @@ -746,10 +746,10 @@ void Player::UpdateExpertise(WeaponAttackType attack) switch (attack) { case BASE_ATTACK: - SetUInt32Value(PLAYER_EXPERTISE, expertise); + SetUInt32Value(ACTIVE_PLAYER_FIELD_EXPERTISE, expertise); break; case OFF_ATTACK: - SetUInt32Value(PLAYER_OFFHAND_EXPERTISE, expertise); + SetUInt32Value(ACTIVE_PLAYER_FIELD_OFFHAND_EXPERTISE, expertise); break; default: break; @@ -855,21 +855,11 @@ bool Creature::UpdateAllStats() return true; } -void Creature::UpdateResistances(uint32 school) -{ - if (school > SPELL_SCHOOL_NORMAL) - { - float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school)); - SetResistance(SpellSchools(school), int32(value)); - } - else - UpdateArmor(); -} - void Creature::UpdateArmor() { + float baseValue = GetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE); float value = GetTotalAuraModValue(UNIT_MOD_ARMOR); - SetArmor(int32(value)); + SetArmor(int32(baseValue), int32(value - baseValue)); } void Creature::UpdateMaxHealth() @@ -1077,13 +1067,18 @@ void Guardian::UpdateResistances(uint32 school) { if (school > SPELL_SCHOOL_NORMAL) { - float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school)); + float baseValue = GetModifierValue(UnitMods(UNIT_MOD_RESISTANCE_START + school), BASE_VALUE); + float bonusValue = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school)) - baseValue; // hunter and warlock pets gain 40% of owner's resistance if (IsPet()) - value += float(CalculatePct(m_owner->GetResistance(SpellSchools(school)), 40)); + { + baseValue += float(CalculatePct(m_owner->GetResistance(SpellSchools(school)), 40)); + bonusValue += float(CalculatePct(m_owner->GetBonusResistanceMod(SpellSchools(school)), 40)); + } - SetResistance(SpellSchools(school), int32(value)); + SetResistance(SpellSchools(school), int32(baseValue)); + SetBonusResistanceMod(SpellSchools(school), int32(bonusValue)); } else UpdateArmor(); @@ -1091,6 +1086,7 @@ void Guardian::UpdateResistances(uint32 school) void Guardian::UpdateArmor() { + float baseValue = 0.0f; float value = 0.0f; float bonus_armor = 0.0f; UnitMods unitMod = UNIT_MOD_ARMOR; @@ -1102,11 +1098,12 @@ void Guardian::UpdateArmor() bonus_armor = m_owner->GetArmor(); value = GetModifierValue(unitMod, BASE_VALUE); + baseValue = value; value *= GetModifierValue(unitMod, BASE_PCT); value += GetModifierValue(unitMod, TOTAL_VALUE) + bonus_armor; value *= GetModifierValue(unitMod, TOTAL_PCT); - SetArmor(int32(value)); + SetArmor(int32(baseValue), int32(value - baseValue)); } void Guardian::UpdateMaxHealth() @@ -1186,8 +1183,8 @@ void Guardian::UpdateAttackPowerAndDamage(bool ranged) //demons benefit from warlocks shadow or fire damage else if (IsPet()) { - int32 fire = owner->GetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE) - owner->GetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FIRE); - int32 shadow = owner->GetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW) - owner->GetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_SHADOW); + int32 fire = owner->GetInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE) - owner->GetInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FIRE); + int32 shadow = owner->GetInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW) - owner->GetInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_SHADOW); int32 maximum = (fire > shadow) ? fire : shadow; if (maximum < 0) maximum = 0; @@ -1197,7 +1194,7 @@ void Guardian::UpdateAttackPowerAndDamage(bool ranged) //water elementals benefit from mage's frost damage else if (GetEntry() == ENTRY_WATER_ELEMENTAL) { - int32 frost = owner->GetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FROST) - owner->GetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FROST); + int32 frost = owner->GetInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FROST) - owner->GetInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FROST); if (frost < 0) frost = 0; SetBonusDamage(int32(frost * 0.4f)); @@ -1230,14 +1227,14 @@ void Guardian::UpdateDamagePhysical(WeaponAttackType attType) //force of nature if (GetEntry() == ENTRY_TREANT) { - int32 spellDmg = m_owner->GetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_NATURE) - m_owner->GetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_NATURE); + int32 spellDmg = m_owner->GetInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_NATURE) - m_owner->GetInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_NATURE); if (spellDmg > 0) bonusDamage = spellDmg * 0.09f; } //greater fire elemental else if (GetEntry() == ENTRY_FIRE_ELEMENTAL) { - int32 spellDmg = m_owner->GetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE) - m_owner->GetInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FIRE); + int32 spellDmg = m_owner->GetInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE) - m_owner->GetInt32Value(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FIRE); if (spellDmg > 0) bonusDamage = spellDmg * 0.4f; } @@ -1266,5 +1263,5 @@ void Guardian::SetBonusDamage(int32 damage) { m_bonusSpellDamage = damage; if (GetOwner()->GetTypeId() == TYPEID_PLAYER) - GetOwner()->SetUInt32Value(PLAYER_PET_SPELL_POWER, damage); + GetOwner()->SetUInt32Value(ACTIVE_PLAYER_FIELD_PET_SPELL_POWER, damage); } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index bd375f96b6c..8261a97c32a 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -111,13 +111,13 @@ bool DispelableAura::RollDispel() const } DamageInfo::DamageInfo(Unit* attacker, Unit* victim, uint32 damage, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, DamageEffectType damageType, WeaponAttackType attackType) - : m_attacker(attacker), m_victim(victim), m_damage(damage), m_spellInfo(spellInfo), m_schoolMask(schoolMask), m_damageType(damageType), m_attackType(attackType), + : m_attacker(attacker), m_victim(victim), m_damage(damage), m_originalDamage(damage), m_spellInfo(spellInfo), m_schoolMask(schoolMask), m_damageType(damageType), m_attackType(attackType), m_absorb(0), m_resist(0), m_block(0), m_hitMask(0) { } DamageInfo::DamageInfo(CalcDamageInfo const& dmgInfo) - : m_attacker(dmgInfo.attacker), m_victim(dmgInfo.target), m_damage(dmgInfo.damage), m_spellInfo(nullptr), m_schoolMask(SpellSchoolMask(dmgInfo.damageSchoolMask)), + : m_attacker(dmgInfo.attacker), m_victim(dmgInfo.target), m_damage(dmgInfo.damage), m_originalDamage(dmgInfo.damage), m_spellInfo(nullptr), m_schoolMask(SpellSchoolMask(dmgInfo.damageSchoolMask)), m_damageType(DIRECT_DAMAGE), m_attackType(dmgInfo.attackType), m_absorb(dmgInfo.absorb), m_resist(dmgInfo.resist), m_block(dmgInfo.blocked_amount), m_hitMask(0) { switch (dmgInfo.TargetState) @@ -171,7 +171,7 @@ DamageInfo::DamageInfo(CalcDamageInfo const& dmgInfo) } DamageInfo::DamageInfo(SpellNonMeleeDamage const& spellNonMeleeDamage, DamageEffectType damageType, WeaponAttackType attackType, uint32 hitMask) - : m_attacker(spellNonMeleeDamage.attacker), m_victim(spellNonMeleeDamage.target), m_damage(spellNonMeleeDamage.damage), + : m_attacker(spellNonMeleeDamage.attacker), m_victim(spellNonMeleeDamage.target), m_damage(spellNonMeleeDamage.damage), m_originalDamage(spellNonMeleeDamage.originalDamage), m_spellInfo(sSpellMgr->GetSpellInfo(spellNonMeleeDamage.SpellID)), m_schoolMask(SpellSchoolMask(spellNonMeleeDamage.schoolMask)), m_damageType(damageType), m_attackType(attackType), m_absorb(spellNonMeleeDamage.absorb), m_resist(spellNonMeleeDamage.resist), m_block(spellNonMeleeDamage.blocked), m_hitMask(hitMask) { @@ -226,7 +226,7 @@ uint32 DamageInfo::GetHitMask() const } HealInfo::HealInfo(Unit* healer, Unit* target, uint32 heal, SpellInfo const* spellInfo, SpellSchoolMask schoolMask) - : _healer(healer), _target(target), _heal(heal), _effectiveHeal(0), _absorb(0), _spellInfo(spellInfo), _schoolMask(schoolMask), _hitMask(0) + : _healer(healer), _target(target), _heal(heal), _originalHeal(heal), _effectiveHeal(0), _absorb(0), _spellInfo(spellInfo), _schoolMask(schoolMask), _hitMask(0) { } @@ -279,8 +279,8 @@ SpellSchoolMask ProcEventInfo::GetSchoolMask() const } SpellNonMeleeDamage::SpellNonMeleeDamage(Unit* _attacker, Unit* _target, uint32 _SpellID, uint32 _SpellXSpellVisualID, uint32 _schoolMask, ObjectGuid _castId) - : target(_target), attacker(_attacker), castId(_castId), SpellID(_SpellID), SpellXSpellVisualID(_SpellXSpellVisualID), damage(0), schoolMask(_schoolMask), - absorb(0), resist(0), periodicLog(false), blocked(0), HitInfo(0), cleanDamage(0), fullBlock(false), preHitHealth(_target->GetHealth()) + : target(_target), attacker(_attacker), castId(_castId), SpellID(_SpellID), SpellXSpellVisualID(_SpellXSpellVisualID), damage(0), originalDamage(0), + schoolMask(_schoolMask), absorb(0), resist(0), periodicLog(false), blocked(0), HitInfo(0), cleanDamage(0), fullBlock(false), preHitHealth(_target->GetHealth()) { } @@ -297,7 +297,7 @@ Unit::Unit(bool isWorldObject) : m_objectType |= TYPEMASK_UNIT; m_objectTypeId = TYPEID_UNIT; - m_updateFlag = UPDATEFLAG_LIVING; + m_updateFlag.MovementUpdate = true; for (uint32 i = 0; i < MAX_ATTACK; ++i) { @@ -1181,6 +1181,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 dama damage = 0; damageInfo->damage = damage; + damageInfo->originalDamage = damage; DamageInfo dmgInfo(*damageInfo, SPELL_DIRECT_DAMAGE, BASE_ATTACK, PROC_HIT_NONE); CalcAbsorbResist(dmgInfo); damageInfo->absorb = dmgInfo.GetAbsorb(); @@ -1227,6 +1228,7 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam damageInfo->damageSchoolMask = GetMeleeDamageSchoolMask(); damageInfo->attackType = attackType; damageInfo->damage = 0; + damageInfo->originalDamage = 0; damageInfo->cleanDamage = 0; damageInfo->absorb = 0; damageInfo->resist = 0; @@ -1295,17 +1297,20 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam case MELEE_HIT_EVADE: damageInfo->HitInfo |= HITINFO_MISS | HITINFO_SWINGNOHITSOUND; damageInfo->TargetState = VICTIMSTATE_EVADES; + damageInfo->originalDamage = damageInfo->damage; damageInfo->damage = 0; damageInfo->cleanDamage = 0; return; case MELEE_HIT_MISS: damageInfo->HitInfo |= HITINFO_MISS; damageInfo->TargetState = VICTIMSTATE_INTACT; + damageInfo->originalDamage = damageInfo->damage; damageInfo->damage = 0; damageInfo->cleanDamage = 0; break; case MELEE_HIT_NORMAL: damageInfo->TargetState = VICTIMSTATE_HIT; + damageInfo->originalDamage = damageInfo->damage; break; case MELEE_HIT_CRIT: { @@ -1320,21 +1325,26 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam if (mod != 0) AddPct(damageInfo->damage, mod); + + damageInfo->originalDamage = damageInfo->damage; break; } case MELEE_HIT_PARRY: damageInfo->TargetState = VICTIMSTATE_PARRY; + damageInfo->originalDamage = damageInfo->damage; damageInfo->cleanDamage += damageInfo->damage; damageInfo->damage = 0; break; case MELEE_HIT_DODGE: damageInfo->TargetState = VICTIMSTATE_DODGE; + damageInfo->originalDamage = damageInfo->damage; damageInfo->cleanDamage += damageInfo->damage; damageInfo->damage = 0; break; case MELEE_HIT_BLOCK: damageInfo->TargetState = VICTIMSTATE_HIT; damageInfo->HitInfo |= HITINFO_BLOCK; + damageInfo->originalDamage = damageInfo->damage; // 30% damage blocked, double blocked amount if block is critical damageInfo->blocked_amount = CalculatePct(damageInfo->damage, damageInfo->target->isBlockCritical() ? damageInfo->target->GetBlockPercent() * 2 : damageInfo->target->GetBlockPercent()); damageInfo->damage -= damageInfo->blocked_amount; @@ -1344,6 +1354,7 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam { damageInfo->HitInfo |= HITINFO_GLANCING; damageInfo->TargetState = VICTIMSTATE_HIT; + damageInfo->originalDamage = damageInfo->damage; int32 leveldif = int32(victim->getLevel()) - int32(getLevel()); if (leveldif > 3) leveldif = 3; @@ -1358,6 +1369,7 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam damageInfo->TargetState = VICTIMSTATE_HIT; // 150% normal damage damageInfo->damage += (damageInfo->damage / 2); + damageInfo->originalDamage = damageInfo->damage; break; default: break; @@ -1372,6 +1384,7 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo* dam resilienceReduction = damageInfo->damage - resilienceReduction; damageInfo->damage -= resilienceReduction; damageInfo->cleanDamage += resilienceReduction; + damageInfo->originalDamage -= resilienceReduction; // Calculate absorb resist if (int32(damageInfo->damage) > 0) @@ -1514,7 +1527,6 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) DamageInfo damageInfo(this, victim, damage, spellInfo, spellInfo->GetSchoolMask(), SPELL_DIRECT_DAMAGE, BASE_ATTACK); victim->CalcAbsorbResist(damageInfo); damage = damageInfo.GetDamage(); - // No Unit::CalcAbsorbResist here - opcode doesn't send that data - this damage is probably not affected by that victim->DealDamageMods(this, damage, nullptr); WorldPackets::CombatLog::SpellDamageShield damageShield; @@ -1522,6 +1534,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) damageShield.Defender = GetGUID(); damageShield.SpellID = spellInfo->Id; damageShield.TotalDamage = damage; + damageShield.OriginalDamage = damageInfo.GetOriginalDamage(); damageShield.OverKill = std::max(int32(damage) - int32(GetHealth()), 0); damageShield.SchoolMask = spellInfo->SchoolMask; damageShield.LogAbsorbed = damageInfo.GetAbsorb(); @@ -1881,6 +1894,7 @@ void Unit::CalcAbsorbResist(DamageInfo& damageInfo) CleanDamage cleanDamage = CleanDamage(splitDamage, 0, BASE_ATTACK, MELEE_HIT_NORMAL); DealDamage(caster, splitDamage, &cleanDamage, DIRECT_DAMAGE, damageInfo.GetSchoolMask(), (*itr)->GetSpellInfo(), false); log.damage = splitDamage; + log.originalDamage = splitDamage; log.absorb = split_absorb; SendSpellNonMeleeDamageLog(&log); @@ -2016,6 +2030,7 @@ void Unit::FakeAttackerStateUpdate(Unit* victim, WeaponAttackType attType /*= BA damageInfo.damageSchoolMask = GetMeleeDamageSchoolMask(); damageInfo.attackType = attType; damageInfo.damage = 0; + damageInfo.originalDamage = 0; damageInfo.cleanDamage = 0; damageInfo.absorb = 0; damageInfo.resist = 0; @@ -2573,7 +2588,7 @@ float Unit::GetUnitDodgeChance(WeaponAttackType attType, Unit const* victim) con float chance = 0.0f; float levelBonus = 0.0f; if (victim->GetTypeId() == TYPEID_PLAYER) - chance = victim->GetFloatValue(PLAYER_DODGE_PERCENTAGE); + chance = victim->GetFloatValue(ACTIVE_PLAYER_FIELD_DODGE_PERCENTAGE); else { if (!victim->IsTotem()) @@ -2617,7 +2632,7 @@ float Unit::GetUnitParryChance(WeaponAttackType attType, Unit const* victim) con tmpitem = playerVictim->GetWeaponForAttack(OFF_ATTACK, true); if (tmpitem) - chance = playerVictim->GetFloatValue(PLAYER_PARRY_PERCENTAGE); + chance = playerVictim->GetFloatValue(ACTIVE_PLAYER_FIELD_PARRY_PERCENTAGE); } } else @@ -2666,7 +2681,7 @@ float Unit::GetUnitBlockChance(WeaponAttackType /*attType*/, Unit const* victim) { Item* tmpitem = playerVictim->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); if (tmpitem && !tmpitem->IsBroken() && tmpitem->GetTemplate()->GetInventoryType() == INVTYPE_SHIELD) - chance = playerVictim->GetFloatValue(PLAYER_BLOCK_PERCENTAGE); + chance = playerVictim->GetFloatValue(ACTIVE_PLAYER_FIELD_BLOCK_PERCENTAGE); } } else @@ -2693,13 +2708,13 @@ float Unit::GetUnitCriticalChance(WeaponAttackType attackType, Unit const* victi switch (attackType) { case BASE_ATTACK: - chance = GetFloatValue(PLAYER_CRIT_PERCENTAGE); + chance = GetFloatValue(ACTIVE_PLAYER_FIELD_CRIT_PERCENTAGE); break; case OFF_ATTACK: - chance = GetFloatValue(PLAYER_OFFHAND_CRIT_PERCENTAGE); + chance = GetFloatValue(ACTIVE_PLAYER_FIELD_OFFHAND_CRIT_PERCENTAGE); break; case RANGED_ATTACK: - chance = GetFloatValue(PLAYER_RANGED_CRIT_PERCENTAGE); + chance = GetFloatValue(ACTIVE_PLAYER_FIELD_RANGED_CRIT_PERCENTAGE); break; // Just for good manner default: @@ -4724,26 +4739,6 @@ int32 Unit::GetMaxNegativeAuraModifierByAffectMask(AuraType auratype, SpellInfo }); } -float Unit::GetResistanceBuffMods(SpellSchools school, bool positive) const -{ - return GetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school); -} - -void Unit::SetResistanceBuffMods(SpellSchools school, bool positive, float val) -{ - SetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val); -} - -void Unit::ApplyResistanceBuffModsMod(SpellSchools school, bool positive, float val, bool apply) -{ - ApplyModSignedFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); -} - -void Unit::ApplyResistanceBuffModsPercentMod(SpellSchools school, bool positive, float val, bool apply) -{ - ApplyPercentModFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); -} - void Unit::InitStatBuffMods() { for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i) @@ -5005,6 +5000,7 @@ void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage const* log) packet.CastID = log->castId; packet.SpellID = log->SpellID; packet.Damage = log->damage; + packet.OriginalDamage = log->originalDamage; if (log->damage > log->preHitHealth) packet.Overkill = log->damage - log->preHitHealth; else @@ -5017,9 +5013,9 @@ void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage const* log) packet.Periodic = log->periodicLog; packet.Flags = log->HitInfo; - WorldPackets::Spells::SandboxScalingData sandboxScalingData; - if (sandboxScalingData.GenerateDataForUnits(log->attacker, log->target)) - packet.SandboxScaling = sandboxScalingData; + WorldPackets::Spells::ContentTuningParams contentTuningParams; + if (contentTuningParams.GenerateDataForUnits(log->attacker, log->target)) + packet.ContentTuning = contentTuningParams; SendCombatLogMessage(&packet); } @@ -5045,10 +5041,10 @@ void Unit::SendPeriodicAuraLog(SpellPeriodicAuraLogInfo* info) data.SpellID = aura->GetId(); data.LogData.Initialize(this); - /// @todo: should send more logs in one packet when multistrike WorldPackets::CombatLog::SpellPeriodicAuraLog::SpellLogEffect spellLogEffect; spellLogEffect.Effect = aura->GetAuraType(); spellLogEffect.Amount = info->damage; + spellLogEffect.OriginalDamage = info->originalDamage; spellLogEffect.OverHealOrKill = info->overDamage; spellLogEffect.SchoolMaskOrPower = aura->GetSpellInfo()->GetSchoolMask(); spellLogEffect.AbsorbedOrAmplitude = info->absorb; @@ -5056,10 +5052,10 @@ void Unit::SendPeriodicAuraLog(SpellPeriodicAuraLogInfo* info) spellLogEffect.Crit = info->critical; /// @todo: implement debug info - WorldPackets::Spells::SandboxScalingData sandboxScalingData; + WorldPackets::Spells::ContentTuningParams contentTuningParams; if (Unit* caster = ObjectAccessor::GetUnit(*this, aura->GetCasterGUID())) - if (sandboxScalingData.GenerateDataForUnits(caster, this)) - spellLogEffect.SandboxScaling = sandboxScalingData; + if (contentTuningParams.GenerateDataForUnits(caster, this)) + spellLogEffect.ContentTuning = contentTuningParams; data.Effects.push_back(spellLogEffect); @@ -5101,6 +5097,7 @@ void Unit::SendAttackStateUpdate(CalcDamageInfo* damageInfo) packet.AttackerGUID = damageInfo->attacker->GetGUID(); packet.VictimGUID = damageInfo->target->GetGUID(); packet.Damage = damageInfo->damage; + packet.OriginalDamage = damageInfo->originalDamage; int32 overkill = damageInfo->damage - damageInfo->target->GetHealth(); packet.OverDamage = (overkill < 0 ? -1 : overkill); @@ -5116,9 +5113,9 @@ void Unit::SendAttackStateUpdate(CalcDamageInfo* damageInfo) packet.LogData.Initialize(damageInfo->attacker); - WorldPackets::Spells::SandboxScalingData sandboxScalingData; - if (sandboxScalingData.GenerateDataForUnits(damageInfo->attacker, damageInfo->target)) - packet.SandboxScaling = sandboxScalingData; + WorldPackets::Spells::ContentTuningParams contentTuningParams; + if (contentTuningParams.GenerateDataForUnits(damageInfo->attacker, damageInfo->target)) + packet.ContentTuning = contentTuningParams; SendCombatLogMessage(&packet); } @@ -5130,6 +5127,7 @@ void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 /*SwingType dmgInfo.attacker = this; dmgInfo.target = target; dmgInfo.damage = Damage - AbsorbDamage - Resist - BlockedAmount; + dmgInfo.originalDamage = Damage; dmgInfo.damageSchoolMask = damageSchoolMask; dmgInfo.absorb = AbsorbDamage; dmgInfo.resist = Resist; @@ -5899,7 +5897,7 @@ void Unit::SetMinion(Minion *minion, bool apply) { SetCritterGUID(minion->GetGUID()); if (GetTypeId() == TYPEID_PLAYER) - minion->SetGuidValue(UNIT_FIELD_BATTLE_PET_COMPANION_GUID, GetGuidValue(PLAYER_FIELD_SUMMONED_BATTLE_PET_ID)); + minion->SetGuidValue(UNIT_FIELD_BATTLE_PET_COMPANION_GUID, GetGuidValue(ACTIVE_PLAYER_FIELD_SUMMONED_BATTLE_PET_ID)); } // PvP, FFAPvP @@ -6354,32 +6352,12 @@ void Unit::SendHealSpellLog(HealInfo& healInfo, bool critical /*= false*/) spellHealLog.TargetGUID = healInfo.GetTarget()->GetGUID(); spellHealLog.CasterGUID = healInfo.GetHealer()->GetGUID(); - spellHealLog.SpellID = healInfo.GetSpellInfo()->Id; spellHealLog.Health = healInfo.GetHeal(); + spellHealLog.OriginalHeal = healInfo.GetOriginalHeal(); spellHealLog.OverHeal = int32(healInfo.GetHeal()) - healInfo.GetEffectiveHeal(); spellHealLog.Absorbed = healInfo.GetAbsorb(); - spellHealLog.Crit = critical; - - /// @todo: 6.x Has to be implemented - /* - packet.ReadBit("Multistrike"); - - var hasCritRollMade = packet.ReadBit("HasCritRollMade"); - var hasCritRollNeeded = packet.ReadBit("HasCritRollNeeded"); - var hasLogData = packet.ReadBit("HasLogData"); - - if (hasCritRollMade) - packet.ReadSingle("CritRollMade"); - - if (hasCritRollNeeded) - packet.ReadSingle("CritRollNeeded"); - - if (hasLogData) - SpellParsers.ReadSpellCastLogData(packet); - */ - spellHealLog.LogData.Initialize(healInfo.GetTarget()); SendCombatLogMessage(&spellHealLog); } @@ -6514,7 +6492,7 @@ float Unit::SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, Damage { for (uint32 i = 0; i < MAX_SPELL_SCHOOL; ++i) if (spellProto->GetSchoolMask() & (1 << i)) - maxModDamagePercentSchool = std::max(maxModDamagePercentSchool, GetFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i)); + maxModDamagePercentSchool = std::max(maxModDamagePercentSchool, GetFloatValue(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i)); } else maxModDamagePercentSchool = GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, spellProto->GetSchoolMask()); @@ -6654,7 +6632,7 @@ int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) const { if (GetTypeId() == TYPEID_PLAYER) { - float overrideSP = GetFloatValue(PLAYER_FIELD_OVERRIDE_SPELL_POWER_BY_AP_PCT); + float overrideSP = GetFloatValue(ACTIVE_PLAYER_FIELD_OVERRIDE_SPELL_POWER_BY_AP_PCT); if (overrideSP > 0.0f) return int32(CalculatePct(GetTotalAttackPowerValue(BASE_ATTACK), overrideSP) + 0.5f); } @@ -6734,7 +6712,7 @@ float Unit::GetUnitSpellCriticalChance(Unit* victim, SpellInfo const* spellProto crit_chance = 0.0f; // For other schools else if (GetTypeId() == TYPEID_PLAYER) - crit_chance = GetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1); + crit_chance = GetFloatValue(ACTIVE_PLAYER_FIELD_SPELL_CRIT_PERCENTAGE1); else crit_chance = (float)m_baseSpellCritChance; // taken @@ -6975,7 +6953,7 @@ float Unit::SpellHealingPctDone(Unit* /*victim*/, SpellInfo const* spellProto) c return 1.0f; if (IsPlayer()) - return GetFloatValue(PLAYER_FIELD_MOD_HEALING_DONE_PCT); + return GetFloatValue(ACTIVE_PLAYER_FIELD_MOD_HEALING_DONE_PCT); float DoneTotalMod = 1.0f; @@ -7074,7 +7052,7 @@ int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) const { if (GetTypeId() == TYPEID_PLAYER) { - float overrideSP = GetFloatValue(PLAYER_FIELD_OVERRIDE_SPELL_POWER_BY_AP_PCT); + float overrideSP = GetFloatValue(ACTIVE_PLAYER_FIELD_OVERRIDE_SPELL_POWER_BY_AP_PCT); if (overrideSP > 0.0f) return int32(CalculatePct(GetTotalAttackPowerValue(BASE_ATTACK), overrideSP) + 0.5f); } @@ -7346,7 +7324,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType { for (uint32 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) if (spellProto->GetSchoolMask() & (1 << i)) - maxModDamagePercentSchool = std::max(maxModDamagePercentSchool, GetFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i)); + maxModDamagePercentSchool = std::max(maxModDamagePercentSchool, GetFloatValue(ACTIVE_PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i)); } else maxModDamagePercentSchool = GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, spellProto->GetSchoolMask()); @@ -9337,6 +9315,19 @@ Stats Unit::GetStatByAuraGroup(UnitMods unitMod) const return stat; } +void Unit::UpdateResistances(uint32 school) +{ + if (school > SPELL_SCHOOL_NORMAL) + { + UnitMods unitMod = UnitMods(UNIT_MOD_RESISTANCE_START + school); + + SetResistance(SpellSchools(school), int32(m_auraModifiersGroup[unitMod][BASE_VALUE])); + SetBonusResistanceMod(SpellSchools(school), int32(GetTotalAuraModValue(unitMod) - GetResistance(SpellSchools(school)))); + } + else + UpdateArmor(); +} + float Unit::GetTotalAttackPowerValue(WeaponAttackType attType) const { if (attType == RANGED_ATTACK) @@ -10340,9 +10331,11 @@ bool Unit::IsPolymorphed() const return spellInfo->GetSpellSpecific() == SPELL_SPECIFIC_MAGE_POLYMORPH; } -void Unit::SetDisplayId(uint32 modelId) +void Unit::SetDisplayId(uint32 modelId, float displayScale /*= 1.f*/) { SetUInt32Value(UNIT_FIELD_DISPLAYID, modelId); + SetFloatValue(UNIT_FIELD_DISPLAY_SCALE, displayScale); + // Set Gender by modelId if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(modelId)) SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, minfo->gender); @@ -10365,7 +10358,7 @@ void Unit::RestoreDisplayId(bool ignorePositiveAurasPreventingMounting /*= false if (!ignorePositiveAurasPreventingMounting) handledAura = (*i); else if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate((*i)->GetMiscValue())) - if (!IsDisallowedMountForm((*i)->GetId(), FORM_NONE, sObjectMgr->ChooseDisplayId(ci))) + if (!IsDisallowedMountForm((*i)->GetId(), FORM_NONE, ObjectMgr::ChooseDisplayId(ci)->CreatureDisplayID)) handledAura = (*i); } // prefer negative auras @@ -11686,7 +11679,7 @@ bool Unit::CreateVehicleKit(uint32 id, uint32 creatureEntry, bool loading /*= fa return false; m_vehicleKit = new Vehicle(this, vehInfo, creatureEntry); - m_updateFlag |= UPDATEFLAG_VEHICLE; + m_updateFlag.Vehicle = true; m_unitTypeMask |= UNIT_MASK_VEHICLE; if (!loading) @@ -11708,7 +11701,7 @@ void Unit::RemoveVehicleKit(bool onRemoveFromWorld /*= false*/) m_vehicleKit = NULL; - m_updateFlag &= ~UPDATEFLAG_VEHICLE; + m_updateFlag.Vehicle = false; m_unitTypeMask &= ~UNIT_MASK_VEHICLE; RemoveFlag64(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK | UNIT_NPC_FLAG_PLAYER_VEHICLE); } @@ -13121,15 +13114,17 @@ void Unit::SendClearTarget() SendMessageToSet(breakTarget.Write(), false); } -uint32 Unit::GetResistance(SpellSchoolMask mask) const +int32 Unit::GetResistance(SpellSchoolMask mask) const { - int32 resist = -1; + Optional<int32> resist; for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) - if (mask & (1 << i) && (resist < 0 || resist > int32(GetResistance(SpellSchools(i))))) - resist = int32(GetResistance(SpellSchools(i))); + { + int32 schoolResistance = GetResistance(SpellSchools(i)) + GetBonusResistanceMod(SpellSchools(i)); + if (mask & (1 << i) && (!resist || *resist > schoolResistance)) + resist = schoolResistance; + } - // resist value will never be negative here - return uint32(resist); + return resist ? *resist : 0; } void CharmInfo::SetIsCommandAttack(bool val) @@ -13673,7 +13668,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) if (target == this) visibleFlag |= UF_FLAG_PRIVATE; else if (GetTypeId() == TYPEID_PLAYER) - valCount = PLAYER_FIELD_END_NOT_SELF; + valCount = PLAYER_END; std::size_t blockCount = UpdateMask::GetBlockCount(valCount); @@ -13721,8 +13716,6 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) // FIXME: Some values at server stored in float format but must be sent to client in uint32 format // there are some float values which may be negative or can't get negative due to other checks else if ((index >= UNIT_FIELD_NEGSTAT && index < UNIT_FIELD_NEGSTAT + MAX_STATS) || - (index >= UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE && index < (UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + MAX_SPELL_SCHOOL)) || - (index >= UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE && index < (UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + MAX_SPELL_SCHOOL)) || (index >= UNIT_FIELD_POSSTAT && index < UNIT_FIELD_POSSTAT + MAX_STATS)) { *data << uint32(m_floatValues[index]); @@ -13756,7 +13749,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) if (cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER) if (target->IsGameMaster()) - displayId = cinfo->GetFirstVisibleModel(); + displayId = cinfo->GetFirstVisibleModel()->CreatureDisplayID; } *data << uint32(displayId); diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 74e2ed60f77..ad8ecf37733 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -576,6 +576,7 @@ class TC_GAME_API DamageInfo Unit* const m_attacker; Unit* const m_victim; uint32 m_damage; + uint32 const m_originalDamage; SpellInfo const* const m_spellInfo; SpellSchoolMask const m_schoolMask; DamageEffectType const m_damageType; @@ -601,6 +602,7 @@ class TC_GAME_API DamageInfo DamageEffectType GetDamageType() const { return m_damageType; } WeaponAttackType GetAttackType() const { return m_attackType; } uint32 GetDamage() const { return m_damage; } + uint32 GetOriginalDamage() const { return m_originalDamage; } uint32 GetAbsorb() const { return m_absorb; } uint32 GetResist() const { return m_resist; } uint32 GetBlock() const { return m_block; } @@ -614,6 +616,7 @@ class TC_GAME_API HealInfo Unit* const _healer; Unit* const _target; uint32 _heal; + uint32 const _originalHeal; uint32 _effectiveHeal; uint32 _absorb; SpellInfo const* const _spellInfo; @@ -629,6 +632,7 @@ class TC_GAME_API HealInfo Unit* GetHealer() const { return _healer; } Unit* GetTarget() const { return _target; } uint32 GetHeal() const { return _heal; } + uint32 GetOriginalHeal() const { return _originalHeal; } uint32 GetEffectiveHeal() const { return _effectiveHeal; } uint32 GetAbsorb() const { return _absorb; } SpellInfo const* GetSpellInfo() const { return _spellInfo; }; @@ -682,6 +686,7 @@ struct CalcDamageInfo Unit *target; // Target for damage uint32 damageSchoolMask; uint32 damage; + uint32 originalDamage; uint32 absorb; uint32 resist; uint32 blocked_amount; @@ -706,6 +711,7 @@ struct TC_GAME_API SpellNonMeleeDamage uint32 SpellID; uint32 SpellXSpellVisualID; uint32 damage; + uint32 originalDamage; uint32 schoolMask; uint32 absorb; uint32 resist; @@ -720,11 +726,12 @@ struct TC_GAME_API SpellNonMeleeDamage struct SpellPeriodicAuraLogInfo { - SpellPeriodicAuraLogInfo(AuraEffect const* _auraEff, uint32 _damage, uint32 _overDamage, uint32 _absorb, uint32 _resist, float _multiplier, bool _critical) - : auraEff(_auraEff), damage(_damage), overDamage(_overDamage), absorb(_absorb), resist(_resist), multiplier(_multiplier), critical(_critical){ } + SpellPeriodicAuraLogInfo(AuraEffect const* _auraEff, uint32 _damage, uint32 _originalDamage, uint32 _overDamage, uint32 _absorb, uint32 _resist, float _multiplier, bool _critical) + : auraEff(_auraEff), damage(_damage), originalDamage(_originalDamage), overDamage(_overDamage), absorb(_absorb), resist(_resist), multiplier(_multiplier), critical(_critical){ } AuraEffect const* auraEff; uint32 damage; + uint32 originalDamage; uint32 overDamage; // overkill/overheal uint32 absorb; uint32 resist; @@ -1033,12 +1040,18 @@ class TC_GAME_API Unit : public WorldObject float GetStat(Stats stat) const { return float(GetUInt32Value(UNIT_FIELD_STAT+stat)); } void SetStat(Stats stat, int32 val) { SetStatInt32Value(UNIT_FIELD_STAT+stat, val); } - uint32 GetArmor() const { return GetResistance(SPELL_SCHOOL_NORMAL); } - void SetArmor(int32 val) { SetResistance(SPELL_SCHOOL_NORMAL, val); } + uint32 GetArmor() const { return GetResistance(SPELL_SCHOOL_NORMAL) + GetBonusResistanceMod(SPELL_SCHOOL_NORMAL); } + void SetArmor(int32 val, int32 bonusVal) + { + SetResistance(SPELL_SCHOOL_NORMAL, val); + SetBonusResistanceMod(SPELL_SCHOOL_NORMAL, bonusVal); + } - uint32 GetResistance(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES+school); } - uint32 GetResistance(SpellSchoolMask mask) const; - void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES+school, val); } + int32 GetResistance(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES + school); } + int32 GetBonusResistanceMod(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_BONUS_RESISTANCE_MODS + school); } + int32 GetResistance(SpellSchoolMask mask) const; + void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES + school, val); } + void SetBonusResistanceMod(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_BONUS_RESISTANCE_MODS + school, val); } uint64 GetHealth() const { return GetUInt64Value(UNIT_FIELD_HEALTH); } uint64 GetMaxHealth() const { return GetUInt64Value(UNIT_FIELD_MAXHEALTH); } @@ -1533,10 +1546,6 @@ class TC_GAME_API Unit : public WorldObject int32 GetMaxPositiveAuraModifierByAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const; int32 GetMaxNegativeAuraModifierByAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const; - float GetResistanceBuffMods(SpellSchools school, bool positive) const; - void SetResistanceBuffMods(SpellSchools school, bool positive, float val); - void ApplyResistanceBuffModsMod(SpellSchools school, bool positive, float val, bool apply); - void ApplyResistanceBuffModsPercentMod(SpellSchools school, bool positive, float val, bool apply); void InitStatBuffMods(); void ApplyStatBuffMod(Stats stat, float val, bool apply); void ApplyStatPercentBuffMod(Stats stat, float val, bool apply); @@ -1620,7 +1629,7 @@ class TC_GAME_API Unit : public WorldObject void SetCanModifyStats(bool modifyStats) { m_canModifyStats = modifyStats; } virtual bool UpdateStats(Stats stat) = 0; virtual bool UpdateAllStats() = 0; - virtual void UpdateResistances(uint32 school) = 0; + virtual void UpdateResistances(uint32 school); virtual void UpdateAllResistances(); virtual void UpdateArmor() = 0; virtual void UpdateMaxHealth() = 0; @@ -1675,10 +1684,11 @@ class TC_GAME_API Unit : public WorldObject void UpdateInterruptMask(); uint32 GetDisplayId() const { return GetUInt32Value(UNIT_FIELD_DISPLAYID); } - virtual void SetDisplayId(uint32 modelId); + virtual void SetDisplayId(uint32 modelId, float displayScale = 1.f); uint32 GetNativeDisplayId() const { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); } + float GetNativeDisplayScale() const { return GetFloatValue(UNIT_FIELD_NATIVE_X_DISPLAY_SCALE); } void RestoreDisplayId(bool ignorePositiveAurasPreventingMounting = false); - void SetNativeDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId); } + void SetNativeDisplayId(uint32 displayId, float displayScale = 1.f) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, displayId); SetFloatValue(UNIT_FIELD_NATIVE_X_DISPLAY_SCALE, displayScale); } void setTransForm(uint32 spellid) { m_transform = spellid;} uint32 getTransForm() const { return m_transform;} |
