public void Handle(GameClient Session, ClientMessage Event) { if (((Session != null) || (Session.GetHabbo() != null)) && (Session.GetHabbo().SnowWar != null)) { SnowStorm snowWar = Session.GetHabbo().SnowWar; string s = Event.PopFixedString(); ServerMessage talk = new ServerMessage(Outgoing.Game2GameChatFromPlayerMessageEvent); talk.AppendInt32(Session.GetHabbo().Id); talk.AppendString(s); snowWar.SendToStorm(talk, false, 0); } }
public void Handle(GameClient Session, ClientMessage Event) { if (((Session != null) || (Session.GetHabbo() != null)) && ((Session.GetHabbo().SnowWar != null) && Session.GetHabbo().SnowWar.WarUsers.Contains(Session.GetHabbo()))) { SnowStorm snowWar = Session.GetHabbo().SnowWar; ServerMessage packet = new ServerMessage(Outgoing.Game2PlayerExitedGameArenaMessageEvent); packet.AppendInt32(Session.GetHabbo().Id); Session.GetHabbo().SnowWar.SendToStorm(packet, true, Session.GetHabbo().Id); snowWar.WarUsers.Remove(Session.GetHabbo()); if ((snowWar.WarOwner == Session.GetHabbo()) && (snowWar.WarUsers.Count > 0)) { snowWar.WarOwner = snowWar.WarUsers[0]; } Session.GetHabbo().SnowWar = null; } }
private void parseAction(string s) { string[] pairs = s.Split('$'); if (pairs.Length > 1) { string sig = pairs[1].Substring(0, 4); if (sig.Equals("unit")) { string id = pairs[1].Substring(5, pairs[1].Length - 5); for (int i = 2; i < pairs.Length; i++) { switch (pairs[i].Substring(0, 4)) { case "move": try { string[] coords = pairs[i].Substring(5, pairs[i].Length - 5).Split(','); Unit u = ((Unit)(GameData.LevelObjects.Find(id))); u.TargetPosition = new Vector2(float.Parse(coords[0]), float.Parse(coords[1])); u.TargetUnit = null; } catch (NullReferenceException e) { string[] coords = pairs[i].Substring(5, pairs[i].Length - 5).Split(','); Unit u = ((Unit)(GameData.LevelObjects.Find(id))); if (u != null) { u.TargetPosition = new Vector2(float.Parse(coords[0]), float.Parse(coords[1])); //u.TargetUnit = null; } Console.WriteLine("null"); } break; case "targ": try { string targID = pairs[i].Substring(5, pairs[i].Length - 5); Unit theUnit = ((Unit)(GameData.LevelObjects.Find(id))); Unit targetU = (Unit)GameData.LevelObjects.Find(targID); theUnit.SetTargetUnit(targID); } catch (NullReferenceException e) { } break; case "tgbd": string bdtgID = pairs[i].Substring(5, pairs[i].Length - 5); ((Unit)(GameData.LevelObjects.Find(id))).targetBuilding = (Building)GameData.Buildings.Find(bdtgID); break; case "buil": //build break; case "damg": try { string[] parameters = pairs[i].Substring(5, pairs[i].Length - 5).Split(','); string attackerID = parameters[1]; Unit attacker = (Unit)(GameData.LevelObjects.Find(attackerID)); ((Unit)(GameData.LevelObjects.Find(id))).DealDamage(int.Parse(parameters[0]), attacker); } catch (NullReferenceException e) { Console.WriteLine(e.ToString()); } break; case "dead": try { GameData.Units.Remove(((Unit)(GameData.LevelObjects.Find(id)))); } catch (NullReferenceException e) { Console.WriteLine(e.ToString()); } break; } } } else if (sig.Equals("bdng")) { Building b = null; bool polytile = false; string id = pairs[1].Substring(5, pairs[1].Length - 5); for (int i = 2; i < pairs.Length; i++) { switch (pairs[i].Substring(0, 4)) { case "type": string type = pairs[i].Substring(5, pairs[i].Length - 5); switch (type) { case "NatureBarracks": b = new NatureBarracks(); break; case "HumanityBarrack": b = new HumanityBarrack(); polytile = true; break; case "SunlightTree": b = new SunlightTree(); break; case "NatureBase": b = new NatureBase(); polytile = true; break; case "HumanityBase": b = new HumanityBase(); polytile = true; break; case "Mine": b = new Mine(); break; case "WaterTree": b = new WaterTree(); break; } break; case "posi": string[] coords = pairs[i].Substring(5, pairs[i].Length - 5).Split(','); b.gridPosition = new Point(int.Parse(coords[0]), int.Parse(coords[1])); break; case "fnsh": GameData.LevelGrid.replaceTile((Tile)GameData.LevelGrid.Objects[b.gridPosition.X, b.gridPosition.Y], b, false); if (polytile) { ((PolyTileBuilding)b).AddQuadCoTiles(); } GameData.Buildings.Add(b); break; case "damg": try { string[] parameters = pairs[i].Substring(5, pairs[i].Length - 5).Split(','); string attackerID = parameters[1]; Unit attacker = (Unit)(GameData.LevelObjects.Find(attackerID)); ((Building)(GameData.Buildings.Find(id))).DealDamage(int.Parse(parameters[0]), attacker); } catch (NullReferenceException e) { Console.WriteLine(e.ToString()); } break; case "dead": try { GameData.Buildings.Remove(((Building)(GameData.LevelObjects.Find(id)))); } catch (NullReferenceException e) { Console.WriteLine(e.ToString()); } break; } } } else if (sig.Equals("spel")) { Spell spell = null; string id = pairs[1].Substring(5, pairs[1].Length - 5); for (int i = 2; i < pairs.Length; i++) { switch (pairs[i].Substring(0, 4)) { case "type": switch (pairs[i].Substring(5, pairs[i].Length - 5)) { case "MeteorStorm": spell = new MeteorStorm(); break; case "SnowStorm": spell = new SnowStorm(); break; case "Spell": spell = new Spell(); break; } break; case "posi": string[] coords = pairs[i].Substring(5, pairs[i].Length - 5).Split(','); spell.Position = new Vector2(float.Parse(coords[0]), float.Parse(coords[1])); break; } } spell.ID = id; GameData.LevelObjects.Add(spell); } else if (sig.Equals("addu")) { Unit u;//$addu:10$type:HumanityWorker$posi:1080,420 u = null; string id = pairs[1].Substring(5, pairs[1].Length - 5); for (int i = 2; i < pairs.Length; i++) { switch (pairs[i].Substring(0, 4)) { case "type": switch (pairs[i].Substring(5, pairs[i].Length - 5)) { case "HumanityWorker": u = new HumanityWorker(); break; case "NatureWorker": u = new NatureWorker(); break; case "Melee1": string asset = ""; asset = "natureWolf"; if (GameData.player.OppositeFaction == Player.Faction.humanity) { asset = "chainsaw"; } u = new Melee1(GameData.player.OppositeFaction, asset, id); break; case "Ranged": asset = "natureWolf"; if (GameData.player.OppositeFaction == Player.Faction.humanity) { asset = "flamethrower"; } u = new Ranged(GameData.player.OppositeFaction, asset, id); break; case "Melee2": asset = "treeUnit"; if (GameData.player.OppositeFaction == Player.Faction.humanity) { asset = "flamethrower"; } u = new Melee2(GameData.player.OppositeFaction, asset, id); break; case "FlameThrower": u = new FlameThrower(); break; case "Unicorn": asset = "unicorn"; if (GameData.player.OppositeFaction == Player.Faction.humanity) { asset = "quad"; } u = new Unicorn(GameData.player.OppositeFaction, asset, id); break; case "WoodCutter": u = new WoodCutter(); break; case "Unit": u = new Unit(); break; } break; case "posi": string[] coords = pairs[i].Substring(5, pairs[i].Length - 5).Split(','); u.Position = new Vector2(int.Parse(coords[0]), int.Parse(coords[1])); break; } } u.ID = id; GameData.Units.Add(u); GameData.unitIdIndex++; } } }
internal void StartGame(SnowStorm War) { War.AssignTeams(); War.WarStarted = 1; ServerMessage SetStep1 = new ServerMessage(Outgoing.SetStep1); SetStep1.AppendInt32(War.WarId); SetStep1.AppendString("SnowStorm level " + War.WarLevel); SetStep1.AppendInt32(0); SetStep1.AppendInt32(War.WarLevel); SetStep1.AppendInt32(2); SetStep1.AppendInt32(War.MaxUsers); SetStep1.AppendString(War.WarOwner.Username); SetStep1.AppendInt32(15); SetStep1.AppendInt32(War.WarUsers.Count); foreach (Habbo habbo in War.WarUsers) { SetStep1.AppendInt32(habbo.Id); SetStep1.AppendString(habbo.Username); SetStep1.AppendString(habbo.Figure); SetStep1.AppendString((habbo.Gender.ToUpper() == "M") ? "M" : "f"); SetStep1.AppendInt32(habbo.SnowTeam); SetStep1.AppendInt32(habbo.SnowLevel); SetStep1.AppendInt32(habbo.SnowPoints); SetStep1.AppendInt32(Essential.GetGame().GetStormWars().LevelScore[habbo.SnowLevel]); } SetStep1.AppendInt32(0); SetStep1.AppendInt32(120); War.SendToStorm(SetStep1, false, 0); ServerMessage EnterArena = new ServerMessage(Outgoing.Game2EnterArenaMessageEvent); EnterArena.AppendInt32(0); EnterArena.AppendInt32(War.WarLevel); EnterArena.AppendInt32(2); EnterArena.AppendInt32(War.WarUsers.Count); foreach (Habbo habbo in War.WarUsers) { EnterArena.AppendInt32(habbo.Id); EnterArena.AppendString(habbo.Username); EnterArena.AppendString(habbo.Figure); EnterArena.AppendString(habbo.Gender.ToLower()); EnterArena.AppendInt32(habbo.SnowTeam); } EnterArena.AppendInt32(50); EnterArena.AppendInt32(50); EnterArena.AppendString(War.Model.SerializeHeightMap()); EnterArena.AppendInt32(War.Model.SnowItems.Count); foreach (SnowItems items in War.Model.SnowItems) { items.SerializeItem(EnterArena); } War.SendToStorm(EnterArena, false, 0); foreach (Habbo habbo in War.WarUsers) { ServerMessage ArenaEntered = new ServerMessage(Outgoing.Game2ArenaEnteredMessageEvent); ArenaEntered.AppendInt32(habbo.Id); ArenaEntered.AppendString(habbo.Username); ArenaEntered.AppendString(habbo.Figure); ArenaEntered.AppendString(habbo.Gender.ToLower()); ArenaEntered.AppendInt32(habbo.SnowTeam); War.SendToStorm(ArenaEntered, false, 0); } ServerMessage StageLoad = new ServerMessage(Outgoing.Game2StageLoadMessageEvent); StageLoad.AppendInt32(0); War.SendToStorm(StageLoad, false, 0); Action <object> action = delegate(object obj) { Thread.Sleep(0x1388); ServerMessage StageStillLoading = new ServerMessage(Outgoing.Game2StageStillLoadingMessageEvent); StageStillLoading.AppendInt32(0); StageStillLoading.AppendInt32(0); War.SendToStorm(StageStillLoading, false, 0); this.LoadArena(War); }; new Task(action, "pingsession").Start(); }
internal void CheckArenaStatic(ServerMessage Message, SnowStorm War) { Message.AppendInt32((int)(20 + War.WarUsers.Count)); Message.AppendInt32(3); Message.AppendInt32(0); Message.AppendInt32(0x6400); Message.AppendInt32(0xaf00); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(0); Message.AppendInt32(3); Message.AppendInt32(1); Message.AppendInt32(0x1c20a); Message.AppendInt32(0x1770a); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(1); Message.AppendInt32(3); Message.AppendInt32(2); Message.AppendInt32(0x1c20a); Message.AppendInt32(0x11080); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(3); Message.AppendInt32(3); Message.AppendInt32(3); Message.AppendInt32(0x1130a); Message.AppendInt32(0x11f80); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(5); Message.AppendInt32(3); Message.AppendInt32(4); Message.AppendInt32(0x1c20a); Message.AppendInt32(0x15180); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(6); Message.AppendInt32(3); Message.AppendInt32(5); Message.AppendInt32(0xc800); Message.AppendInt32(0x11080); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(7); Message.AppendInt32(3); Message.AppendInt32(6); Message.AppendInt32(0x6400); Message.AppendInt32(0x16a80); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(10); Message.AppendInt32(3); Message.AppendInt32(7); Message.AppendInt32(0x1c20a); Message.AppendInt32(0xe100); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(14); Message.AppendInt32(3); Message.AppendInt32(8); Message.AppendInt32(0x1c20a); Message.AppendInt32(0x12c0a); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(15); Message.AppendInt32(3); Message.AppendInt32(9); Message.AppendInt32(0x15e0a); Message.AppendInt32(0x11080); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(0x10); Message.AppendInt32(3); Message.AppendInt32(10); Message.AppendInt32(0x6400); Message.AppendInt32(0xd480); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(0x11); Message.AppendInt32(3); Message.AppendInt32(11); Message.AppendInt32(0x1c20a); Message.AppendInt32(0xbb80); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(0x12); Message.AppendInt32(3); Message.AppendInt32(12); Message.AppendInt32(0x12c0a); Message.AppendInt32(0x11080); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(20); Message.AppendInt32(3); Message.AppendInt32(13); Message.AppendInt32(0x6400); Message.AppendInt32(0x11f80); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(0x15); Message.AppendInt32(3); Message.AppendInt32(14); Message.AppendInt32(0x1130a); Message.AppendInt32(0xbb80); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(0x18); Message.AppendInt32(3); Message.AppendInt32(15); Message.AppendInt32(0x6400); Message.AppendInt32(0x1450a); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(0x19); Message.AppendInt32(3); Message.AppendInt32(0x10); Message.AppendInt32(0x1130a); Message.AppendInt32(0x15180); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(0x1b); Message.AppendInt32(3); Message.AppendInt32(0x11); Message.AppendInt32(0x1130a); Message.AppendInt32(0xed80); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(0x1d); Message.AppendInt32(3); Message.AppendInt32(0x12); Message.AppendInt32(0x6400); Message.AppendInt32(0xfa00); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(30); Message.AppendInt32(3); Message.AppendInt32(0x13); Message.AppendInt32(0xfa00); Message.AppendInt32(0x11080); Message.AppendInt32(12); Message.AppendInt32(12); Message.AppendInt32(0x23); }
internal void LoadArena(SnowStorm War) { ServerMessage StageStarting = new ServerMessage(Outgoing.Game2StageStartingMessageEvent); StageStarting.AppendInt32(0); StageStarting.AppendString("snowwar_arena_0"); StageStarting.AppendInt32(5); this.CheckArenaStatic(StageStarting, War); int xyz = 0; foreach (Habbo habbo in War.WarUsers) { //habbo.SnowUserId = xyz; StageStarting.AppendInt32(5); //StageStarting.AppendInt32(0); StageStarting.AppendInt32(habbo.SnowUserId); StageStarting.AppendInt32(habbo.SnowX); StageStarting.AppendInt32(habbo.SnowY); StageStarting.AppendInt32((int)(habbo.SnowX / 0xc80)); StageStarting.AppendInt32((int)(habbo.SnowY / 0xc80)); StageStarting.AppendInt32(habbo.SnowRot); StageStarting.AppendInt32(5); StageStarting.AppendInt32(5); StageStarting.AppendInt32(0); StageStarting.AppendInt32(0); StageStarting.AppendInt32(0); StageStarting.AppendInt32((int)(habbo.SnowX / 0xc80)); StageStarting.AppendInt32((int)(habbo.SnowY / 0xc80)); StageStarting.AppendInt32(habbo.SnowX); StageStarting.AppendInt32(habbo.SnowY); StageStarting.AppendInt32(0); //StageStarting.AppendInt32(0); StageStarting.AppendInt32(habbo.SnowTeam); StageStarting.AppendInt32(habbo.Id); StageStarting.AppendString(habbo.Username); StageStarting.AppendString(habbo.Motto); StageStarting.AppendString(habbo.Figure); StageStarting.AppendString(habbo.Gender.ToLower()); xyz++; } War.SendToStorm(StageStarting, false, 0); Thread.Sleep(5000); foreach (Habbo habbo in War.WarUsers) { ServerMessage PlayerExited = new ServerMessage(Outgoing.Game2PlayerExitedGameArenaMessageEvent); PlayerExited.AppendInt32(habbo.Id); PlayerExited.AppendInt32(20); habbo.GetClient().SendMessage(PlayerExited); } Thread thrd = new Thread(delegate() { int countdown = 120; while (countdown != 0) { ServerMessage StageRunning = new ServerMessage(Outgoing.Game2StageRunningMessageEvent); StageRunning.AppendInt32(countdown--); War.SendToStorm(StageRunning); ServerMessage Message5_0 = new ServerMessage(2352);//Game2FullGameStatusMessageEvent Message5_0.AppendInt32(1); Message5_0.AppendInt32(1); Message5_0.AppendInt32(1); Message5_0.AppendInt32(1); Message5_0.AppendInt32(1); Message5_0.AppendInt32(countdown); War.SendToStorm(Message5_0); Thread.Sleep(1000); } }); thrd.Start(); War.SnowStormStart(); }
public void Handle(GameClient Session, ClientMessage Event) { // Session.SendNotification("Sorry. Diese Funktion ist im Moment noch nicht verfügbar! Wir arbeiten daran :)"); Action <object> action2 = null; SnowStorm War = Session.GetClientMessageHandler().CheckAGame(); if (War == null) { War = new SnowStorm(Session.GetHabbo()); } if (!War.WarUsers.Contains(Session.GetHabbo())) { War.WarUsers.Add(Session.GetHabbo()); } ServerMessage message = new ServerMessage(Outgoing.CreateWar); message.AppendInt32(-1); message.AppendString("SnowStorm level " + War.WarLevel); message.AppendInt32(0); message.AppendInt32(War.WarLevel); message.AppendInt32(2); message.AppendInt32(War.MaxUsers); message.AppendString(War.WarOwner.Username); message.AppendInt32(0x11); message.AppendInt32(War.WarUsers.Count); foreach (Habbo WarUser in War.WarUsers) { message.AppendInt32(WarUser.Id); message.AppendString(WarUser.Username); message.AppendString(WarUser.Figure); message.AppendString(WarUser.Gender.ToLower()); message.AppendInt32(-1); message.AppendInt32(WarUser.SnowLevel); message.AppendInt32(WarUser.SnowPoints); message.AppendInt32(1); } message.AppendInt32(120); Session.SendMessage(message); //Session.GetHabbo().SnowUserId = War.WarUsers.Count; War.SendToStorm(Session.GetClientMessageHandler().AddToNewGame(War), false, Session.GetHabbo().Id); if (War.WarOwner == Session.GetHabbo()) { if (action2 == null) { action2 = delegate(object obj) { while (War.Countdown != 0) { War.Countdown--; Thread.Sleep(1000); } try { this.StartGame(War); }catch { foreach (Habbo h in War.WarUsers) { if (h != null && h.GetClient() != null) { h.GetClient().SendNotification("Spiel wurde abgebrochen. Der Ersteller ist offline gegangen!"); } } } }; } Action <object> action = action2; new Task(action, "break").Start(); } ServerMessage packet = new ServerMessage(Outgoing.StartCounter); packet.AppendInt32(War.Countdown); Session.SendMessage(packet); }