Ejemplo n.º 1
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];
                Town      town      = Town.FromRegion(m_From.Region);

                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;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void EventSink_Speech(SpeechEventArgs e)
        {
            Mobile from = e.Mobile;

            int[] keywords = e.Keywords;

            for (int i = 0; i < keywords.Length; ++i)
            {
                switch (keywords[i])
                {
                case 0x00E4:     // *i wish to access the city treasury*
                {
                    Town town = Town.FromRegion(from.Region);

                    if (town == null || !town.IsFinance(from) || !from.Alive)
                    {
                        break;
                    }

                    if (FactionGump.Exists(from))
                    {
                        from.SendLocalizedMessage(1042160);         // You already have a faction menu open.
                    }
                    else if (town.Owner != null && from is PlayerMobile)
                    {
                        from.SendGump(new FinanceGump((PlayerMobile)from, town.Owner, town));
                    }

                    break;
                }

                case 0x0ED:     // *i am sheriff*
                {
                    Town town = Town.FromRegion(from.Region);

                    if (town == null || !town.IsSheriff(from) || !from.Alive)
                    {
                        break;
                    }

                    if (FactionGump.Exists(from))
                    {
                        from.SendLocalizedMessage(1042160);         // You already have a faction menu open.
                    }
                    else if (town.Owner != null)
                    {
                        from.SendGump(new SheriffGump((PlayerMobile)from, town.Owner, town));
                    }

                    break;
                }

                case 0x00EF:     // *you are fired*
                {
                    Town town = Town.FromRegion(from.Region);

                    if (town == null)
                    {
                        break;
                    }

                    if (town.IsFinance(from) || town.IsSheriff(from))
                    {
                        town.BeginOrderFiring(from);
                    }

                    break;
                }

                case 0x00E5:     // *i wish to resign as finance minister*
                {
                    PlayerState pl = PlayerState.Find(from);

                    if (pl != null && pl.Finance != null)
                    {
                        pl.Finance.Finance = null;
                        from.SendLocalizedMessage(1005081);         // You have been fired as Finance Minister
                    }

                    break;
                }

                case 0x00EE:     // *i wish to resign as sheriff*
                {
                    PlayerState pl = PlayerState.Find(from);

                    if (pl != null && pl.Sheriff != null)
                    {
                        pl.Sheriff.Sheriff = null;
                        from.SendLocalizedMessage(1010270);         // You have been fired as Sheriff
                    }

                    break;
                }

                case 0x00E9:     // *what is my faction term status*
                {
                    PlayerState pl = PlayerState.Find(from);

                    if (pl != null && pl.IsLeaving)
                    {
                        if (Faction.CheckLeaveTimer(from))
                        {
                            break;
                        }

                        TimeSpan remaining = (pl.Leaving + Faction.LeavePeriod) - DateTime.UtcNow;

                        if (remaining.TotalDays >= 1)
                        {
                            from.SendLocalizedMessage(1042743, remaining.TotalDays.ToString("N0"));        // Your term of service will come to an end in ~1_DAYS~ days.
                        }
                        else if (remaining.TotalHours >= 1)
                        {
                            from.SendLocalizedMessage(1042741, remaining.TotalHours.ToString("N0"));         // Your term of service will come to an end in ~1_HOURS~ hours.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1042742);         // Your term of service will come to an end in less than one hour.
                        }
                    }
                    else if (pl != null)
                    {
                        from.SendLocalizedMessage(1042233);         // You are not in the process of quitting the faction.
                    }

                    break;
                }

                case 0x00EA:     // *message faction*
                {
                    Faction faction = Faction.Find(from);

                    if (faction == null || !faction.IsCommander(from))
                    {
                        break;
                    }

                    if (from.AccessLevel == AccessLevel.Player && !faction.FactionMessageReady)
                    {
                        from.SendLocalizedMessage(1010264);         // The required time has not yet passed since the last message was sent
                    }
                    else
                    {
                        faction.BeginBroadcast(from);
                    }

                    break;
                }

                case 0x00EC:     // *showscore*
                {
                    PlayerState pl = PlayerState.Find(from);

                    if (pl != null)
                    {
                        Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(ShowScore_Sandbox), pl);
                    }

                    break;
                }

                case 0x0178:     // i honor your leadership
                {
                    Faction faction = Faction.Find(from);

                    if (faction != null)
                    {
                        faction.BeginHonorLeadership(from);
                    }

                    break;
                }
                }
            }
        }
Ejemplo n.º 3
0
        public override void OnSpeech(SpeechEventArgs e)
        {
            base.OnSpeech(e);

            Mobile from = e.Mobile;

            if (!e.Handled && InRange(from, ListenRange) && from.Alive)
            {
                if (e.HasKeyword(0xE6) && (Insensitive.Equals(e.Speech, "orders") || WasNamed(e.Speech))) // *orders*
                {
                    if (m_Town == null || !m_Town.IsSheriff(from))
                    {
                        this.Say(1042189); // I don't work for you!
                    }
                    else if (Town.FromRegion(this.Region) == m_Town)
                    {
                        this.Say(1042180); // Your orders, sire?
                        m_OrdersEnd = DateTime.UtcNow + TimeSpan.FromSeconds(10.0);
                    }
                }
                else if (DateTime.UtcNow < m_OrdersEnd)
                {
                    if (m_Town != null && m_Town.IsSheriff(from) && Town.FromRegion(this.Region) == m_Town)
                    {
                        m_OrdersEnd = DateTime.UtcNow + TimeSpan.FromSeconds(10.0);

                        bool         understood = true;
                        ReactionType newType    = 0;

                        if (Insensitive.Contains(e.Speech, "attack"))
                        {
                            newType = ReactionType.Attack;
                        }
                        else if (Insensitive.Contains(e.Speech, "warn"))
                        {
                            newType = ReactionType.Warn;
                        }
                        else if (Insensitive.Contains(e.Speech, "ignore"))
                        {
                            newType = ReactionType.Ignore;
                        }
                        else
                        {
                            understood = false;
                        }

                        if (understood)
                        {
                            understood = false;

                            if (Insensitive.Contains(e.Speech, "civil"))
                            {
                                ChangeReaction(null, newType);
                                understood = true;
                            }

                            List <Faction> factions = Faction.Factions;

                            for (int i = 0; i < factions.Count; ++i)
                            {
                                Faction faction = factions[i];

                                if (faction != m_Faction && Insensitive.Contains(e.Speech, faction.Definition.Keyword))
                                {
                                    ChangeReaction(faction, newType);
                                    understood = true;
                                }
                            }
                        }
                        else if (Insensitive.Contains(e.Speech, "patrol"))
                        {
                            Home              = Location;
                            RangeHome         = 6;
                            Combatant         = null;
                            m_Orders.Movement = MovementType.Patrol;
                            Say(1005146); // This spot looks like it needs protection!  I shall guard it with my life.
                            understood = true;
                        }
                        else if (Insensitive.Contains(e.Speech, "follow"))
                        {
                            Home              = Location;
                            RangeHome         = 6;
                            Combatant         = null;
                            m_Orders.Follow   = from;
                            m_Orders.Movement = MovementType.Follow;
                            Say(1005144); // Yes, Sire.
                            understood = true;
                        }

                        if (!understood)
                        {
                            Say(1042183); // I'm sorry, I don't understand your orders...
                        }
                    }
                }
            }
        }