[Bug Fix] NPC Faction War prevention. (#3595)

* [Bug] NPC Faction War prevention.

This should assist with prevention of NPC Faction waring. I have been using this code on my server for over 5 years with no coredumps or any noted bugs. This was brought up as users have reported a few events where they can trigger NPC's to fight each other.

* Correct a few entries to line up with updated code.

* Re-add missing RestTimer functionality
This commit is contained in:
Fryguy
2023-11-19 11:40:15 -05:00
committed by GitHub
parent c0fe0f11f7
commit f7780b0247
7 changed files with 69 additions and 63 deletions
+10 -3
View File
@@ -3885,11 +3885,12 @@ void Mob::DoBuffTic(const Buffs_Struct &buff, int slot, Mob *caster)
if (IsDetrimentalSpell(buff.spellid)) {
if (caster->IsClient()) {
if (!caster->CastToClient()->GetFeigned())
if (!caster->CastToClient()->GetFeigned()) {
AddToHateList(caster, -effect_value);
} else if (!IsClient()) // Allow NPC's to generate hate if casted on other
// NPC's.
}
} else if (!IsClient()) { // Allow NPC's to generate hate if casted on other NPC's
AddToHateList(caster, -effect_value);
}
}
effect_value = caster->GetActDoTDamage(buff.spellid, effect_value, this);
@@ -3990,6 +3991,12 @@ void Mob::DoBuffTic(const Buffs_Struct &buff, int slot, Mob *caster)
case SE_Charm: {
if (!caster || !PassCharismaCheck(caster, buff.spellid)) {
BuffFadeByEffect(SE_Charm);
// Remove from hate list of any NPC's hate list and remove all NPCs this hate list
if (IsNPC()) {
entity_list.RemoveFromHateLists(this);
WipeHateList(true);
}
}
break;