示例#1
0
        public Table(Player player, TableType type)
        {
            lock (TableManager.Tables.SyncRoot)
            {
                if ((TableId = TableManager.Tables.GetAvailableTableId()) == 0)
                {
                    return;
                }

                Type                = type;
                Delete              = false;
                Founder             = player.ActiveCharacter.Name;
                Name                = String.Format("{0}'s Table", Founder);
                Duration            = new Interval(600000, false);
                InvitedCharacterIds = new ListCollection <Int32>();

                TableManager.Tables.Add(this);
                Network.SendTo(GamePacket.Outgoing.World.TableCreated(this), Network.SendToType.Tavern);
            }
        }
示例#2
0
        public new void Add(Arena arena)
        {
            base.Add(arena);

            Network.SendTo(GamePacket.Outgoing.World.ArenaCreated(arena), Network.SendToType.Tavern);

            for (Int32 j = 0; j < PlayerManager.Players.Count; j++)
            {
                Player player = PlayerManager.Players[j];
                if (player == null)
                {
                    continue;
                }

                if (!player.IsInArena && player.TableId != 0)
                {
                    Network.Send(player, GamePacket.Outgoing.World.ArenaState(arena, player));
                }
            }
        }
示例#3
0
        private void ProcessTables()
        {
            while (_workerThread != null)
            {
                lock (Tables.SyncRoot)
                {
                    for (Int32 i = Tables.Count - 1; i >= 0; i--)
                    {
                        Table table = Tables[i];
                        if (table == null)
                        {
                            continue;
                        }

                        if (table.Duration.HasElapsed || table.Delete)
                        {
                            table.Delete = true;

                            if (PlayerManager.Players.Any(p => p.TableId == table.TableId) || ArenaManager.Arenas.Any(a => a.TableId == table.TableId))
                            {
                                table.Duration.Reset();
                                table.Delete = false;
                            }

                            if (table.Delete)
                            {
                                Network.SendTo(GamePacket.Outgoing.World.TableDeleted(table), Network.SendToType.Tavern);
                                Tables.RemoveAt(i);
                            }
                        }
                    }
                }

                Thread.Sleep(200);
            }
        }
示例#4
0
        private void ProcessArenas()
        {
            Boolean resetStatusUpdate = false;

            while (WorkerThread != null)
            {
                lock (Arenas.SyncRoot)
                {
                    for (Int32 i = Arenas.Count - 1; i >= 0; i--)
                    {
                        Arena arena = Arenas[i];
                        if (arena == null)
                        {
                            continue;
                        }

                        lock (arena.SyncRoot)
                        {
                            if (arena.CurrentState == Arena.State.Ended)
                            {
                                continue;
                            }

                            if (arena.CurrentState == Arena.State.CleanUp)
                            {
                                Arenas.Remove(arena);
                                continue;
                            }

                            Team winningTeam = arena.WinningTeam;

                            if (arena.CountdownTick == null && winningTeam != Team.Neutral)
                            {
                                switch (winningTeam)
                                {
                                case Team.Chaos:
                                {
                                    arena.CurrentState = Arena.State.ChaosVictory;
                                    break;
                                }

                                case Team.Balance:
                                {
                                    arena.CurrentState = Arena.State.BalanceVictory;
                                    break;
                                }

                                case Team.Order:
                                {
                                    arena.CurrentState = Arena.State.OrderVictory;
                                    break;
                                }
                                }

                                arena.CountdownTick = new Interval(29000, false);
                            }
                            else if (winningTeam == Team.Neutral)
                            {
                                arena.CurrentState  = Arena.State.Normal;
                                arena.CountdownTick = null;
                            }

                            if (arena.Ruleset.Rules.HasFlag(ArenaRuleset.ArenaRule.GuildRules))
                            {
                                if (arena.GuildRulesBroadcast.HasElapsed)
                                {
                                    if (arena.ArenaPlayers.GetTeamPlayerCount(Team.Chaos) > 0 || !arena.ArenaTeams.Chaos.Shrine.IsDead)
                                    {
                                        Network.SendTo(arena, GamePacket.Outgoing.System.DirectTextMessage(null, String.Format("[Guild Match] Chaos: {0:0.00}", arena.ArenaTeams.Chaos.Shrine.GuildPoints)), Network.SendToType.Arena);
                                    }

                                    if (arena.ArenaPlayers.GetTeamPlayerCount(Team.Order) > 0 || !arena.ArenaTeams.Order.Shrine.IsDead)
                                    {
                                        Network.SendTo(arena, GamePacket.Outgoing.System.DirectTextMessage(null, String.Format("[Guild Match] Order: {0:0.00}", arena.ArenaTeams.Order.Shrine.GuildPoints)), Network.SendToType.Arena);
                                    }

                                    if (arena.ArenaPlayers.GetTeamPlayerCount(Team.Balance) > 0 || !arena.ArenaTeams.Balance.Shrine.IsDead)
                                    {
                                        Network.SendTo(arena, GamePacket.Outgoing.System.DirectTextMessage(null, String.Format("[Guild Match] Balance: {0:0.00}", arena.ArenaTeams.Balance.Shrine.GuildPoints)), Network.SendToType.Arena);
                                    }

                                    Team guildWinTeam = Team.Neutral;

                                    if (winningTeam == Team.Neutral)
                                    {
                                        if (arena.ArenaTeams.Order.Shrine.GuildPoints > arena.ArenaTeams.Chaos.Shrine.GuildPoints && arena.ArenaTeams.Order.Shrine.GuildPoints > arena.ArenaTeams.Balance.Shrine.GuildPoints)
                                        {
                                            guildWinTeam = Team.Order;
                                        }

                                        if (arena.ArenaTeams.Balance.Shrine.GuildPoints > arena.ArenaTeams.Chaos.Shrine.GuildPoints && arena.ArenaTeams.Balance.Shrine.GuildPoints > arena.ArenaTeams.Order.Shrine.GuildPoints)
                                        {
                                            guildWinTeam = Team.Balance;
                                        }

                                        if (arena.ArenaTeams.Chaos.Shrine.GuildPoints > arena.ArenaTeams.Order.Shrine.GuildPoints && arena.ArenaTeams.Chaos.Shrine.GuildPoints > arena.ArenaTeams.Balance.Shrine.GuildPoints)
                                        {
                                            guildWinTeam = Team.Chaos;
                                        }
                                    }
                                    else
                                    {
                                        guildWinTeam = winningTeam;
                                    }

                                    Network.SendTo(arena, GamePacket.Outgoing.System.DirectTextMessage(null, String.Format("[Guild Match] Winning Team: {0}", (guildWinTeam == Team.Neutral) ? "None" : guildWinTeam.ToString())), Network.SendToType.Arena);
                                }

                                if (arena.Duration.RemainingSeconds < 600 && arena.GuildRulesBroadcast.Duration == 600000)
                                {
                                    arena.GuildRulesBroadcast = new Interval(120000, true);
                                }

                                if (arena.CountdownTick != null && arena.CountdownTick.ElapsedSeconds >= 9)
                                {
                                    Single pointsGiven = 1f;

                                    if (arena.CountdownTick.ElapsedSeconds >= 10)
                                    {
                                        pointsGiven += 0.33f * (arena.CountdownTick.ElapsedSeconds - 10);
                                    }

                                    switch (winningTeam)
                                    {
                                    case Team.Chaos:
                                    {
                                        arena.ArenaTeams.Chaos.Shrine.GuildPoints += pointsGiven;
                                        break;
                                    }

                                    case Team.Balance:
                                    {
                                        arena.ArenaTeams.Balance.Shrine.GuildPoints += pointsGiven;
                                        break;
                                    }

                                    case Team.Order:
                                    {
                                        arena.ArenaTeams.Order.Shrine.GuildPoints += pointsGiven;
                                        break;
                                    }

                                    case Team.Neutral:
                                    {
                                        break;
                                    }
                                    }
                                }
                            }

                            if (arena.CountdownTick != null && arena.CountdownTick.HasElapsed)
                            {
                                arena.EndState     = arena.CurrentState;
                                arena.CurrentState = Arena.State.Ended;
                                continue;
                            }

                            if ((arena.TimeLimit - arena.Duration.ElapsedSeconds) <= 60 && arena.CurrentState == Arena.State.Normal)
                            {
                                arena.CurrentState = Arena.State.OneMinute;
                            }

                            if (arena.Duration.HasElapsed)
                            {
                                arena.CurrentState = Arena.State.Ended;
                                continue;
                            }

                            if (StatusTick.HasElapsed)
                            {
                                if (arena.ArenaPlayers.Count > 0)
                                {
                                    arena.IdleDuration.Reset();
                                }
                                if (arena.IdleDuration.HasElapsed)
                                {
                                    arena.CurrentState = Arena.State.Ended;
                                }

                                resetStatusUpdate = true;

                                for (Int32 j = 0; j < arena.ArenaPlayers.Count; j++)
                                {
                                    ArenaPlayer arenaPlayer = arena.ArenaPlayers[j];
                                    if (arenaPlayer == null)
                                    {
                                        continue;
                                    }

                                    Network.Send(arenaPlayer.WorldPlayer, GamePacket.Outgoing.World.ArenaState(arena, arenaPlayer.WorldPlayer));
                                    Network.SendTo(arena, GamePacket.Outgoing.Arena.PlayerState(arenaPlayer), Network.SendToType.Arena);
                                }
                            }
                        }
                    }
                }

                if (resetStatusUpdate)
                {
                    resetStatusUpdate = false;
                    StatusTick.Reset();
                }

                Thread.Sleep(100);
            }
        }
示例#5
0
        public ArenaPlayer(Player player, Arena arena)
        {
            lock (arena.SyncRoot)
            {
                WorldPlayer = player;
                OwnerArena  = arena;

                lock (OwnerArena.ArenaPlayers.SyncRoot)
                {
                    OwnerArena.ArenaPlayers.ForEach(delegate(ArenaPlayer arenaPlayer)
                    {
                        if (arenaPlayer.WorldPlayer == player)
                        {
                            OwnerArena.PlayerLeft(arenaPlayer);
                        }
                    });
                }

                if ((ArenaPlayerId = OwnerArena.ArenaPlayers.GetAvailablePlayerId()) == 0)
                {
                    return;
                }

                WorldPlayer.PingInitialized = false;
                WorldPlayer.TableId         = 0;
                WorldPlayer.ActiveArena     = arena;
                WorldPlayer.LastArenaId     = arena.ArenaId;

                ActiveTeam      = OwnerArena.Ruleset.Rules.HasFlag(ArenaRuleset.ArenaRule.NoTeams) ? Team.Neutral : WorldPlayer.ActiveTeam;
                ActiveCharacter = player.ActiveCharacter;

                _previousLocation     = new Vector3(0, 0, 0);
                _previousLocationTick = 0;

                Location  = new Vector3(0, 0, 0);
                Direction = 0;

                CurrentGridBlock         = null;
                CurrentGridBlockFlagData = new GridBlockFlagData();

                InCombatTime        = new Interval(7000, false);
                NonFriendlyWallTime = new Interval(1000, false);
                FriendlyWallTime    = new Interval(1000, false);
                ValhallaProtection  = new Interval(2000, false);
                ActiveTime          = new Interval(0, false);
                BoundingBox         = new OrientedBoundingBox(Location, PlayerStandingSize, 0.0f);

                StatusFlags  = StatusFlag.None;
                SpecialFlags = SpecialFlag.None;

                Effects = new Effect[21];

                MoveSpeed          = 0;
                StateReceivedCount = 0;
                LastStateReceived  = NativeMethods.PerformanceCount;

                LastAttacker = null;

                JoinTime = DateTime.Now;

                HasFliedSinceHackDetect = false;

                MaxHp = player.ActiveCharacter.MaxHealth;

                if (ActiveShrine == null)
                {
                    if (ActiveTeam == Team.Neutral)
                    {
                        CurrentHp = MaxHp;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    if (ActiveShrine.IsDisabled)
                    {
                        Network.Send(WorldPlayer, GamePacket.Outgoing.Player.SendPlayerId(this));

                        Thread.Sleep(500);

                        Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.SuccessfulArenaEntry());

                        Thread.Sleep(100);

                        OwnerArena.ArenaKickPlayer(this);

                        return;
                    }

                    CurrentHp = ActiveShrine.IsDead ? (Int16)0 : MaxHp;
                }

                Network.Send(WorldPlayer, GamePacket.Outgoing.Player.SendPlayerId(this));

                if (!WorldPlayer.Flags.HasFlag(PlayerFlag.Hidden))
                {
                    Network.SendTo(WorldPlayer, GamePacket.Outgoing.World.PlayerLeave(WorldPlayer), Network.SendToType.Tavern, false);
                    Network.SendTo(WorldPlayer, GamePacket.Outgoing.World.PlayerJoin(WorldPlayer), Network.SendToType.Tavern, false);

                    Network.SendToArena(this, GamePacket.Outgoing.Arena.PlayerJoin(this), false);
                }

                if (OwnerArena.ArenaPlayerHistory.FindByCharacterId(WorldPlayer.ActiveCharacter.CharacterId) == null)
                {
                    OwnerArena.ArenaPlayerHistory.Add(this);
                }

                WorldPlayer.ActiveArenaPlayer = this;
                OwnerArena.ArenaPlayers.Add(this);

                OwnerArena.AveragePlayerLevel = OwnerArena.ArenaPlayers.GetAveragePlayerLevel();
            }

            lock (OwnerArena.SyncRoot)
            {
                Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.UpdateShrinePoolState(arena));
            }

            Thread.Sleep(500);

            Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.SuccessfulArenaEntry());

            Thread.Sleep(100);

            lock (OwnerArena.SyncRoot)
            {
                for (Int32 i = 0; i < OwnerArena.Signs.Count; i++)
                {
                    Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.CastSign(this, OwnerArena.Signs[i].RawData));
                }
            }

            Thread.Sleep(100);

            lock (OwnerArena.SyncRoot)
            {
                for (Int32 i = 0; i < OwnerArena.Walls.Count; i++)
                {
                    Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.CastWall(arena.Walls[i].RawData));
                }
            }

            Thread.Sleep(100);

            lock (OwnerArena.SyncRoot)
            {
                for (Int32 i = 0; i < arena.Grid.Triggers.Count; i++)
                {
                    Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.ActivatedTrigger(OwnerArena.Grid.Triggers[i]));
                }
            }

            if (OwnerArena.Ruleset.Mode == ArenaRuleset.ArenaMode.Custom)
            {
                Network.Send(WorldPlayer, GamePacket.Outgoing.System.DirectTextMessage(WorldPlayer, String.Format("This arena has the following rules: {0}.", arena.Ruleset.Rules)));
            }

            if (OwnerArena.Ruleset.Rules.HasFlag(ArenaRuleset.ArenaRule.ExpEvent))
            {
                Network.Send(WorldPlayer, GamePacket.Outgoing.System.DirectTextMessage(WorldPlayer, String.Format("If your team wins this match, you will earn {0:0,0} experience.", (WorldPlayer.Flags.HasFlag(PlayerFlag.MagestormPlus) ? OwnerArena.EventExp * 2f : OwnerArena.EventExp))));
            }

            Network.Send(WorldPlayer, GamePacket.Outgoing.System.DirectTextMessage(WorldPlayer, String.Format("This arena currently has an EXP bonus of {0}%.", ((arena.Grid.ExpBonus + (Properties.Settings.Default.ExpMultiplier - 1.0f) + (WorldPlayer.Flags.HasFlag(PlayerFlag.MagestormPlus) ? 0.2f : 0.0f)) * 100))));
        }