[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
+4
View File
@@ -1062,6 +1062,10 @@ void Mob::AI_Process() {
SetTarget(hate_list.GetClosestEntOnHateList(this));
else {
if (AI_target_check_timer->Check()) {
if (IsNPC() && (!IsPet() || (HasOwner() && GetOwner()->IsNPC())) && !CastToNPC()->WillAggroNPCs()) {
WipeHateList(true); // wipe NPCs from hate list to prevent faction war
}
if (IsFocused()) {
if (!target) {
SetTarget(hate_list.GetEntWithMostHateOnList(this));