Ejemplo n.º 1
0
        public override void OnDoubleClick(Mobile from)
        {
            if (!from.InRange(Location, 3) || !from.InLOS(this) || !from.CanSee(this))
            {
                from.LocalOverheadMessage(Network.MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
            }
            else if (Arena != null)
            {
                ArenaDuel duel = Arena.CurrentDuel;

                if (duel != null && duel.InPreFight)
                {
                    from.SendLocalizedMessage(1115968); // You cannot exit until this duel has started.
                    return;
                }

                from.SendGump(new ConfirmCallbackGump((PlayerMobile)from, 1115969, 1115970, null, null, (m, state) =>
                {
                    Arena.RemovePlayer((PlayerMobile)m);

                    if (duel != null && !duel.Complete)
                    {
                        duel.OnPlayerLeave((PlayerMobile)m);
                    }
                }));
            }
        }
Ejemplo n.º 2
0
        public void RecordRankings(ArenaDuel duel, ArenaTeam winners)
        {
            List <ArenaStats> rankings;

            rankings = duel.BattleMode == BattleMode.Team ? TeamRankings : SurvivalRankings;

            foreach (KeyValuePair <PlayerMobile, PlayerStatsEntry> part in duel.GetParticipants())
            {
                PlayerMobile pm    = part.Key;
                ArenaStats   stats = rankings.FirstOrDefault(r => r.Owner == pm);

                if (stats == null)
                {
                    stats = new ArenaStats(pm);
                    rankings.Add(stats);
                }

                ArenaTeam team = duel.GetTeam(pm);

                if (team != winners)
                {
                    stats.Ranking -= 33;
                }
                else
                {
                    stats.Ranking += 33;
                }
            }

            rankings.Sort();
        }
Ejemplo n.º 3
0
 public static void SendParticipantMessage(ArenaDuel duel, int message, bool inRegion = false, string args = "", int hue = 0x1F)
 {
     foreach (var part in duel.GetParticipants(inRegion))
     {
         SendMessage(part.Key, message, args, hue);
     }
 }
Ejemplo n.º 4
0
        public override bool OnDoubleClick(Mobile m, object o)
        {
            if (Arena.CurrentDuel != null)
            {
                ArenaDuel duel = Arena.CurrentDuel;

                if (o is BasePotion && duel.PotionRules != PotionRules.All)
                {
                    if (duel.PotionRules == PotionRules.None || o is BaseHealPotion)
                    {
                        return(false);
                    }
                }
            }

            if (o is Corpse corpse && corpse.Owner != m)
            {
                m.SendLocalizedMessage(1010054); // You cannot loot that corpse!!
                return(false);
            }

            if (o is BallOfSummoning summoning)
            {
                MessageHelper.SendLocalizedMessageTo(summoning, m, 1054125, 0x5); // The Crystal Ball fills with a blue mist. Your pet is not responding to the summons.
                return(false);
            }

            if (o is BraceletOfBinding)
            {
                return(false);
            }

            return(base.OnDoubleClick(m, o));
        }
Ejemplo n.º 5
0
        public override bool OnBeginSpellCast(Mobile m, ISpell spell)
        {
            if (Arena.CurrentDuel != null)
            {
                ArenaDuel duel = Arena.CurrentDuel;

                if (duel.InPreFight)
                {
                    m.SendLocalizedMessage(502629); // You cannot cast spells here.
                    return(false);
                }

                if (!duel.RidingFlyingAllowed && spell is FlySpell)
                {
                    m.SendLocalizedMessage(1115997); // The rules prohibit riding a mount or flying.
                    return(false);
                }

                if (!duel.FieldSpellsAllowed && (spell is FireFieldSpell || spell is ParalyzeFieldSpell || spell is PoisonFieldSpell || spell is EnergyFieldSpell ||
                                                 spell is WallOfStoneSpell))
                {
                    m.SendLocalizedMessage(1010391); // A magical aura surrounds you and prevents the spell.
                    return(false);
                }
            }

            return(base.OnBeginSpellCast(m, spell));
        }
Ejemplo n.º 6
0
 public static void SendParticipantMessage(ArenaDuel duel, int message, bool inRegion = false, string args = "", int hue = 0x1F)
 {
     foreach (KeyValuePair <PlayerMobile, PlayerStatsEntry> part in duel.GetParticipants(inRegion))
     {
         SendMessage(part.Key, message, args, hue);
     }
 }
Ejemplo n.º 7
0
        public void OnTick()
        {
            CurrentDuel?.OnTick();

            foreach (KeyValuePair <ArenaDuel, DateTime> kvp in PendingDuels)
            {
                if (kvp.Value < DateTime.UtcNow)
                {
                    _Remove.Add(kvp.Key);
                }
            }

            if (_Remove.Count > 0)
            {
                for (var index = 0; index < _Remove.Count; index++)
                {
                    ArenaDuel duel = _Remove[index];

                    if (PendingDuels.ContainsKey(duel))
                    {
                        PendingDuels.Remove(duel);
                    }
                }

                _Remove.Clear();
            }
        }
Ejemplo n.º 8
0
        public void OnDuelEnd(ArenaDuel duel)
        {
            CurrentDuel = null;

            foreach (Corpse corpse in Region.GetEnumeratedItems().OfType <Corpse>())
            {
                if (corpse.Owner != null && corpse.Owner.InRange(corpse.Location, 30))
                {
                    corpse.MoveToWorld(corpse.Owner.Location, corpse.Owner.Map);
                }
                else
                {
                    corpse.MoveToWorld(GetRandomRemovalLocation(), Definition.Map);
                }
            }

            if (BookedDuels.Count > 0)
            {
                ArenaDuel newDuel = BookedDuels[0];
                CurrentDuel = newDuel;

                PVPArenaSystem.SendParticipantMessage(newDuel, 1153141); // Your session has been booked. Please wait a few moments to start the fight.

                Timer.DelayCall(BookedDuelBegin, () =>
                {
                    newDuel.DoPreDuel();
                });

                BookedDuels.Remove(newDuel);
            }
        }
Ejemplo n.º 9
0
 public void AddPendingDuel(ArenaDuel duel)
 {
     if (!PendingDuels.ContainsKey(duel))
     {
         PendingDuels[duel] = DateTime.UtcNow + PendingDuelExpirationTime;
     }
 }
Ejemplo n.º 10
0
        public ArenaGate(ArenaDuel duel)
            : base(0xF6C)
        {
            Duel    = duel;
            Movable = false;

            Hue = 1194;
        }
Ejemplo n.º 11
0
        public void Serialize(GenericWriter writer)
        {
            writer.Write(1);

            writer.Write(SurvivalRankings.Count);
            for (var index = 0; index < SurvivalRankings.Count; index++)
            {
                ArenaStats ranking = SurvivalRankings[index];
                ranking.Serialize(writer);
            }

            writer.Write(TeamRankings.Count);
            for (var index = 0; index < TeamRankings.Count; index++)
            {
                ArenaStats ranking = TeamRankings[index];
                ranking.Serialize(writer);
            }

            writer.Write(Blockers.Count);
            for (var index = 0; index < Blockers.Count; index++)
            {
                Item blocker = Blockers[index];
                writer.Write(blocker);
            }

            writer.Write(Stone);
            writer.Write(Manager);
            writer.Write(Banner1);
            writer.Write(Banner2);

            writer.Write(PendingDuels.Count);
            foreach (KeyValuePair <ArenaDuel, DateTime> kvp in PendingDuels)
            {
                kvp.Key.Serialize(writer);
                writer.WriteDeltaTime(kvp.Value);
            }

            writer.Write(BookedDuels.Count);
            for (var index = 0; index < BookedDuels.Count; index++)
            {
                ArenaDuel duel = BookedDuels[index];
                duel.Serialize(writer);
            }

            if (CurrentDuel != null)
            {
                writer.Write(1);
                CurrentDuel.Serialize(writer);
            }
            else
            {
                writer.Write(0);
            }
        }
Ejemplo n.º 12
0
        public void RemovePendingDuel(ArenaDuel duel, bool cancel = false)
        {
            if (PendingDuels.ContainsKey(duel))
            {
                PendingDuels.Remove(duel);

                if (cancel)
                {
                    PVPArenaSystem.SendParticipantMessage(duel, 1115947); // The session owner has canceled the duel.
                }
            }
        }
Ejemplo n.º 13
0
        public override bool OnTarget(Mobile m, Target t, object o)
        {
            ArenaDuel duel = Arena.CurrentDuel;

            if (t is TeleportSpell.InternalTarget && Region.Find(m.Location, m.Map) != this)
            {
                m.SendLocalizedMessage(501035); // You cannot teleport from here to the destination.
                return(false);
            }

            return(base.OnTarget(m, t, o));
        }
Ejemplo n.º 14
0
        public bool AllowItemEquip(PlayerMobile pm, Item item)
        {
            ArenaDuel duel = Arena.CurrentDuel;

            if (duel != null && !duel.RangedWeaponsAllowed && item is BaseRanged)
            {
                pm.SendLocalizedMessage(1115996); // The rules prohibit the use of ranged weapons!
                return(false);
            }

            return(true);
        }
Ejemplo n.º 15
0
        public override void OnDoubleClick(Mobile from)
        {
            if (from is PlayerMobile && from.InRange(Location, 10))
            {
                PlayerMobile pm = from as PlayerMobile;

                if (pm.Young)
                {
                    from.SendLocalizedMessage(1116002); // Young players and Trial Account users may not participate in duels.
                }
                else if (Arena != null && PVPArenaSystem.Enabled)
                {
                    if (Arena.CurrentDuel != null && Arena.CurrentDuel.IsParticipant(pm))
                    {
                        if (Arena.CurrentDuel.InPreFight)
                        {
                            BaseGump.SendGump(new OfferDuelGump(pm, Arena.CurrentDuel, Arena, false, true));
                        }
                        else
                        {
                            from.SendLocalizedMessage(1116387); // Please wait until the session which you participated is finished completely.
                        }
                    }
                    else
                    {
                        ArenaDuel duel = Arena.GetPendingDuel(from);

                        if (duel == null)
                        {
                            ArenaDuel booked = PVPArenaSystem.Instance.GetBookedDuel(pm);

                            if (booked != null)
                            {
                                BaseGump.SendGump(new OfferDuelGump(pm, booked, booked.Arena, true));
                            }
                            else
                            {
                                BaseGump.SendGump(new ArenaStoneGump(pm, Arena));
                            }
                        }
                        else
                        {
                            BaseGump.SendGump(new PendingDuelGump(pm, duel, Arena));
                        }
                    }
                }
            }
            else
            {
                from.SendLocalizedMessage(502138); // That is too far away for you to use.
            }
        }
Ejemplo n.º 16
0
 public DuelProfile(ArenaDuel duel)
 {
     Entries              = duel.Entries;
     RoomType             = duel.RoomType;
     BattleMode           = duel.BattleMode;
     Ranked               = duel.Ranked;
     TimeLimit            = duel.TimeLimit;
     EntryFee             = duel.EntryFee;
     PetSlots             = duel.PetSlots;
     RidingFlyingAllowed  = duel.RidingFlyingAllowed;
     RangedWeaponsAllowed = duel.RangedWeaponsAllowed;
     SummonSpellsAllowed  = duel.SummonSpellsAllowed;
     FieldSpellsAllowed   = duel.FieldSpellsAllowed;
     PotionRules          = duel.PotionRules;
 }
Ejemplo n.º 17
0
        public static bool HasSameIP(Mobile m, ArenaDuel duel)
        {
            if (duel == null || m.AccessLevel > AccessLevel.Player)
            {
                return(false);
            }

            foreach (KeyValuePair <PlayerMobile, PlayerStatsEntry> kvp in duel.GetParticipants())
            {
                if (IsSameIP(m, kvp.Key))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 18
0
        public void TryBeginDuel(ArenaDuel duel)
        {
            if (PendingDuels.ContainsKey(duel))
            {
                PendingDuels.Remove(duel);
            }

            if (CurrentDuel == null && BookedDuels.Count == 0)
            {
                CurrentDuel = duel;
                duel.DoPreDuel();
            }
            else
            {
                BookedDuels.Add(duel);
                PVPArenaSystem.SendParticipantMessage(duel, 1115960); // There are currently no open arenas. Your duel session has been added to the booking queue.
            }
        }
Ejemplo n.º 19
0
        public void RecordRankings(ArenaDuel duel, ArenaTeam winners)
        {
            List <ArenaStats> rankings;

            rankings = duel.BattleMode == BattleMode.Team ? TeamRankings : SurvivalRankings;

            foreach (KeyValuePair <PlayerMobile, PlayerStatsEntry> part in duel.GetParticipants())
            {
                PlayerMobile pm    = part.Key;
                ArenaStats   stats = null;

                for (var index = 0; index < rankings.Count; index++)
                {
                    var r = rankings[index];

                    if (r.Owner == pm)
                    {
                        stats = r;
                        break;
                    }
                }

                if (stats == null)
                {
                    stats = new ArenaStats(pm);
                    rankings.Add(stats);
                }

                ArenaTeam team = duel.GetTeam(pm);

                if (team != winners)
                {
                    stats.Ranking -= 33;
                }
                else
                {
                    stats.Ranking += 33;
                }
            }

            rankings.Sort();
        }
Ejemplo n.º 20
0
        public ArenaDuel GetBookedDuel(PlayerMobile pm)
        {
            for (var index = 0; index < Arenas.Count; index++)
            {
                PVPArena arena = Arenas[index];

                if (arena.BookedDuels.Count > 0)
                {
                    for (var i = 0; i < arena.BookedDuels.Count; i++)
                    {
                        ArenaDuel duel = arena.BookedDuels[i];

                        if (duel.IsParticipant(pm))
                        {
                            return(duel);
                        }
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 21
0
        public void RecordRankings(ArenaDuel duel, ArenaTeam winners)
        {
            List <ArenaStats> rankings;

            if (duel.BattleMode == BattleMode.Team)
            {
                rankings = TeamRankings;
            }
            else
            {
                rankings = SurvivalRankings;
            }

            foreach (var part in duel.GetParticipants())
            {
                var        pm    = part.Key;
                ArenaStats stats = rankings.FirstOrDefault(r => r.Owner == pm);

                if (stats == null)
                {
                    stats = new ArenaStats(pm);
                    rankings.Add(stats);
                }

                var team = duel.GetTeam(pm);

                if (team != winners)
                {
                    stats.Ranking -= 33;
                }
                else
                {
                    stats.Ranking += 33;
                }
            }

            rankings.Sort();
        }
Ejemplo n.º 22
0
        public void Deserialize(GenericReader reader)
        {
            int version = reader.ReadInt();

            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                ArenaStats stats = new ArenaStats(reader);

                if (stats.Owner != null)
                {
                    SurvivalRankings.Add(stats);
                }
            }

            count = reader.ReadInt();
            for (int i = 0; i < count; i++)
            {
                ArenaStats stats = new ArenaStats(reader);

                if (stats.Owner != null)
                {
                    TeamRankings.Add(stats);
                }
            }

            count = reader.ReadInt();
            for (int i = 0; i < count; i++)
            {
                Item blocker = reader.ReadItem();

                if (blocker != null)
                {
                    Blockers.Add(blocker);
                }
            }

            Stone   = reader.ReadItem() as ArenaStone;
            Manager = reader.ReadMobile() as ArenaManager;
            Banner1 = reader.ReadItem() as ArenaExitBanner;
            Banner2 = reader.ReadItem() as ArenaExitBanner;

            count = reader.ReadInt();
            for (int i = 0; i < count; i++)
            {
                ArenaDuel duel = new ArenaDuel(reader, this);
                DateTime  dt   = reader.ReadDeltaTime();

                PendingDuels[duel] = dt;
            }

            count = reader.ReadInt();
            for (int i = 0; i < count; i++)
            {
                BookedDuels.Add(new ArenaDuel(reader, this));
            }

            if (reader.ReadInt() == 1)
            {
                CurrentDuel = new ArenaDuel(reader, this);
            }

            if (Stone != null)
            {
                Stone.Arena = this;
            }

            if (Manager != null)
            {
                Manager.Arena = this;
            }

            if (Banner1 != null)
            {
                Banner1.Arena = this;
            }

            if (Banner2 != null)
            {
                Banner2.Arena = this;
            }

            if (version == 0)
            {
                foreach (var blocker in Blockers)
                {
                    if (blocker != null)
                    {
                        blocker.Delete();
                    }
                }

                ColUtility.Free(Blockers);
            }
        }