From 89c68bf712733bf4a655734c23d8864f6e58673b Mon Sep 17 00:00:00 2001 From: killerwife Date: Thu, 28 Sep 2023 09:02:56 +0200 Subject: [PATCH] Unit: Another batch of renames --- src/game/Entities/Unit.cpp | 72 +++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/game/Entities/Unit.cpp b/src/game/Entities/Unit.cpp index 4bfb603210..682bda84ef 100644 --- a/src/game/Entities/Unit.cpp +++ b/src/game/Entities/Unit.cpp @@ -2886,29 +2886,29 @@ void Unit::SendMeleeAttackStop(const Unit& victim) const DETAIL_FILTER_LOG(LOG_FILTER_COMBAT, "%s stopped attacking %s", GetGuidStr().c_str(), victim.GetGuidStr().c_str()); } -SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell, uint32* heartbeatResistChance/* = nullptr*/) +SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spellInfo, uint32* heartbeatResistChance/* = nullptr*/) { Die die; - die.set(UNIT_COMBAT_DIE_MISS, CalculateSpellMissChance(pVictim, SPELL_SCHOOL_MASK_NORMAL, spell)); - die.set(UNIT_COMBAT_DIE_RESIST, CalculateSpellResistChance(pVictim, SPELL_SCHOOL_MASK_NORMAL, spell)); - if (pVictim->CanReactOnAbility(spell)) - { - const WeaponAttackType attackType = GetWeaponAttackType(spell); - if (pVictim->CanDodgeAbility(this, spell)) - die.set(UNIT_COMBAT_DIE_DODGE, pVictim->CalculateEffectiveDodgeChance(this, attackType, spell)); - if (pVictim->CanParryAbility(this, spell)) - die.set(UNIT_COMBAT_DIE_PARRY, pVictim->CalculateEffectiveParryChance(this, attackType, spell)); - if (pVictim->CanDeflectAbility(this, spell)) - die.set(UNIT_COMBAT_DIE_DEFLECT, pVictim->CalculateAbilityDeflectChance(this, spell)); - if (pVictim->CanBlockAbility(this, spell, true)) - die.set(UNIT_COMBAT_DIE_BLOCK, pVictim->CalculateEffectiveBlockChance(this, attackType, spell)); - } - DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "MeleeSpellHitResult: New ability hit die: %u [MISS:%u, RESIST:%u, DODGE:%u, PARRY:%u, DEFLECT:%u, BLOCK:%u]", spell->Id, + die.set(UNIT_COMBAT_DIE_MISS, CalculateSpellMissChance(pVictim, SPELL_SCHOOL_MASK_NORMAL, spellInfo)); + die.set(UNIT_COMBAT_DIE_RESIST, CalculateSpellResistChance(pVictim, SPELL_SCHOOL_MASK_NORMAL, spellInfo)); + if (pVictim->CanReactOnAbility(spellInfo)) + { + const WeaponAttackType attackType = GetWeaponAttackType(spellInfo); + if (pVictim->CanDodgeAbility(this, spellInfo)) + die.set(UNIT_COMBAT_DIE_DODGE, pVictim->CalculateEffectiveDodgeChance(this, attackType, spellInfo)); + if (pVictim->CanParryAbility(this, spellInfo)) + die.set(UNIT_COMBAT_DIE_PARRY, pVictim->CalculateEffectiveParryChance(this, attackType, spellInfo)); + if (pVictim->CanDeflectAbility(this, spellInfo)) + die.set(UNIT_COMBAT_DIE_DEFLECT, pVictim->CalculateAbilityDeflectChance(this, spellInfo)); + if (pVictim->CanBlockAbility(this, spellInfo, true)) + die.set(UNIT_COMBAT_DIE_BLOCK, pVictim->CalculateEffectiveBlockChance(this, attackType, spellInfo)); + } + DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "MeleeSpellHitResult: New ability hit die: %u [MISS:%u, RESIST:%u, DODGE:%u, PARRY:%u, DEFLECT:%u, BLOCK:%u]", spellInfo->Id, die.chance[UNIT_COMBAT_DIE_MISS], die.chance[UNIT_COMBAT_DIE_RESIST], die.chance[UNIT_COMBAT_DIE_DODGE], die.chance[UNIT_COMBAT_DIE_PARRY], die.chance[UNIT_COMBAT_DIE_DEFLECT], die.chance[UNIT_COMBAT_DIE_BLOCK]); // Memorize heartbeat resist chance if needed: - if (heartbeatResistChance && spell->HasAttribute(SPELL_ATTR_HEARTBEAT_RESIST)) + if (heartbeatResistChance && spellInfo->HasAttribute(SPELL_ATTR_HEARTBEAT_RESIST)) *heartbeatResistChance = (die.chance[UNIT_COMBAT_DIE_RESIST] + die.chance[UNIT_COMBAT_DIE_MISS]); const uint32 random = urand(1, 10000); @@ -2928,19 +2928,19 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell, return SPELL_MISS_NONE; } -SpellMissInfo Unit::MagicSpellHitResult(Unit* pVictim, SpellEntry const* spell, SpellSchoolMask schoolMask, uint32* heartbeatResistChance/* = nullptr*/) +SpellMissInfo Unit::MagicSpellHitResult(Unit* pVictim, SpellEntry const* spellInfo, SpellSchoolMask schoolMask, uint32* heartbeatResistChance/* = nullptr*/) { Die die; - die.set(UNIT_COMBAT_DIE_RESIST, CalculateSpellResistChance(pVictim, schoolMask, spell)); + die.set(UNIT_COMBAT_DIE_RESIST, CalculateSpellResistChance(pVictim, schoolMask, spellInfo)); /* Deflect for spells is currently unused up until WotLK, commented out for performance if (victim->CanDeflectAbility(this, spell)) die.set(UNIT_COMBAT_DIE_DEFLECT, victim->CalculateAbilityDeflectChance(this, spell)); */ - DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "MagicSpellHitResult: New spell hit die: %u [RESIST:%u, DEFLECT:%u]", spell->Id, + DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "MagicSpellHitResult: New spell hit die: %u [RESIST:%u, DEFLECT:%u]", spellInfo->Id, die.chance[UNIT_COMBAT_DIE_RESIST], die.chance[UNIT_COMBAT_DIE_DEFLECT]); // Memorize heartbeat resist chance if needed: - if (heartbeatResistChance && spell->HasAttribute(SPELL_ATTR_HEARTBEAT_RESIST)) + if (heartbeatResistChance && spellInfo->HasAttribute(SPELL_ATTR_HEARTBEAT_RESIST)) *heartbeatResistChance = (die.chance[UNIT_COMBAT_DIE_RESIST] + die.chance[UNIT_COMBAT_DIE_MISS]); const uint32 random = urand(1, 10000); @@ -2956,7 +2956,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* pVictim, SpellEntry const* spell, return SPELL_MISS_NONE; } -SpellMissInfo Unit::SpellHitResult(WorldObject* caster, Unit* pVictim, SpellEntry const* spell, uint8 effectMask, bool reflectable, bool reflected, uint32* heartbeatResistChance/* = nullptr*/) +SpellMissInfo Unit::SpellHitResult(WorldObject* caster, Unit* pVictim, SpellEntry const* spellInfo, uint8 effectMask, bool reflectable, bool reflected, uint32* heartbeatResistChance/* = nullptr*/) { // Dead units can't be missed, can't resist, reflect, etc if (!pVictim->IsAlive()) @@ -2967,33 +2967,33 @@ SpellMissInfo Unit::SpellHitResult(WorldObject* caster, Unit* pVictim, SpellEntr return SPELL_MISS_EVADE; // !!! - SpellSchoolMask schoolMask = GetSpellSchoolMask(spell); + SpellSchoolMask schoolMask = GetSpellSchoolMask(spellInfo); // All positive spells can`t miss // TODO: client not show miss log for this spells - so need find info for this in dbc and use it! - if (IsPositiveEffectMask(spell, effectMask, caster, pVictim)) + if (IsPositiveEffectMask(spellInfo, effectMask, caster, pVictim)) { - if (pVictim->IsImmuneToSpell(spell, reflected ? false : (caster == pVictim), effectMask, caster)) + if (pVictim->IsImmuneToSpell(spellInfo, reflected ? false : (caster == pVictim), effectMask, caster)) return SPELL_MISS_IMMUNE; // Check for immune to damage as hit result if spell hit composed entirely out of damage effects - if (IsSpellEffectsDamage(*spell, effectMask) && pVictim->IsImmuneToDamage(schoolMask)) + if (IsSpellEffectsDamage(*spellInfo, effectMask) && pVictim->IsImmuneToDamage(schoolMask)) return SPELL_MISS_IMMUNE; return SPELL_MISS_NONE; } // !!!UNHACKME: Self-resists suppression hack for channeled spells until spell execution is modernized with effectmasks: Drain Soul, Blizzard, RoF - if (pVictim == caster && IsChanneledSpell(spell)) + if (pVictim == caster && IsChanneledSpell(spellInfo)) { for (uint32 i = EFFECT_INDEX_0; i < MAX_EFFECT_INDEX; ++i) { - if (IsCasterSourceTarget(spell->EffectImplicitTargetA[i]) || IsCasterSourceTarget(spell->EffectImplicitTargetB[i])) + if (IsCasterSourceTarget(spellInfo->EffectImplicitTargetA[i]) || IsCasterSourceTarget(spellInfo->EffectImplicitTargetB[i])) return SPELL_MISS_NONE; } } // wand case - bool wand = spell->Id == 5019; + bool wand = spellInfo->Id == 5019; if (wand && caster->IsPlayer() && !!(static_cast(caster)->getClassMask() & CLASSMASK_WAND_USERS)) schoolMask = static_cast(caster)->GetRangedDamageSchoolMask(); @@ -3004,14 +3004,14 @@ SpellMissInfo Unit::SpellHitResult(WorldObject* caster, Unit* pVictim, SpellEntr if (roll_chance_combat(chance)) return SPELL_MISS_REFLECT; } - if (!spell->HasAttribute(SPELL_ATTR_NO_IMMUNITIES)) + if (!spellInfo->HasAttribute(SPELL_ATTR_NO_IMMUNITIES)) { // TODO: improve for partial application // Check for immune - if (!wand && pVictim->IsImmuneToSpell(spell, reflected ? false : (caster == pVictim), effectMask, caster)) + if (!wand && pVictim->IsImmuneToSpell(spellInfo, reflected ? false : (caster == pVictim), effectMask, caster)) return SPELL_MISS_IMMUNE; // Check for immune to damage as hit result if spell hit composed entirely out of damage effects - if (IsSpellEffectsDamage(*spell, effectMask) && pVictim->IsImmuneToDamage(schoolMask)) + if (IsSpellEffectsDamage(*spellInfo, effectMask) && pVictim->IsImmuneToDamage(schoolMask)) return SPELL_MISS_IMMUNE; } @@ -3021,15 +3021,15 @@ SpellMissInfo Unit::SpellHitResult(WorldObject* caster, Unit* pVictim, SpellEntr else if (caster->IsGameObject()) hitCaster = static_cast(caster)->GetOwner(); - if (hitCaster && !spell->HasAttribute(SPELL_ATTR_EX3_NO_AVOIDANCE)) + if (hitCaster && !spellInfo->HasAttribute(SPELL_ATTR_EX3_NO_AVOIDANCE)) { - switch (spell->DmgClass) + switch (spellInfo->DmgClass) { case SPELL_DAMAGE_CLASS_MELEE: case SPELL_DAMAGE_CLASS_RANGED: - return hitCaster->MeleeSpellHitResult(pVictim, spell, heartbeatResistChance); + return hitCaster->MeleeSpellHitResult(pVictim, spellInfo, heartbeatResistChance); case SPELL_DAMAGE_CLASS_MAGIC: - return hitCaster->MagicSpellHitResult(pVictim, spell, schoolMask, heartbeatResistChance); + return hitCaster->MagicSpellHitResult(pVictim, spellInfo, schoolMask, heartbeatResistChance); case SPELL_DAMAGE_CLASS_NONE: // Usually never misses, but needs more research for some spells break;