//GS
public virtual bool IsTeamEnemy{ get{ return !IsFakePlayer; } } // Are other teams my enemy?
public virtual bool IsPlayerEnemy{ get{ return !IsFakePlayer; } } // Are players my enemy?
public virtual bool IsFakePlayer{ get{ return false; } } // Am I considered a player by creatures?
// Fake Player Same-Team Creature Targets
public virtual bool IsMonsterEnemy{ get{ return true; } } // Are aggressive creatures my enemy?
public virtual bool IsAnimalEnemy{ get{ return false; } } // Are passive creatures my enemy?
public virtual bool IsGoodEnemy{ get{ return Karma < 0; } } // Are good-aligned creatures my enemy?
public virtual bool IsEvilEnemy{ get{ return Karma > 0; } } // Are evil-aliged creatures my enemy?
public virtual bool IsEnemy(Mobile m)
{
XmlIsEnemy a = (XmlIsEnemy)XmlAttach.FindAttachment(this, typeof(XmlIsEnemy));
if (a != null)
{
return a.IsEnemy(m);
}
// Are they a Guard?
if (m is BaseGuard)
{
return false;
}
OppositionGroup g = OppositionGroup;
// Are they part of my Opposition Group?
if (g != null && g.IsEnemy(this, m))
{
return true;
}
// Are they part of my Faction?
if (GetFactionAllegiance(m) == Allegiance.Ally)
{
return false;
}
Ethic ourEthic = EthicAllegiance;
Player pl = Ethics.Player.Find(m, true);
// Are they part of my Ethic?
if (pl != null && pl.IsShielded && (ourEthic == null || ourEthic == pl.Ethic))
{
return false;
}
BaseCreature c = m as BaseCreature;
// Ignore a player, player pet, or fake player?
if (!IsPlayerEnemy)
{
if (m is PlayerMobile)
{
return false;
}
if (c != null && (c.Controlled || c.IsFakePlayer))
{
return false;
}
}
// Am I a fake player?
if (IsFakePlayer)
{
// Ignore a non-creature, pet, fake player, or militia fighter
if (c != null && !c.Controlled && !c.IsFakePlayer && !(m is MilitiaFighter))
{
// Are they an aggressive creature?
if (c.FightMode == FightMode.Closest || c.FightMode == FightMode.Strongest || c.FightMode == FightMode.Weakest)
{
// Do I fight aggressive creatures?
if (IsMonsterEnemy)
{
return true;
}
}
// Are they a passive creature?
else if (c.FightMode == FightMode.Aggressor)
{
// Do I fight passive creatures?
if (IsAnimalEnemy)
{
return true;
}
}
// Are they a good-aligned creature?
else if (c.FightMode == FightMode.Evil)
{
// Do I fight good-aligned creatures?
if (IsGoodEnemy)
{
return true;
}
}
// Are they an evil-aligned creature?
else if (c.FightMode == FightMode.Good)
{
// Do I fight evil-aligned creatures?
if (IsEvilEnemy)
{
return true;
}
}
}
}
// Are they a non-creature, fake player, or militia fighter?
if (!(m is BaseCreature) || m is MilitiaFighter || c.IsFakePlayer)
{
return true;
}
// Summons should have same rules as their master, if their master is another creature
if (c.Summoned && c.SummonMaster != null && c.SummonMaster is BaseCreature)
{
c = c.SummonMaster as BaseCreature;
}
BaseCreature t = this;
// Summons should have same rules as their master, if their master is another creature
if (t.Summoned && t.SummonMaster != null && t.SummonMaster is BaseCreature)
{
t = t.SummonMaster as BaseCreature;
}
// Do we fight other teams? Are we on different teams?
if (IsTeamEnemy && (t.m_iTeam != c.m_iTeam))
{
return true;
}
// This section is somewhat weird, since BaseAI is the only place I know that uses IsEnemy
// But it specifically prevents summoned/controlled creatures from checking IsEnemy
// Left in, just in case it's used somewhere else.
if (!IsPlayerEnemy)
{
// EVEN if I'm not Summoned/Controlled, DON'T fight those who are Summoned/Controlled
if (!(t.Summoned || t.Controlled))
{
return false;
}
// If Summoned/Controlled, fight those who are not Summoned/Controlled
return !(c.Summoned || c.Controlled);
}
// If Summoned/Controlled, fight those who are not Summoned/Controlled
// If not Summoned/Controlled, fight those who are Summoned/Controlled
return (t.Summoned || t.Controlled) != (c.Summoned || c.Controlled);
}
//GS//