using System; using System.Collections.Generic; using System.Linq; using System.Text; using Blizzard.HabboHotel.Rooms; using Blizzard.HabboHotel.Users; using Blizzard.HabboHotel.Wired; using System.Threading; namespace Blizzard.HabboHotel.Items { class FurniInteractor { ItemsData ItemData; RoomItem Item; Habbo User; RoomsData cRoom; Room Room; internal FurniInteractor(Habbo U, ItemsData I = null, RoomItem R = null, RoomsData sR = null, Room ssR = null) { ItemData = I; Item = R; User = U; cRoom = sR; Room = ssR; } internal void WalkOnFurni() { try { if (Item == null || Item.Id == 0 || Item.Id.ToString() == "") return; if (User == null || User.Id == 0 || User.Id.ToString() == "") return; #region Wired Trigger: Walks Of Furni foreach (RoomItem Ite in cRoom.FloorItems) { if (Ite.GetBaseItem().Name == "wf_trg_walks_off_furni") { foreach (RoomItem It in Room.GetItemsForXY(User.LastX, User.LastY)) { if (Ite.WiredItems.Contains(It.Id)) { foreach (RoomItem I in Room.GetItemsForXY(Ite.X, Ite.Y)) { WiredEffects Eff = new WiredEffects(I, User); Eff.DoWiredEffects(); } } } } } #endregion if (ItemData.Name == "rare_stand") { User.RotBody = Item.Rot; User.RotHead = Item.Rot; User.UpdateState(); } if (ItemData.CanSit) { User.IsSit = true; User.RotHead = Item.Rot; User.RotBody = Item.Rot; string UserZ = Room.GetHForXY(Item.X, Item.Y, Item).ToString().Replace(',', '.'); if (!UserZ.Contains(".")) UserZ += ".0"; User.UpdateMyState("sit", UserZ); User.CurrentState = "sit"; } #region Wired Triggers foreach (RoomItem zItem in cRoom.FloorItems) { if (zItem.GetBaseItem().Name == "wf_trg_walks_on_furni") { if (zItem.WiredItems.Contains(Item.Id)) { zItem.ExtraData = "1"; zItem.UpdateState(User); foreach (RoomItem uItem in Room.GetItemsForXY(zItem.X, zItem.Y)) { WiredEffects Eff = new WiredEffects(uItem, User); Eff.DoWiredEffects(); } zItem.ExtraData = "0"; zItem.UpdateState(User); } } } #endregion #region Roller Furniture if (Item.GetBaseItem().Name.StartsWith("queue")) { // Is user on XY if (User.RequestToWalk && !User.IsWalking) return; string UserZ = Room.SecondGetHForXY(Item.SquareInFront.X, Item.SquareInFront.Y).ToString().Replace(',', '.'); if (!UserZ.Contains(".")) UserZ += ".0"; // CfPBKPBPAHpNJOGDJH0.45{2}0.45{2}{1} ServerMessage Message = new ServerMessage("Cf"); Message.AddInt(User.X); Message.AddInt(User.Y); Message.AddInt(Item.SquareInFront.X); Message.AddInt(Item.SquareInFront.Y); Message.AddBoolean(false); Message.AddInt(Item.Id); Message.AddInt(User.RotBody); Message.AddInt(User.VirtualId); Message.AddStringWithBreak(User.Z); Message.AddStringWithBreak(UserZ); User.SendMessage(Message); Thread.Sleep(300); User.X = Item.SquareInFront.X; User.Y = Item.SquareInFront.Y; User.Z = UserZ; User.UpdateState(); Thread.Sleep(900); List Is = Room.GetItemsForXY(Item.SquareInFront.X, Item.SquareInFront.Y); if (Is.Count > 0) { foreach (RoomItem I in Is) { ItemsData U = I.GetBaseItem(); FurniInteractor Inter = new FurniInteractor(User, U, I, cRoom, Room); Inter.WalkOnFurni(); } } else { FurniInteractor Inter = new FurniInteractor(User); Inter.WalkWithoutFurni(Room); } //Room.MoveItemToXY(Item, Item.SquareInFront.X, Item.SquareInFront.Y, Item.Rot); } #endregion #region Football Items if (Item.GetBaseItem().Name.StartsWith("fball_")) { #region Balls if (Item.GetBaseItem().Name.Contains("_ball")) { int newX = Item.X; int newY = Item.X; int staticX = Item.X; int staticY = Item.Y; Item.ExtraData = "1"; Item.UpdateState(User); int e = (new Random()).Next(2, 6); for (int i = 0; i != e; i++) { if (User.RotBody == 4) newY = staticY + i; else if (User.RotBody == 0) newY = staticY - i; else if (User.RotBody == 6) newX = staticX - i; else if (User.RotBody == 2) newX = staticX + i; else if (User.RotBody == 3) { newX = staticX + i; newY = staticY + i; } else if (User.RotBody == 7) { newX = staticX - i; newY = staticY - i; } else if (User.RotBody == 1) { newX = staticX + i; newY = staticY - i; } else if (User.RotBody == 5) { newX = staticX - i; newY = staticY + i; } if (!Room.IsValidTile(newX, newY)) return; List ItemsOnXY = Room.GetItemsForXY(newX, newY); foreach (RoomItem sItem in ItemsOnXY) { if (sItem.GetBaseItem().Name.StartsWith("fball_ptch")) continue; if (sItem.GetBaseItem().Name.StartsWith("fball_goal")) { string color = (sItem.GetBaseItem().Name.Split('_'))[2]; foreach (RoomItem zItem in cRoom.FloorItems) { if (zItem.GetBaseItem().Name.StartsWith("fball_score")) { string zcolor = (zItem.GetBaseItem().Name.Split('_'))[2]; if (color == zcolor) { if (zItem.ExtraData == "") zItem.ExtraData = "0"; int Goal = int.Parse(zItem.ExtraData); Goal++; zItem.ExtraData = Goal.ToString(); zItem.UpdateState(User); User.Greet(); } } } Room.MoveItemToXY(Item, newX, newY, Item.Rot); return; } } Room.MoveItemToXY(Item, newX, newY, Item.Rot); Thread.Sleep(80); } Item.ExtraData = "0"; Item.UpdateState(User); } #endregion } #endregion #region Battle Ball Items if (Item.GetBaseItem().Name.StartsWith("bb_")) { #region Battle Patchs if (Item.GetBaseItem().Name.Contains("patch")) { if (!cRoom.BattleOnGame) return; if (cRoom.BattlePause) return; if (User.CurrentEffect != 33 && User.CurrentEffect != 34 && User.CurrentEffect != 35 && User.CurrentEffect != 36) return; if (Item.ExtraData == "") Item.ExtraData = "0"; int Color = int.Parse(Item.ExtraData); string color = "r"; if (User.CurrentEffect == 34) color = "g"; else if (User.CurrentEffect == 35) color = "b"; else if (User.CurrentEffect == 36) color = "y"; /* Banzai States 0 = Inactive 1 = Battle Banzai! 2 = ? Red Tiles 3 = State1 4 = State2 5 = Locked Green Tiles 6 = State1 7 = State2 8 = Locked Blue Tiles 9 = State1 10 = State2 11 = Locked Yellow Tiles 12 = State1 13 = State2 14 = Locked */ if (Color > 0 && Color != 5 && Color != 8 && Color != 11 && Color != 14) { int NextColor = 0; if (Color == 1) { NextColor = 3; if (color == "g") NextColor = 6; else if (color == "b") NextColor = 9; else if (color == "y") NextColor = 12; } else if (Color == 3 || Color == 6 || Color == 9 || Color == 12) { if (Color == 3 && color != "r") { NextColor = 3; if (color == "g") NextColor = 6; else if (color == "b") NextColor = 9; else if (color == "y") NextColor = 12; } else if (Color == 6 && color != "g") { NextColor = 3; if (color == "g") NextColor = 6; else if (color == "b") NextColor = 9; else if (color == "y") NextColor = 12; } else if (Color == 9 && color != "b") { NextColor = 3; if (color == "g") NextColor = 6; else if (color == "b") NextColor = 9; else if (color == "y") NextColor = 12; } else if (Color == 12 && color != "y") { NextColor = 3; if (color == "g") NextColor = 6; else if (color == "b") NextColor = 9; else if (color == "y") NextColor = 12; } else { NextColor = 4; if (color == "g") NextColor = 7; else if (color == "b") NextColor = 10; else if (color == "y") NextColor = 13; } } else if (Color == 4 || Color == 7 || Color == 10 || Color == 13) { if (Color == 4 && color != "r") { NextColor = 3; if (color == "g") NextColor = 6; else if (color == "b") NextColor = 9; else if (color == "y") NextColor = 12; } else if (Color == 7 && color != "g") { NextColor = 3; if (color == "g") NextColor = 6; else if (color == "b") NextColor = 9; else if (color == "y") NextColor = 12; } else if (Color == 10 && color != "b") { NextColor = 3; if (color == "g") NextColor = 6; else if (color == "b") NextColor = 9; else if (color == "y") NextColor = 12; } else if (Color == 13 && color != "y") { NextColor = 3; if (color == "g") NextColor = 6; else if (color == "b") NextColor = 9; else if (color == "y") NextColor = 12; } else { NextColor = 5; if (color == "g") NextColor = 8; else if (color == "b") NextColor = 11; else if (color == "y") NextColor = 14; // Add a score #region Scores foreach (RoomItem It in cRoom.FloorItems) { if (It.GetBaseItem().Name.Contains("bb_score")) { string tcolor = It.GetBaseItem().Name.Split('_')[2]; if (tcolor == color) { if (It.ExtraData == "") { It.ExtraData = "0"; } int ex = int.Parse(It.ExtraData); ex += 1; It.ExtraData = ex.ToString(); It.UpdateState(User); break; } else { continue; } } } #endregion } } Item.ExtraData = NextColor.ToString(); Item.UpdateState(User); } } #endregion #region Battle Gates if (Item.GetBaseItem().Name.Contains("gate")) { string color = Item.GetBaseItem().Name.Split('_')[2]; int EffectId = -1; if (color == "r") { EffectId = 33; } else if (color == "b") { EffectId = 35; } else if (color == "y") { EffectId = 36; } else if (color == "g") { EffectId = 34; } if (User.CurrentEffect != EffectId) { if (User.CurrentEffect == 33 || User.CurrentEffect == 34 || User.CurrentEffect == 35 || User.CurrentEffect == 36) { if (Item.ExtraData == "") { Item.ExtraData = "0"; } int ex2 = int.Parse(Item.ExtraData); if (ex2 == 5) return; string scolor = "r"; if (User.CurrentEffect == 34) scolor = "g"; else if (User.CurrentEffect == 35) scolor = "b"; else if (User.CurrentEffect == 36) scolor = "y"; foreach (RoomItem It in cRoom.FloorItems) { if (It.GetBaseItem().Name.Contains("bb_gate")) { string tcolor = It.GetBaseItem().Name.Split('_')[2]; if (tcolor == scolor) { if (It.ExtraData == "") { It.ExtraData = "0"; } int ex = int.Parse(It.ExtraData); ex--; It.ExtraData = ex.ToString(); It.UpdateState(User); } else { continue; } } } } if (Item.ExtraData == "") { Item.ExtraData = "0"; } int extra = int.Parse(Item.ExtraData); extra++; Item.ExtraData = extra.ToString(); Item.UpdateState(User); (new EffectsInventory()).ShowEffect(User, EffectId); } else { int extra = int.Parse(Item.ExtraData); extra--; Item.ExtraData = extra.ToString(); Item.UpdateState(User); (new EffectsInventory()).ShowEffect(User, -1); } } #endregion } #endregion #region Freeze Items if (Item.GetBaseItem().Name.StartsWith("es_")) { #region Freeze Gates if (Item.GetBaseItem().Name.Contains("gate")) { string color = Item.GetBaseItem().Name.Split('_')[2]; int EffectId = -1; if (color == "r") { EffectId = 40; } else if (color == "b") { EffectId = 42; } else if (color == "y") { EffectId = 43; } else if (color == "g") { EffectId = 41; } if (User.CurrentEffect != EffectId) { if (User.CurrentEffect == 40 || User.CurrentEffect == 41 || User.CurrentEffect == 42 || User.CurrentEffect == 43) { if (Item.ExtraData == "") { Item.ExtraData = "0"; } int ex2 = int.Parse(Item.ExtraData); if (ex2 == 5) return; string scolor = "r"; if (User.CurrentEffect == 41) scolor = "g"; else if (User.CurrentEffect == 42) scolor = "b"; else if (User.CurrentEffect == 43) scolor = "y"; foreach (RoomItem It in cRoom.FloorItems) { if (It.GetBaseItem().Name.Contains("es_gate")) { string tcolor = It.GetBaseItem().Name.Split('_')[2]; if (tcolor == scolor) { if (It.ExtraData == "") { It.ExtraData = "0"; } int ex = int.Parse(It.ExtraData); ex--; It.ExtraData = ex.ToString(); It.UpdateState(User); } else { continue; } } } } if (Item.ExtraData == "") { Item.ExtraData = "0"; } int extra = int.Parse(Item.ExtraData); extra++; Item.ExtraData = extra.ToString(); Item.UpdateState(User); (new EffectsInventory()).ShowEffect(User, EffectId); } else { int extra = int.Parse(Item.ExtraData); extra--; Item.ExtraData = extra.ToString(); Item.UpdateState(User); (new EffectsInventory()).ShowEffect(User, -1); } } #endregion if (!cRoom.FreezeOnGame) return; #region Freeze Boxes if (Item.GetBaseItem().Name == "es_box") { if (Item.ExtraData == "") Item.ExtraData = "0"; if (Item.ExtraData != "0") { if (User.CurrentEffect != 40 && User.CurrentEffect != 41 && User.CurrentEffect != 42 && User.CurrentEffect != 43) return; // Some powers :D! if (Item.ExtraData == "2000") { //freezerange += 1; Item.ExtraData = "12000"; Item.UpdateState(User); } else if (Item.ExtraData == "3000") { User.frzBalls += 1; Item.ExtraData = "13000"; Item.UpdateState(User); } else if (Item.ExtraData == "4000") { User.HasFreezeDiagonal = true; Item.ExtraData = "14000"; Item.UpdateState(User); } else if (Item.ExtraData == "5000") { //User.HyperBalls++; Item.ExtraData = "15000"; Item.UpdateState(User); } else if (Item.ExtraData == "6000") { Item.ExtraData = "16000"; Item.UpdateState(User); User.FreezeLives += 1; User.SeeMyFreezeLives(); string scolor = "r"; if (User.CurrentEffect == 41) scolor = "g"; else if (User.CurrentEffect == 42) scolor = "b"; else if (User.CurrentEffect == 43) scolor = "y"; foreach (RoomItem sItem in cRoom.FloorItems) { if (sItem.GetBaseItem().Name == "es_score_" + scolor) { User.AddPoints(sItem, scolor); break; } } } else if (Item.ExtraData == "7000") { Item.ExtraData = "17000"; Item.UpdateState(User); Thread Shield = new Thread(new ThreadStart(ThreadShield)); if (StaticGame.FreezeShieldsSystem.ContainsKey(User.Id)) { Thread Shield2 = StaticGame.FreezeShieldsSystem[User.Id]; Shield2.Abort(); StaticGame.FreezeShieldsSystem.Remove(User.Id); } StaticGame.FreezeShieldsSystem.Add(User.Id, Shield); Shield.Start(); Thread.Sleep(1); } } } #endregion } #endregion } catch (Exception e) { BlizzardSystem.WriteLine("Error walking: " + e.ToString()); } } internal void ThreadShield() { int CurrentEffect = User.CurrentEffect; if (CurrentEffect != 49 && CurrentEffect != 50 && CurrentEffect != 51 && CurrentEffect != 52) (new EffectsInventory()).ShowEffect(User, CurrentEffect + 9); // SHIELD else (new EffectsInventory()).ShowEffect(User, CurrentEffect); // SHIELD User.HasFreezeShield = true; Thread.Sleep(15000); if (CurrentEffect != 49 && CurrentEffect != 50 && CurrentEffect != 51 && CurrentEffect != 52) (new EffectsInventory()).ShowEffect(User, CurrentEffect); // SHIELD else (new EffectsInventory()).ShowEffect(User, CurrentEffect - 9); // SHIELD User.HasFreezeShield = false; Thread Shield = StaticGame.FreezeShieldsSystem[User.Id]; Shield.Abort(); StaticGame.FreezeShieldsSystem.Remove(User.Id); } internal void WalkWithoutFurni(Room CRoom) { try { RoomsData zRoom = RoomsData.Rooms[User.CurrentRoomId]; #region Wired Trigger: Walks Off Furni foreach (RoomItem Ite in zRoom.FloorItems) { if (Ite.GetBaseItem().Name == "wf_trg_walks_off_furni") { foreach (RoomItem It in CRoom.GetItemsForXY(User.LastX, User.LastY)) { if (Ite.WiredItems.Contains(It.Id)) { foreach (RoomItem I in CRoom.GetItemsForXY(Ite.X, Ite.Y)) { WiredEffects Eff = new WiredEffects(I, User); Eff.DoWiredEffects(); } } } } } #endregion if (User.IsSit) { User.CurrentState = ""; User.IsSit = false; User.UpdateMyState("", ""); } if (User.CurrentState != "mv") { User.Z = CRoom.SecondGetHForXY(User.X, User.Y).ToString().Replace(",", "."); User.UpdateState(); } } catch (Exception e) { BlizzardSystem.WriteLine("Error walking: " + e.ToString()); } } } }