Example #1
0
        public override bool IsEnemy(Mobile m)
        {
            Faction ourFaction   = m_Faction;
            Faction theirFaction = Faction.Find(m);

            if (theirFaction == null && m is BaseFactionGuard)
            {
                theirFaction = ((BaseFactionGuard)m).Faction;
            }
            if (m is BaseCreature)
            {
                if (((BaseCreature)m).FactionAllegiance != null && FactionAllegiance != null && ((BaseCreature)m).FactionAllegiance != FactionAllegiance)
                {
                    return(true);
                }
            }

            if (ourFaction != null && theirFaction != null && ourFaction != theirFaction)
            {
                ReactionType reactionType = Orders.GetReaction(theirFaction).Type;

                if (reactionType == ReactionType.Attack)
                {
                    return(true);
                }

                if (m is BaseFactionGuard)
                {
                    return(true);
                }

                if (theirFaction != null)
                {
                    List <AggressorInfo> list = m.Aggressed;

                    for (int i = 0; i < list.Count; ++i)
                    {
                        AggressorInfo ai = list[i];

                        if (ai.Defender is BaseFactionGuard)
                        {
                            BaseFactionGuard bf = (BaseFactionGuard)ai.Defender;

                            if (bf.Faction == ourFaction)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Example #2
0
        public override bool IsEnemy(Mobile m, RelationshipFilter filter)
        {
            Faction ourFaction   = m_Faction;
            Faction theirFaction = Faction.Find(m);

            if (theirFaction == null && m is BaseFactionGuard)
            {
                theirFaction = ((BaseFactionGuard)m).Faction;
            }

            if (ourFaction != null && theirFaction != null && ourFaction != theirFaction)
            {
                ReactionType reactionType = Orders.GetReaction(theirFaction).Type;

                if (reactionType == ReactionType.Attack)
                {
                    return(true);
                }

                if (theirFaction != null)
                {
                    List <AggressorInfo> list = m.Aggressed;

                    for (int i = 0; i < list.Count; ++i)
                    {
                        AggressorInfo ai = list[i] as AggressorInfo;

                        if (ai == null)
                        {
                            continue;
                        }

                        if (ai.Defender is BaseFactionGuard)
                        {
                            BaseFactionGuard bf = (BaseFactionGuard)ai.Defender;

                            if (bf.Faction == ourFaction)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Example #3
0
        public bool RegisterGuard(BaseFactionGuard guard)
        {
            if (guard == null)
            {
                return(false);
            }

            GuardList guardList = FindGuardList(guard.GetType());

            if (guardList == null)
            {
                return(false);
            }

            guardList.Guards.Add(guard);
            return(true);
        }
Example #4
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (!m_Town.IsSheriff(m_From) || m_Town.Owner != m_Faction)
            {
                m_From.SendLocalizedMessage(1010339); // You no longer control this city
                return;
            }

            int index = info.ButtonID - 1;

            if (index >= 0 && index < m_Town.GuardLists.Count)
            {
                GuardList guardList = m_Town.GuardLists[index];

                if (Town.FromRegion(m_From.Region) != m_Town)
                {
                    m_From.SendLocalizedMessage(1010305); // You must be in your controlled city to buy Items
                }
                else if (guardList.Guards.Count >= guardList.Definition.Maximum)
                {
                    m_From.SendLocalizedMessage(
                        1010306); // You currently have too many of this enhancement type to place another
                }
                else if (BaseBoat.FindBoatAt(m_From.Location, m_From.Map) != null)
                {
                    m_From.SendMessage("You cannot place a guard here");
                }
                else if (m_Town.Silver >= guardList.Definition.Price)
                {
                    BaseFactionGuard guard = guardList.Construct();

                    if (guard != null)
                    {
                        guard.Faction = m_Faction;
                        guard.Town    = m_Town;

                        m_Town.Silver -= guardList.Definition.Price;

                        guard.MoveToWorld(m_From.Location, m_From.Map);
                        guard.Home = guard.Location;
                    }
                }
            }
        }
Example #5
0
        public void EndOrderFiring(Mobile from, object obj)
        {
            bool   isFinance = IsFinance(from);
            bool   isSheriff = IsSheriff(from);
            string type      = null;

            if (isFinance && isSheriff)               // GM only
            {
                type = "vendor or guard";
            }
            else if (isFinance)
            {
                type = "vendor";
            }
            else if (isSheriff)
            {
                type = "guard";
            }

            if (obj is BaseFactionVendor)
            {
                BaseFactionVendor vendor = (BaseFactionVendor)obj;

                if (vendor.Town == this && isFinance)
                {
                    vendor.Delete();
                }
            }
            else if (obj is BaseFactionGuard)
            {
                BaseFactionGuard guard = (BaseFactionGuard)obj;

                if (guard.Town == this && isSheriff)
                {
                    guard.Delete();
                }
            }
            else
            {
                from.SendMessage("That is not a {0}!", type);
            }
        }
Example #6
0
        public bool UnregisterGuard(BaseFactionGuard guard)
        {
            if (guard == null)
            {
                return(false);
            }

            GuardList guardList = FindGuardList(guard.GetType());

            if (guardList == null)
            {
                return(false);
            }

            if (!guardList.Guards.Contains(guard))
            {
                return(false);
            }

            guardList.Guards.Remove(guard);
            return(true);
        }
Example #7
0
 public FactionGuardAI(BaseFactionGuard guard)
     : base(guard)
 {
     m_Guard = guard;
 }
Example #8
0
		public bool UnregisterGuard( BaseFactionGuard guard )
		{
			if ( guard == null )
				return false;

			GuardList guardList = FindGuardList( guard.GetType() );

			if ( guardList == null )
				return false;

			if ( !guardList.Guards.Contains( guard ) )
				return false;

			guardList.Guards.Remove( guard );
			return true;
		}
Example #9
0
		public bool RegisterGuard( BaseFactionGuard guard )
		{
			if ( guard == null )
				return false;

			GuardList guardList = FindGuardList( guard.GetType() );

			if ( guardList == null )
				return false;

			guardList.Guards.Add( guard );
			return true;
		}
		public FactionGuardAI(BaseFactionGuard guard)
			: base(guard)
		{
			m_Guard = guard;
		}