Skip to content

Commit

Permalink
Fix maul and swipe clearcasting bug (#2580)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepopo978 authored Dec 5, 2024
1 parent a4de48f commit 272cf70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions src/game/Spells/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3726,7 +3726,7 @@ SpellCastResult Spell::prepare(Aura* triggeredByAura, uint32 chance)
}

// Fill cost data
m_powerCost = CalculatePowerCost(m_spellInfo, m_casterUnit, this, m_CastItem);
m_powerCost = CalculatePowerCost(m_spellInfo, m_casterUnit, this, m_CastItem, false);

if (Player* pPlayer = m_caster->ToPlayer())
if (pPlayer->HasCheatOption(PLAYER_CHEAT_NO_POWER))
Expand Down Expand Up @@ -3977,7 +3977,7 @@ void Spell::cast(bool skipCheck)
{
// Nostalrius - compute power cost once again at cast finished
// (in case of mana reduction buff proc while casting)
m_powerCost = CalculatePowerCost(m_spellInfo, m_casterUnit, this, m_CastItem);
m_powerCost = CalculatePowerCost(m_spellInfo, m_casterUnit, this, m_CastItem, true);
castResult = CheckPower();
if (castResult != SPELL_CAST_OK)
{
Expand Down Expand Up @@ -7563,7 +7563,7 @@ SpellCastResult Spell::CheckRange(bool strict)
return SPELL_CAST_OK;
}

uint32 Spell::CalculatePowerCost(SpellEntry const* spellInfo, Unit* caster, Spell* spell, Item* castItem)
uint32 Spell::CalculatePowerCost(SpellEntry const* spellInfo, Unit* caster, Spell* spell, Item* castItem, bool casting)
{
if (!caster)
return 0;
Expand Down Expand Up @@ -7616,10 +7616,18 @@ uint32 Spell::CalculatePowerCost(SpellEntry const* spellInfo, Unit* caster, Spel
powerCost += caster->GetInt32Value(UNIT_FIELD_POWER_COST_MODIFIER + school);
#endif

// Apply cost mod by spell
// Apply cost mod by spell unless delayed
if (spell)
{
if (Player* modOwner = caster->GetSpellModOwner())
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_COST, powerCost, spell);
{
// avoid consuming procs during prepare for melee swing spells
if (casting || !spellInfo->IsNextMeleeSwingSpell())
{
modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_COST, powerCost, spell);
}
}
}

if (spellInfo->Attributes & SPELL_ATTR_SCALES_WITH_CREATURE_LEVEL)
powerCost = int32(powerCost / (1.117f * spellInfo->spellLevel / caster->GetLevel() - 0.1327f));
Expand Down
2 changes: 1 addition & 1 deletion src/game/Spells/Spell.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ class Spell
SpellCastResult CheckCasterAuras() const;

float CalculateDamage(SpellEffectIndex i, Unit* target) { return m_caster->CalculateSpellEffectValue(target, m_spellInfo, i, &m_currentBasePoints[i], this); }
static uint32 CalculatePowerCost(SpellEntry const* spellInfo, Unit* caster, Spell* spell = nullptr, Item* castItem = nullptr);
static uint32 CalculatePowerCost(SpellEntry const* spellInfo, Unit* caster, Spell* spell = nullptr, Item* castItem = nullptr, bool casting = true);

bool HaveTargetsForEffect(SpellEffectIndex effect) const;
void Delayed();
Expand Down

0 comments on commit 272cf70

Please sign in to comment.