Esempio n. 1
0
        public override void OnUserWalk(GameClient session, RoomItem item, RoomUser user)
        {
            if (session == null || item == null || user == null)
                return;

            int distance = PathFinder.GetDistance(user.X, user.Y, item.X, item.Y);

            if (distance > 0 || user.GoalX == 0 && user.GoalY == 0)
                return;

            item.ExtraData = "0";
            item.UpdateState(false, true);
            item.InteractingUser = 1;

            if (user.GoalX != item.X || user.GoalY != item.Y)
                return;

            switch (user.RotBody)
            {
                case 3:
                case 4:
                case 5:
                    user.MoveTo(item.GetRoom()
                        .GetGameMap()
                        .CanWalk(item.SquareBehind.X, item.SquareBehind.Y, user.AllowOverride)
                        ? item.SquareBehind
                        : item.SquareInFront);
                    break;

                default:
                    user.MoveTo(item.GetRoom()
                        .GetGameMap()
                        .CanWalk(item.SquareInFront.X, item.SquareInFront.Y, user.AllowOverride)
                        ? item.SquareInFront
                        : item.SquareBehind);
                    break;
            }
        }
 public override void OnTrigger(GameClient Session, RoomItem RoomItem_0, int int_0, bool bool_0)
 {
     if (Session != null)
     {
         RoomUser @class = Session.GetHabbo().CurrentRoom.GetRoomUserByHabbo(Session.GetHabbo().Id);
         Room     class2 = RoomItem_0.GetRoom();
         if (RoomItem_0.GetRoom().method_99(RoomItem_0.GetX, RoomItem_0.Int32_1, @class.X, @class.Y))
         {
             RoomItem_0.GetRoom().method_10(@class, RoomItem_0);
             int num  = RoomItem_0.GetX;
             int num2 = RoomItem_0.Int32_1;
             RoomItem_0.ExtraData = "11";
             if (@class.BodyRotation == 4)
             {
                 num2--;
             }
             else
             {
                 if (@class.BodyRotation == 0)
                 {
                     num2++;
                 }
                 else
                 {
                     if (@class.BodyRotation == 6)
                     {
                         num++;
                     }
                     else
                     {
                         if (@class.BodyRotation == 2)
                         {
                             num--;
                         }
                         else
                         {
                             if (@class.BodyRotation == 3)
                             {
                                 num--;
                                 num2--;
                             }
                             else
                             {
                                 if (@class.BodyRotation == 1)
                                 {
                                     num--;
                                     num2++;
                                 }
                                 else
                                 {
                                     if (@class.BodyRotation == 7)
                                     {
                                         num++;
                                         num2++;
                                     }
                                     else
                                     {
                                         if (@class.BodyRotation == 5)
                                         {
                                             num++;
                                             num2--;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             @class.MoveTo(RoomItem_0.GetX, RoomItem_0.Int32_1);
             class2.method_79(null, RoomItem_0, num, num2, 0, false, true, true);
         }
     }
 }
Esempio n. 3
0
        public void OnTrigger(GameClient session, RoomItem item, int request, bool hasRights)
        {
            if (session == null)
            {
                return;
            }
            RoomUser roomUserByHabbo = item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(session.GetHabbo().Id);

            if (roomUserByHabbo == null)
            {
                return;
            }

            {
                if (Math.Abs(roomUserByHabbo.X - item.X) < 2 && Math.Abs(roomUserByHabbo.Y - item.Y) < 2)
                {
                    roomUserByHabbo.SetRot(PathFinder.CalculateRotation(roomUserByHabbo.X, roomUserByHabbo.Y, item.X, item.Y), false);
                    Room room  = item.GetRoom();
                    var  point = new Point(0, 0);
                    switch (roomUserByHabbo.RotBody)
                    {
                    case 4:
                        point = new Point(item.X, item.Y + 1);
                        break;

                    case 0:
                        point = new Point(item.X, item.Y - 1);
                        break;

                    case 6:
                        point = new Point(item.X - 1, item.Y);
                        break;

                    default:
                        if (roomUserByHabbo.RotBody != 2)
                        {
                            return;
                        }
                        point = new Point(item.X + 1, item.Y);
                        break;
                    }
                    if (!room.GetGameMap().ValidTile2(point.X, point.Y))
                    {
                        return;
                    }
                    double num           = item.GetRoom().GetGameMap().SqAbsoluteHeight(point.X, point.Y);
                    var    serverMessage = new ServerMessage();
                    serverMessage.Init(LibraryParser.OutgoingRequest("ItemAnimationMessageComposer"));
                    serverMessage.AppendInteger(item.X);
                    serverMessage.AppendInteger(item.Y);
                    serverMessage.AppendInteger(point.X);
                    serverMessage.AppendInteger(point.Y);
                    serverMessage.AppendInteger(1);
                    serverMessage.AppendInteger(item.Id);
                    serverMessage.AppendString(item.Z.ToString(Plus.CultureInfo));
                    serverMessage.AppendString(num.ToString(Plus.CultureInfo));
                    serverMessage.AppendInteger(0);
                    room.SendMessage(serverMessage);
                    item.GetRoom().GetRoomItemHandler().SetFloorItem(roomUserByHabbo.GetClient(), item, point.X, point.Y, item.Rot, false, false, false);
                }
                else
                {
                    roomUserByHabbo.MoveTo(item.X + 1, item.Y);
                }
            }
        }
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            if (Session == null || Session.GetHabbo() == null || Session.GetHabbo().GetInventoryComponent() == null)
            {
                return;
            }



            Room Room;

            if (!BiosEmuThiago.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room))
            {
                return;
            }

            int PetId = Packet.PopInt();

            RoomUser Pet = null;

            if (!Room.GetRoomUserManager().TryGetPet(PetId, out Pet))
            {
                //Check kick rights, just because it seems most appropriate.
                if ((!Room.CheckRights(Session) && Room.WhoCanKick != 2 && Room.Group == null) || (Room.Group != null && !Room.CheckRights(Session, false, true)))
                {
                    return;
                }

                //Okay so, we've established we have no pets in this room by this virtual Id, let us check out users, maybe they're creeping as a pet?!
                RoomUser TargetUser = Session.GetHabbo().CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(PetId);
                if (TargetUser == null)
                {
                    return;
                }

                //Check some values first, please!
                if (TargetUser.GetClient() == null || TargetUser.GetClient().GetHabbo() == null)
                {
                    return;
                }

                //Update the targets PetId.
                TargetUser.GetClient().GetHabbo().PetId = 0;

                //Quickly remove the old user instance.
                Room.SendMessage(new UserRemoveComposer(TargetUser.VirtualId));

                //Add the new one, they won't even notice a thing!!11 8-)
                Room.SendMessage(new UsersComposer(TargetUser));
                return;
            }

            if (Session.GetHabbo().Id != Pet.PetData.OwnerId && !Room.CheckRights(Session, true, false))
            {
                Session.SendWhisper("Você só pode recolher os seus próprios animais de estimação, para tirar um animal de estimação deve ter direitos.");
                return;
            }

            if (Pet.RidingHorse)
            {
                RoomUser UserRiding = Room.GetRoomUserManager().GetRoomUserByVirtualId(Pet.HorseID);
                if (UserRiding != null)
                {
                    UserRiding.RidingHorse = false;
                    UserRiding.ApplyEffect(-1);
                    UserRiding.MoveTo(new Point(UserRiding.X + 1, UserRiding.Y + 1));
                }
                else
                {
                    Pet.RidingHorse = false;
                }
            }

            Pet.PetData.RoomId       = 0;
            Pet.PetData.PlacedInRoom = false;

            Pet pet = Pet.PetData;

            if (pet != null)
            {
                using (IQueryAdapter dbClient = BiosEmuThiago.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.runFastQuery("UPDATE `bots` SET `room_id` = '0', `x` = '0', `Y` = '0', `Z` = '0' WHERE `id` = '" + pet.PetId + "' LIMIT 1");
                    dbClient.runFastQuery("UPDATE `bots_petdata` SET `experience` = '" + pet.experience + "', `energy` = '" + pet.Energy + "', `nutrition` = '" + pet.Nutrition + "', `respect` = '" + pet.Respect + "' WHERE `id` = '" + pet.PetId + "' LIMIT 1");
                }
            }

            if (pet.OwnerId != Session.GetHabbo().Id)
            {
                GameClient Target = BiosEmuThiago.GetGame().GetClientManager().GetClientByUserID(pet.OwnerId);
                if (Target != null)
                {
                    if (Target.GetHabbo().GetInventoryComponent().TryAddPet(Pet.PetData))
                    {
                        Target.SendMessage(new PetInventoryComposer(Target.GetHabbo().GetInventoryComponent().GetPets()));
                    }
                }

                Room.GetRoomUserManager().RemoveBot(Pet.VirtualId, false);
                return;
            }

            if (Session.GetHabbo().GetInventoryComponent().TryAddPet(Pet.PetData))
            {
                Room.GetRoomUserManager().RemoveBot(Pet.VirtualId, false);
                Session.SendMessage(new PetInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetPets()));
            }
        }
Esempio n. 5
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (!Room.CheckRights(Session, true))
            {
                Session.SendWhisper("Oops, only the room owner can run this command!");
                return;
            }

            if (Room.GetRoomUserManager().GetPets().Count > 0)
            {
                foreach (RoomUser Pet in Room.GetRoomUserManager().GetUserList().ToList())
                {
                    if (Pet == null)
                    {
                        continue;
                    }

                    if (Pet.RidingHorse)
                    {
                        RoomUser UserRiding = Room.GetRoomUserManager().GetRoomUserByVirtualId(Pet.HorseID);
                        if (UserRiding != null)
                        {
                            UserRiding.RidingHorse = false;
                            UserRiding.ApplyEffect(-1);
                            UserRiding.MoveTo(new Point(UserRiding.X + 1, UserRiding.Y + 1));
                        }
                        else
                        {
                            Pet.RidingHorse = false;
                        }
                    }

                    Pet.PetData.RoomId       = 0;
                    Pet.PetData.PlacedInRoom = false;

                    Pet pet = Pet.PetData;
                    if (pet != null)
                    {
                        using (IQueryAdapter dbClient = RavenEnvironment.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunQuery("UPDATE `bots` SET `room_id` = '0', `x` = '0', `Y` = '0', `Z` = '0' WHERE `id` = '" + pet.PetId + "' LIMIT 1");
                            dbClient.RunQuery("UPDATE `bots_petdata` SET `experience` = '" + pet.experience + "', `energy` = '" + pet.Energy + "', `nutrition` = '" + pet.Nutrition + "', `respect` = '" + pet.Respect + "' WHERE `id` = '" + pet.PetId + "' LIMIT 1");
                        }
                    }

                    if (pet.OwnerId != Session.GetHabbo().Id)
                    {
                        GameClient Target = RavenEnvironment.GetGame().GetClientManager().GetClientByUserID(pet.OwnerId);
                        if (Target != null)
                        {
                            Target.GetHabbo().GetInventoryComponent().TryAddPet(Pet.PetData);
                            Room.GetRoomUserManager().RemoveBot(Pet.VirtualId, false);

                            Target.SendMessage(new PetInventoryComposer(Target.GetHabbo().GetInventoryComponent().GetPets()));
                            return;
                        }
                    }

                    Session.GetHabbo().GetInventoryComponent().TryAddPet(Pet.PetData);
                    Room.GetRoomUserManager().RemoveBot(Pet.VirtualId, false);
                    Session.SendMessage(new PetInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetPets()));
                }
                Session.SendWhisper("Success, removed all pets.");
            }
            else
            {
                Session.SendWhisper("Oops, there isn't any pets in here!?");
            }
        }
        public void OnTrigger(GameClient Session, Item Item, int Request, bool HasRights)
        {
            if (Session == null)
            {
                return;
            }

            RoomUser User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (User == null)
            {
                return;
            }

            if (!((Math.Abs((User.X - Item.GetX)) >= 2) || (Math.Abs((User.Y - Item.GetY)) >= 2)))
            {
                User.SetRot(Rotation.Calculate(User.X, User.Y, Item.GetX, Item.GetY), false);
                if (User.RotBody % 2 != 0)
                {
                    User.MoveTo(Item.GetX + 1, Item.GetY);
                    return;
                }
                Room  Room     = Item.GetRoom();
                Point NewPoint = new Point(0, 0);
                if (User.RotBody == 4)
                {
                    NewPoint = new Point(Item.GetX, Item.GetY + 1);
                }

                if (User.RotBody == 0)
                {
                    NewPoint = new Point(Item.GetX, Item.GetY - 1);
                }

                if (User.RotBody == 6)
                {
                    NewPoint = new Point(Item.GetX - 1, Item.GetY);
                }

                if (User.RotBody == 2)
                {
                    NewPoint = new Point(Item.GetX + 1, Item.GetY);
                }

                if (Room.GetGameMap().ValidTile(NewPoint.X, NewPoint.Y) &&
                    Room.GetGameMap().ItemCanBePlacedHere(NewPoint.X, NewPoint.Y) &&
                    Room.GetGameMap().CanRollItemHere(NewPoint.X, NewPoint.Y))
                {
                    double NewZ = Item.GetRoom().GetGameMap().SqAbsoluteHeight(NewPoint.X, NewPoint.Y);

                    /*var mMessage = new ServerMessage();
                     * mMessage.Init(Outgoing.ObjectOnRoller); // Cf
                     * mMessage.AppendInt32(Item.GetX);
                     * mMessage.AppendInt32(Item.GetY);
                     * mMessage.AppendInt32(NewPoint.X);
                     * mMessage.AppendInt32(NewPoint.Y);
                     * mMessage.AppendInt32(1);
                     * mMessage.AppendInt32(Item.Id);
                     * mMessage.AppendString(Item.GetZ.ToString().Replace(',', '.'));
                     * mMessage.AppendString(NewZ.ToString().Replace(',', '.'));
                     * mMessage.AppendInt32(0);
                     * Room.SendMessage(mMessage);*/

                    Room.SendMessage(new SlideObjectBundleComposer(Item.GetX, Item.GetY, Item.GetZ, NewPoint.X, NewPoint.Y, NewZ, 0, 0, Item.Id));

                    Item.GetRoom().GetRoomItemHandler().SetFloorItem(User.GetClient(), Item, NewPoint.X, NewPoint.Y, Item.Rotation, false, false, false);
                }
            }
            else
            {
                User.MoveTo(Item.GetX + 1, Item.GetY);
            }
        }
Esempio n. 7
0
        public override void OnUserSay(RoomUser User, string Message)
        {
            if (User == null)
            {
                return;
            }

            RoomUser Pet = GetRoomUser();

            if (Pet == null)
            {
                return;
            }

            if (Pet.PetData.DBState != DatabaseUpdateState.NeedsInsert)
            {
                Pet.PetData.DBState = DatabaseUpdateState.NeedsUpdate;
            }

            if (Message.ToLower().Equals(Pet.PetData.Name.ToLower()))
            {
                Pet.SetRot(Rotation.Calculate(Pet.X, Pet.Y, User.X, User.Y), false);
                return;
            }

            //if (!Pet.Statusses.ContainsKey("gst thr"))
            //    Pet.Statusses.Add("gst, TextHandling.GetString(Pet.Z));

            if ((Message.ToLower().StartsWith(Pet.PetData.Name.ToLower() + " ") && User.GetClient().GetHabbo().Username.ToLower() == Pet.PetData.OwnerName.ToLower()) || (Message.ToLower().StartsWith(Pet.PetData.Name.ToLower() + " ") && PlusEnvironment.GetGame().GetChatManager().GetPetCommands().TryInvoke(Message.Substring(Pet.PetData.Name.ToLower().Length + 1)) == 8))
            {
                string Command = Message.Substring(Pet.PetData.Name.ToLower().Length + 1);

                int r = RandomNumber.GenerateRandom(1, 8); // Made Random
                if (Pet.PetData.Energy > 10 && r < 6 || Pet.PetData.Level > 15 || PlusEnvironment.GetGame().GetChatManager().GetPetCommands().TryInvoke(Command) == 8)
                {
                    RemovePetStatus(); // Remove Status

                    switch (PlusEnvironment.GetGame().GetChatManager().GetPetCommands().TryInvoke(Command))
                    {
                        // TODO - Level you can use the commands at...



                        #region free

                    case 1:
                        RemovePetStatus();

                        //int randomX = PlusEnvironment.GetRandomNumber(0, GetRoom().Model.MapSizeX);
                        //int randomY = PlusEnvironment.GetRandomNumber(0, GetRoom().Model.MapSizeY);
                        Point nextCoord = GetRoom().GetGameMap().getRandomWalkableSquare();
                        Pet.MoveTo(nextCoord.X, nextCoord.Y);

                        Pet.PetData.Addexperience(10);     // Give XP

                        break;

                        #endregion

                        #region here

                    case 2:

                        RemovePetStatus();

                        int NewX = User.X;
                        int NewY = User.Y;

                        ActionTimer = 30;     // Reset ActionTimer

                        #region Rotation

                        if (User.RotBody == 4)
                        {
                            NewY = User.Y + 1;
                        }
                        else if (User.RotBody == 0)
                        {
                            NewY = User.Y - 1;
                        }
                        else if (User.RotBody == 6)
                        {
                            NewX = User.X - 1;
                        }
                        else if (User.RotBody == 2)
                        {
                            NewX = User.X + 1;
                        }
                        else if (User.RotBody == 3)
                        {
                            NewX = User.X + 1;
                            NewY = User.Y + 1;
                        }
                        else if (User.RotBody == 1)
                        {
                            NewX = User.X + 1;
                            NewY = User.Y - 1;
                        }
                        else if (User.RotBody == 7)
                        {
                            NewX = User.X - 1;
                            NewY = User.Y - 1;
                        }
                        else if (User.RotBody == 5)
                        {
                            NewX = User.X - 1;
                            NewY = User.Y + 1;
                        }

                        #endregion

                        Pet.PetData.Addexperience(10);     // Give XP

                        Pet.MoveTo(NewX, NewY);
                        break;

                        #endregion

                        #region sit

                    case 3:
                        // Remove Status
                        RemovePetStatus();

                        Pet.PetData.Addexperience(10);     // Give XP

                        // Add Status
                        Pet.Statusses.Add("sit", TextHandling.GetString(Pet.Z));
                        Pet.UpdateNeeded = true;

                        ActionTimer = 25;
                        EnergyTimer = 10;
                        break;

                        #endregion

                        #region lay

                    case 4:
                        // Remove Status
                        RemovePetStatus();

                        // Add Status
                        Pet.Statusses.Add("lay", TextHandling.GetString(Pet.Z));
                        Pet.UpdateNeeded = true;

                        Pet.PetData.Addexperience(10);     // Give XP

                        ActionTimer = 30;
                        EnergyTimer = 5;
                        break;

                        #endregion

                        #region dead

                    case 5:
                        // Remove Status
                        RemovePetStatus();

                        // Add Status
                        Pet.Statusses.Add("ded", TextHandling.GetString(Pet.Z));
                        Pet.UpdateNeeded = true;

                        Pet.PetData.Addexperience(10);     // Give XP

                        // Don't move to speak for a set amount of time.
                        SpeechTimer = 45;
                        ActionTimer = 30;

                        break;

                        #endregion

                        #region sleep

                    case 6:
                        // Remove Status
                        RemovePetStatus();

                        Pet.Chat("ZzzZZZzzzzZzz", false);
                        Pet.Statusses.Add("lay", TextHandling.GetString(Pet.Z));
                        Pet.UpdateNeeded = true;

                        Pet.PetData.Addexperience(10);     // Give XP

                        // Don't move to speak for a set amount of time.
                        EnergyTimer = 5;
                        SpeechTimer = 30;
                        ActionTimer = 45;
                        break;

                        #endregion

                        #region jump

                    case 7:
                        // Remove Status
                        RemovePetStatus();

                        // Add Status
                        Pet.Statusses.Add("jmp", TextHandling.GetString(Pet.Z));
                        Pet.UpdateNeeded = true;

                        Pet.PetData.Addexperience(10);     // Give XP

                        // Don't move to speak for a set amount of time.
                        EnergyTimer = 5;
                        SpeechTimer = 10;
                        ActionTimer = 5;
                        break;

                        #endregion

                        #region breed
                    case 46:

                        break;
                        #endregion

                    default:
                        string[] Speech = PlusEnvironment.GetGame().GetChatManager().GetPetLocale().GetValue("pet.unknowncommand");

                        Pet.Chat(Speech[RandomNumber.GenerateRandom(0, Speech.Length - 1)], false);
                        break;
                    }
                    Pet.PetData.PetEnergy(false); // Remove Energy
                }
                else
                {
                    RemovePetStatus(); // Remove Status

                    if (Pet.PetData.Energy < 10)
                    {
                        //GetRoomUser refers to the pet
                        //User refers to Owner

                        RoomUser UserRiding = GetRoom().GetRoomUserManager().GetRoomUserByVirtualId(Pet.HorseID);;

                        if (UserRiding.RidingHorse)
                        {
                            Pet.Chat("Preciso sentar", false);
                            UserRiding.RidingHorse = false;
                            Pet.RidingHorse        = false;
                            UserRiding.ApplyEffect(-1);
                            UserRiding.MoveTo(new Point(GetRoomUser().X + 1, GetRoomUser().Y + 1));
                        }

                        string[] Speech = PlusEnvironment.GetGame().GetChatManager().GetPetLocale().GetValue("pet.tired");

                        var RandomSpeech = new CryptoRandom();
                        Pet.Chat(Speech[RandomNumber.GenerateRandom(0, Speech.Length - 1)], false);

                        Pet.Statusses.Add("lay", TextHandling.GetString(Pet.Z));
                        Pet.UpdateNeeded = true;

                        SpeechTimer = 50;
                        ActionTimer = 45;
                        EnergyTimer = 5;
                    }
                    else
                    {
                        string[] Speech = PlusEnvironment.GetGame().GetChatManager().GetPetLocale().GetValue("pet.lazy");

                        var RandomSpeech = new CryptoRandom();
                        Pet.Chat(Speech[RandomNumber.GenerateRandom(0, Speech.Length - 1)], false);

                        Pet.PetData.PetEnergy(false); // Remove Energy
                    }
                }
            }
            //Pet = null;
        }
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room;

            if (!BiosEmuThiago.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room))
            {
                return;
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (User == null)
            {
                return;
            }

            int  PetId = Packet.PopInt();
            bool Type  = Packet.PopBoolean();

            RoomUser Pet = null;

            if (!Room.GetRoomUserManager().TryGetPet(PetId, out Pet))
            {
                return;
            }

            if (Pet.PetData == null)
            {
                return;
            }

            if (Pet.PetData.AnyoneCanRide == 0 && Pet.PetData.OwnerId != User.UserId)
            {
                Session.SendNotification(
                    "Não pode montar esse cavalo.\nO dono do cavalo não deixou ninguém andar!");
                return;
            }

            if (Type)
            {
                if (Pet.RidingHorse)
                {
                    string[] Speech2       = BiosEmuThiago.GetGame().GetChatManager().GetPetLocale().GetValue("pet.alreadymounted");
                    var      RandomSpeech2 = new Random();
                    Pet.Chat(Speech2[RandomSpeech2.Next(0, Speech2.Length - 1)], false);
                }
                else if (User.RidingHorse)
                {
                    Session.SendNotification("Você já está montando um cavalo!");
                }
                else
                {
                    if (Pet.Statusses.Count > 0)
                    {
                        Pet.Statusses.Clear();
                    }

                    int NewX2 = User.X;
                    int NewY2 = User.Y;
                    Room.SendMessage(Room.GetRoomItemHandler().UpdateUserOnRoller(Pet, new Point(NewX2, NewY2), 0, Room.GetGameMap().SqAbsoluteHeight(NewX2, NewY2)));
                    Room.SendMessage(Room.GetRoomItemHandler().UpdateUserOnRoller(User, new Point(NewX2, NewY2), 0, Room.GetGameMap().SqAbsoluteHeight(NewX2, NewY2) + 1));

                    User.MoveTo(NewX2, NewY2);

                    Pet.ClearMovement(true);

                    User.RidingHorse = true;
                    Pet.RidingHorse  = true;
                    Pet.HorseID      = User.VirtualId;
                    User.HorseID     = Pet.VirtualId;

                    User.ApplyEffect(77);

                    User.RotBody = Pet.RotBody;
                    User.RotHead = Pet.RotHead;

                    User.UpdateNeeded = true;
                    Pet.UpdateNeeded  = true;
                }
            }
            else
            {
                if (User.VirtualId == Pet.HorseID)
                {
                    Pet.Statusses.Remove("sit");
                    Pet.Statusses.Remove("lay");
                    Pet.Statusses.Remove("snf");
                    Pet.Statusses.Remove("eat");
                    Pet.Statusses.Remove("ded");
                    Pet.Statusses.Remove("jmp");
                    User.RidingHorse = false;
                    User.HorseID     = 0;
                    Pet.RidingHorse  = false;
                    Pet.HorseID      = 0;
                    User.MoveTo(new Point(User.X, User.Y));
                    User.ApplyEffect(-1);
                    User.UpdateNeeded = true;
                    Pet.UpdateNeeded  = true;
                }
                else
                {
                    Session.SendNotification("Não foi possível desmontar o cavalo - Você não está montando!");
                }
            }

            Room.SendMessage(new PetInformationComposer(Pet.PetData, Pet.RidingHorse));
            Room.SendMessage(new PetHorseFigureInformationComposer(Pet));
        }
Esempio n. 9
0
        public void OnTrigger(GameClient Session, Item Item, int Request, bool HasRights)
        {
            if (Item.ExtraData != "1" && Item.InteractingUser == 0 && Session != null)
            {
                RoomUser User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

                if (Item.GetBaseItem().VendingIds.Count >= 1)
                {
                    if (User == null)
                    {
                        return;
                    }

                    if (!Gamemap.TilesTouching(User.X, User.Y, Item.GetX, Item.GetY))
                    {
                        User.MoveTo(Item.SquareInFront);
                        return;
                    }

                    Item.InteractingUser = Session.GetHabbo().Id;

                    User.CanWalk = false;
                    User.ClearMovement(true);
                    User.SetRot(Rotation.Calculate(User.X, User.Y, Item.GetX, Item.GetY), false);

                    Item.RequestUpdate(2, true);

                    Item.ExtraData = "1";
                    Item.UpdateState(false, true);
                }
                else if (Item.GetBaseItem().EffectId > 0)
                {
                    if (User == null)
                    {
                        return;
                    }

                    if (!User.IsBot)
                    {
                        if (!Gamemap.TilesTouching(User.X, User.Y, Item.GetX, Item.GetY))
                        {
                            User.MoveTo(Item.SquareInFront);
                            return;
                        }

                        if (Item == null || Item.GetBaseItem() == null || User.GetClient() == null || User.GetClient().GetHabbo() == null || User.GetClient().GetHabbo().Effects() == null)
                        {
                            return;
                        }

                        if (Item.GetBaseItem().EffectId == 0 && User.GetClient().GetHabbo().Effects().CurrentEffect == 0)
                        {
                            return;
                        }

                        User.GetClient().GetHabbo().Effects().ApplyEffect(Item.GetBaseItem().EffectId);
                        Item.InteractingUser = Session.GetHabbo().Id;

                        User.CanWalk = false;
                        User.ClearMovement(true);
                        User.SetRot(Rotation.Calculate(User.X, User.Y, Item.GetX, Item.GetY), false);

                        Item.RequestUpdate(2, true);

                        Item.ExtraData = "1";
                        Item.UpdateState(false, true);
                    }
                }
            }
        }
Esempio n. 10
0
        public void OnTrigger(GameClient Session, RoomItem Item, int Request, bool HasRights)
        {
            if (Session == null)
            {
                return;
            }
            RoomUser roomUserByHabbo = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (roomUserByHabbo == null)
            {
                return;
            }
            checked
            {
                if (Math.Abs(roomUserByHabbo.X - Item.GetX) < 2 && Math.Abs(roomUserByHabbo.Y - Item.GetY) < 2)
                {
                    roomUserByHabbo.SetRot(PathFinder.CalculateRotation(roomUserByHabbo.X, roomUserByHabbo.Y, Item.GetX, Item.GetY), false);
                    Room  room  = Item.GetRoom();
                    Point point = new Point(0, 0);
                    if (roomUserByHabbo.RotBody == 4)
                    {
                        point = new Point(Item.GetX, Item.GetY + 1);
                    }
                    else
                    {
                        if (roomUserByHabbo.RotBody == 0)
                        {
                            point = new Point(Item.GetX, Item.GetY - 1);
                        }
                        else
                        {
                            if (roomUserByHabbo.RotBody == 6)
                            {
                                point = new Point(Item.GetX - 1, Item.GetY);
                            }
                            else
                            {
                                if (roomUserByHabbo.RotBody != 2)
                                {
                                    return;
                                }
                                point = new Point(Item.GetX + 1, Item.GetY);
                            }
                        }
                    }
                    if (room.GetGameMap().validTile(point.X, point.Y))
                    {
                        double        num           = Item.GetRoom().GetGameMap().SqAbsoluteHeight(point.X, point.Y);
                        ServerMessage serverMessage = new ServerMessage();
                        serverMessage.Init(Outgoing.ItemAnimationMessageComposer);
                        serverMessage.AppendInt32(Item.GetX);
                        serverMessage.AppendInt32(Item.GetY);
                        serverMessage.AppendInt32(point.X);
                        serverMessage.AppendInt32(point.Y);
                        serverMessage.AppendInt32(1);
                        serverMessage.AppendUInt(Item.Id);
                        serverMessage.AppendString(Item.GetZ.ToString(CyberEnvironment.cultureInfo));
                        serverMessage.AppendString(num.ToString(CyberEnvironment.cultureInfo));
                        serverMessage.AppendInt32(0);
                        room.SendMessage(serverMessage);
                        Item.GetRoom().GetRoomItemHandler().SetFloorItem(roomUserByHabbo.GetClient(), Item, point.X, point.Y, Item.Rot, false, false, false);
                        return;
                    }
                }
                else
                {
                    roomUserByHabbo.MoveTo(Item.GetX + 1, Item.GetY);
                }
            }
        }
Esempio n. 11
0
        internal void ProcessUpdates()
        {
            this.UpdateCounter--;

            if (this.UpdateCounter <= 0 || IsTrans)
            {
                this.UpdateNeeded  = false;
                this.UpdateCounter = 0;

                RoomUser User  = null;
                RoomUser User2 = null;

                switch (GetBaseItem().InteractionType)
                {
                case InteractionType.onewaygate:

                    User = null;

                    if (InteractingUser > 0)
                    {
                        User = GetRoom().GetRoomUserManager().GetRoomUserByHabbo(InteractingUser);
                        //GetRoom().FreeSqareForUsers(mX, mY);
                    }

                    if (User != null && User.X == mX && User.Y == mY)
                    {
                        ExtraData = "1";

                        User.MoveTo(SquareBehind);

                        ReqUpdate(1, false);
                        UpdateState(false, true);
                    }
                    else if (User != null && User.Coordinate == SquareBehind)
                    {
                        User.UnlockWalking();

                        ExtraData       = "0";
                        InteractingUser = 0;

                        UpdateState(false, true);
                    }
                    else if (ExtraData == "1")
                    {
                        ExtraData = "0";
                        UpdateState(false, true);
                    }

                    if (User == null)
                    {
                        InteractingUser = 0;
                    }

                    break;

                case InteractionType.teleport:

                    User  = null;
                    User2 = null;

                    bool keepDoorOpen   = false;
                    bool showTeleEffect = false;

                    // Do we have a primary user that wants to go somewhere?
                    if (InteractingUser > 0)
                    {
                        User = GetRoom().GetRoomUserManager().GetRoomUserByHabbo(InteractingUser);

                        // Is this user okay?
                        if (User != null)
                        {
                            // Is he in the tele?
                            if (User.Coordinate == Coordinate)
                            {
                                //Remove the user from the square
                                User.AllowOverride = false;

                                if (TeleHandler.IsTeleLinked(Id, mRoom))
                                {
                                    showTeleEffect = true;

                                    if (true)
                                    {
                                        // Woop! No more delay.
                                        uint TeleId = TeleHandler.GetLinkedTele(Id, mRoom);
                                        uint RoomId = TeleHandler.GetTeleRoomId(TeleId, mRoom);

                                        // Do we need to tele to the same room or gtf to another?
                                        if (RoomId == this.RoomId)
                                        {
                                            RoomItem Item = GetRoom().GetRoomItemHandler().GetItem(TeleId);

                                            if (Item == null)
                                            {
                                                User.UnlockWalking();
                                            }
                                            else
                                            {
                                                // Set pos
                                                User.SetPos(Item.GetX, Item.GetY, Item.GetZ);
                                                User.SetRot(Item.Rot, false);

                                                // Force tele effect update (dirty)
                                                Item.ExtraData = "2";
                                                Item.UpdateState(false, true);

                                                // Set secondary interacting user
                                                Item.InteractingUser2 = InteractingUser;
                                            }
                                        }
                                        else
                                        {
                                            // Let's run the teleport delegate to take futher care of this.. WHY DARIO?!
                                            if (!User.IsBot && User != null && User.GetClient() != null && User.GetClient().GetHabbo() != null && User.GetClient().GetMessageHandler() != null)
                                            {
                                                User.GetClient().GetHabbo().IsTeleporting     = true;
                                                User.GetClient().GetHabbo().TeleportingRoomID = RoomId;
                                                User.GetClient().GetHabbo().TeleporterId      = TeleId;
                                                User.GetClient().GetMessageHandler().PrepareRoomForUser(RoomId, "");
                                            }
                                            //ButterflyEnvironment.GetGame().GetRoomManager().AddTeleAction(new TeleUserData(User.GetClient().GetMessageHandler(), User.GetClient().GetHabbo(), RoomId, TeleId));
                                        }

                                        // We're done with this tele. We have another one to bother.
                                        InteractingUser = 0;
                                    }
                                    else
                                    {
                                        // We're linked, but there's a delay, so decrease the delay and wait it out.
                                        //User.TeleDelay--;
                                    }
                                }
                                else
                                {
                                    // This tele is not linked, so let's gtfo.
                                    User.UnlockWalking();
                                    InteractingUser = 0;
                                }
                            }
                            // Is he in front of the tele?
                            else if (User.Coordinate == SquareInFront)
                            {
                                User.AllowOverride = true;
                                // Open the door
                                keepDoorOpen = true;

                                // Lock his walking. We're taking control over him. Allow overriding so he can get in the tele.
                                if (User.IsWalking && (User.GoalX != mX || User.GoalY != mY))
                                {
                                    User.ClearMovement(true);
                                }

                                User.CanWalk       = false;
                                User.AllowOverride = true;

                                // Move into the tele
                                User.MoveTo(Coordinate.X, Coordinate.Y, true);
                            }
                            // Not even near, do nothing and move on for the next user.
                            else
                            {
                                InteractingUser = 0;
                            }
                        }
                        else
                        {
                            // Invalid user, do nothing and move on for the next user.
                            InteractingUser = 0;
                        }
                    }

                    // Do we have a secondary user that wants to get out of the tele?
                    if (InteractingUser2 > 0)
                    {
                        User2 = GetRoom().GetRoomUserManager().GetRoomUserByHabbo(InteractingUser2);

                        // Is this user okay?
                        if (User2 != null)
                        {
                            // If so, open the door, unlock the user's walking, and try to push him out in the right direction. We're done with him!
                            keepDoorOpen = true;
                            User2.UnlockWalking();
                            User2.MoveTo(SquareInFront);
                        }

                        // This is a one time thing, whether the user's valid or not.
                        InteractingUser2 = 0;
                    }

                    // Set the new item state, by priority
                    if (keepDoorOpen)
                    {
                        if (ExtraData != "1")
                        {
                            ExtraData = "1";
                            UpdateState(false, true);
                        }
                    }
                    else if (showTeleEffect)
                    {
                        if (ExtraData != "2")
                        {
                            ExtraData = "2";
                            UpdateState(false, true);
                        }
                    }
                    else
                    {
                        if (ExtraData != "0")
                        {
                            ExtraData = "0";
                            UpdateState(false, true);
                        }
                    }

                    // We're constantly going!
                    ReqUpdate(1, false);

                    break;

                case InteractionType.bottle:

                    ExtraData = ButterflyEnvironment.GetRandomNumber(0, 7).ToString();
                    UpdateState();
                    break;

                case InteractionType.dice:

                    ExtraData = ButterflyEnvironment.GetRandomNumber(1, 6).ToString();
                    UpdateState();
                    break;

                case InteractionType.habbowheel:

                    ExtraData = ButterflyEnvironment.GetRandomNumber(1, 10).ToString();
                    UpdateState();
                    break;

                case InteractionType.loveshuffler:

                    if (ExtraData == "0")
                    {
                        ExtraData = ButterflyEnvironment.GetRandomNumber(1, 4).ToString();
                        ReqUpdate(20, false);
                    }
                    else if (ExtraData != "-1")
                    {
                        ExtraData = "-1";
                    }

                    UpdateState(false, true);
                    break;

                case InteractionType.alert:

                    if (this.ExtraData == "1")
                    {
                        this.ExtraData = "0";
                        this.UpdateState(false, true);
                    }

                    break;

                case InteractionType.vendingmachine:

                    if (this.ExtraData == "1")
                    {
                        User = GetRoom().GetRoomUserManager().GetRoomUserByHabbo(InteractingUser);

                        if (User != null)
                        {
                            User.UnlockWalking();

                            int randomDrink = GetBaseItem().VendingIds[ButterflyEnvironment.GetRandomNumber(0, (GetBaseItem().VendingIds.Count - 1))];
                            User.CarryItem(randomDrink);
                        }

                        this.InteractingUser = 0;
                        this.ExtraData       = "0";

                        UpdateState(false, true);
                    }

                    break;


                case InteractionType.scoreboard:
                {
                    if (string.IsNullOrEmpty(ExtraData))
                    {
                        break;
                    }


                    int seconds = 0;

                    try
                    {
                        seconds = int.Parse(ExtraData);
                    }
                    catch { }

                    if (seconds > 0)
                    {
                        if (interactionCountHelper == 1)
                        {
                            seconds--;
                            interactionCountHelper = 0;

                            ExtraData = seconds.ToString();
                            UpdateState();
                        }
                        else
                        {
                            interactionCountHelper++;
                        }

                        UpdateCounter = 1;
                    }
                    else
                    {
                        UpdateCounter = 0;
                    }

                    break;
                }

                case InteractionType.banzaicounter:
                {
                    if (string.IsNullOrEmpty(ExtraData))
                    {
                        break;
                    }


                    int seconds = 0;

                    try
                    {
                        seconds = int.Parse(ExtraData);
                    }
                    catch { }

                    if (seconds > 0)
                    {
                        if (interactionCountHelper == 1)
                        {
                            seconds--;
                            interactionCountHelper = 0;

                            ExtraData = seconds.ToString();
                            UpdateState();
                        }
                        else
                        {
                            interactionCountHelper++;
                        }

                        UpdateCounter = 1;
                    }
                    else
                    {
                        UpdateCounter = 0;
                        GetRoom().GetBanzai().BanzaiEnd();
                    }

                    break;
                }

                case InteractionType.banzaitele:
                {
                    ExtraData = string.Empty;
                    UpdateState();
                    break;
                }

                /*
                 * 3 = Red 1
                 * 4 = Red 2
                 * 5 = Red 3
                 *
                 * 6 = Green 1
                 * 7 = Green 2
                 * 8 = Green 3
                 *
                 * 9 = Blue 1
                 * 10= Blue 2
                 * 11= Blue 3
                 *
                 * 12= Yellow 1
                 * 13= Yellow 2
                 * 14= Yellow 3
                 */
                case InteractionType.banzaifloor:
                {
                    if (value == 3)
                    {
                        if (interactionCountHelper == 1)
                        {
                            interactionCountHelper = 0;

                            switch (team)
                            {
                            case Team.blue:
                            {
                                ExtraData = "11";
                                break;
                            }

                            case Team.green:
                            {
                                ExtraData = "8";
                                break;
                            }

                            case Team.red:
                            {
                                ExtraData = "5";
                                break;
                            }

                            case Team.yellow:
                            {
                                ExtraData = "14";
                                break;
                            }
                            }
                        }
                        else
                        {
                            ExtraData = "";
                            interactionCountHelper++;
                        }

                        UpdateState();

                        interactionCount++;

                        if (interactionCount < 16)
                        {
                            UpdateCounter = 1;
                        }
                        else
                        {
                            UpdateCounter = 0;
                        }
                    }
                    break;
                }

                case InteractionType.banzaipuck:
                {
                    if (interactionCount > 4)
                    {
                        interactionCount++;
                        UpdateCounter = 1;
                    }
                    else
                    {
                        interactionCount = 0;
                        UpdateCounter    = 0;
                    }

                    break;
                }

                case InteractionType.freezetile:
                {
                    if (InteractingUser > 0)
                    {
                        ExtraData = "11000";
                        UpdateState(false, true);

                        GetRoom().GetFreeze().onFreezeTiles(this, freezePowerUp, InteractingUser);
                        InteractingUser        = 0;
                        interactionCountHelper = 0;
                    }
                    break;
                }

                case InteractionType.freezetimer:
                {
                    if (string.IsNullOrEmpty(ExtraData))
                    {
                        break;
                    }

                    if (!GetRoom().GetFreeze().GameIsStarted)
                    {
                        GetRoom().GetFreeze().StartGame();
                    }

                    int seconds = 0;

                    try
                    {
                        seconds = int.Parse(ExtraData);
                    }
                    catch { }

                    if (seconds > 0)
                    {
                        if (interactionCountHelper == 1)
                        {
                            seconds--;
                            interactionCountHelper = 0;

                            ExtraData = seconds.ToString();
                            UpdateState();
                        }
                        else
                        {
                            interactionCountHelper++;
                        }

                        UpdateCounter = 1;
                    }
                    else
                    {
                        UpdateNeeded = false;
                        GetRoom().GetFreeze().StopGame();
                    }

                    break;
                }
                }
            }
        }
Esempio n. 12
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Introduce el nombre del usuario que deseas hacer el super pull.");
                return;
            }

            //if (!Room.SPullEnabled && !Room.CheckRights(Session, true) && !Session.GetHabbo().GetPermissions().HasRight("room_override_custom_config"))
            //{
            //    Session.SendWhisper("Oops, al parecer el dueño de la sala ha prohibido hacer los super pull en su sala.");
            //    return;
            //}

            GameClient TargetClient = RavenEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);

            if (TargetClient == null)
            {
                Session.SendWhisper("Hay un Error, no se encuentra al usuario online o no se encuentra en la sala.");
                return;
            }

            RoomUser TargetUser = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Id);

            if (TargetUser == null)
            {
                Session.SendWhisper("Hay un Error, no se encuentra al usuario online o no se encuentra en la sala..");
                return;
            }

            if (TargetClient.GetHabbo().Username == Session.GetHabbo().Username)
            {
                Session.SendWhisper("Vamos.. Seguramente usted no se querra empujar a si mismo!");
                return;
            }

            if (TargetUser.TeleportEnabled)
            {
                Session.SendWhisper("Oops, you cannot push a user whilst they have their teleport mode enabled.");
                return;
            }

            RoomUser ThisUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (ThisUser == null)
            {
                return;
            }

            if (ThisUser.SetX - 1 == Room.GetGameMap().Model.DoorX)
            {
                Session.SendWhisper("Por favor, no tire a ese usuario fuera de la Habitacion :c ");
                return;
            }

            if (ThisUser.RotBody % 2 != 0)
            {
                ThisUser.RotBody--;
            }
            if (ThisUser.RotBody == 0)
            {
                TargetUser.MoveTo(ThisUser.X, ThisUser.Y - 1);
            }
            else if (ThisUser.RotBody == 2)
            {
                TargetUser.MoveTo(ThisUser.X + 1, ThisUser.Y);
            }
            else if (ThisUser.RotBody == 4)
            {
                TargetUser.MoveTo(ThisUser.X, ThisUser.Y + 1);
            }
            else if (ThisUser.RotBody == 6)
            {
                TargetUser.MoveTo(ThisUser.X - 1, ThisUser.Y);
            }

            Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "*super pulls " + Params[1] + " to them*", 0, ThisUser.LastBubble));
            return;
        }
Esempio n. 13
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
                return;

            Room Room;

            if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room))
                return;

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            if (User == null)
                return;

            int PetId = Packet.PopInt();
            bool Type = Packet.PopBoolean();
           
            RoomUser Pet = null;
            if (!Room.GetRoomUserManager().TryGetPet(PetId, out Pet))
                return;

            if (Pet.PetData == null)
                return;
            
            if (Pet.PetData.AnyoneCanRide == 0 && Pet.PetData.OwnerId != User.UserId)
            {
                Session.SendNotification(
                    "You are unable to ride this horse.\nThe owner of the pet has not selected for anyone to ride it.");
                return;
            }

            if (Type)
            {
                if (Pet.RidingHorse)
                {
                    string[] Speech2 = PlusEnvironment.GetGame().GetChatManager().GetPetLocale().GetValue("pet.alreadymounted");
                    var RandomSpeech2 = new Random();
                    Pet.Chat(Speech2[RandomSpeech2.Next(0, Speech2.Length - 1)], false);
                }
                else if (User.RidingHorse)
                {
                    Session.SendNotification("You are already riding a horse!");
                }
                else
                {
                    if (Pet.Statusses.Count > 0)
                        Pet.Statusses.Clear();

                    int NewX2 = User.X;
                    int NewY2 = User.Y;
                    Room.SendPacket(Room.GetRoomItemHandler() .UpdateUserOnRoller(Pet, new Point(NewX2, NewY2), 0, Room.GetGameMap().SqAbsoluteHeight(NewX2, NewY2)));
                    Room.SendPacket(Room.GetRoomItemHandler() .UpdateUserOnRoller(User, new Point(NewX2, NewY2), 0, Room.GetGameMap().SqAbsoluteHeight(NewX2, NewY2) + 1));

                    User.MoveTo(NewX2, NewY2);
                    
                    Pet.ClearMovement(true);

                    User.RidingHorse = true;
                    Pet.RidingHorse = true;
                    Pet.HorseID = User.VirtualId;
                    User.HorseID = Pet.VirtualId;
                   
                    User.ApplyEffect(77);
            
                    User.RotBody = Pet.RotBody;
                    User.RotHead = Pet.RotHead;
            
                    User.UpdateNeeded = true;
                    Pet.UpdateNeeded = true;

     

                }
            }
            else
            {
                if (User.VirtualId == Pet.HorseID)
                {
                    Pet.Statusses.Remove("sit");
                    Pet.Statusses.Remove("lay");
                    Pet.Statusses.Remove("snf");
                    Pet.Statusses.Remove("eat");
                    Pet.Statusses.Remove("ded");
                    Pet.Statusses.Remove("jmp");
                    User.RidingHorse = false;
                    User.HorseID = 0;
                    Pet.RidingHorse = false;
                    Pet.HorseID = 0;
                    User.MoveTo(new Point(User.X + 2, User.Y + 2));
                    User.ApplyEffect(-1);
                    User.UpdateNeeded = true;
                    Pet.UpdateNeeded = true;
                }
                else
                {
                    Session.SendNotification("Could not dismount this horse - You are not riding it!");
                }
            }

            Room.SendPacket(new PetHorseFigureInformationComposer(Pet));
        }
Esempio n. 14
0
        public bool Execute(params object[] Params)
        {
            if (Params == null || Params.Length == 0)
            {
                return(false);
            }

            if (String.IsNullOrEmpty(StringData))
            {
                return(false);
            }

            Habbo Player = (Habbo)Params[0];

            if (Player == null)
            {
                return(false);
            }

            RoomUser Human = Instance.GetRoomUserManager().GetRoomUserByHabbo(Player.Id);

            if (Human == null)
            {
                return(false);
            }

            string[] Stuff = StringData.Split(';');
            if (Stuff.Length != 2)
            {
                return(false);//This is important, incase a c**t scripts.
            }
            string Username = Stuff[1];

            RoomUser User = Instance.GetRoomUserManager().GetBotByName(Username);

            if (User == null)
            {
                return(false);
            }

            int FollowMode = 0;

            if (!int.TryParse(Stuff[0], out FollowMode))
            {
                return(false);
            }

            if (FollowMode == 0)
            {
                User.BotData.ForcedUserTargetMovement = 0;

                if (User.IsWalking)
                {
                    User.ClearMovement(true);
                }
            }
            else if (FollowMode == 1)
            {
                User.BotData.ForcedUserTargetMovement = Player.Id;

                if (User.IsWalking)
                {
                    User.ClearMovement(true);
                }
                User.MoveTo(Human.X, Human.Y);
            }

            return(true);
        }
Esempio n. 15
0
        public void HandlePullTheHandleForPolice(GameClients.GameClient Session, RoomItem Item, int Request, bool HasRights)
        {
            RoomUser User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);


            if (Item.InteractingUser2 != User.UserId)
            {
                Item.InteractingUser2 = User.UserId;
            }

            if (User == null)
            {
                return;
            }

            if (User.Coordinate != Item.SquareInFront && User.CanWalk)
            {
                User.MoveTo(Item.SquareInFront);
                return;
            }

            if (!Session.GetRoleplay().MultiCoolDown.ContainsKey("rp_vswitch"))
            {
                Session.GetRoleplay().MultiCoolDown.Add("rp_vswitch", 0);
            }
            if (Session.GetRoleplay().MultiCoolDown["rp_vswitch"] > 0)
            {
                Session.SendWhisperBubble("You must wait until you can pull the switch! [" + Session.GetRoleplay().MultiCoolDown["rp_vswitch"] + "/15]", 1);
                return;
            }

            lock (Plus.GetGame().GetClientManager().Clients.Values)
            {
                foreach (GameClient client in Plus.GetGame().GetClientManager().Clients.Values)
                {
                    if (client == null)
                    {
                        continue;
                    }
                    if (client.GetRoleplay() == null)
                    {
                        continue;
                    }
                    if (!JobManager.validJob(client.GetRoleplay().JobId, client.GetRoleplay().JobRank))
                    {
                        continue;
                    }
                    if (!client.GetRoleplay().JobHasRights("police"))
                    {
                        continue;
                    }
                    if (!client.GetRoleplay().JobHasRights("swat"))
                    {
                        continue;
                    }
                    if (!client.GetRoleplay().Working)
                    {
                        continue;
                    }

                    string msg = Session.GetHabbo().UserName + " has pulled the switch at [Room ID: " + Session.GetHabbo().CurrentRoomId + "], asking for help!";
                    Radio.send(msg, Session);
                }
            }
            RoleplayManager.Shout(Session, "*Pulls the trigger of the switch, notifying the cops*", 4);
            Session.GetRoleplay().MultiCoolDown["rp_vswitch"] = 15;
            Session.GetRoleplay().CheckingMultiCooldown       = true;
        }
Esempio n. 16
0
        public void OnTrigger(GameClient Session, RoomItem Item, int Request, bool HasRights)
        {
            if (Session == null)
            {
                return;
            }

            RoomUser User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (Item.InteractingUser2 != User.UserId)
            {
                Item.InteractingUser2 = User.UserId;
            }

            if (User == null)
            {
                return;
            }
            if (Item.GetBaseItem().InteractionType == Interaction.OneWayGate)
            {
                if (User.Coordinate != Item.SquareInFront && User.CanWalk)
                {
                    User.MoveTo(Item.SquareInFront);
                    return;
                }

                if (Session.GetRoleplay().Dead || Session.GetRoleplay().Jailed)
                {
                    if (Session.GetRoleplay().JobId != 3 && !Session.GetRoleplay().Working)
                    {
                        Session.SendWhisper("You are dead or jailed");
                    }
                    return;
                }
            }

            if (Item.BaseItem == 1010 && Session.GetRoleplay().Working == false)
            {
                Session.SendWhisper("You must be working to enter this gate");
                return;
            }

            if (Item.BaseItem == 1013 && (!JobManager.JobRankData[Session.GetRoleplay().JobId, Session.GetRoleplay().JobRank].canSendHome() || !Session.GetRoleplay().Working))
            {
                if (Session.GetRoleplay().JobId == 3 && Session.GetRoleplay().Working)
                {
                    Session.Shout("*Slides police badge and enters the managers gate*", 4, false);
                }
                else
                {
                    Session.SendWhisper("You must be a(n) manager to enter this gate");
                    return;
                }
            }

            if (Item.BaseItem == 1008)
            {
                if (Session.GetHabbo().Credits < 10)
                {
                    Session.SendWhisper("Insufficient funds - Requires $10");
                    return;
                }
                else
                {
                    if (Session.GetRoleplay().JobId != 3 || !Session.GetRoleplay().Working)
                    {
                        Session.GetHabbo().Credits = Session.GetHabbo().Credits - 10;
                        Session.GetHabbo().UpdateCreditsBalance();
                        Session.SendWhisper("Charged $10 to enter this gate");
                    }
                    else
                    {
                        Session.Shout("*Slides police badge and enters the gate for free*", 4, false);
                    }
                }
            }

            if (!Item.GetRoom().GetGameMap().ValidTile(Item.SquareBehind.X, Item.SquareBehind.Y) ||
                !Item.GetRoom().GetGameMap().CanWalk(Item.SquareBehind.X, Item.SquareBehind.Y, false) ||
                !Item.GetRoom().GetGameMap().SquareIsOpen(Item.SquareBehind.X, Item.SquareBehind.Y, false))
            {
                return;
            }

            if ((User.LastInteraction - Plus.GetUnixTimestamp() < 0) && User.InteractingGate &&
                User.GateId == Item.Id)
            {
                User.InteractingGate = false;
                User.GateId          = 0;
            }


            if (!Item.GetRoom().GetGameMap().CanWalk(Item.SquareBehind.X, Item.SquareBehind.Y, User.AllowOverride))
            {
                return;
            }

            if (Item.GetRoom().GetGameMap().CanWalk(Item.SquareBehind.X, Item.SquareBehind.Y, User.AllowOverride) && User.Coordinate == Item.SquareInFront && (Item.InteractingUser == 0))
            {
                Item.ExtraData = "1";
                System.Threading.Thread.Sleep(1000);
                Item.InteractingUser = User.HabboId;
                User.CanWalk         = false;
                User.AllowOverride   = true;
                Item.UpdateState(false, true);
                User.MoveTo(Item.Coordinate);
                Item.ExtraData = "0";
                User.MoveTo(Item.SquareBehind);
                Item.UpdateState(false, true);
                User.CanWalk = true;
                System.Threading.Thread.Sleep(1000);
                User.AllowOverride   = false;
                Item.InteractingUser = 0;
            }
            else if (Item.GetRoom().GetGameMap().CanWalk(Item.SquareInFront.X, Item.SquareInFront.Y, User.AllowOverride) && User.Coordinate == Item.SquareBehind && (Item.InteractingUser == 0))
            {
                Item.ExtraData = "1";
                System.Threading.Thread.Sleep(1000);
                Item.InteractingUser = User.HabboId;
                User.CanWalk         = false;
                User.AllowOverride   = true;
                Item.UpdateState(false, true);
                User.MoveTo(Item.Coordinate);
                Item.ExtraData = "0";
                User.MoveTo(Item.SquareInFront);
                Item.UpdateState(false, true);
                User.CanWalk = true;
                System.Threading.Thread.Sleep(1000);
                User.AllowOverride   = false;
                Item.InteractingUser = 0;
            }
        }
        public void OnTrigger(GameClient Session, Item Item, int Request, bool HasRights)
        {
            RoomUser User = null;

            if (Session != null)
            {
                User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            }

            if (User == null)
            {
                return;
            }

            if (Gamemap.TilesTouching(Item.GetX, Item.GetY, User.X, User.Y))
            {
                if (Item.ExtraData == null || Item.ExtraData.Length <= 1 || !Item.ExtraData.Contains(Convert.ToChar(5).ToString()))
                {
                    Point pointOne;
                    Point pointTwo;

                    switch (Item.Rotation)
                    {
                    case 2:
                        pointOne = new Point(Item.GetX, Item.GetY + 1);
                        pointTwo = new Point(Item.GetX, Item.GetY - 1);
                        break;

                    case 4:
                        pointOne = new Point(Item.GetX - 1, Item.GetY);
                        pointTwo = new Point(Item.GetX + 1, Item.GetY);
                        break;

                    default:
                        return;
                    }

                    RoomUser UserOne = Item.GetRoom().GetRoomUserManager().GetUserForSquare(pointOne.X, pointOne.Y);
                    RoomUser UserTwo = Item.GetRoom().GetRoomUserManager().GetUserForSquare(pointTwo.X, pointTwo.Y);

                    if (UserOne == null || UserTwo == null)
                    {
                        Session.SendNotification("We couldn't find a valid user to lock this love lock with.");
                    }
                    else if (UserOne.GetClient() == null || UserTwo.GetClient() == null)
                    {
                        Session.SendNotification("We couldn't find a valid user to lock this love lock with.");
                    }
                    else if (UserOne.HabboId != Item.UserID && UserTwo.HabboId != Item.UserID)
                    {
                        Session.SendNotification("You can only use this item with the item owner.");
                    }
                    else
                    {
                        UserOne.CanWalk = false;
                        UserTwo.CanWalk = false;

                        Item.InteractingUser  = UserOne.GetClient().GetHabbo().Id;
                        Item.InteractingUser2 = UserTwo.GetClient().GetHabbo().Id;

                        UserOne.GetClient().SendMessage(new LoveLockDialogueMessageComposer(Item.Id));
                        UserTwo.GetClient().SendMessage(new LoveLockDialogueMessageComposer(Item.Id));
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                User.MoveTo(Item.SquareInFront);
            }
        }
Esempio n. 18
0
        public void Execute(GameClient Session, Room Room, RoomUser UserRoom, string[] Params)
        {
            Room room = Session.GetHabbo().CurrentRoom;

            if (room == null)
            {
                return;
            }

            RoomUser roomuser = room.GetRoomUserManager().GetRoomUserByHabboId(Session.GetHabbo().Id);

            if (roomuser == null)
            {
                return;
            }

            if (Params.Length != 2)
            {
                return;
            }

            RoomUser TargetUser = room.GetRoomUserManager().GetRoomUserByHabbo(Params[1]);

            if (TargetUser == null)
            {
                return;
            }

            if (TargetUser.GetClient().GetHabbo().Id == Session.GetHabbo().Id)
            {
                return;
            }

            if (TargetUser.GetClient().GetHabbo().PremiumProtect&& !Session.GetHabbo().HasFuse("fuse_mod"))
            {
                roomuser.SendWhisperChat(ButterflyEnvironment.GetLanguageManager().TryGetValue("premium.notallowed", Session.Langue));
                return;
            }

            roomuser.OnChat("*Tire " + Params[1] + "*", 0, false);
            if (roomuser.RotBody % 2 != 0)
            {
                roomuser.RotBody--;
            }

            if (roomuser.RotBody == 0)
            {
                TargetUser.MoveTo(roomuser.X, roomuser.Y - 1);
            }
            else if (roomuser.RotBody == 2)
            {
                TargetUser.MoveTo(roomuser.X + 1, roomuser.Y);
            }
            else if (roomuser.RotBody == 4)
            {
                TargetUser.MoveTo(roomuser.X, roomuser.Y + 1);
            }
            else if (roomuser.RotBody == 6)
            {
                TargetUser.MoveTo(roomuser.X - 1, roomuser.Y);
            }
        }
Esempio n. 19
0
        public override void OnUserSay(RoomUser User, string Message)
        {
            RoomUser roomUser = this.GetRoomUser();

            if (roomUser.PetData.DBState != DatabaseUpdateState.NeedsInsert)
            {
                roomUser.PetData.DBState = DatabaseUpdateState.NeedsUpdate;
            }

            if (roomUser.PetData.OwnerId != User.GetClient().GetHabbo().Id)
            {
                return;
            }

            if (!Message.ToLower().StartsWith(roomUser.PetData.Name.ToLower() + " "))
            {
                return;
            }

            if (Message.ToLower().Equals(roomUser.PetData.Name.ToLower()))
            {
                roomUser.SetRot(Rotation.Calculate(roomUser.X, roomUser.Y, User.X, User.Y), false);
            }
            else
            {
                string input        = Message.Substring(roomUser.PetData.Name.ToLower().Length + 1);
                int    randomNumber = ButterflyEnvironment.GetRandomNumber(1, 8);
                if (roomUser.PetData.Energy > 10 && randomNumber < 6)
                {
                    this.RemovePetStatus();
                    switch (ButterflyEnvironment.GetGame().GetChatManager().GetPetCommands().TryInvoke(input))
                    {
                    case 0:     //Libre
                        this.RemovePetStatus();
                        Point randomWalkableSquare = this.GetRoom().GetGameMap().getRandomWalkableSquare(this.GetBotData().X, this.GetBotData().Y);
                        roomUser.MoveTo(randomWalkableSquare.X, randomWalkableSquare.Y);
                        roomUser.PetData.AddExpirience(10);
                        break;

                    case 1:     //Assis
                        this.RemovePetStatus();
                        roomUser.PetData.AddExpirience(10);
                        roomUser.SetStatus("sit", TextHandling.GetString(roomUser.Z));
                        roomUser.IsSit        = true;
                        roomUser.UpdateNeeded = true;
                        this.ActionTimer      = 25;
                        this.EnergyTimer      = 10;
                        break;

                    case 2:     //Couché
                        this.RemovePetStatus();
                        roomUser.SetStatus("lay", TextHandling.GetString(roomUser.Z));
                        roomUser.IsLay        = true;
                        roomUser.UpdateNeeded = true;
                        roomUser.PetData.AddExpirience(10);
                        this.ActionTimer = 30;
                        this.EnergyTimer = 5;
                        break;

                    case 3:
                        this.RemovePetStatus();
                        int pX = User.X;
                        int pY = User.Y;
                        this.ActionTimer = 30;
                        if (User.RotBody == 4)
                        {
                            pY = User.Y + 1;
                        }
                        else if (User.RotBody == 0)
                        {
                            pY = User.Y - 1;
                        }
                        else if (User.RotBody == 6)
                        {
                            pX = User.X - 1;
                        }
                        else if (User.RotBody == 2)
                        {
                            pX = User.X + 1;
                        }
                        else if (User.RotBody == 3)
                        {
                            pX = User.X + 1;
                            pY = User.Y + 1;
                        }
                        else if (User.RotBody == 1)
                        {
                            pX = User.X + 1;
                            pY = User.Y - 1;
                        }
                        else if (User.RotBody == 7)
                        {
                            pX = User.X - 1;
                            pY = User.Y - 1;
                        }
                        else if (User.RotBody == 5)
                        {
                            pX = User.X - 1;
                            pY = User.Y + 1;
                        }
                        roomUser.PetData.AddExpirience(10);
                        roomUser.MoveTo(pX, pY);
                        break;

                    case 4:     //demande
                        this.RemovePetStatus();
                        roomUser.PetData.AddExpirience(10);
                        roomUser.SetRot(Rotation.Calculate(roomUser.X, roomUser.Y, User.X, User.Y), false);
                        roomUser.SetStatus("beg", TextHandling.GetString(roomUser.Z));
                        roomUser.UpdateNeeded = true;
                        this.ActionTimer      = 25;
                        this.EnergyTimer      = 10;
                        break;

                    case 5:
                        this.RemovePetStatus();
                        roomUser.SetStatus("ded", TextHandling.GetString(roomUser.Z));
                        roomUser.UpdateNeeded = true;
                        roomUser.PetData.AddExpirience(10);
                        this.SpeechTimer = 45;
                        this.ActionTimer = 30;
                        break;

                    case 6:
                        break;

                    case 7:
                        break;

                    case 8:
                        break;

                    case 9:
                        this.RemovePetStatus();
                        roomUser.SetStatus("jmp", TextHandling.GetString(roomUser.Z));
                        roomUser.UpdateNeeded = true;
                        roomUser.PetData.AddExpirience(10);
                        this.EnergyTimer = 5;
                        this.SpeechTimer = 10;
                        this.ActionTimer = 5;
                        break;

                    case 10:
                        break;

                    case 11:
                        break;

                    case 12:
                        break;

                    case 13:     //Panier ?
                        this.RemovePetStatus();
                        roomUser.OnChat("ZzzZZZzzzzZzz", 0, false);
                        roomUser.SetStatus("lay", TextHandling.GetString(roomUser.Z));
                        roomUser.IsLay        = true;
                        roomUser.UpdateNeeded = true;
                        roomUser.PetData.AddExpirience(10);
                        this.EnergyTimer = 5;
                        this.SpeechTimer = 30;
                        this.ActionTimer = 45;
                        break;

                    case 14:
                        break;

                    case 15:
                        break;

                    case 16:
                        break;

                    case 17:
                        break;

                    case 18:
                        break;

                    case 19:
                        break;

                    case 20:
                        break;

                    default:
                        string[] strArray = ButterflyEnvironment.GetLanguageManager().TryGetValue("pet.unknowncommand", roomUser.mRoom.RoomData.Langue).Split(new char[1] {
                            ','
                        });
                        Random random = new Random();
                        roomUser.OnChat(strArray[random.Next(0, strArray.Length - 1)], 0, false);
                        break;
                    }
                    roomUser.PetData.PetEnergy(false);
                    roomUser.PetData.PetEnergy(false);
                }
                else
                {
                    this.RemovePetStatus();
                    if (!roomUser.mRoom.RoomMutePets)
                    {
                        if (roomUser.PetData.Energy < 10)
                        {
                            string[] strArray = ButterflyEnvironment.GetLanguageManager().TryGetValue("pet.tired", roomUser.mRoom.RoomData.Langue).Split(new char[1] {
                                ','
                            });
                            Random random = new Random();
                            roomUser.OnChat(strArray[random.Next(0, strArray.Length - 1)], 0, false);
                            roomUser.SetStatus("lay", TextHandling.GetString(roomUser.Z));
                            roomUser.IsLay   = true;
                            this.SpeechTimer = 50;
                            this.ActionTimer = 45;
                            this.EnergyTimer = 5;
                        }
                        else
                        {
                            string[] strArray = ButterflyEnvironment.GetLanguageManager().TryGetValue("pet.lazy", roomUser.mRoom.RoomData.Langue).Split(new char[1] {
                                ','
                            });
                            Random random = new Random();
                            roomUser.OnChat(strArray[random.Next(0, strArray.Length - 1)], 0, false);
                            roomUser.PetData.PetEnergy(false);
                        }
                    }
                }
            }
        }
Esempio n. 20
0
        public override void OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRights)
        {
            Room     room            = Item.GetRoom();
            RoomUser roomUserByHabbo = room.GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (roomUserByHabbo != null && room != null)
            {
                Coord coord  = new Coord(Item.GetX + 1, Item.GetY);
                Coord coord2 = new Coord(Item.GetX - 1, Item.GetY);
                Coord coord3 = new Coord(Item.GetX, Item.GetY + 1);
                Coord coord4 = new Coord(Item.GetX, Item.GetY - 1);
                if ((roomUserByHabbo.Coordinate != coord) && (roomUserByHabbo.Coordinate != coord2) && (roomUserByHabbo.Coordinate != coord3) && (roomUserByHabbo.Coordinate != coord4))
                {
                    if (roomUserByHabbo.CanWalk)
                    {
                        roomUserByHabbo.MoveTo(Item.Coordinate);
                    }
                }
                else
                {
                    int num  = Item.GetX;
                    int num2 = Item.GetY;
                    if (roomUserByHabbo.Coordinate == coord)
                    {
                        num  = Item.GetX - 1;
                        num2 = Item.GetY;
                    }
                    else
                    {
                        if (roomUserByHabbo.Coordinate == coord2)
                        {
                            num  = Item.GetX + 1;
                            num2 = Item.GetY;
                        }
                        else
                        {
                            if (roomUserByHabbo.Coordinate == coord3)
                            {
                                num  = Item.GetX;
                                num2 = Item.GetY - 1;
                            }
                            else
                            {
                                if (roomUserByHabbo.Coordinate == coord4)
                                {
                                    num  = Item.GetX;
                                    num2 = Item.GetY + 1;
                                }
                            }
                        }
                    }
                    if (room.method_37(num, num2, true, true, true, true, false))
                    {
                        List <RoomItem> list_ = new List <RoomItem>();
                        list_ = room.method_93(num, num2);
                        double        double_ = room.method_84(num, num2, list_);
                        ServerMessage Message = new ServerMessage(230u);
                        Message.AppendInt32(Item.GetX);
                        Message.AppendInt32(Item.GetY);
                        Message.AppendInt32(num);
                        Message.AppendInt32(num2);
                        Message.AppendInt32(1);
                        Message.AppendUInt(Item.Id);
                        Message.AppendByte(2);
                        Message.AppendStringWithBreak(double_.ToString());
                        Message.AppendString("M");
                        room.SendMessage(Message, null);
                        room.method_81(Item, num, num2, double_);
                    }
                }
            }
        }
Esempio n. 21
0
        public void Execute(GameClient session, Room room, string[] Params)
        {
            if (!room.CheckRights(session, true))
            {
                session.SendWhisper("Oops, only the room owner can run this command!");
                return;
            }

            if (room.GetRoomUserManager().GetPets().Count == 0)
            {
                session.SendWhisper("Oops, there isn't any pets in here!?");
            }

            foreach (RoomUser bot in room.GetRoomUserManager().GetUserList().ToList())
            {
                if (bot == null)
                {
                    continue;
                }

                if (bot.RidingHorse)
                {
                    RoomUser rider = room.GetRoomUserManager().GetRoomUserByVirtualId(bot.HorseID);
                    if (rider != null)
                    {
                        rider.RidingHorse = false;
                        rider.ApplyEffect(-1);
                        rider.MoveTo(new Point(rider.X + 1, rider.Y + 1));
                    }
                    else
                    {
                        bot.RidingHorse = false;
                    }
                }

                Pet pet = bot.PetData;
                if (pet != null)
                {
                    return;
                }

                pet.RoomId       = 0;
                pet.PlacedInRoom = false;

                room.GetRoomUserManager().RemoveBot(bot.VirtualId, false);

                if (pet.OwnerId != session.GetHabbo().Id)
                {
                    GameClient targetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUserId(pet.OwnerId);
                    if (targetClient != null)
                    {
                        if (targetClient.GetHabbo().GetInventoryComponent().TryAddPet(pet))
                        {
                            targetClient.SendPacket(new PetInventoryComposer(targetClient.GetHabbo().GetInventoryComponent().GetPets()));
                        }
                    }
                }

                if (session.GetHabbo().GetInventoryComponent().TryAddPet(pet))
                {
                    session.SendPacket(new PetInventoryComposer(session.GetHabbo().GetInventoryComponent().GetPets()));
                }

                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.RunQuery("UPDATE `bots` SET `room_id` = '0', `x` = '0', `Y` = '0', `Z` = '0' WHERE `id` = '" + pet.PetId + "' LIMIT 1");
                    dbClient.RunQuery("UPDATE `bots_petdata` SET `experience` = '" + pet.experience + "', `energy` = '" + pet.Energy + "', `nutrition` = '" + pet.Nutrition + "', `respect` = '" + pet.Respect + "' WHERE `id` = '" + pet.PetId + "' LIMIT 1");
                }
            }

            session.SendWhisper("All pets have been kicked from the room.");
        }
Esempio n. 22
0
 public override void OnTrigger(GameClient Session, RoomItem Item, int Request, bool UserHasRight)
 {
     if (this.Modes != 0 && (UserHasRight || Item.GetBaseItem().InteractionType.ToLower() == "switch"))
     {
         if (Item.GetBaseItem().InteractionType.ToLower() == "switch" && Session != null)
         {
             RoomUser @class = Session.GetHabbo().CurrentRoom.GetRoomUserByHabbo(Session.GetHabbo().Id);
             if (@class.Coordinate.X - Item.SquareInFront.X > 1 || @class.Coordinate.Y - Item.SquareInFront.Y > 1)
             {
                 if (@class.CanWalk)
                 {
                     @class.MoveTo(Item.Coordinate);
                     return;
                 }
                 return;
             }
         }
         int num = 0;
         if (Item.ExtraData.Length > 0)
         {
             num = int.Parse(Item.ExtraData);
         }
         int num2;
         if (num <= 0)
         {
             num2 = 1;
         }
         else
         {
             if (num >= this.Modes)
             {
                 num2 = 0;
             }
             else
             {
                 num2 = num + 1;
             }
         }
         if (Item.GetBaseItem().Name.Contains("jukebox"))
         {
             ServerMessage Message = new ServerMessage(327u);
             if (num2 == 1)
             {
                 Message.AppendInt32(7);
                 Message.AppendInt32(6);
                 Message.AppendInt32(7);
                 Message.AppendInt32(0);
                 Message.AppendInt32(0);
                 Item.int_0        = 1;
                 Item.TimerRunning = true;
                 Item.UpdateNeeded = true;
             }
             else
             {
                 Message.AppendInt32(-1);
                 Message.AppendInt32(-1);
                 Message.AppendInt32(-1);
                 Message.AppendInt32(-1);
                 Message.AppendInt32(0);
                 Item.int_0        = 0;
                 Item.TimerRunning = false;
                 Item.GetRoom().int_13 = 0;
             }
             Item.GetRoom().SendMessage(Message, null);
         }
         double double_ = Item.TotalHeight;
         Item.ExtraData = num2.ToString();
         Item.UpdateState();
         if (double_ != Item.TotalHeight)
         {
             Dictionary <int, AffectedTile> dictionary = Item.GetAffectedTiles;
             if (dictionary == null)
             {
                 dictionary = new Dictionary <int, AffectedTile>();
             }
             Item.GetRoom().UpdateUserStatus(Item.GetRoom().GetUserForSquare(Item.GetX, Item.GetY), true, false);
             foreach (AffectedTile current in dictionary.Values)
             {
                 Item.GetRoom().UpdateUserStatus(Item.GetRoom().GetUserForSquare(current.X, current.Y), true, false);
             }
         }
         if (Session != null)
         {
             RoomUser RoomUser_ = Session.GetHabbo().CurrentRoom.GetRoomUserByHabbo(Session.GetHabbo().Id);
             Item.GetRoom().method_10(RoomUser_, Item);
         }
     }
 }
        public bool Execute(params object[] Params)
        {
            if (Params == null || Params.Length == 0 || String.IsNullOrEmpty(this.StringData))
            {
                return(false);
            }

            RoomUser User = this.Instance.GetRoomUserManager().GetBotByName(this.StringData);

            if (User == null)
            {
                return(false);
            }

            Random      rand  = new Random();
            List <Item> Items = SetItems.Values.ToList();

            Items = Items.OrderBy(x => rand.Next()).ToList();

            if (Items.Count == 0)
            {
                return(false);
            }

            Item Item = Items.First();

            if (Item == null)
            {
                return(false);
            }

            if (!Instance.GetRoomItemHandler().GetFloor.Contains(Item))
            {
                SetItems.TryRemove(Item.Id, out Item);

                if (Items.Contains(Item))
                {
                    Items.Remove(Item);
                }

                if (SetItems.Count == 0 || Items.Count == 0)
                {
                    return(false);
                }

                Item = Items.First();
                if (Item == null)
                {
                    return(false);
                }
            }

            if (this.Instance.GetGameMap() == null)
            {
                return(false);
            }

            if (User.IsWalking)
            {
                User.ClearMovement(true);
            }

            User.BotData.ForcedMovement   = true;
            User.BotData.TargetCoordinate = new Point(Item.GetX, Item.GetY);
            User.MoveTo(Item.GetX, Item.GetY);

            return(true);
        }
Esempio n. 24
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room;

            if (!ButterflyEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room))
            {
                return;
            }

            RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabboId(Session.GetHabbo().Id);

            if (User == null)
            {
                return;
            }

            int  PetId = Packet.PopInt();
            bool Type  = Packet.PopBoolean();

            RoomUser Pet = null;

            if (!Room.GetRoomUserManager().TryGetPet(PetId, out Pet))
            {
                return;
            }

            if (Pet.PetData == null || Pet.PetData.Type != 13)
            {
                return;
            }

            if (!Pet.PetData.AnyoneCanRide && Pet.PetData.OwnerId != User.UserId)
            {
                return;
            }

            if (Math.Abs(User.X - Pet.X) >= 2 || Math.Abs(User.Y - Pet.Y) >= 2)
            {
                User.MoveTo(Pet.X, Pet.Y);
                return;
            }

            if (Type && !User.RidingHorse)
            {
                if (Pet.RidingHorse)
                {
                    string Speechtxt = ButterflyEnvironment.GetLanguageManager().TryGetValue("pet.alreadymounted", Session.Langue);
                    Pet.OnChat(Speechtxt, 0, false);
                }
                else if (User.RidingHorse)
                {
                    return;
                }
                else
                {
                    if (Pet._statusses.Count > 0)
                    {
                        Pet._statusses.Clear();
                    }

                    int NewX2 = Pet.X;
                    int NewY2 = Pet.Y;
                    Room.SendPacket(Room.GetRoomItemHandler().UpdateUserOnRoller(User, new Point(NewX2, NewY2), 0, Room.GetGameMap().SqAbsoluteHeight(NewX2, NewY2) + 1));
                    Room.SendPacket(Room.GetRoomItemHandler().UpdateUserOnRoller(Pet, new Point(NewX2, NewY2), 0, Room.GetGameMap().SqAbsoluteHeight(NewX2, NewY2)));

                    User.MoveTo(NewX2, NewY2);

                    User.RidingHorse = true;
                    Pet.RidingHorse  = true;
                    Pet.HorseID      = User.VirtualId;
                    User.HorseID     = Pet.VirtualId;

                    if (Pet.PetData.Saddle == 9)
                    {
                        User.ApplyEffect(77);
                    }
                    else
                    {
                        User.ApplyEffect(103);
                    }

                    User.RotBody = Pet.RotBody;
                    User.RotHead = Pet.RotHead;

                    User.UpdateNeeded = true;
                    Pet.UpdateNeeded  = true;
                }
            }
            else
            {
                if (User.VirtualId == Pet.HorseID)
                {
                    Pet._statusses.Remove("sit");
                    Pet._statusses.Remove("lay");
                    Pet._statusses.Remove("snf");
                    Pet._statusses.Remove("eat");
                    Pet._statusses.Remove("ded");
                    Pet._statusses.Remove("jmp");
                    User.RidingHorse = false;
                    User.HorseID     = 0;
                    Pet.RidingHorse  = false;
                    Pet.HorseID      = 0;
                    User.MoveTo(new Point(User.X + 1, User.Y + 1));
                    User.ApplyEffect(-1);
                    User.UpdateNeeded = true;
                    Pet.UpdateNeeded  = true;
                }
            }

            Room.SendPacket(new PetHorseFigureInformationComposer(Pet));
        }
Esempio n. 25
0
        public override void OnUserSay(RoomUser RoomUser, string string_0)
        {
            RoomUser Pet = base.GetRoomUser();

            if (Pet.RoomBot.RoomUser_0 == null)
            {
                if (string_0.ToLower().Equals(Pet.PetData.Name.ToLower()))
                {
                    Pet.method_9(Class107.smethod_0(Pet.X, Pet.Y, RoomUser.X, RoomUser.Y));
                }
                else
                {
                    if (string_0.ToLower().StartsWith(Pet.PetData.Name.ToLower() + " ") && RoomUser.GetClient().GetHabbo().Username.ToLower() == base.GetRoomUser().PetData.OwnerName.ToLower())
                    {
                        string key = string_0.Substring(Pet.PetData.Name.ToLower().Length + 1);
                        if ((Pet.PetData.Energy >= 10 && this.method_4() < 6) || Pet.PetData.Level >= 15)
                        {
                            Pet.Statusses.Clear();
                            if (!HabboIM.GetGame().GetRoleManager().dictionary_5.ContainsKey(key))
                            {
                                string[] array = new string[]
                                {
                                    HabboIMEnvironment.GetExternalText("pet_response_confused1"),
                                    HabboIMEnvironment.GetExternalText("pet_response_confused2"),
                                    HabboIMEnvironment.GetExternalText("pet_response_confused3"),
                                    HabboIMEnvironment.GetExternalText("pet_response_confused4"),
                                    HabboIMEnvironment.GetExternalText("pet_response_confused5"),
                                    HabboIMEnvironment.GetExternalText("pet_response_confused6"),
                                    HabboIMEnvironment.GetExternalText("pet_response_confused7")
                                };
                                Random random = new Random();
                                Pet.HandleSpeech(null, array[random.Next(0, array.Length - 1)], false);
                            }
                            else
                            {
                                switch (HabboIM.GetGame().GetRoleManager().dictionary_5[key])
                                {
                                case 0:
                                    // Remove Status
                                    RemovePetStatus();

                                    this.SpeechTimer = 0;
                                    this.ActionTimer = 0;
                                    this.FollowType  = FollowType.None;

                                    // Add Status
                                    Pet.Statusses.Add("sit", TextHandling.GetString(Pet.double_0));
                                    break;

                                case 1:
                                    this.ActionTimer = 25;
                                    this.FollowType  = FollowType.None;

                                    // Remove Status
                                    RemovePetStatus();

                                    Pet.PetData.AddExpirience(10, -10);     // Give XP

                                    // Add Status
                                    Pet.Statusses.Add("sit", TextHandling.GetString(Pet.double_0));
                                    break;

                                case 2:
                                    this.ActionTimer = 30;
                                    this.FollowType  = FollowType.None;

                                    // Remove Status
                                    RemovePetStatus();

                                    Pet.PetData.AddExpirience(10, -10);     // Give XP

                                    // Add Status
                                    Pet.Statusses.Add("lay", TextHandling.GetString(Pet.double_0));
                                    break;

                                case 3:
                                    this.ActionTimer = 30;
                                    this.FollowType  = FollowType.None;

                                    RemovePetStatus();

                                    int NewX = RoomUser.X;
                                    int NewY = RoomUser.Y;

                                    #region Rotation
                                    if (RoomUser.BodyRotation == 4)
                                    {
                                        NewY = RoomUser.Y + 1;
                                    }
                                    else if (RoomUser.BodyRotation == 0)
                                    {
                                        NewY = RoomUser.Y - 1;
                                    }
                                    else if (RoomUser.BodyRotation == 6)
                                    {
                                        NewX = RoomUser.X - 1;
                                    }
                                    else if (RoomUser.BodyRotation == 2)
                                    {
                                        NewX = RoomUser.X + 1;
                                    }
                                    else if (RoomUser.BodyRotation == 3)
                                    {
                                        NewX = RoomUser.X + 1;
                                        NewY = RoomUser.Y + 1;
                                    }
                                    else if (RoomUser.BodyRotation == 1)
                                    {
                                        NewX = RoomUser.X + 1;
                                        NewY = RoomUser.Y - 1;
                                    }
                                    else if (RoomUser.BodyRotation == 7)
                                    {
                                        NewX = RoomUser.X - 1;
                                        NewY = RoomUser.Y - 1;
                                    }
                                    else if (RoomUser.BodyRotation == 5)
                                    {
                                        NewX = RoomUser.X - 1;
                                        NewY = RoomUser.Y + 1;
                                    }
                                    #endregion

                                    Pet.PetData.AddExpirience(11, -10);     // Give XP

                                    Pet.MoveTo(NewX, NewY);
                                    break;

                                case 4:
                                    this.ActionTimer = 10;
                                    this.FollowType  = FollowType.None;

                                    //Remove Status
                                    RemovePetStatus();

                                    Pet.PetData.AddExpirience(15, -13);     // Give XP

                                    Pet.Statusses.Add("beg", TextHandling.GetString(Pet.double_0));
                                    break;

                                case 5:
                                    this.ActionTimer = 30;
                                    this.FollowType  = FollowType.None;

                                    // Remove Status
                                    RemovePetStatus();

                                    // Add Status
                                    Pet.Statusses.Add("ded", TextHandling.GetString(Pet.double_0));

                                    Pet.PetData.AddExpirience(20, -18);     // Give XP
                                    break;

                                case 6:
                                    this.ActionTimer = 120;
                                    this.FollowType  = FollowType.None;

                                    // Remove Status
                                    RemovePetStatus();

                                    // Add Status
                                    Pet.Statusses.Add("sit", TextHandling.GetString(Pet.double_0));

                                    Pet.PetData.AddExpirience(20, -18);     // Give XP

                                    Pet.MoveTo(Pet.X, Pet.Y);
                                    break;

                                case 7:
                                    this.ActionTimer = 120;
                                    this.FollowType  = FollowType.Normal;
                                    this.FollowUser  = RoomUser;

                                    Pet.PetData.AddExpirience(30, -30);     // Give XP

                                    this.PetFollowUser(RoomUser, Pet, FollowType.Normal);
                                    break;

                                case 8:
                                    //Stand
                                    break;

                                case 9:
                                    this.ActionTimer = 5;
                                    this.FollowType  = FollowType.None;

                                    // Remove Status
                                    RemovePetStatus();

                                    // Add Status
                                    Pet.Statusses.Add("jmp", TextHandling.GetString(Pet.double_0));

                                    Pet.PetData.AddExpirience(35, -30);     // Give XP
                                    break;

                                case 10:
                                    // Remove Status
                                    RemovePetStatus();

                                    Pet.PetData.AddExpirience(35, -30);     // Give XP

                                    this.SpeechTimer = 2;
                                    this.FollowType  = FollowType.None;
                                    break;

                                case 11:
                                    //Play
                                    break;

                                case 12:
                                    // Remove Status
                                    RemovePetStatus();

                                    Pet.PetData.AddExpirience(35, -30);     // Give XP

                                    this.SpeechTimer = 120;
                                    this.FollowType  = FollowType.None;
                                    break;

                                case 13:
                                    //Nest
                                    break;

                                case 14:
                                    //Drink
                                    break;

                                case 15:
                                    this.ActionTimer = 120;
                                    this.FollowType  = FollowType.Left;
                                    this.FollowUser  = RoomUser;

                                    Pet.PetData.AddExpirience(35, -30);     // Give XP

                                    this.PetFollowUser(RoomUser, Pet, FollowType.Left);
                                    break;

                                case 16:
                                    this.FollowType = FollowType.Right;
                                    this.FollowUser = RoomUser;

                                    Pet.PetData.AddExpirience(35, -30);     // Give XP

                                    this.PetFollowUser(RoomUser, Pet, FollowType.Right);
                                    break;

                                case 17:
                                    //Play football
                                    break;

                                case 24:
                                    //Move forwar
                                    break;

                                case 25:
                                    //Turn left
                                    break;

                                case 26:
                                    //Turn right
                                    break;

                                case 43:
                                    //Eat
                                    break;
                                }
                            }
                        }
                        else
                        {
                            string[] array2 = new string[]
                            {
                                HabboIMEnvironment.GetExternalText("pet_response_sleeping1"),
                                HabboIMEnvironment.GetExternalText("pet_response_sleeping2"),
                                HabboIMEnvironment.GetExternalText("pet_response_sleeping3"),
                                HabboIMEnvironment.GetExternalText("pet_response_sleeping4"),
                                HabboIMEnvironment.GetExternalText("pet_response_sleeping5")
                            };
                            string[] array3 = new string[]
                            {
                                HabboIMEnvironment.GetExternalText("pet_response_refusal1"),
                                HabboIMEnvironment.GetExternalText("pet_response_refusal2"),
                                HabboIMEnvironment.GetExternalText("pet_response_refusal3"),
                                HabboIMEnvironment.GetExternalText("pet_response_refusal4"),
                                HabboIMEnvironment.GetExternalText("pet_response_refusal5")
                            };
                            Pet.int_10 = Pet.int_12;
                            Pet.int_11 = Pet.int_13;
                            Pet.Statusses.Clear();
                            if (Pet.PetData.Energy < 10)
                            {
                                Random random2 = new Random();
                                Pet.HandleSpeech(null, array2[random2.Next(0, array2.Length - 1)], false);
                                if (Pet.PetData.Type != 13u)
                                {
                                    Pet.Statusses.Add("lay", Pet.double_0.ToString());
                                }
                                else
                                {
                                    Pet.Statusses.Add("lay", (Pet.double_0 - 1.0).ToString());
                                }
                                this.SpeechTimer = 25;
                                this.ActionTimer = 20;
                                base.GetRoomUser().PetData.PetEnergy(25);
                            }
                            else
                            {
                                Random random2 = new Random();
                                Pet.HandleSpeech(null, array3[random2.Next(0, array3.Length - 1)], false);
                            }
                        }
                        Pet.UpdateNeeded = true;
                    }
                }
            }
        }
Esempio n. 26
0
        public void OnTrigger(GameClient Session, Item Item, int Request, bool HasRights)
        {
            RoomUser User = null;

            if (Session != null)
            {
                User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);
            }

            if (User == null)
            {
                return;
            }

            if (Gamemap.TilesTouching(Item.GetX, Item.GetY, User.X, User.Y))
            {
                if (Item.ExtraData == null || Item.ExtraData.Length <= 1 || !Item.ExtraData.Contains(Convert.ToChar(5).ToString()))
                {
                    Point pointOne;
                    Point pointTwo;

                    switch (Item.Rotation)
                    {
                    case 2:
                        pointOne = new Point(Item.GetX, Item.GetY + 1);
                        pointTwo = new Point(Item.GetX, Item.GetY - 1);
                        break;

                    case 4:
                        pointOne = new Point(Item.GetX - 1, Item.GetY);
                        pointTwo = new Point(Item.GetX + 1, Item.GetY);
                        break;

                    default:
                        return;
                    }

                    RoomUser UserOne = Item.GetRoom().GetRoomUserManager().GetUserForSquare(pointOne.X, pointOne.Y);
                    RoomUser UserTwo = Item.GetRoom().GetRoomUserManager().GetUserForSquare(pointTwo.X, pointTwo.Y);

                    if (UserOne == null || UserTwo == null)
                    {
                        Session.SendNotification("No pudimos encontrar un usuario válido para bloquear este bloqueo de amor.");
                    }
                    else if (UserOne.GetClient() == null || UserTwo.GetClient() == null)
                    {
                        Session.SendNotification("No pudimos encontrar un usuario válido para bloquear este bloqueo de amor.");
                    }
                    else if (UserOne.HabboId != Item.UserID && UserTwo.HabboId != Item.UserID)
                    {
                        Session.SendNotification("Usted puede utilizar solamente este artículo con el dueño del artículor.");
                    }
                    else
                    {
                        UserOne.CanWalk = false;
                        UserTwo.CanWalk = false;

                        Item.InteractingUser  = UserOne.GetClient().GetHabbo().Id;
                        Item.InteractingUser2 = UserTwo.GetClient().GetHabbo().Id;

                        UserOne.GetClient().SendMessage(new LoveLockDialogueMessageComposer(Item.Id));
                        UserTwo.GetClient().SendMessage(new LoveLockDialogueMessageComposer(Item.Id));
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                User.MoveTo(Item.SquareInFront);
            }
        }
Esempio n. 27
0
        public void PetFollowUser(RoomUser RoomUser, RoomUser Pet, FollowType FollowType)
        {
            RemovePetStatus();

            int NewX = RoomUser.X;
            int NewY = RoomUser.Y;

            #region Rotation
            if (RoomUser.BodyRotation == 4)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewY = RoomUser.Y - 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewX = RoomUser.X + 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewX = RoomUser.X - 1;
                }
            }
            else if (RoomUser.BodyRotation == 0)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewY = RoomUser.Y + 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewX = RoomUser.X - 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewX = RoomUser.X + 1;
                }
            }
            else if (RoomUser.BodyRotation == 6)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewX = RoomUser.X + 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewY = RoomUser.Y + 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewY = RoomUser.Y - 1;
                }
            }
            else if (RoomUser.BodyRotation == 2)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewX = RoomUser.X - 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewY = RoomUser.Y - 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewY = RoomUser.Y + 1;
                }
            }
            else if (RoomUser.BodyRotation == 3)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewX = RoomUser.X - 1;
                    NewY = RoomUser.Y - 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewY = RoomUser.Y - 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewX = RoomUser.X - 1;
                }
            }
            else if (RoomUser.BodyRotation == 1)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewX = RoomUser.X - 1;
                    NewY = RoomUser.Y + 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewX = RoomUser.X - 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewY = RoomUser.Y + 1;
                }
            }
            else if (RoomUser.BodyRotation == 7)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewX = RoomUser.X + 1;
                    NewY = RoomUser.Y + 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewY = RoomUser.Y + 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewX = RoomUser.X + 1;
                }
            }
            else if (RoomUser.BodyRotation == 5)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewX = RoomUser.X + 1;
                    NewY = RoomUser.Y - 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewX = RoomUser.X + 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewY = RoomUser.Y - 1;
                }
            }
            #endregion

            if (Pet.X != NewX && Pet.Y != NewY)
            {
                Pet.MoveTo(NewX, NewY);
            }
        }
Esempio n. 28
0
        public override void OnTrigger(GameClient session, RoomItem item, int request, bool hasRights)
        {
            if (!hasRights)
            {
                return;
            }

            RoomUser user = item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(session.GetHabbo().Id);

            if (user == null)
            {
                return;
            }

            Room room = session.GetHabbo().CurrentRoom;

            if (room == null)
            {
                return;
            }

            int effectId = Convert.ToInt32(item.GetBaseItem().Name.Replace("fxbox_fx", ""));

            try
            {
                while (PathFinder.GetDistance(user.X, user.Y, item.X, item.Y) > 1)
                {
                    if (user.RotBody == 0)
                    {
                        user.MoveTo(item.X, item.Y + 1);
                    }
                    else if (user.RotBody == 2)
                    {
                        user.MoveTo(item.X - 1, item.Y);
                    }
                    else if (user.RotBody == 4)
                    {
                        user.MoveTo(item.X, item.Y - 1);
                    }
                    else if (user.RotBody == 6)
                    {
                        user.MoveTo(item.X + 1, item.Y);
                    }
                    else
                    {
                        user.MoveTo(item.X, item.Y + 1); // Diagonal user...
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                if (PathFinder.GetDistance(user.X, user.Y, item.X, item.Y) == 1)
                {
                    session.GetHabbo().GetAvatarEffectsInventoryComponent().AddNewEffect(effectId, -1, 0);
                    session.GetHabbo().GetAvatarEffectsInventoryComponent().ActivateCustomEffect(effectId);

                    Thread.Sleep(500); //Wait 0.5 second until remove furniture. (Delay)

                    room.GetRoomItemHandler().RemoveFurniture(session, item.Id, false);

                    using (IQueryAdapter commitableQueryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                        commitableQueryReactor.RunFastQuery("DELETE FROM items_rooms WHERE id = " + item.Id);
                }
            }
        }
Esempio n. 29
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (!Room.CheckRights(Session, true))
            {
                Session.SendWhisper("Bem, somente o proprietário da sala pode executar esse comando!");
                return;
            }

            if (Room.GetRoomUserManager().GetPets().Count > 0)
            {
                foreach (RoomUser Pet in Room.GetRoomUserManager().GetUserList().ToList())
                {
                    if (Pet == null)
                    {
                        continue;
                    }

                    if (Pet.RidingHorse)
                    {
                        RoomUser UserRiding = Room.GetRoomUserManager().GetRoomUserByVirtualId(Pet.HorseID);
                        if (UserRiding != null)
                        {
                            UserRiding.RidingHorse = false;
                            UserRiding.ApplyEffect(-1);
                            UserRiding.MoveTo(new Point(UserRiding.X + 1, UserRiding.Y + 1));
                        }
                        else
                        {
                            Pet.RidingHorse = false;
                        }
                    }

                    Pet.PetData.RoomId       = 0;
                    Pet.PetData.PlacedInRoom = false;

                    Pet pet = Pet.PetData;
                    if (pet != null)
                    {
                        using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.runFastQuery("UPDATE `bots` SET `room_id` = '0', `x` = '0', `Y` = '0', `Z` = '0' WHERE `id` = '" + pet.PetId + "' LIMIT 1");
                            dbClient.runFastQuery("UPDATE `bots_petdata` SET `experience` = '" + pet.experience + "', `energy` = '" + pet.Energy + "', `nutrition` = '" + pet.Nutrition + "', `respect` = '" + pet.Respect + "' WHERE `id` = '" + pet.PetId + "' LIMIT 1");
                        }
                    }

                    if (pet.OwnerId != Session.GetHabbo().Id)
                    {
                        GameClient Target = CloudServer.GetGame().GetClientManager().GetClientByUserID(pet.OwnerId);
                        if (Target != null)
                        {
                            Target.GetHabbo().GetInventoryComponent().TryAddPet(Pet.PetData);
                            Room.GetRoomUserManager().RemoveBot(Pet.VirtualId, false);

                            Target.SendMessage(new PetInventoryComposer(Target.GetHabbo().GetInventoryComponent().GetPets()));
                            return;
                        }
                    }

                    Session.GetHabbo().GetInventoryComponent().TryAddPet(Pet.PetData);
                    Room.GetRoomUserManager().RemoveBot(Pet.VirtualId, false);
                    Session.SendMessage(new PetInventoryComposer(Session.GetHabbo().GetInventoryComponent().GetPets()));
                }
                Session.SendWhisper("Sucesso, retirou todos os animais de estimação.");
            }
            else
            {
                Session.SendWhisper("Bem, não há nenhum animal de estimação aqui!?");
            }
        }
Esempio n. 30
0
        public void Execute(GameClients.GameClient Session, Rooms.Room Room, string[] Params)
        {
            if (Params.Length == 1)
            {
                Session.SendWhisper("Please enter the username of the user you wish to push.");
                return;
            }

            if (!Room.PushEnabled && !Session.GetHabbo().GetPermissions().HasRight("room_override_custom_config"))
            {
                Session.SendWhisper("Oops, it appears that the room owner has disabled the ability to use the push command in here.");
                return;
            }

            GameClient TargetClient = PlusEnvironment.GetGame().GetClientManager().GetClientByUsername(Params[1]);

            if (TargetClient == null)
            {
                Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online.");
                return;
            }

            RoomUser TargetUser = Room.GetRoomUserManager().GetRoomUserByHabbo(TargetClient.GetHabbo().Id);

            if (TargetUser == null)
            {
                Session.SendWhisper("An error occoured whilst finding that user, maybe they're not online or in this room.");
                return;
            }

            if (TargetClient.GetHabbo().Username == Session.GetHabbo().Username)
            {
                Session.SendWhisper("Come on, surely you don't want to push yourself!");
                return;
            }

            if (TargetUser.TeleportEnabled)
            {
                Session.SendWhisper("Oops, you cannot push a user whilst they have their teleport mode enabled.");
                return;
            }

            RoomUser ThisUser = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (ThisUser == null)
            {
                return;
            }

            if (!((Math.Abs(TargetUser.X - ThisUser.X) >= 2) || (Math.Abs(TargetUser.Y - ThisUser.Y) >= 2)))
            {
                if (TargetUser.SetX - 1 == Room.GetGameMap().Model.DoorX)
                {
                    Session.SendWhisper("Please don't push that user out of the room :(!");
                    return;
                }

                if (TargetUser.RotBody == 4)
                {
                    TargetUser.MoveTo(TargetUser.X, TargetUser.Y + 1);
                }

                if (ThisUser.RotBody == 0)
                {
                    TargetUser.MoveTo(TargetUser.X, TargetUser.Y - 1);
                }

                if (ThisUser.RotBody == 6)
                {
                    TargetUser.MoveTo(TargetUser.X - 1, TargetUser.Y);
                }

                if (ThisUser.RotBody == 2)
                {
                    TargetUser.MoveTo(TargetUser.X + 1, TargetUser.Y);
                }

                if (ThisUser.RotBody == 3)
                {
                    TargetUser.MoveTo(TargetUser.X + 1, TargetUser.Y);
                    TargetUser.MoveTo(TargetUser.X, TargetUser.Y + 1);
                }

                if (ThisUser.RotBody == 1)
                {
                    TargetUser.MoveTo(TargetUser.X + 1, TargetUser.Y);
                    TargetUser.MoveTo(TargetUser.X, TargetUser.Y - 1);
                }

                if (ThisUser.RotBody == 7)
                {
                    TargetUser.MoveTo(TargetUser.X - 1, TargetUser.Y);
                    TargetUser.MoveTo(TargetUser.X, TargetUser.Y - 1);
                }

                if (ThisUser.RotBody == 5)
                {
                    TargetUser.MoveTo(TargetUser.X - 1, TargetUser.Y);
                    TargetUser.MoveTo(TargetUser.X, TargetUser.Y + 1);
                }

                Room.SendMessage(new ChatComposer(ThisUser.VirtualId, "*pushes " + Params[1] + "*", 0, ThisUser.LastBubble));
            }
            else
            {
                Session.SendWhisper("Oops, " + Params[1] + " is not close enough!");
            }
        }
Esempio n. 31
0
        public void OnTrigger(GameClient Session, Item Item, int Request, bool HasRights)
        {
            if (Session == null)
            {
                return;
            }

            RoomUser User = Item.GetRoom().GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

            if (Item == null || User == null)
            {
                return;
            }

            if (Item.InteractingUser2 != User.UserId)
            {
                Item.InteractingUser2 = User.UserId;
            }

            if (Item.GetBaseItem().InteractionType == InteractionType.ONE_WAY_GATE)
            {
                if (Item.GetBaseItem().ItemName == "one_way_door*2")
                {
                    if (!RoleplayGameManager.RunningGames.ContainsKey(GameMode.Brawl))
                    {
                        Session.SendWhisper("Não há nenhum evento de briga no momento!", 1);
                        return;
                    }
                }
                else if (Item.GetBaseItem().ItemName == "one_way_door*5")
                {
                    if (!RoleplayGameManager.RunningGames.ContainsKey(GameMode.SoloQueue))
                    {
                        RoleplayGameManager.CreateGame("soloqueue");
                    }
                }
                else if (Item.GetBaseItem().ItemName == "one_way_door*6")
                {
                    if (!RoleplayGameManager.RunningGames.ContainsKey(GameMode.SoloQueueGuns))
                    {
                        RoleplayGameManager.CreateGame("soloqueueguns");
                    }
                }

                if (User.Coordinate != Item.SquareInFront && User.CanWalk)
                {
                    User.MoveTo(Item.SquareInFront);
                    return;
                }
                if (!Item.GetRoom().GetGameMap().ValidTile(Item.SquareBehind.X, Item.SquareBehind.Y) || !Item.GetRoom().GetGameMap().CanWalk(Item.SquareBehind.X, Item.SquareBehind.Y, false) || !Item.GetRoom().GetGameMap().SquareIsOpen(Item.SquareBehind.X, Item.SquareBehind.Y, false))
                {
                    return;
                }

                if ((User.LastInteraction - PlusEnvironment.GetUnixTimestamp() < 0) && User.InteractingGate && User.GateId == Item.Id)
                {
                    User.InteractingGate = false;
                    User.GateId          = 0;
                }

                if (!Item.GetRoom().GetGameMap().CanWalk(Item.SquareBehind.X, Item.SquareBehind.Y, User.AllowOverride))
                {
                    return;
                }

                if (Item.InteractingUser == 0)
                {
                    #region Brawl
                    if (Item.GetBaseItem().ItemName == "one_way_door*2")
                    {
                        if (RoleplayGameManager.RunningGames.ContainsKey(GameMode.Brawl))
                        {
                            if (Session.GetRoleplay().Game != null && Session.GetRoleplay().Game.GetGameMode() == GameMode.Brawl)
                            {
                                Session.SendWhisper("Você já está no evento Briga!", 1);
                                return;
                            }
                            else
                            {
                                if (Session.GetRoleplay().IsWorking)
                                {
                                    Session.GetRoleplay().IsWorking = false;
                                }

                                if (RoleplayGameManager.AddPlayerToGame(RoleplayGameManager.GetGame(GameMode.Brawl), Session, "") != "OK")
                                {
                                    return;
                                }

                                if (Session.GetRoleplay().EquippedWeapon != null)
                                {
                                    Session.GetRoleplay().EquippedWeapon = null;
                                }

                                if (Session.GetRoleplay().InsideTaxi)
                                {
                                    Session.GetRoleplay().InsideTaxi = false;
                                }
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                    #endregion

                    #region SoloQueue
                    else if (Item.GetBaseItem().ItemName == "one_way_door*5")
                    {
                        if (RoleplayGameManager.RunningGames.ContainsKey(GameMode.SoloQueue))
                        {
                            if (Session.GetRoleplay().Game != null && Session.GetRoleplay().Game.GetGameMode() == GameMode.SoloQueue)
                            {
                                Session.SendWhisper("Você já está no Evento SoloQueue!", 1);
                                return;
                            }
                            else if (Session.GetRoleplay().IsWanted)
                            {
                                Session.SendWhisper("Você não pode completar esta ação enquanto você é procurado!", 1);
                                return;
                            }
                            else
                            {
                                if (Session.GetRoleplay().IsWorking)
                                {
                                    Session.GetRoleplay().IsWorking = false;
                                }

                                if (RoleplayGameManager.AddPlayerToGame(RoleplayGameManager.GetGame(GameMode.SoloQueue), Session, "") != "OK")
                                {
                                    return;
                                }

                                if (Session.GetRoleplay().EquippedWeapon != null)
                                {
                                    Session.GetRoleplay().EquippedWeapon = null;
                                }

                                if (Session.GetRoleplay().InsideTaxi)
                                {
                                    Session.GetRoleplay().InsideTaxi = false;
                                }
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                    #endregion

                    #region SoloQueue Guns
                    else if (Item.GetBaseItem().ItemName == "one_way_door*6")
                    {
                        if (RoleplayGameManager.RunningGames.ContainsKey(GameMode.SoloQueueGuns))
                        {
                            if (Session.GetRoleplay().Game != null && Session.GetRoleplay().Game == RoleplayGameManager.GetGame(GameMode.SoloQueueGuns))
                            {
                                Session.SendWhisper("Você já está no evento SoloQueue!", 1);
                                return;
                            }
                            else if (Session.GetRoleplay().IsWanted)
                            {
                                Session.SendWhisper("Você não pode completar esta ação enquanto você é procurado!", 1);
                                return;
                            }
                            else
                            {
                                if (Session.GetRoleplay().IsWorking)
                                {
                                    Session.GetRoleplay().IsWorking = false;
                                }

                                if (RoleplayGameManager.AddPlayerToGame(RoleplayGameManager.GetGame(GameMode.SoloQueueGuns), Session, "") != "OK")
                                {
                                    return;
                                }

                                if (Session.GetRoleplay().InsideTaxi)
                                {
                                    Session.GetRoleplay().InsideTaxi = false;
                                }
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                    #endregion

                    User.InteractingGate = true;
                    User.GateId          = Item.Id;
                    Item.InteractingUser = User.HabboId;

                    User.CanWalk = false;

                    if (User.IsWalking && (User.GoalX != Item.SquareInFront.X || User.GoalY != Item.SquareInFront.Y))
                    {
                        User.ClearMovement(true);
                    }

                    User.AllowOverride = true;
                    User.MoveTo(Item.Coordinate);

                    Item.RequestUpdate(4, true);
                }
            }
        }
Esempio n. 32
0
        private void PullUser(RoomUser roomuserTarget, RoomUser roomuserSource)
        {
            if (roomuserTarget == null)
                return;

            Point userSquare = roomuserTarget.Coordinate;
            Point closestSquare = roomuserTarget.Coordinate;

            Point a = new Point(userSquare.X, userSquare.Y++);
            if (CoordinationUtil.GetDistance(closestSquare, a) < CoordinationUtil.GetDistance(closestSquare, roomuserTarget.Coordinate))
                closestSquare = a;

            Point b = new Point(userSquare.X, userSquare.Y--);
            if (CoordinationUtil.GetDistance(closestSquare, b) < CoordinationUtil.GetDistance(closestSquare, roomuserTarget.Coordinate))
                closestSquare = b;

            Point c = new Point(userSquare.X++, userSquare.Y);
            if (CoordinationUtil.GetDistance(closestSquare, c) < CoordinationUtil.GetDistance(closestSquare, roomuserTarget.Coordinate))
                closestSquare = c;

            Point d = new Point(userSquare.X--, userSquare.Y++);
            if (CoordinationUtil.GetDistance(closestSquare, d) < CoordinationUtil.GetDistance(closestSquare, roomuserTarget.Coordinate))
                closestSquare = d;

            Point e = new Point(userSquare.X++, userSquare.Y--);
            if (CoordinationUtil.GetDistance(closestSquare, e) < CoordinationUtil.GetDistance(closestSquare, roomuserTarget.Coordinate))
                closestSquare = e;

            Point f = new Point(userSquare.X--, userSquare.Y);
            if (CoordinationUtil.GetDistance(closestSquare, f) < CoordinationUtil.GetDistance(closestSquare, roomuserTarget.Coordinate))
                closestSquare = f;

            roomuserTarget.MoveTo(closestSquare);
            roomuserSource.Chat(Session, string.Format(LanguageLocale.GetValue("commands.pulluser"), roomuserTarget.GetUsername()), true);
        }
Esempio n. 33
0
        public void PetFollowUser(RoomUser RoomUser, RoomUser Pet, FollowType FollowType)
        {
            RemovePetStatus();

            int NewX = RoomUser.X;
            int NewY = RoomUser.Y;

            #region Rotation
            if (RoomUser.BodyRotation == 4)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewY = RoomUser.Y - 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewX = RoomUser.X + 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewX = RoomUser.X - 1;
                }
            }
            else if (RoomUser.BodyRotation == 0)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewY = RoomUser.Y + 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewX = RoomUser.X - 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewX = RoomUser.X + 1;
                }
            }
            else if (RoomUser.BodyRotation == 6)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewX = RoomUser.X + 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewY = RoomUser.Y + 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewY = RoomUser.Y - 1;
                }
            }
            else if (RoomUser.BodyRotation == 2)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewX = RoomUser.X - 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewY = RoomUser.Y - 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewY = RoomUser.Y + 1;
                }
            }
            else if (RoomUser.BodyRotation == 3)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewX = RoomUser.X - 1;
                    NewY = RoomUser.Y - 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewY = RoomUser.Y - 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewX = RoomUser.X - 1;
                }
            }
            else if (RoomUser.BodyRotation == 1)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewX = RoomUser.X - 1;
                    NewY = RoomUser.Y + 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewX = RoomUser.X - 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewY = RoomUser.Y + 1;
                }
            }
            else if (RoomUser.BodyRotation == 7)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewX = RoomUser.X + 1;
                    NewY = RoomUser.Y + 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewY = RoomUser.Y + 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewX = RoomUser.X + 1;
                }
            }
            else if (RoomUser.BodyRotation == 5)
            {
                if (FollowType == FollowType.Normal)
                {
                    NewX = RoomUser.X + 1;
                    NewY = RoomUser.Y - 1;
                }
                else if (FollowType == FollowType.Left)
                {
                    NewX = RoomUser.X + 1;
                }
                if (FollowType == FollowType.Right)
                {
                    NewY = RoomUser.Y - 1;
                }
            }
            #endregion

            if (Pet.X != NewX && Pet.Y != NewY)
            {
                Pet.MoveTo(NewX, NewY);
            }
        }