Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Core/Units: removed several totem related checks that should not be h…
Browse files Browse the repository at this point in the history
…andled the way they are
  • Loading branch information
Ovahlord committed Oct 25, 2023
1 parent daf3772 commit c919bf6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 43 deletions.
3 changes: 3 additions & 0 deletions src/server/game/AI/CoreAI/TotemAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 11 additions & 43 deletions src/server/game/Entities/Unit/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -10015,7 +9983,7 @@ Unit* Unit::SelectNearbyTarget(Unit* exclude, float dist) const
// remove not LoS targets
for (std::list<Unit*>::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;
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit c919bf6

Please sign in to comment.