Move functions out of mob.h and cleanup

This commit is contained in:
nytmyr
2025-01-30 22:25:54 -06:00
parent 9b72672945
commit e039ce2e37
32 changed files with 1312 additions and 1260 deletions
-105
View File
@@ -7568,108 +7568,3 @@ bool Mob::CheckWaterLoS(Mob* m)
zone->watermap->InLiquid(m->GetPosition())
);
}
bool Mob::IsImmuneToBotSpell(uint16 spell_id, Mob* caster)
{
int effect_index;
if (!caster) {
return false;
}
//TODO: this function loops through the effect list for
//this spell like 10 times, this could easily be consolidated
//into one loop through with a switch statement.
LogSpells("Checking to see if we are immune to spell [{}] cast by [{}]", spell_id, caster->GetName());
if (!IsValidSpell(spell_id)) {
return true;
}
if (GetSpecialAbility(SpecialAbility::DispellImmunity) && IsDispelSpell(spell_id)) {
return true;
}
if (GetSpecialAbility(SpecialAbility::PacifyImmunity) && IsHarmonySpell(spell_id)) {
return true;
}
if (!GetSpecialAbility(SpecialAbility::MesmerizeImmunity) && IsMesmerizeSpell(spell_id)) {
// check max level for spell
effect_index = GetSpellEffectIndex(spell_id, SE_Mez);
assert(effect_index >= 0);
// NPCs get to ignore the max level
if (
(GetLevel() > spells[spell_id].max_value[effect_index]) &&
(!caster->IsNPC() || (caster->IsNPC() && !RuleB(Spells, NPCIgnoreBaseImmunity)))
) {
return true;
}
}
// slow and haste spells
if (GetSpecialAbility(SpecialAbility::SlowImmunity) && IsEffectInSpell(spell_id, SE_AttackSpeed)) {
return true;
}
// client vs client fear
if (!GetSpecialAbility(SpecialAbility::FearImmunity) && IsEffectInSpell(spell_id, SE_Fear)) {
effect_index = GetSpellEffectIndex(spell_id, SE_Fear);
if (IsClient() && caster->IsClient() && (caster->CastToClient()->GetGM() == false)) {
LogSpells("Clients cannot fear eachother!");
caster->MessageString(Chat::Red, IMMUNE_FEAR); // need to verify message type, not in MQ2Cast for easy look up
return true;
}
else if (GetLevel() > spells[spell_id].max_value[effect_index] && spells[spell_id].max_value[effect_index] != 0) {
return true;
}
else if (CheckAATimer(aaTimerWarcry)) {
return true;
}
}
if (!GetSpecialAbility(SpecialAbility::CharmImmunity) && IsCharmSpell(spell_id)) {
if (this == caster) {
return true;
}
//let npcs cast whatever charm on anyone
if (!caster->IsNPC()) {
// check level limit of charm spell
effect_index = GetSpellEffectIndex(spell_id, SE_Charm);
assert(effect_index >= 0);
if (GetLevel() > spells[spell_id].max_value[effect_index] && spells[spell_id].max_value[effect_index] != 0) {
return true;
}
}
}
if (
GetSpecialAbility(SpecialAbility::SnareImmunity) &&
(
IsEffectInSpell(spell_id, SE_Root) ||
IsEffectInSpell(spell_id, SE_MovementSpeed)
)
) {
if (GetSpecialAbility(SpecialAbility::SnareImmunity)) {
return true;
}
}
if (IsLifetapSpell(spell_id)) {
if (this == caster) {
return true;
}
}
if (IsSacrificeSpell(spell_id)) {
if (this == caster) {
return true;
}
}
return false;
}