Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix maul + swipe clearcasting bug #2580

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/game/Spells/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3684,7 +3684,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 @@ -3939,7 +3939,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 @@ -7498,7 +7498,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 @@ -7551,10 +7551,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 @@ -361,7 +361,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
Loading