Server.Mobiles.BaseCreature.IsEnemy C# (CSharp) Méthode

IsEnemy() public méthode

public IsEnemy ( Mobile m ) : bool
m Mobile
Résultat bool
        public virtual bool IsEnemy( Mobile m )
        {
            OppositionGroup g = this.OppositionGroup;

            if ( g != null && g.IsEnemy( this, m ) )
                return true;

            if ( m is BaseGuard )
                return false;

            if ( GetFactionAllegiance( m ) == Allegiance.Ally )
                return false;

            Ethics.Ethic ourEthic = EthicAllegiance;
            Ethics.Player pl = Ethics.Player.Find( m, true );

            if ( pl != null && pl.IsShielded && ( ourEthic == null || ourEthic == pl.Ethic ) )
                return false;

            if ( !(m is BaseCreature) || m is Server.Engines.Quests.Haven.MilitiaFighter )
                return true;

            if( TransformationSpellHelper.UnderTransformation( m, typeof( EtherealVoyageSpell ) ) )
                return false;

            if ( m is PlayerMobile && ( (PlayerMobile)m ).HonorActive )
                return false;

            BaseCreature c = (BaseCreature)m;

            return ( m_iTeam != c.m_iTeam || ( (m_bSummoned || m_bControlled) != (c.m_bSummoned || c.m_bControlled) )/* || c.Combatant == this*/ );
        }

Usage Example

Exemple #1
0
        public static void BlizzardDamage_Callback(object state)
        {
            //Point3D loc = (Point3D)state;

            object[] states = ((object[])state);
            Mobile   ag     = states[0] as Mobile;
            Point3D  loc    = ((Point3D)states[1]);

            if (ag == null || !ag.Alive || ag.Map == Map.Internal)
            {
                return;
            }

            IPooledEnumerable eable = ag.Map.GetMobilesInRange(loc, 0);

            foreach (Mobile m in eable)
            {
                if (m.Blessed || m == null || m.Map == Map.Internal || m.Map == null || !m.Alive || !ag.CanBeHarmful(m))
                {
                    return;
                }

                else if (m is PlayerMobile)
                {
                    PlayerMobile p = m as PlayerMobile;

                    if (p.AccessLevel == AccessLevel.Player)
                    {
                        AOS.Damage(p, ag, 100, 0, 0, 0, 100, 0);
                    }
                    else
                    {
                        p.SendMessage("With your godly powers you avoid the damage");
                    }
                }

                else if (m is BaseCreature)
                {
                    BaseCreature b = m as BaseCreature;

                    if (b.IsEnemy(ag))
                    {
                        AOS.Damage(b, ag, 300, 0, 0, 0, 100, 0);
                    }
                }
            }
            eable.Free();
        }
BaseCreature