/////////////////////////////////////////////////// // Member Functions /////////////////////////////////////////////////// /// <summary> /// Performs script initialization /// </summary> public Royale(Arena arena, Script_Multi baseScript) { _baseScript = baseScript; _arena = arena; _config = arena._server._zoneConfig; _storm = new Boundary(_arena, 0, 0, 0, 0); _red = _arena.getTeamByName("Red"); _blue = _arena.getTeamByName("Blue"); _rand = new Random(); _activeTeams = new List <Team>(); _playersReady = new Dictionary <string, bool>(); _tickLastReadyCheck = 0; _tickLastPlayingCheck = 0; _tickGameStarting = 0; //test playing = 0; manualTeamSizePick = 0; bClassic = false; // Turn on looting. bGameLocked = false; bAllPlayersReady = false; bSquadRoyale = false; if (_arena._name.StartsWith("[Royale] Squad")) { bSquadRoyale = true; _baseScript.AllowPrivateTeams(true, 8); } }
public void gameSetup() { _arena.sendArenaMessage("$A new game is starting in 30 seconds or less. Please unspec in the next 15 seconds to play in the next tournament."); foreach (Player player in _arena.PlayersIngame) { if (player._team._name == "Red" || player._team._name == "Blue") { pickTeam(player); } } List <int> teamSizePickList = new List <int>(); int playersToConsider = _arena.PlayerCount; // later adjust this for private teams. if (playersToConsider <= 7) { teamSizePickList.Add(1); } if ((playersToConsider >= 4) && (playersToConsider <= 16)) { teamSizePickList.Add(2); } if (playersToConsider % 2 == 0) //If can split team evenly ,add that team size. { teamSizePickList.Add(playersToConsider / 2); } if (((playersToConsider % 3 == 0) && (playersToConsider != 3)) || ((playersToConsider >= 11) && (playersToConsider <= 30))) { teamSizePickList.Add(3); } if (((playersToConsider % 4 == 0) && (playersToConsider != 4)) || ((playersToConsider >= 22) && (playersToConsider <= 40))) { teamSizePickList.Add(4); } if (((playersToConsider % 5 == 0) && (playersToConsider != 5)) || ((playersToConsider >= 28) && (playersToConsider <= 50))) { teamSizePickList.Add(5); } if (((playersToConsider % 6 == 0) && (playersToConsider != 6)) || ((playersToConsider >= 34) && (playersToConsider <= 60))) { teamSizePickList.Add(6); } if (((playersToConsider % 7 == 0) && (playersToConsider != 7)) || ((playersToConsider >= 40) && (playersToConsider <= 70))) { teamSizePickList.Add(7); } Random randTeamSizePick = new Random(); int teamSizePick = teamSizePickList[randTeamSizePick.Next(teamSizePickList.Count)]; _playersPerTeam = teamSizePick; if (_gameCount >= 2) // change to 3 to scramble every 3 games. need to compare team size last game to this pick { _arena.sendArenaMessage("Teams have been scrambled"); _arena.scrambleTeams(_arena.PlayersIngame.Where(p => !p._team._isPrivate), _arena.Teams.Where(team => team.IsPublic && team._name != "spec" && team._name.StartsWith("Public")).ToList(), _playersPerTeam); _gameCount = 0; } //Even out any private teams that are OVER our current limit foreach (Team team in _arena.ActiveTeams.Where(tm => tm._isPrivate)) { List <Player> playersRemoved = new List <Player>(); //If they are within our parameter, ignore. if (team.ActivePlayerCount <= _playersPerTeam) { continue; } int numToRemove = team.ActivePlayerCount - _playersPerTeam; for (int i = 1; i < numToRemove; i++) { Player rndPlayer = team.ActivePlayers.PickRandom(); if (rndPlayer == null) { continue; } pickTeam(rndPlayer); rndPlayer.sendMessage(0, "You've randomly been moved to a public team to keep teams even."); } } _arena.sendArenaMessage(String.Format("&--Max team size for this game: {0}", _playersPerTeam)); _arena.sendArenaMessage("&---Game will start early by having all players 'Ready Up' by walking over a Dropship Portal."); _baseScript.AllowPrivateTeams(true, _playersPerTeam); }
/// <summary> /// Allows the script to maintain itself /// </summary> public bool Poll(int now) { //Should we check game state yet? // List<Player> crowns = _activeCrowns; if (now - _lastGameCheck <= Arena.gameCheckInterval) { return(true); } _lastGameCheck = now; //Do we have enough players ingame? if (!bSquadRoyale) { playing = _arena.PlayerCount; } else if (bSquadRoyale) { if (_tickLastPlayingCheck == 0) { _tickLastPlayingCheck = now; } else if (now - _tickLastPlayingCheck > 1000) { playing = 0; foreach (Player player in _arena.Players) { if (player._team._name == "spec" || player._team._name == "Red" || player._team._name == "Blue") { } else { playing++; } } int privateTeamCount = 0; foreach (Team team in _arena.Teams) { if (team.AllPlayers.Count() > 0 && team._isPrivate) { privateTeamCount++; } } if (privateTeamCount <= 1) { playing = 0; } _tickLastPlayingCheck = now; } } if (_arena._bGameRunning) { _storm.Poll(now); //Check win conditions checkForwinner(now); } //Update our tickers if (_baseScript._tickGameStarted > 0 && now - _arena._tickGameStarted > 2000) { if (now - _tickGameLastTickerUpdate > 1000) { updateTickers(); _tickGameLastTickerUpdate = now; } } if (_arena._bGameRunning && playing < _minPlayers && _arena._bIsPublic && _victoryTeam == null) { _baseScript.bJackpot = false; //Stop the game and reset voting _arena.gameEnd(); } if (playing < _minPlayers && _arena._bIsPublic) { _baseScript._tickGameStarting = 0; _arena.setTicker(1, 3, 0, "Not Enough Players"); bGameLocked = false; } if (playing < _minPlayers && !_arena._bIsPublic && !_arena._bGameRunning) { _baseScript._tickGameStarting = 0; _arena.setTicker(1, 3, 0, "Private arena, Waiting for arena owner to start the game!"); } //Do we have enough to start a game? if (!_arena._bGameRunning && _baseScript._tickGameStarting == 0 && playing >= _minPlayers && _arena._bIsPublic) { _baseScript._tickGameStarting = now; gameSetup(); //Put 15 second locked timer in _arena.setTicker(1, 3, 20 * 100, "Time until entrance into the tournament is locked: ", delegate() { //Trigger the game start bGameLocked = true; if (!bSquadRoyale) { _baseScript.AllowPrivateTeams(false, 1); //Scramble it up _arena.scrambleTeams(_arena.PlayersIngame.Where(p => !p._team._isPrivate), _arena.Teams.Where(team => team.IsPublic && team._name != "spec" && team._name.StartsWith("Public")).ToList(), _playersPerTeam); } else { } _arena.setTicker(1, 3, 15 * 100, "Time until tournament starts: ", delegate() { //Trigger the game start }); }); } if (_baseScript._tickGameStarting > 0 && now - _baseScript._tickGameStarting > 15000) { if (_tickLastReadyCheck == 0) { _tickLastReadyCheck = now; } else if (now - _tickLastReadyCheck > 2000) { if (checkForAllPlayersReady()) { _arena.gameStart(); if (bSquadRoyale) { _baseScript.AllowPrivateTeams(false, 1); } } else if (now - _baseScript._tickGameStarting > 35000) { _arena.gameStart(); if (bSquadRoyale) { _baseScript.AllowPrivateTeams(false, 1); } } _tickLastReadyCheck = now; } // _arena.sendArenaMessage(String.Format("Test Before: {0}", checkForAllPlayersReady())); } return(true); }