[Bug Fix] Cancel Magic SE fix (#3890)

* [Bug Fix] Cancel Magic SE fix

Cancel Magic should always attempt the first slot for dispell.

* Add back TryDispell
This commit is contained in:
Fryguy 2024-01-07 15:02:43 -05:00 committed by GitHub
parent 2d6c9f881a
commit fc8ace91cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 13 deletions

View File

@ -939,6 +939,7 @@ public:
void TrySympatheticProc(Mob *target, uint32 spell_id);
uint16 GetSympatheticFocusEffect(focusType type, uint16 spell_id);
bool TryFadeEffect(int slot);
void DispelMagic(Mob* casterm, uint16 spell_id, int effect_value);
uint16 GetSpellEffectResistChance(uint16 spell_id);
int32 GetVulnerability(Mob *caster, uint32 spell_id, uint32 ticsremaining, bool from_buff_tic = false);
int64 GetFcDamageAmtIncoming(Mob *caster, int32 spell_id, bool from_buff_tic = false);

View File

@ -1094,22 +1094,13 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
snprintf(effect_desc, _EDLEN, "Cancel Magic: %d", effect_value);
#endif
if(GetSpecialAbility(UNDISPELLABLE)){
if (caster)
if (caster) {
caster->MessageString(Chat::SpellFailure, SPELL_NO_EFFECT, spells[spell_id].name);
}
break;
}
int buff_count = GetMaxTotalSlots();
for(int slot = 0; slot < buff_count; slot++) {
if(IsValidSpell(buffs[slot].spellid) &&
spells[buffs[slot].spellid].dispel_flag == 0 &&
!IsDiscipline(buffs[slot].spellid))
{
if (caster && TryDispel(caster->GetCasterLevel(spell_id), buffs[slot].casterlevel, effect_value)){
BuffFadeBySlot(slot);
slot = buff_count;
}
}
}
DispelMagic(caster, spell_id, effect_value);
break;
}
@ -7300,6 +7291,22 @@ bool Mob::PassLimitClass(uint32 Classes_, uint16 Class_)
return false;
}
void Mob::DispelMagic(Mob* caster, uint16 spell_id, int effect_value)
{
for (int slot = 0; slot < GetMaxTotalSlots(); slot++) {
if (
buffs[slot].spellid != SPELL_UNKNOWN &&
spells[buffs[slot].spellid].dispel_flag == 0 &&
!IsDiscipline(buffs[slot].spellid)
) {
if (caster && TryDispel(caster->GetCasterLevel(spell_id), buffs[slot].casterlevel, effect_value)) {
BuffFadeBySlot(slot);
break;
}
}
}
}
uint16 Mob::GetSpellEffectResistChance(uint16 spell_id)
{