Пример #1
0
        public void Deserialize(GenericReader reader)
        {
            int version = reader.ReadInt();
            m_DuelType = reader.ReadInt();
            m_Potions = reader.ReadBool();
            m_Summoning = reader.ReadBool();
            m_Looting = reader.ReadBool();
            m_player1 = reader.ReadMobile();
            m_player2 = reader.ReadMobile();
            m_start = reader.ReadDateTime();
            m_end = reader.ReadDateTime();
            m_winner = reader.ReadInt();
            m_Arena = (ArenaControl)reader.ReadItem();

            int duelTicks = reader.ReadInt();
            if (duelTicks > 0)
            {
                m_DuelTimer = new DuelTimer(this, duelTicks);
                m_DuelTimer.Start();
            }

            int countTicks = reader.ReadInt();
            if (countTicks > 0)
            {
                m_CountTimer = new CountTimer(this, countTicks);
                m_CountTimer.Start();
            }
        }
Пример #2
0
        public void Begin()
        {
            if (Ladder.Duellers.Contains(m_player1))
            {
                m_player1.SendMessage("Duel has been canceled because you are already involved in a duel.");
                m_player2.SendMessage("Duel has been canceled because your opponent is already involved in a duel.");
            }
            else if (Ladder.Duellers.Contains(m_player2))
            {
                m_player2.SendMessage("Duel has been canceled because you are already involved in a duel.");
                m_player1.SendMessage("Duel has been canceled because your opponent is already involved in a duel.");
            }
//			else if (m_player1.NetState != null && m_player2.NetState != null && m_player1.NetState.Address.Equals(m_player2.NetState.Address))
//			{
//				m_player2.SendMessage("Duel has been canceled because multiclienting is not allowed.");
//				m_player1.SendMessage("Duel has been canceled because multiclienting is not allowed.");
//			}
			else if (m_player1.Region != m_player2.Region || !(m_player1.Region is CustomRegion) || !(((CustomRegion)m_player1.Region).Controller is LadderAreaControl))
            {
                m_player2.SendMessage("Duel has been canceled because you weren't both in a Ladder Area");
                m_player1.SendMessage("Duel has been canceled because you weren't both in a Ladder Area");

            }
            else if ((m_Arena = ((LadderAreaControl)((CustomRegion)m_player1.Region).Controller).GetArena()) == null)
            {
                // no arena
                m_player2.SendMessage("Duel has been canceled because there were no free arenas. If this problem persists, page a GM to make some more arenas.");
                m_player1.SendMessage("Duel has been canceled because there were no free arenas. If this problem persists, page a GM to make some more arenas.");

            }
            else if (m_player1.Spell != null || m_player2.Spell != null)
            {
                m_player2.SendMessage("Duel has been canceled because precasting spells is not allowed.");
                m_player1.SendMessage("Duel has been canceled because precasting spells is not allowed.");
            }
			else if (m_player1.RawStr != m_player1.Str || m_player1.RawDex != m_player1.Dex || m_player1.RawInt != m_player1.Int)
			{
				m_player2.SendMessage("Duel has been canceled because your opponent was pre-duel buffed, which is not allowed(Potion, spell, etc. buffs)");
				m_player1.SendMessage("Duel has been canceled because your were pre-duel buffed, which is not allowed(Potion, spell, etc. buffs)");
			}
			else if (m_player2.RawStr != m_player2.Str || m_player2.RawDex != m_player2.Dex || m_player2.RawInt != m_player2.Int)
			{
				m_player1.SendMessage("Duel has been canceled because your opponent was pre-duel buffed, which is not allowed(Potion, spell, etc. buffs)");
				m_player2.SendMessage("Duel has been canceled because your were pre-duel buffed, which is not allowed(Potion, spell, etc. buffs)");
			}
			else if (m_player1.Mana != m_player1.Int)
			{
				m_player2.SendMessage("Duel has been canceled because your opponent was not full in spirit. He needs to meditate.");
				m_player1.SendMessage("Duel has been canceled because your your spirit is not full. Meditate to full spirit before duelling.");
			}
			else if (m_player2.Mana != m_player2.Int)
			{
				m_player1.SendMessage("Duel has been canceled because your opponent was not full in spirit. He needs to meditate.");
				m_player2.SendMessage("Duel has been canceled because your your spirit is not full. Meditate to full spirit before duelling.");
			}
			else
            {

                BitArray m_RestrictedSpells = m_Arena.RestrictedSpells;
                BitArray m_RestrictedSkills = m_Arena.RestrictedSkills;
                // Set up arena
                m_Arena.InUse = true;

                // These flags are default
                m_Arena.PlayerLogoutDelay = TimeSpan.FromDays(1);
                m_Arena.AllowHousing = false;
                m_Arena.AllowSpawn = false;
                m_Arena.CanMountEthereal = false;
                m_Arena.CannotEnter = false;
                m_Arena.CanUseStuckMenu = false;
                m_Arena.ItemDecay = true;
                m_Arena.ShowEnterMessage = false;
                m_Arena.ShowExitMessage = false;
                m_Arena.CannotLootOwnCorpse = false;
                m_Arena.IsGuarded = false;

                // Ban everything until countdown is finished
                for (int i = 0; i < m_RestrictedSpells.Length; i++)
                {
                    m_RestrictedSpells[i] = true; ;
                }

                for (int i = 0; i < m_RestrictedSkills.Length; i++)
                {
                    m_RestrictedSkills[i] = true;
                }



                // Set arena flags to false until count
                m_Arena.AllowBenifitPlayer = false;
                m_Arena.AllowHarmPlayer = false;
                m_Arena.CanBeDamaged = false;
                //m_Arena.CanHeal = false;
                m_Arena.CanRessurect = false;
                m_Arena.AllowBenifitNPC = false;
                m_Arena.AllowHarmNPC = false;
                m_Arena.CanLootPlayerCorpse = false;
                m_Arena.CanLootNPCCorpse = false;
                m_Arena.CanUsePotions = false;


                // Save out location
                m_Arena.OutMap = m_player1.Map;
                m_Arena.OutLoc = m_player1.Location;


                m_start = DateTime.Now;
                Ladder.Duellers.Add(m_player1);
                Ladder.Duellers.Add(m_player2);
                Ladder.Duels.Add(this);

                // Disarm

                ArrayList equipitems = new ArrayList(m_player1.Items);
                foreach (Item item in equipitems)
                {
					if (item is BaseWeapon && !Ladder.WeapAllowed((PlayerMobile)m_player1, (BaseWeapon)item) && m_player1.Backpack != null)
					{
						m_player1.SendMessage("The weapon you are wielding is now allowed in this duel. It has been put into your backpack.");
						m_player1.Backpack.DropItem(item);
                    }
                }

                equipitems = new ArrayList(m_player2.Items);
                foreach (Item item in equipitems)
                {
					if (item is BaseWeapon && !Ladder.WeapAllowed((PlayerMobile)m_player2,(BaseWeapon)item) && m_player2.Backpack != null)
					{
						m_player2.SendMessage("The weapon you are wielding is now allowed in this duel. It has been put into your backpack.");
						m_player2.Backpack.DropItem(item);
                    }
                }

                //Dismount
                if (m_player1.Mounted)
                {
                    IMount mount = (IMount)m_player1.Mount;
                    if (mount != null)
                        mount.Rider = null;
                }
                if (m_player2.Mounted)
                {
                    IMount mount = (IMount)m_player2.Mount;
                    if (mount != null)
                        mount.Rider = null;
                }

                //Remove reflect/RA
                m_player1.MagicDamageAbsorb = 0;
                m_player2.MagicDamageAbsorb = 0;

                m_player1.MeleeDamageAbsorb = 0;
                m_player2.MeleeDamageAbsorb = 0;



				//Remove bandages/petals/petsum
                if (m_DuelType == 1)
                {
                    if (m_player1.Backpack != null && m_player1.BankBox != null)
                    {
                        Item[] bandages = m_player1.Backpack.FindItemsByType(typeof(Bandage), true);

                        for (int i = 0; i < bandages.Length; i++)
                        {
                            m_player1.BankBox.DropItem(bandages[i]);
                        }
                        Item[] petals = m_player1.Backpack.FindItemsByType(typeof(OrangePetals), true);
                        for (int i = 0; i < petals.Length; i++)
                        {
                            m_player1.BankBox.DropItem(petals[i]);
                        }

                        Item[] petBalls = m_player1.Backpack.FindItemsByType(typeof(PetSummonBall), true);
                        for (int i = 0; i < petBalls.Length; i++)
                        {
                            m_player1.BankBox.DropItem(petBalls[i]);
                        }
                    }

                    if (m_player2.Backpack != null && m_player2.BankBox != null)
                    {
                        Item[] bandages = m_player2.Backpack.FindItemsByType(typeof(Bandage), true);

                        for (int i = 0; i < bandages.Length; i++)
                        {
                            m_player2.BankBox.DropItem(bandages[i]);
                        }
                        Item[] petals = m_player2.Backpack.FindItemsByType(typeof(OrangePetals), true);
                        for (int i = 0; i < petals.Length; i++)
                        {
                            m_player2.BankBox.DropItem(petals[i]);
                        }

                        Item[] petBalls = m_player2.Backpack.FindItemsByType(typeof(PetSummonBall), true);
                        for (int i = 0; i < petBalls.Length; i++)
                        {
                            m_player2.BankBox.DropItem(petBalls[i]);
                        }
                    }
                }


                // Teleport and freeze players
                m_player1.Map = m_Arena.Map;
                m_player2.Map = m_Arena.Map;
                m_player1.Location = m_Arena.StartLoc1;
                m_player2.Location = m_Arena.StartLoc2;

                m_player1.Frozen = true;
                m_player2.Frozen = true;

				//m_player1.Hits = MaxHits;
				m_player1.Heal(100);
				m_player1.FixedParticles(0x376A, 9, 32, 5005, EffectLayer.Waist);
				m_player1.PlaySound(0x1F2);

				//m_player2.Hits = MaxHits;
				m_player2.Heal(100);
				m_player2.FixedParticles(0x376A, 9, 32, 5005, EffectLayer.Waist);
				m_player2.PlaySound(0x1F2);

				m_player1.CloseAllGumps();
                m_player2.CloseAllGumps();
                m_player1.SendMessage("Challenge accepted, the duel will begin in 5 seconds!!");
                m_player2.SendMessage("Challenge accepted, the duel will begin in 5 seconds!!");

                m_CountTimer = new CountTimer(this, 5);
                m_CountTimer.Start();
            }

        }