Example #1
0
        public static void Initialize()
        {
            EventSink.PlayerDeath += new PlayerDeathEventHandler(EventSink_PlayerDeath);
            EventSink.Logout      += new LogoutEventHandler(EventSink_Logout);
            EventSink.Login       += new LoginEventHandler(EventSink_Login);
            EventSink.Movement    += new MovementEventHandler(EventSink_Movement);
            EventSink.WorldSave   += new WorldSaveEventHandler(EventSink_WorldSave);

            PlayerMobile.AllowBeneficialHandler = new AllowBeneficialHandler(PlayerMobile_AllowBenificial);
            PlayerMobile.AllowHarmfulHandler    = new AllowHarmfulHandler(PlayerMobile_AllowHarmful);

            Notoriety.Handler = new NotorietyHandler(Notoriety_HandleNotoriety);

            CommandSystem.Register("OnsiteConfig", AccessLevel.Administrator, new CommandEventHandler(OnCommand_OnsiteConfig));
            CommandSystem.Register("Duel", AccessLevel.Player, new CommandEventHandler(OnCommand_Duel));

            m_Instance              = new DuelController();
            m_TimeoutTable          = new Dictionary <Serial, LogoutTimeoutTimer>();
            m_DuelTable             = new Dictionary <Serial, Duel>();
            m_PointsTable           = new Dictionary <Serial, DuelPoints>();
            m_DeclineDuelList       = new List <Mobile>();
            m_DuelStartTimeoutTable = new Dictionary <Serial, DuelStartTimer>();

            LoadSaves();
        }
Example #2
0
		public static void Initialize()
		{
			EventSink.PlayerDeath += new PlayerDeathEventHandler(EventSink_PlayerDeath);
			EventSink.Logout += new LogoutEventHandler(EventSink_Logout);
			EventSink.Login += new LoginEventHandler(EventSink_Login);
			EventSink.Movement += new MovementEventHandler(EventSink_Movement);
			EventSink.WorldSave += new WorldSaveEventHandler(EventSink_WorldSave);

			PlayerMobile.AllowBeneficialHandler = new AllowBeneficialHandler(PlayerMobile_AllowBenificial);
			PlayerMobile.AllowHarmfulHandler = new AllowHarmfulHandler(PlayerMobile_AllowHarmful);

			Notoriety.Handler = new NotorietyHandler(Notoriety_HandleNotoriety);

			CommandSystem.Register("OnsiteConfig", AccessLevel.Administrator, new CommandEventHandler(OnCommand_OnsiteConfig));
			CommandSystem.Register("Duel", AccessLevel.Player, new CommandEventHandler(OnCommand_Duel));

			m_Instance = new DuelController();
			m_TimeoutTable = new Dictionary<Serial, LogoutTimeoutTimer>();
			m_DuelTable = new Dictionary<Serial, Duel>();
			m_PointsTable = new Dictionary<Serial, DuelPoints>();
			m_DeclineDuelList = new List<Mobile>();
			m_DuelStartTimeoutTable = new Dictionary<Serial, DuelStartTimer>();

			LoadSaves();
		}
Example #3
0
        protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType)
        {
            base.OnTargetCancel(from, cancelType);

            m_Duel.Broadcast("The duel was canceled.");
            DuelController.DestroyDuel(m_Duel);

            from.SendMessage("You have cancelled the duel request.");
        }
Example #4
0
 private void HandlePoints(Mobile m, bool winner)
 {
     if (winner)
     {
         DuelController.AddWin(this, m);
     }
     else
     {
         DuelController.AddLoss(this, m);
     }
 }
Example #5
0
        internal void Serialize(GenericWriter writer)
        {
            writer.WriteEncodedInt(0);             // version

            writer.Write((Server.Mobile)m_Mobile);

            DuelController.WritePointsDictionary(m_FastestWins, writer);
            DuelController.WritePointsDictionary(m_LongestWins, writer);
            DuelController.WritePointsDictionary(m_FastestLoses, writer);
            DuelController.WritePointsDictionary(m_LongestLoses, writer);
            DuelController.WriteIntDictionary(m_Wins, writer);
            DuelController.WriteIntDictionary(m_Loses, writer);
        }
Example #6
0
        private void CompleteDuel()
        {
            List <Mobile> contestants = new List <Mobile>();

            contestants.AddRange(m_Attackers);
            contestants.AddRange(m_Defenders);

            for (int i = 0; i < contestants.Count; i++)
            {
                FixMobile(contestants[i]);
            }

            DuelController.DestroyDuel(this);
        }
Example #7
0
        protected override void OnTick()
        {
            m_Duel.Broadcast(32, "The duel has timed out...");

            if (m_Duel != null)
            {
                DuelController.DestroyDuel(m_Duel);
            }

            if (DuelController.DuelStartTimeoutTable.ContainsKey(m_Duel.Creator.Serial))
            {
                DuelController.DuelStartTimeoutTable.Remove(m_Duel.Creator.Serial);
            }

            Stop();
        }
Example #8
0
        public DuelPoints(GenericReader reader)
        {
            int version = reader.ReadEncodedInt();

            switch (version)
            {
            case 0:
            {
                m_Mobile       = reader.ReadMobile();
                m_FastestWins  = DuelController.ReadPointsDictionary(reader);
                m_LongestWins  = DuelController.ReadPointsDictionary(reader);
                m_FastestLoses = DuelController.ReadPointsDictionary(reader);
                m_LongestLoses = DuelController.ReadPointsDictionary(reader);
                m_Wins         = DuelController.ReadIntDictionary(reader);
                m_Loses        = DuelController.ReadIntDictionary(reader);

                break;
            }
            }
        }
Example #9
0
 public void Broadcast(int hue, string msg)
 {
     DuelController.Broadcast(hue, msg, Contestants);
 }
Example #10
0
 public void Broadcast(string msg)
 {
     DuelController.Broadcast(msg, Contestants);
 }
Example #11
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            Mobile  m      = sender.Mobile;
            Buttons button = (Buttons)info.ButtonID;

            if (m == null || m_Duel == null)
            {
                return;
            }

            if (m_DeclinesDuels && button != Buttons.toggleBtn && button != Buttons.closeBtn)
            {
                m.SendMessage("You can't start a duel if you have chosen to not accept duel invites.");
                m.SendMessage("Check the allow duel invites box before you start a duel.");
                m.SendGump(new DuelConfigGump(m_Duel));
                return;
            }

            switch (button)
            {
            case Buttons.closeBtn:
            {
                DuelController.DestroyDuel(m_Duel);
                m.SendMessage("The duel was not created.");
                break;
            }

            case Buttons.oneBtn:
            {
                m_Duel.SpotsRemaing = 1;
                m_Duel.Configure(1);
                m_Duel.Contestants.Add(m_Duel.Creator);

                m.SendMessage("Please select the player you wish to duel.");
                m.Target = new DuelTarget(m, m_Duel);

                break;
            }

            case Buttons.twoBtn:
            {
                m_Duel.SpotsRemaing = 3;
                m_Duel.Configure(2);
                m_Duel.Contestants.Add(m_Duel.Creator);

                m.SendMessage("Please select a player to add to the duel.");
                m.SendMessage("Do not be concerned with what side they will be on at this point.");
                m.Target = new DuelTarget(m, m_Duel);
                break;
            }

            case Buttons.threeBtn:
            {
                m_Duel.SpotsRemaing = 5;
                m_Duel.Configure(3);
                m_Duel.Contestants.Add(m_Duel.Creator);

                m.SendMessage("Please select a player to add to the duel.");
                m.SendMessage("Do not be concerned with what side they will be on at this point.");
                m.Target = new DuelTarget(m, m_Duel);
                break;
            }

            case Buttons.fourBtn:
            {
                m_Duel.SpotsRemaing = 7;
                m_Duel.Configure(4);
                m_Duel.Contestants.Add(m_Duel.Creator);

                m.SendMessage("Please select a player to add to the duel.");
                m.SendMessage("Do not be concerned with what side they will be on at this point.");
                m.Target = new DuelTarget(m, m_Duel);
                break;
            }

            case Buttons.fiveBtn:
            {
                m_Duel.SpotsRemaing = 9;
                m_Duel.Configure(5);
                m_Duel.Contestants.Add(m_Duel.Creator);

                m.SendMessage("Please select a player to add to the duel.");
                m.SendMessage("Do not be concerned with what side they will be on at this point.");
                m.Target = new DuelTarget(m, m_Duel);
                break;
            }

            case Buttons.toggleBtn:
            {
                if (m_DeclinesDuels)
                {
                    DuelController.DeclineDuelList.Remove(m_Duel.Creator);
                }
                else
                {
                    DuelController.DeclineDuelList.Add(m_Duel.Creator);
                }

                m.CloseGump(typeof(DuelConfigGump));
                m.SendGump(new DuelConfigGump(m_Duel));

                break;
            }
            }
        }
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            Mobile m = sender.Mobile;

            if (m == null || m_Duel == null)
            {
                return;
            }

            int[] sw = info.Switches;

            if (sw.Length != (m_Duel.Attackers.Capacity + m_Duel.Defenders.Capacity))
            {
                m_Duel.Creator.SendMessage("Some players were not assigned to a team. Please try again.");
                m_Duel.Creator.CloseGump(typeof(DuelTeamSelectionGump));
                m_Duel.Creator.SendGump(new DuelTeamSelectionGump(m_Duel));
                return;
            }

            List <int> switches = new List <int>(sw);

            switch ((Buttons)info.ButtonID)
            {
            case Buttons.closeBtn:
            {
                m_Duel.Broadcast("The duel was canceled.");
                DuelController.DestroyDuel(m_Duel);
                break;
            }

            case Buttons.startBtn:
            {
                int teamCheckOne = 0;
                int teamCheckTwo = 0;

                for (int i = 0; i < m_MobileEntries.Count; i++)
                {
                    if (switches.Contains(m_MobileEntries[i].TeamOne))
                    {
                        teamCheckOne++;
                    }
                    else
                    {
                        teamCheckTwo++;
                    }
                }

                if (teamCheckOne != teamCheckTwo)
                {
                    m_Duel.Creator.SendMessage("The two teams were not even, please try again.");
                    m_Duel.Creator.CloseGump(typeof(DuelTeamSelectionGump));
                    m_Duel.Creator.SendGump(new DuelTeamSelectionGump(m_Duel));
                    return;
                }
                else
                {
                    for (int i = 0; i < m_MobileEntries.Count; i++)
                    {
                        if (switches.Contains(m_MobileEntries[i].TeamOne))
                        {
                            m_Duel.Attackers.Add(m_MobileEntries[i].Mobile);
                        }
                        else
                        {
                            m_Duel.Defenders.Add(m_MobileEntries[i].Mobile);
                        }
                    }

                    //m_Duel.Contestants.Clear();

                    m_Duel.CheckBegin();
                }

                break;
            }
            }
        }
Example #13
0
        protected override void OnTarget(Mobile from, object target)
        {
            if (target is PlayerMobile)
            {
                Mobile m = (Mobile)target;

                if (m.NetState == null)
                {
                    from.SendMessage("That player is not online.");
                    from.SendMessage("Select a new target.");
                    from.Target = new DuelTarget(m_Mobile, m_Duel);
                    return;
                }
                else if (DuelController.DeclineDuelList.Contains(m))
                {
                    from.SendMessage("This person has elected to decline all duels.");
                    from.SendMessage("Select a new target.");
                    from.Target = new DuelTarget(m_Mobile, m_Duel);
                    return;
                }
                else if (m == from)
                {
                    from.SendMessage("You slap yourself across the face and declare yourself the winner.");
                    from.SendMessage("Select a new target.");
                    from.Target = new DuelTarget(m_Mobile, m_Duel);
                    return;
                }
                if (m.Criminal)
                {
                    m.SendMessage("You may not start a duel with someone who is flagged criminal.");
                    from.SendMessage("Select a new target.");
                    from.Target = new DuelTarget(m_Mobile, m_Duel);
                    return;
                }
                else if (Spells.SpellHelper.CheckCombat(m))
                {
                    from.SendMessage("That person is currently in combat. You must wait to duel them.");
                    from.SendMessage("Select a new target.");
                    from.Target = new DuelTarget(m_Mobile, m_Duel);
                    return;
                }
                else if (DuelController.IsInDuel(m))
                {
                    from.SendMessage("That person is currently in a duel. You must wait to duel them.");
                    from.SendMessage("Select a new target.");
                    from.Target = new DuelTarget(m_Mobile, m_Duel);
                    return;
                }
                else
                {
                    if (m_Duel != null)
                    {
                        m_Duel.SpotsRemaing--;
                        m.CloseGump(typeof(DuelAcceptGump));
                        m.SendGump(new DuelAcceptGump(m, m_Duel));
                        from.SendMessage("{0} has been invited to join the duel.", m.Name);

                        if (m_Duel.SpotsRemaing != 0)
                        {
                            m_Duel.Creator.SendMessage("Select another player to join the duel.");
                            m_Duel.Creator.Target = new DuelTarget(m_Duel.Creator, m_Duel);
                        }
                    }
                }
            }
            else
            {
                from.SendMessage("That is not a player.");
                from.SendMessage("Select a new target.");
                from.Target = new DuelTarget(m_Mobile, m_Duel);
                return;
            }
        }