fix: Abusing summons offscreen (#1175)

This commit is contained in:
mark1145 2022-10-01 07:54:19 +10:00 committed by GitHub
parent f5122fff2a
commit aa270ac868
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2588,6 +2588,8 @@ public abstract class BaseAI
Mobile newFocusMob = null; Mobile newFocusMob = null;
var val = double.MinValue; var val = double.MinValue;
Mobile enemySummonMob = null;
var enemySummonVal = double.MinValue;
var eable = map.GetMobilesInRange(m_Mobile.Location, iRange); var eable = map.GetMobilesInRange(m_Mobile.Location, iRange);
@ -2631,7 +2633,8 @@ public abstract class BaseAI
var bc = m as BaseCreature; var bc = m as BaseCreature;
var pm = m as PlayerMobile; var pm = m as PlayerMobile;
if (Core.AOS && bc?.Summoned == true && bc?.Controlled != true) // Monster don't attack it's own summon
if (Core.AOS && bc != null && bc.Summoned && bc.SummonMaster == m_Mobile)
{ {
continue; continue;
} }
@ -2718,17 +2721,23 @@ public abstract class BaseAI
} }
var theirVal = m_Mobile.GetFightModeRanking(m, acqType, bPlayerOnly); var theirVal = m_Mobile.GetFightModeRanking(m, acqType, bPlayerOnly);
if (theirVal > val && m_Mobile.InLOS(m)) if (theirVal > val && m_Mobile.InLOS(m))
{ {
newFocusMob = m; newFocusMob = m;
val = theirVal; val = theirVal;
} }
// The summon is targeted when nothing else around. Otherwise this monster enters idle mode.
// Do a check for this edge case so players cannot abuse by casting EVs offscreen to kill an idle monster.
else if (Core.AOS && theirVal > enemySummonVal && m_Mobile.InLOS(m) && bc?.Summoned == true && bc?.Controlled != true)
{
enemySummonMob = m;
enemySummonVal = theirVal;
}
} }
eable.Free(); eable.Free();
m_Mobile.FocusMob = newFocusMob; m_Mobile.FocusMob = newFocusMob ?? enemySummonMob;
return m_Mobile.FocusMob != null; return m_Mobile.FocusMob != null;
} }