/// <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? int playing = _arena.PlayerCount; 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, 15 * 100, "Time until entrance into the tournament is locked: ", delegate() { //Trigger the game start bGameLocked = true; _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(); } else if (now - _baseScript._tickGameStarting > 30000) { _arena.gameStart(); } _tickLastReadyCheck = now; } // _arena.sendArenaMessage(String.Format("Test Before: {0}", checkForAllPlayersReady())); } return(true); }
/// <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); }