Example #1
0
        /// <summary>
        /// Responds to the event
        /// </summary>
        public void Execute(object Source, object[] Params)
        {
            GameClient Client = (GameClient)Source;

            if (Client == null || Client.GetRoleplay() == null || Client.GetHabbo() == null)
            {
                return;
            }

            Room Room = (Room)Params[0];

            TutorialBadge(Client, Params);

            if (Client.GetRoleplay().PoliceTrial)
            {
                Client.GetRoleplay().PoliceTrial = false;
            }

            #region WebSocket Dialogue Check
            Client.GetRoleplay().ClearWebSocketDialogue();
            #endregion

            #region Police Car Enable Check
            if (Client.GetRoomUser() != null)
            {
                if (Client.GetRoomUser().CurrentEffect == EffectsList.CarPolice)
                {
                    Client.GetRoomUser().ApplyEffect(EffectsList.None);
                }
            }
            #endregion

            #region Spawn/Update Texas Hold 'Em Furni
            if (TexasHoldEmManager.GetGamesByRoomId(Room.RoomId).Count > 0)
            {
                List <TexasHoldEm> Games = TexasHoldEmManager.GetGamesByRoomId(Room.RoomId);

                foreach (TexasHoldEm Game in Games)
                {
                    if (Game != null)
                    {
                        #region PotSquare Check
                        if (Game.PotSquare.Furni != null)
                        {
                            if (Game.PotSquare.Furni.GetX != Game.PotSquare.X && Game.PotSquare.Furni.GetY != Game.PotSquare.Y && Game.PotSquare.Furni.GetZ != Game.PotSquare.Z && Game.PotSquare.Furni.Rotation != Game.PotSquare.Rotation)
                            {
                                if (Room.GetRoomItemHandler().GetFloor.Contains(Game.PotSquare.Furni))
                                {
                                    Room.GetRoomItemHandler().RemoveFurniture(null, Game.PotSquare.Furni.Id);
                                }
                                Game.PotSquare.SpawnDice();
                            }
                        }
                        else
                        {
                            Game.PotSquare.SpawnDice();
                        }
                        #endregion

                        #region JoinGate Check
                        if (Game.JoinGate.Furni != null)
                        {
                            if (Game.JoinGate.Furni.GetX != Game.JoinGate.X && Game.JoinGate.Furni.GetY != Game.JoinGate.Y && Game.JoinGate.Furni.GetZ != Game.JoinGate.Z && Game.JoinGate.Furni.Rotation != Game.JoinGate.Rotation)
                            {
                                if (Room.GetRoomItemHandler().GetFloor.Contains(Game.JoinGate.Furni))
                                {
                                    Room.GetRoomItemHandler().RemoveFurniture(null, Game.JoinGate.Furni.Id);
                                }
                                Game.JoinGate.SpawnDice();
                            }
                        }
                        else
                        {
                            Game.JoinGate.SpawnDice();
                        }
                        #endregion

                        #region Player1 Check
                        foreach (TexasHoldEmItem Item in Game.Player1.Values)
                        {
                            if (Item.Furni != null)
                            {
                                if (Item.Furni.GetX != Item.X && Item.Furni.GetY != Item.Y && Item.Furni.GetZ != Item.Z && Item.Furni.Rotation != Item.Rotation)
                                {
                                    if (Room.GetRoomItemHandler().GetFloor.Contains(Item.Furni))
                                    {
                                        Room.GetRoomItemHandler().RemoveFurniture(null, Item.Furni.Id);
                                    }
                                    Item.SpawnDice();
                                }
                            }
                            else
                            {
                                Item.SpawnDice();
                            }
                        }
                        #endregion

                        #region Player2 Check
                        foreach (TexasHoldEmItem Item in Game.Player2.Values)
                        {
                            if (Item.Furni != null)
                            {
                                if (Item.Furni.GetX != Item.X && Item.Furni.GetY != Item.Y && Item.Furni.GetZ != Item.Z && Item.Furni.Rotation != Item.Rotation)
                                {
                                    if (Room.GetRoomItemHandler().GetFloor.Contains(Item.Furni))
                                    {
                                        Room.GetRoomItemHandler().RemoveFurniture(null, Item.Furni.Id);
                                    }
                                    Item.SpawnDice();
                                }
                            }
                            else
                            {
                                Item.SpawnDice();
                            }
                        }
                        #endregion

                        #region Player3 Check
                        foreach (TexasHoldEmItem Item in Game.Player3.Values)
                        {
                            if (Item.Furni != null)
                            {
                                if (Item.Furni.GetX != Item.X && Item.Furni.GetY != Item.Y && Item.Furni.GetZ != Item.Z && Item.Furni.Rotation != Item.Rotation)
                                {
                                    if (Room.GetRoomItemHandler().GetFloor.Contains(Item.Furni))
                                    {
                                        Room.GetRoomItemHandler().RemoveFurniture(null, Item.Furni.Id);
                                    }
                                    Item.SpawnDice();
                                }
                            }
                            else
                            {
                                Item.SpawnDice();
                            }
                        }
                        #endregion

                        #region Banker Check
                        foreach (TexasHoldEmItem Item in Game.Banker.Values)
                        {
                            if (Item.Furni != null)
                            {
                                if (Item.Furni.GetX != Item.X && Item.Furni.GetY != Item.Y && Item.Furni.GetZ != Item.Z && Item.Furni.Rotation != Item.Rotation)
                                {
                                    if (Room.GetRoomItemHandler().GetFloor.Contains(Item.Furni))
                                    {
                                        Room.GetRoomItemHandler().RemoveFurniture(null, Item.Furni.Id);
                                    }
                                    Item.SpawnDice();
                                }
                            }
                            else
                            {
                                Item.SpawnDice();
                            }
                        }
                        #endregion
                    }
                }
            }
            #endregion

            #region Spawn/Update Turf Flag Furni
            if (Room.TurfEnabled)
            {
                Turf Turf = TurfManager.GetTurf(Room.RoomId);

                if (Turf != null)
                {
                    if (Turf.FlagSpawned)
                    {
                        if (Turf.Flag.GroupId != Turf.GangId || (Turf.Flag.GetX != Turf.FlagX && Turf.Flag.GetY != Turf.FlagY))
                        {
                            Turf.SpawnFlag();
                        }
                    }
                    else
                    {
                        Turf.SpawnFlag();
                    }
                }
            }
            #endregion

            #region Spawn/Update House Signs
            List <House> Houses = PlusEnvironment.GetGame().GetHouseManager().GetHousesBySignRoomId(Room.Id);
            if (Houses.Count > 0)
            {
                foreach (House House in Houses)
                {
                    if (House.Sign.Spawned)
                    {
                        if (House.Sign.Item.GetX != House.Sign.X && House.Sign.Item.GetY != House.Sign.Y && House.Sign.Item.GetZ != House.Sign.Z)
                        {
                            House.SpawnSign();
                        }
                    }
                    else
                    {
                        House.SpawnSign();
                    }
                }
            }
            #endregion

            #region Spawn/Update Farming Spaces
            List <FarmingSpace> FarmingSpaces = FarmingManager.GetFarmingSpacesByRoomId(Room.Id);
            if (FarmingSpaces.Count > 0)
            {
                foreach (FarmingSpace Space in FarmingSpaces)
                {
                    if (Space.Spawned)
                    {
                        if (Space.Item.GetX != Space.X && Space.Item.GetY != Space.Y && Space.Item.GetZ != Space.Z)
                        {
                            Space.SpawnSign();
                        }
                    }
                    else
                    {
                        Space.SpawnSign();
                    }
                }
            }
            #endregion

            #region Spawn Jailbreak Fence
            if (Room.RoomId == Convert.ToInt32(RoleplayData.GetData("jail", "outsideroomid")) && !JailbreakManager.JailbreakActivated)
            {
                int X   = Convert.ToInt32(RoleplayData.GetData("jailbreak", "fencex"));
                int Y   = Convert.ToInt32(RoleplayData.GetData("jailbreak", "fencey"));
                int Rot = Convert.ToInt32(RoleplayData.GetData("jailbreak", "fencerotation"));

                if (Room.GetRoomItemHandler().GetFloor.Where(x => x.BaseItem == 8049 && x.GetX == X && x.GetY == Y).ToList().Count <= 0)
                {
                    double MaxHeight = 0.0;
                    Item   ItemInFront;
                    if (Room.GetGameMap().GetHighestItemForSquare(new Point(X, Y), out ItemInFront))
                    {
                        if (ItemInFront != null)
                        {
                            MaxHeight = ItemInFront.TotalHeight;
                        }
                    }

                    RoleplayManager.PlaceItemToRoom(null, 8049, 0, X, Y, MaxHeight, Rot, false, Room.RoomId, false);
                }
            }
            #endregion

            #region Taxi Message
            if (Client.GetRoleplay().AntiArrowCheck)
            {
                Client.GetRoleplay().AntiArrowCheck = false;
            }

            if (Client.GetRoleplay().InsideTaxi)
            {
                int Bubble = (Client.GetHabbo().GetPermissions().HasRight("mod_tool") && Client.GetRoleplay().StaffOnDuty) ? 23 : 4;
                Client.GetRoleplay().InsideTaxi = false;

                new Thread(() =>
                {
                    Thread.Sleep(500);
                    RoleplayManager.Shout(Client, "*Chega ao meu destino*", Bubble);
                }).Start();
            }
            else
            {
                PlusEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Client, QuestType.SOCIAL_VISIT);
            }
            #endregion

            #region Room Entrance Message
            if (Room.EnterRoomMessage != "none")
            {
                new Thread(() =>
                {
                    Thread.Sleep(500);
                    Client.SendWhisper(Room.EnterRoomMessage, 34);
                }).Start();
            }
            #endregion

            #region Main checks

            BotInteractionCheck(Client, Params);

            if (Client.GetRoleplay().Game == null && Client.GetRoleplay().Team == null)
            {
                HomeRoomCheck(Client, Params);
                JobCheck(Client, Params);
                SendhomeCheck(Client, Params);
                DeathCheck(Client, Params);
                JailCheck(Client, Params);
                WantedCheck(Client, Params);
                ProbationCheck(Client, Params);

                #region AFK check

                if (Client.GetRoomUser() != null)
                {
                    Client.GetHabbo().Poof(true);
                }

                #endregion
            }
            #endregion

            #region Event/Game Checks
            else
            {
                if (Client.GetRoleplay().Game != null && Client.GetRoleplay().Team != null)
                {
                    if (!Client.GetRoleplay().GameSpawned || Client.GetRoleplay().NeedsRespawn)
                    {
                        if (Client.GetRoleplay().Game != Games.RoleplayGameManager.GetGame(Games.GameMode.Brawl))
                        {
                            var OldCoord = new Point(Client.GetRoomUser().Coordinate.X, Client.GetRoomUser().Coordinate.Y);
                            var NewCoord = new Point(Client.GetRoleplay().Team.SpawnPoint.X, Client.GetRoleplay().Team.SpawnPoint.Y);

                            Client.GetHabbo().CurrentRoom.GetGameMap().UpdateUserMovement(OldCoord, NewCoord, Client.GetRoomUser());
                            Client.GetRoomUser().SetPos(NewCoord.X, NewCoord.Y, Client.GetHabbo().CurrentRoom.GetGameMap().GetHeightForSquare(NewCoord));

                            if (Client.GetRoleplay().NeedsRespawn)
                            {
                                if (Client.GetRoomUser() != null)
                                {
                                    Client.GetRoomUser().CanWalk = false;
                                }
                            }

                            if (!Client.GetRoleplay().GameSpawned)
                            {
                                Client.GetRoleplay().GameSpawned = true;
                                Client.SendNotification(Client.GetRoleplay().Game.GetName() + " Começou! Boa sorte!");
                            }
                        }
                    }
                }
            }
            #endregion
        }
Example #2
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            #region Variables
            Group Gang       = GroupManager.GetGang(Session.GetRoleplay().GangId);
            Turf  Turf       = TurfManager.GetTurf(Room.RoomId);
            bool  InsideTurf = false;
            #endregion

            #region Conditions
            if (Turf == null)
            {
                Session.SendWhisper("A sala em que você se encontra não é um território de gangue!", 1);
                return;
            }

            if (Turf.GangId == Session.GetRoleplay().GangId)
            {
                Session.SendWhisper("Sua gangue já possui esse território!", 1);
                return;
            }

            if (Gang == null)
            {
                Session.SendWhisper("Você não faz parte de nenhuma gangue para capturar este território!", 1);
                return;
            }

            if (Gang.Id <= 1000)
            {
                Session.SendWhisper("Você não faz parte de nenhuma gangue para capturar este território!", 1);
                return;
            }

            if (Session.GetRoleplay().IsDead)
            {
                Session.SendWhisper("Você não pode capturar um território de gangue enquanto está morto", 1);
                return;
            }

            if (Session.GetRoleplay().IsJailed)
            {
                Session.SendWhisper("Você não pode capturar um território de gangue enquanto está preso!", 1);
                return;
            }

            if (Session.GetRoomUser().Frozen)
            {
                Session.SendWhisper("Você não pode capturar um território de gangue enquanto você está atordoado!", 1);
                return;
            }

            if (Session.GetRoleplay().GangId == Turf.GangId)
            {
                Session.SendWhisper("Sua gangue já possui esse território de gangue!", 1);
                return;
            }

            if (Turf.CaptureSquares.Where(x => x.X == Session.GetRoomUser().Coordinate.X&& x.Y == Session.GetRoomUser().Coordinate.Y).ToList().Count > 0)
            {
                InsideTurf = true;
            }

            if (!InsideTurf)
            {
                Session.SendWhisper("Você não está dentro da zona de território de gangue!", 1);
                return;
            }

            if (Session.GetRoleplay().TimerManager.ActiveTimers.ContainsKey("gcapturar") || Session.GetRoleplay().CapturingTurf != null)
            {
                Session.SendWhisper("Você já está capturando um território de gangue!", 1);
                return;
            }

            if (Session.GetRoleplay().DrivingCar)
            {
                Session.SendWhisper("Você não pode capturar um território enquanto dirige um veículo ", 1);
                return;
            }
            #endregion

            #region Execute
            Session.Shout("*Começa a capturar o território para a minha Gangue [" + Gang.Name + "]*", 4);
            Session.SendWhisper("Você tem 5 minutos restantes até capturar este território!", 1);

            Session.GetRoleplay().TimerManager.CreateTimer("gcapturar", 1000, false);
            Session.GetRoleplay().CapturingTurf = Turf;

            Group CurrentGang = GroupManager.GetGang(Turf.GangId);

            if (CurrentGang.Id > 1000)
            {
                lock (CurrentGang.Members.Values)
                {
                    foreach (GroupMember Member in CurrentGang.Members.Values)
                    {
                        GameClient Client = PlusEnvironment.GetGame().GetClientManager().GetClientByUserID(Member.UserId);

                        if (Client == null)
                        {
                            continue;
                        }

                        Client.SendWhisper("[GANGUE] Seu território de gangue no quarto " + Room.Name + " [ID: " + Room.Id + "] está sendo capturado!", 34);
                    }
                }
            }
            #endregion
        }
Example #3
0
        public void UnloadRoom(Room Room, bool RemoveData = false)
        {
            if (Room == null)
            {
                return;
            }

            #region Roleplay Checks

            #region Turf
            Turf Turf = TurfManager.GetTurf(Room.RoomId);

            if (Turf != null)
            {
                Turf.Flag        = null;
                Turf.FlagSpawned = false;
            }
            #endregion

            #region Texas Hold Em
            List <TexasHoldEm> Games = TexasHoldEmManager.GetGamesByRoomId(Room.Id);
            if (Games.Count > 0)
            {
                foreach (TexasHoldEm Game in Games)
                {
                    if (Game != null)
                    {
                        #region PotSquare Check
                        Game.PotSquare.Furni = null;
                        #endregion

                        #region JoinGate Check
                        Game.JoinGate.Furni = null;
                        #endregion

                        #region Player1 Check
                        foreach (TexasHoldEmItem Item in Game.Player1.Values)
                        {
                            Item.Furni = null;
                        }
                        #endregion

                        #region Player2 Check
                        foreach (TexasHoldEmItem Item in Game.Player2.Values)
                        {
                            Item.Furni = null;
                        }
                        #endregion

                        #region Player3 Check
                        foreach (TexasHoldEmItem Item in Game.Player3.Values)
                        {
                            Item.Furni = null;
                        }
                        #endregion

                        #region Banker Check
                        foreach (TexasHoldEmItem Item in Game.Banker.Values)
                        {
                            Item.Furni = null;
                        }
                        #endregion
                    }
                }
            }
            #endregion

            #region Farming
            List <FarmingSpace> FarmingSpaces = FarmingManager.GetFarmingSpacesByRoomId(Room.Id);
            if (FarmingSpaces.Count > 0)
            {
                foreach (FarmingSpace Space in FarmingSpaces)
                {
                    if (Space != null)
                    {
                        Space.Item    = null;
                        Space.Spawned = false;
                    }
                }
            }
            #endregion

            #region Houses
            List <House> Houses = PlusEnvironment.GetGame().GetHouseManager().GetHousesBySignRoomId(Room.Id);
            if (Houses.Count > 0)
            {
                foreach (House House in Houses)
                {
                    if (House.Sign != null)
                    {
                        House.Sign.Item    = null;
                        House.Sign.Spawned = false;
                    }
                }
            }
            #endregion

            #region Bots
            RoleplayBotManager.EjectRoomsDeployedBots(Room);
            #endregion

            #endregion

            new Thread(() => {
                Thread.Sleep(200);
                Room room = null;
                if (this._rooms.TryRemove(Room.RoomId, out room))
                {
                    Room.Dispose();

                    if (RemoveData)
                    {
                        RoomData Data = null;
                        this._loadedRoomData.TryRemove(Room.Id, out Data);
                    }
                }
            }).Start();
        }