From c919bf6bcfcb12777ae7be88805d9f6e913458e1 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Wed, 25 Oct 2023 03:48:53 +0200 Subject: [PATCH] Core/Units: removed several totem related checks that should not be handled the way they are --- src/server/game/AI/CoreAI/TotemAI.cpp | 3 ++ src/server/game/Entities/Unit/Unit.cpp | 54 ++++++-------------------- 2 files changed, 14 insertions(+), 43 deletions(-) diff --git a/src/server/game/AI/CoreAI/TotemAI.cpp b/src/server/game/AI/CoreAI/TotemAI.cpp index d3ee3f3d82..cda3017e11 100644 --- a/src/server/game/AI/CoreAI/TotemAI.cpp +++ b/src/server/game/AI/CoreAI/TotemAI.cpp @@ -39,6 +39,9 @@ void TotemAI::JustAppeared() NullCreatureAI::JustAppeared(); _spellInfo = sSpellMgr->GetSpellInfo(me->m_spells[0]); + if (!_spellInfo) + return; + if (_spellInfo->IsPassive()) DoCastSelf(_spellInfo->Id); else diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 9fedcba0ca..0a09f063e9 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -2428,14 +2428,11 @@ float Unit::GetUnitDodgeChance(WeaponAttackType attType, Unit const* victim) con } else { - if (!victim->IsTotem()) - { - chance += victim->GetTotalAuraModifier(SPELL_AURA_MOD_DODGE_PERCENT); - if (skillDifference <= 10) - chance = 5.f + skillDifference * 0.1f; - else - chance = 6.f + (skillDifference - 10) * 0.1f; - } + chance += victim->GetTotalAuraModifier(SPELL_AURA_MOD_DODGE_PERCENT); + if (skillDifference <= 10) + chance = 5.f + skillDifference * 0.1f; + else + chance = 6.f + (skillDifference - 10) * 0.1f; } // Reduce enemy dodge chance by SPELL_AURA_MOD_COMBAT_RESULT_CHANCE @@ -2477,7 +2474,7 @@ float Unit::GetUnitParryChance(WeaponAttackType attType, Unit const* victim) con else { // Allow parries for creatures only if it's not a totem, does have a virtual item equipped and does not have CREATURE_FLAG_EXTRA_NO_PARRY - if (!victim->IsTotem() && (victim->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0) || victim->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1)) && + if (victim->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0) || victim->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1) && !(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY)) { chance += victim->GetTotalAuraModifier(SPELL_AURA_MOD_PARRY_PERCENT); @@ -2539,7 +2536,7 @@ float Unit::GetUnitBlockChance(Unit const* victim) const } else { - if (!victim->IsTotem() && !(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK)) + if (!(victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK)) { chance = 5.0f; chance += victim->GetTotalAuraModifier(SPELL_AURA_MOD_BLOCK_PERCENT); @@ -3239,13 +3236,6 @@ void Unit::_UnapplyAura(AuraApplicationMap::iterator& i, AuraRemoveFlags removeM // all effect mustn't be applied ASSERT(!aurApp->GetEffectMask()); - // Remove totem at next update if totem loses its aura - if (aurApp->GetRemoveMode().HasFlag(AuraRemoveFlags::Expired) && GetTypeId() == TYPEID_UNIT && IsTotem()) - { - if (ToTotem()->GetSpell() == aura->GetId() && ToTotem()->GetTotemType() == TOTEM_PASSIVE) - ToTotem()->setDeathState(JUST_DIED); - } - // Remove aurastates only if were not found if (!auraStateFound) ModifyAuraState(auraState, false); @@ -5741,13 +5731,9 @@ void Unit::SetCharm(Unit* charm, bool apply) // Hook for OnHeal Event sScriptMgr->OnHeal(healer, victim, (uint32&)gain); - Unit* unit = healer; - if (healer && healer->GetTypeId() == TYPEID_UNIT && healer->IsTotem()) - unit = healer->GetOwner(); - - if (unit) + if (healer) { - if (Player* player = unit->ToPlayer()) + if (Player* player = healer->ToPlayer()) { if (!healInfo.GetSpellInfo() || !healInfo.GetSpellInfo()->HasAttribute(SPELL_ATTR7_DO_NOT_COUNT_FOR_PVP_SCOREBOARD)) if (Battleground* bg = player->GetBattleground()) @@ -5931,11 +5917,6 @@ int32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, int3 return int32(std::max(float(pdamage + DoneTotal) * DoneTotalMod, 0.0f)); } - // Totems get their bonus damage from their owner - if (IsCreature() && IsTotem()) - if (Unit* creator = ObjectAccessor::GetUnit(*this, GetCreatorGUID())) - return creator->SpellDamageBonusDone(victim, spellProto, pdamage, damagetype, effIndex, stack, spell, aurEff); - DoneTotalMod = SpellDamagePctDone(victim, spellProto, damagetype); // done scripted mod (take it from owner) @@ -6086,10 +6067,6 @@ float Unit::SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, Damage if (spellProto->HasAttribute(SPELL_ATTR6_IGNORE_CASTER_DAMAGE_MODIFIERS)) return 1.0f; - // For totems pct done mods are calculated when its calculation is run on the player in SpellDamageBonusDone. - if (GetTypeId() == TYPEID_UNIT && IsTotem()) - return 1.0f; - // Done total percent damage auras float DoneTotalMod = 1.0f; @@ -6687,11 +6664,6 @@ float Unit::SpellCritChanceTaken(Unit const* caster, SpellInfo const* spellInfo, int32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, int32 healamount, DamageEffectType damagetype, uint8 effIndex, uint32 stack /*= 1*/, Spell* spell /*= nullptr*/, AuraEffect const* aurEff /*= nullptr*/) const { - // For totems get healing bonus from owner (statue isn't totem in fact) - if (GetTypeId() == TYPEID_UNIT && IsTotem()) - if (Unit* creator = ObjectAccessor::GetUnit(*this, GetCreatorGUID())) - return creator->SpellHealingBonusDone(victim, spellProto, healamount, damagetype, effIndex, stack, spell, aurEff); - // Some spells don't benefit from done mods if (spellProto->HasAttribute(SPELL_ATTR3_IGNORE_CASTER_MODIFIERS)) return healamount; @@ -6802,10 +6774,6 @@ int32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, int float Unit::SpellHealingPctDone(Unit* victim, SpellInfo const* spellProto) const { - // For totems pct done mods are calculated when its calculation is run on the player in SpellHealingBonusDone. - if (GetTypeId() == TYPEID_UNIT && IsTotem()) - return 1.0f; - // No bonus healing for potion spells if (spellProto->SpellFamilyName == SPELLFAMILY_POTION) return 1.0f; @@ -10015,7 +9983,7 @@ Unit* Unit::SelectNearbyTarget(Unit* exclude, float dist) const // remove not LoS targets for (std::list::iterator tIter = targets.begin(); tIter != targets.end();) { - if (!IsWithinLOSInMap(*tIter) || (*tIter)->IsTotem() || (*tIter)->IsSpiritService() || (*tIter)->IsCritter()) + if (!IsWithinLOSInMap(*tIter) || (*tIter)->IsSpiritService() || (*tIter)->IsCritter()) targets.erase(tIter++); else ++tIter; @@ -10503,7 +10471,7 @@ void Unit::PlayOneShotAnimKitId(uint16 animKitId) } // Do KILL and KILLED procs. KILL proc is called only for the unit who landed the killing blow (and its owner - for pets and totems) regardless of who tapped the victim - if (attacker && (attacker->IsPet() || attacker->IsTotem())) + if (attacker && attacker->IsGuardian()) { // proc only once for victim if (Unit* owner = attacker->GetOwner())