/// <summary> /// Handle a new gamestate /// </summary> /// <param name="gs"></param> public void OnNewGameState(GameState gs) { Core.handleGameState(gs); }
static void OnNewGameState(GameState gs) { if (!IsPlanted && gs.Round.Phase == RoundPhase.Live && gs.Round.Bomb == BombState.Planted && gs.Previously.Round.Bomb == BombState.Undefined) { IsPlanted = true; Global.geh.SetBombState(BombState.Planted); } else if (IsPlanted && gs.Round.Phase == RoundPhase.FreezeTime) { IsPlanted = false; Global.geh.SetBombState(BombState.Undefined); } else if (IsPlanted && gs.Round.Bomb == BombState.Defused) { Global.geh.SetBombState(BombState.Defused); } else if (IsPlanted && gs.Round.Bomb == BombState.Exploded) { Global.geh.SetBombState(BombState.Exploded); } Global.geh.SetTeam(gs.Player.Team); Global.geh.SetHealth(gs.Player.State.Health); Global.geh.SetFlashAmount(gs.Player.State.Flashed); Global.geh.SetBurnAmount(gs.Player.State.Burning); Global.geh.SetClip(gs.Player.Weapons.ActiveWeapon.AmmoClip); Global.geh.SetClipMax(gs.Player.Weapons.ActiveWeapon.AmmoClipMax); Global.geh.SetPlayerActivity(gs.Player.Activity); }
/// <summary> /// Returns if the game is live /// </summary> public static bool bGameActive(ref CSGSI.GameState gs) { try { return((gs.Round.Phase.ToString().ToLower() == "live" || gs.Round.Phase.ToString().ToLower() == "over") && (gs.Map.Phase.ToString().ToLower() == "live" || gs.Map.Phase.ToString().ToLower() == "intermission")); } catch (System.Exception) { return(false); } }
static void OnNewGameState(GameState gs) { if (gs.Player.MatchStats.Kills == 1) { roundkills = 1; } if (gs.Player.MatchStats.Kills == 2) { roundkills = 2; } if (gs.Player.MatchStats.Kills == 3) { roundkills = 3; } if (gs.Player.MatchStats.Kills == 4) { roundkills = 4; } if (gs.Player.MatchStats.Kills == 5) { roundkills = 5; } if (gs.Player.MatchStats.Kills == 6) { roundkills = 6; } if (gs.Player.MatchStats.Kills == 7) { roundkills = 7; } if (gs.Player.MatchStats.Kills == 8) { roundkills = 8; } if (gs.Player.MatchStats.Kills == 9) { roundkills = 9; } if (gs.Player.MatchStats.Kills == 11) { roundkills = 11; } if (gs.Player.MatchStats.Kills == 12) { roundkills = 12; } if (gs.Player.MatchStats.Kills == 13) { roundkills = 13; } if (gs.Player.MatchStats.Kills == 14) { roundkills = 14; } if (gs.Player.MatchStats.Kills == 15) { roundkills = 15; } if (gs.Player.MatchStats.Kills == 16) { roundkills = 16; } if (gs.Player.MatchStats.Kills == 17) { roundkills = 17; } if (gs.Player.MatchStats.Kills == 18) { roundkills = 18; } if (gs.Player.MatchStats.Kills == 19) { roundkills = 19; } if (gs.Player.MatchStats.Kills == 20) { roundkills = 20; } if (gs.Player.MatchStats.Kills == 20) { roundkills = 20; } if (gs.Player.MatchStats.Kills == 21) { roundkills = 21; } if (gs.Player.MatchStats.Kills == 21) { roundkills = 21; } if (gs.Player.MatchStats.Kills == 22) { roundkills = 22; } if (gs.Player.MatchStats.Kills == 23) { roundkills = 23; } if (gs.Player.MatchStats.Kills == 24) { roundkills = 24; } if (gs.Player.MatchStats.Kills == 25) { roundkills = 25; } if (gs.Player.MatchStats.Kills == 26) { roundkills = 26; } if (gs.Player.MatchStats.Kills == 27) { roundkills = 27; } if (gs.Player.MatchStats.Kills == 28) { roundkills = 28; } if (gs.Player.MatchStats.Kills == 29) { roundkills = 29; } if (gs.Player.MatchStats.Kills == 30) { roundkills = 30; } if (gs.Player.MatchStats.Kills == 31) { roundkills = 31; } if (gs.Player.MatchStats.Kills == 32) { roundkills = 32; } if (gs.Player.MatchStats.Kills == 33) { roundkills = 33; } if (gs.Player.MatchStats.Kills == 34) { roundkills = 34; } if (gs.Player.MatchStats.Kills == 35) { roundkills = 35; } if (gs.Player.MatchStats.Kills == 36) { roundkills = 36; } if (gs.Player.MatchStats.Kills == 37) { roundkills = 37; } if (gs.Player.MatchStats.Kills == 38) { roundkills = 38; } if (gs.Player.MatchStats.Kills == 39) { roundkills = 39; } if (gs.Player.MatchStats.Kills == 40) { roundkills = 40; } if (gs.Player.MatchStats.Kills == 41) { roundkills = 41; } if (gs.Player.MatchStats.Kills == 42) { roundkills = 42; } if (gs.Player.MatchStats.Kills == 43) { roundkills = 43; } if (gs.Player.MatchStats.Kills == 44) { roundkills = 44; } if (gs.Player.MatchStats.Kills == 45) { roundkills = 45; } if (gs.Player.MatchStats.Kills == 46) { roundkills = 46; } if (gs.Player.MatchStats.Kills == 47) { roundkills = 47; } if (gs.Player.MatchStats.Kills == 48) { roundkills = 48; } if (gs.Player.MatchStats.Kills == 49) { roundkills = 49; } if (gs.Player.MatchStats.Kills == 50) { roundkills = 50; } if (roundkills >= roundkillsreq) { Stream str = Properties.Resources.wooow; SoundPlayer snd = new SoundPlayer(str); snd.Play(); roundkillsreq = roundkills + 1; Console.WriteLine("WOOOW mittari: " + roundkills); } if (roundkills > 50) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("!!! YLITIT 50 TAPON RAJAN!! Were all out of sounds !!!"); Console.ForegroundColor = ConsoleColor.White; } }
/// <summary> /// Kills and deaths are updated in this method /// </summary> static void OnNewGameState(GameState gs) { if (gs.Player.HasData) { if (Utils.myname.Length == 0) { Utils.myname = gs.Player.Name; } } if (Object.Equals(oldState, default(GameState))) { oldState = gs; return; } if (Utils.bGameActive(ref gs) && isLocalPlayer(ref gs)) { // share gamestate Utils.gameState = gs; if (((double)gs.Player.Weapons.ActiveWeapon.AmmoClip / (double)gs.Player.Weapons.ActiveWeapon.AmmoClipMax) < 0.3 && (gs.Player.Weapons.ActiveWeapon.AmmoClip < oldState.Player.Weapons.ActiveWeapon.AmmoClip) && isGun(gs.Player.Weapons.ActiveWeapon.Type) && gs.Player.Weapons.ActiveWeapon.AmmoClipMax > 1) { Console.Beep(2334, 256); } oldAmmo = gs.Player.Weapons.ActiveWeapon.AmmoClip; // round 1 start check thing if (gs.Round.Phase.ToString().ToLower() == "live" && gs.Map.Round == 1 && (oldState.Map.Phase.ToString().ToLower() == "freezetime" && oldState.Round.Phase.ToString().ToLower() == "freezetime")) { Utils.owo($"Game start event"); } // beep boop when round is over and new one has begun if (oldState.Round.Phase.ToString().ToLower() == "over" && gs.Round.Phase.ToString().ToLower() == "freezetime") { Utils.syncPlayAudio(new int[] { 800, 400, 100 }, new int[] { 700, 400, 600 }); } if (playerKills == -64) { playerKills = gs.Player.MatchStats.Kills; } var curkills = gs.Player.MatchStats.Kills; if (curkills > playerKills) { if (Utils.settings.kills || Utils.settings.killsRadio) { for (int i = 0; i < (curkills - playerKills); i++) { if (Utils._puntualMode) { string o = $"say Kill #{gs.Player.State.RoundKills} [Round {(gs.Map.Round + 1).ToString()}]"; //o += $" [{gs.Player.Weapons.ActiveWeapon.Name.Substring(7).ToUpper()}]"; //if (gs.Player.Weapons.ActiveWeapon.AmmoClipMax > 0) o+= $"({gs.Player.Weapons.ActiveWeapon.AmmoClip}/{gs.Player.Weapons.ActiveWeapon.AmmoClipMax}) "; if (gs.Player.State.RoundKillHS > roundHS) { o += $" (HS)"; } roundHS = gs.Player.State.RoundKillHS; if (gs.Player.State.Flashed != 0) { o += $" / {Math.Round((double)(gs.Player.State.Flashed / (double)255) * 100, 1)}% flashed"; } if (gs.Player.State.Smoked != 0) { o += $" / {Math.Round((double)(gs.Player.State.Smoked / (double)255) * 100, 1)}% smoked"; } if (gs.Player.State.Burning != 0) { o += $" / {Math.Round((double)(gs.Player.State.Burning / (double)255) * 100, 1)}% burning"; } o += $"{Environment.NewLine} enemydown"; Utils.owo(o); } if (Utils._singlesMode) { Utils.owo("say beep boop i got a kill" + Environment.NewLine + "enemydown"); } else if (!Utils._singlesMode && !Utils._puntualMode) { onKill(ref gs); } } } } playerKills = curkills; if (myDeaths == -1) { myDeaths = gs.Player.MatchStats.Deaths; } var curDeaths = gs.Player.MatchStats.Deaths; if (Utils.settings.deaths) { // TODO logic needs improving here if (curDeaths > myDeaths && !(gs.Map.Round == 1 && gs.Player.MatchStats.Deaths == 0)) { if (Utils._puntualMode) // todo { Utils.owo("say oops i have died"); } if (Utils._singlesMode) { Utils.owo("say ouch ow i died"); } else if (!Utils._singlesMode && !Utils._puntualMode) { onDeath(ref gs); } } } myDeaths = curDeaths; } oldState = gs; }
void OnNewGameState(GameState gs) { if (gs.Player.SteamID.Equals(s.ConvertToUInt64().ToString())) { if (!gs.Player.MatchStats.Kills.ToString().Equals("-1")) { this.kNum.Text = gs.Player.MatchStats.Kills.ToString(); } if (!gs.Player.MatchStats.Deaths.ToString().Equals("-1")) { this.dNum.Text = gs.Player.MatchStats.Deaths.ToString(); } if (!gs.Player.MatchStats.Assists.ToString().Equals("-1")) { this.aNum.Text = gs.Player.MatchStats.Assists.ToString(); } if (!gs.Player.State.RoundKills.ToString().Equals("-1")) { this.kThisRound.Text = gs.Player.State.RoundKills.ToString() + " /"; } if (gs.Round.Phase.Equals("freezetime")) { this.kThisRound.Text = "0 /"; } } }
/// <summary> /// Handle a new game state /// </summary> /// <param name="gs"></param> public static void handleGameState(GameState gs) { if (keyController.keyboard != null) { //Find what team the player is on. if (gs.Player.Team.ToString() != "Undefined") { if (gs.Player.Team.ToString() == "T") isT = true; else if (gs.Player.Team.ToString() == "CT") isT = false; inGame = true; } else { inGame = false; } //if the new game state says the bomb is planted and the application thinks the bomb isin't // planted, start the bomb timer and set bombPlanted. if (gs.Round.Bomb.ToString() != "Undefined" && !bombPlanted) { currentBomb = maxBomb; bombPlanted = true; deadTime = bombTimes[0]; } //if the new game state says the round has been won and the bomb state is uundefined reset // the bomb related variables if (gs.Round.WinTeam.ToString() != "Undefined" || gs.Round.Bomb.ToString() == "Undefined") { bombPlanted = false; deadTime = 0; flashTime = 0; currentBomb = 0; bombTick = 0; } //Weapon and ammo counts. //reset these two first. hasC4 = false; grenadeCount = 0; bool hasPrimary = false; bool hasSecondary = false; for (int i = 0; i < gs.Player.Weapons.Count; ++i) { if (gs.Player.Weapons[i].Type.ToString() != "Undefined") { switch (gs.Player.Weapons[i].Type.ToString()) { case ("Rifle"): case ("SubmachineGun"): case ("Shotgun"): case ("SniperRifle"): case ("MachineGun"): primaryMax = gs.Player.Weapons[i].AmmoClipMax; primaryCurrent = gs.Player.Weapons[i].AmmoClip; primaryReserve = gs.Player.Weapons[i].AmmoReserve; hasPrimary = true; break; case ("Pistol"): secondaryMax = gs.Player.Weapons[i].AmmoClipMax; secondaryCurrent = gs.Player.Weapons[i].AmmoClip; secondaryReserve = gs.Player.Weapons[i].AmmoReserve; hasSecondary = true; break; case ("Grenade"): ++grenadeCount; break; case ("C4"): hasC4 = true; break; default: break; } } } if (!hasPrimary) { primaryCurrent = 0; primaryReserve = 0; } if(!hasSecondary) { secondaryCurrent = 0; secondaryReserve = 0; } //Health and Armor status. hasHelmet = false; healthCurrent = gs.Player.State.Health; armorCurrent = gs.Player.State.Armor; hasHelmet = gs.Player.State.Helmet; flashAmount = gs.Player.State.Flashed; burningAmount = gs.Player.State.Burning; keyController.handleGameState(); } }
private void ReceiveGameState(IAsyncResult result) { HttpListenerContext context; try { context = _Listener.EndGetContext(result); } catch (ObjectDisposedException e) { // Listener was Closed due to call of Stop(); return; } finally { waitForConnection.Set(); } HttpListenerRequest request = context.Request; string JSON; using (Stream inputStream = request.InputStream) { using (StreamReader sr = new StreamReader(inputStream)) { JSON = sr.ReadToEnd(); } } using (HttpListenerResponse response = context.Response) { response.StatusCode = (int)HttpStatusCode.OK; response.StatusDescription = "OK"; response.Close(); } CurrentGameState = new GameState(JSON); }