fix: Fixes pets from attacking themselves (#2265)

### Summary

Stops pets from attacking themselves.
This commit is contained in:
Bohica 2025-11-15 10:15:10 -08:00 committed by GitHub
parent 6f5b7f7a6b
commit 5667017874
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 0 deletions

View file

@ -46,6 +46,14 @@ public class AnimalAI : BaseAI
{ {
var combatant = Mobile.Combatant; var combatant = Mobile.Combatant;
if (Mobile.Controlled && combatant == Mobile)
{
DebugSay("I should not attack myself!");
Mobile.Combatant = null;
Action = ActionType.Guard;
return true;
}
if (combatant == null || combatant.Deleted || combatant.Map != Mobile.Map || !combatant.Alive || if (combatant == null || combatant.Deleted || combatant.Map != Mobile.Map || !combatant.Alive ||
combatant.IsDeadBondedPet) combatant.IsDeadBondedPet)
{ {

View file

@ -624,6 +624,14 @@ public class MageAI : BaseAI
var c = Mobile.Combatant; var c = Mobile.Combatant;
Mobile.Warmode = true; Mobile.Warmode = true;
if (Mobile.Controlled && c == Mobile)
{
DebugSay("I should not attack myself!");
Mobile.Combatant = null;
Action = ActionType.Guard;
return true;
}
if (c?.Deleted != false || !c.Alive || c.IsDeadBondedPet || !Mobile.CanSee(c) || if (c?.Deleted != false || !c.Alive || c.IsDeadBondedPet || !Mobile.CanSee(c) ||
!Mobile.CanBeHarmful(c, false) || c.Map != Mobile.Map) !Mobile.CanBeHarmful(c, false) || c.Map != Mobile.Map)
{ {

View file

@ -33,6 +33,14 @@ public class MeleeAI : BaseAI
{ {
var combatant = Mobile.Combatant; var combatant = Mobile.Combatant;
if (Mobile.Controlled && combatant == Mobile)
{
DebugSay("I should not attack myself!");
Mobile.Combatant = null;
Action = ActionType.Guard;
return true;
}
if (combatant == null || combatant.Deleted || combatant.Map != Mobile.Map || !combatant.Alive || if (combatant == null || combatant.Deleted || combatant.Map != Mobile.Map || !combatant.Alive ||
combatant.IsDeadBondedPet) combatant.IsDeadBondedPet)
{ {