[Cleanup] Cleanup Special Ability Code (#4365)

* [Cleanup] Cleanup Special Ability-based Code

* Update emu_constants.cpp

* Update emu_constants.cpp

* Update emu_constants.cpp

* Update special_ability.cpp

* Cleanup

* Update emu_constants.cpp
This commit is contained in:
Alex King
2024-06-01 19:20:43 -04:00
committed by GitHub
parent d01d091b47
commit 76b9ce0ac1
27 changed files with 622 additions and 564 deletions
+12 -12
View File
@@ -747,7 +747,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
max_level = RuleI(Spells, BaseImmunityLevel);
// NPCs get to ignore max_level for their spells.
// Ignore if spell is beneficial (ex. Harvest)
if (IsDetrimentalSpell(spell.id) && (GetSpecialAbility(UNSTUNABLE) ||
if (IsDetrimentalSpell(spell.id) && (GetSpecialAbility(SpecialAbility::StunImmunity) ||
((GetLevel() > max_level) && caster && (!caster->IsNPC() ||
(caster->IsNPC() && !RuleB(Spells, NPCIgnoreBaseImmunity))))))
{
@@ -1103,7 +1103,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
#ifdef SPELL_EFFECT_SPAM
snprintf(effect_desc, _EDLEN, "Cancel Magic: %d", effect_value);
#endif
if(GetSpecialAbility(UNDISPELLABLE)){
if(GetSpecialAbility(SpecialAbility::DispellImmunity)){
if (caster) {
caster->MessageString(Chat::SpellFailure, SPELL_NO_EFFECT, spells[spell_id].name);
}
@@ -1119,7 +1119,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
#ifdef SPELL_EFFECT_SPAM
snprintf(effect_desc, _EDLEN, "Dispel Detrimental: %d", effect_value);
#endif
if(GetSpecialAbility(UNDISPELLABLE)){
if(GetSpecialAbility(SpecialAbility::DispellImmunity)){
if (caster)
caster->MessageString(Chat::SpellFailure, SPELL_NO_EFFECT, spells[spell_id].name);
break;
@@ -1150,7 +1150,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
#ifdef SPELL_EFFECT_SPAM
snprintf(effect_desc, _EDLEN, "Dispel Beneficial: %d", effect_value);
#endif
if(GetSpecialAbility(UNDISPELLABLE)){
if(GetSpecialAbility(SpecialAbility::DispellImmunity)){
if (caster)
caster->MessageString(Chat::SpellFailure, SPELL_NO_EFFECT, spells[spell_id].name);
break;
@@ -1551,7 +1551,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
max_level = RuleI(Spells, BaseImmunityLevel); // Default max is 55 level limit
// NPCs ignore level limits in their spells
if(GetSpecialAbility(UNSTUNABLE) ||
if(GetSpecialAbility(SpecialAbility::StunImmunity) ||
((GetLevel() > max_level)
&& caster && (!caster->IsNPC() || (caster->IsNPC() && !RuleB(Spells, NPCIgnoreBaseImmunity)))))
{
@@ -3043,12 +3043,12 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
if (!caster)
break;
if (IsNPC() && GetSpecialAbility(UNSTUNABLE)) {
if (IsNPC() && GetSpecialAbility(SpecialAbility::StunImmunity)) {
caster->MessageString(Chat::SpellFailure, IMMUNE_STUN);
break;
}
if (IsNPC() && GetSpecialAbility(UNFEARABLE)) {
if (IsNPC() && GetSpecialAbility(SpecialAbility::FearImmunity)) {
caster->MessageString(Chat::SpellFailure, IMMUNE_FEAR);
break;
}
@@ -4461,8 +4461,8 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses)
}
//If owner dead, briefly setting Immmune Aggro while hatelists wipe for both pet and targets is needed to ensure no reaggroing.
else if (IsNPC()){
bool immune_aggro = GetSpecialAbility(IMMUNE_AGGRO); //check if already immune aggro
SetSpecialAbility(IMMUNE_AGGRO, 1);
bool has_aggro_immunity = GetSpecialAbility(SpecialAbility::AggroImmunity); //check if already immune aggro
SetSpecialAbility(SpecialAbility::AggroImmunity, 1);
WipeHateList();
if (IsCasting()) {
InterruptSpell(CastingSpellID());
@@ -4478,8 +4478,8 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses)
}
}
if (!immune_aggro) {
SetSpecialAbility(IMMUNE_AGGRO, 0);
if (!has_aggro_immunity) {
SetSpecialAbility(SpecialAbility::AggroImmunity, 0);
}
}
SendAppearancePacket(AppearanceType::Animation, Animation::Standing);
@@ -9904,7 +9904,7 @@ bool Mob::HarmonySpellLevelCheck(int32 spell_id, Mob *target)
for (int i = 0; i < EFFECT_COUNT; i++) {
// not important to check limit on SE_Lull as it doesnt have one and if the other components won't land, then SE_Lull wont either
if (spells[spell_id].effect_id[i] == SE_ChangeFrenzyRad || spells[spell_id].effect_id[i] == SE_Harmony) {
if ((spells[spell_id].max_value[i] != 0 && target->GetLevel() > spells[spell_id].max_value[i]) || target->GetSpecialAbility(IMMUNE_PACIFY)) {
if ((spells[spell_id].max_value[i] != 0 && target->GetLevel() > spells[spell_id].max_value[i]) || target->GetSpecialAbility(SpecialAbility::PacifyImmunity)) {
return false;
}
}