fix: Attempts to fix IsEnemy with NPC summons again again. (#2052)
This commit is contained in:
parent
5d53825c21
commit
9f50ae431a
1 changed files with 22 additions and 23 deletions
|
|
@ -278,7 +278,7 @@ namespace Server.Mobiles
|
|||
private bool m_bTamable;
|
||||
private int m_ColdResistance;
|
||||
|
||||
private bool m_Controlled; // Is controlled
|
||||
private bool _controlled; // Is controlled
|
||||
private Mobile m_ControlMaster; // My master
|
||||
private OrderType m_ControlOrder; // My order
|
||||
|
||||
|
|
@ -370,7 +370,7 @@ namespace Server.Mobiles
|
|||
|
||||
Debug = false;
|
||||
|
||||
m_Controlled = false;
|
||||
_controlled = false;
|
||||
m_ControlMaster = null;
|
||||
ControlTarget = null;
|
||||
m_ControlOrder = OrderType.None;
|
||||
|
|
@ -749,15 +749,15 @@ namespace Server.Mobiles
|
|||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool Controlled
|
||||
{
|
||||
get => m_Controlled;
|
||||
get => _controlled;
|
||||
set
|
||||
{
|
||||
if (m_Controlled == value)
|
||||
if (_controlled == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_Controlled = value;
|
||||
_controlled = value;
|
||||
Delta(MobileDelta.Noto);
|
||||
|
||||
InvalidateProperties();
|
||||
|
|
@ -1353,24 +1353,23 @@ namespace Server.Mobiles
|
|||
return false;
|
||||
}
|
||||
|
||||
if (FightMode == FightMode.Evil && m.Karma < 0 || c.FightMode == FightMode.Evil && Karma < 0)
|
||||
if (m_Team != c.Team || FightMode == FightMode.Evil && m.Karma < 0 || c.FightMode == FightMode.Evil && Karma < 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_Team != c.Team)
|
||||
var master = GetMaster();
|
||||
var cMaster = c.GetMaster();
|
||||
|
||||
if (master == null)
|
||||
{
|
||||
return true;
|
||||
// Non-summons will attack summons of non-NPCs
|
||||
return cMaster != null && cMaster is not BaseCreature;
|
||||
}
|
||||
|
||||
var targetControlled = c._summoned || c.m_Controlled;
|
||||
|
||||
if (_summoned || m_Controlled)
|
||||
{
|
||||
return targetControlled || c.IsEnemy(GetMaster());
|
||||
}
|
||||
|
||||
return targetControlled && IsEnemy(c.GetMaster());
|
||||
// Summons will attack others summons, if they are enemies with their master
|
||||
// Pets will attack non-summons, but not other summons (legacy logic)
|
||||
return (master as BaseCreature)?.IsEnemy(cMaster ?? m) ?? cMaster == null;
|
||||
}
|
||||
|
||||
public override string ApplyNameSuffix(string suffix)
|
||||
|
|
@ -1871,7 +1870,7 @@ namespace Server.Mobiles
|
|||
// Version 2
|
||||
writer.Write((int)FightMode);
|
||||
|
||||
writer.Write(m_Controlled);
|
||||
writer.Write(_controlled);
|
||||
writer.Write(m_ControlMaster);
|
||||
writer.Write(ControlTarget);
|
||||
writer.Write(ControlDest);
|
||||
|
|
@ -2021,7 +2020,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
FightMode = (FightMode)reader.ReadInt();
|
||||
|
||||
m_Controlled = reader.ReadBool();
|
||||
_controlled = reader.ReadBool();
|
||||
m_ControlMaster = reader.ReadEntity<Mobile>();
|
||||
ControlTarget = reader.ReadEntity<Mobile>();
|
||||
ControlDest = reader.ReadPoint3D();
|
||||
|
|
@ -2049,7 +2048,7 @@ namespace Server.Mobiles
|
|||
{
|
||||
FightMode = FightMode.Closest;
|
||||
|
||||
m_Controlled = false;
|
||||
_controlled = false;
|
||||
m_ControlMaster = null;
|
||||
ControlTarget = null;
|
||||
m_ControlOrder = OrderType.None;
|
||||
|
|
@ -2517,7 +2516,7 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
|
||||
if (aggressor.ChangingCombatant && (m_Controlled || _summoned) &&
|
||||
if (aggressor.ChangingCombatant && (_controlled || _summoned) &&
|
||||
(ct == OrderType.Come || !Core.ML && ct == OrderType.Stay || ct is OrderType.Stop or OrderType.None or OrderType.Follow))
|
||||
{
|
||||
ControlTarget = aggressor;
|
||||
|
|
@ -2561,7 +2560,7 @@ namespace Server.Mobiles
|
|||
AIObject?.GetContextMenuEntries(from, ref list);
|
||||
}
|
||||
|
||||
if (m_bTamable && !m_Controlled && from.Alive)
|
||||
if (m_bTamable && !_controlled && from.Alive)
|
||||
{
|
||||
list.Add(new TameEntry(from.Female ? AllowFemaleTamer : AllowMaleTamer));
|
||||
}
|
||||
|
|
@ -3748,7 +3747,7 @@ namespace Server.Mobiles
|
|||
return BardMaster;
|
||||
}
|
||||
|
||||
if (m_Controlled && m_ControlMaster != null)
|
||||
if (_controlled && m_ControlMaster != null)
|
||||
{
|
||||
return m_ControlMaster;
|
||||
}
|
||||
|
|
@ -4117,7 +4116,7 @@ namespace Server.Mobiles
|
|||
|
||||
public virtual bool IsFriend(Mobile m) =>
|
||||
OppositionGroup?.IsEnemy(this, m) != true && m is BaseCreature c && m_Team == c.m_Team
|
||||
&& (_summoned || m_Controlled) == (c._summoned || c.m_Controlled);
|
||||
&& (_summoned || _controlled) == (c._summoned || c._controlled);
|
||||
|
||||
public virtual Allegiance GetFactionAllegiance(Mobile mob)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue