Exemple #1
0
        //internal void AddSaddle()
        //{
        //    Room Room = FirewindEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

        //    if (Room == null || (!Room.AllowPets && !Room.CheckRights(Session, true)))
        //    {
        //        return;
        //    }

        //    uint ItemId = Request.ReadUInt32();
        //    RoomItem Item = Room.GetRoomItemHandler().GetItem(ItemId);
        //    if (Item == null)
        //        return; ;

        //    uint PetId = Request.ReadUInt32();
        //    RoomUser PetUser = Room.GetRoomUserManager().GetPet(PetId);

        //    if (PetUser == null || PetUser.PetData == null || PetUser.PetData.OwnerId != Session.GetHabbo().Id)
        //    {
        //        return;
        //    }

        //    Room.GetRoomItemHandler().RemoveFurniture(Session, Item.Id);
        //    PetUser.PetData.HaveSaddle = true;

        //    using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
        //    {
        //        //dbClient.addParameter("userid", Session.GetHabbo().Id);
        //        dbClient.runFastQuery("UPDATE user_pets SET have_saddle = 1 WHERE id = " + PetUser.PetData.PetId);
        //    }
        //}

        //internal void RemoveSaddle()
        //{
        //    Room Room = FirewindEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

        //    if (Room == null || (!Room.AllowPets && !Room.CheckRights(Session, true)))
        //    {
        //        return;
        //    }

        //    uint PetId = Request.ReadUInt32();
        //    RoomUser PetUser = Room.GetRoomUserManager().GetPet(PetId);

        //    if (PetUser == null || PetUser.PetData == null || PetUser.PetData.OwnerId != Session.GetHabbo().Id)
        //    {
        //        return;
        //    }

        //    FirewindEnvironment.GetGame().GetCatalog().DeliverItems(Session, FirewindEnvironment.GetGame().GetItemManager().GetItem((uint)2804), 1, "");
        //    PetUser.PetData.HaveSaddle = false;

        //    using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
        //    {
        //        //dbClient.addParameter("userid", Session.GetHabbo().Id);
        //        dbClient.runFastQuery("UPDATE user_pets SET have_saddle = 0 WHERE id = " + PetUser.PetData.PetId);
        //    }
        //}

        //internal void MountPet()
        //{
        //    // RWUAM_MOUNT_PET
        //    // RWUAM_DISMOUNT_PET

        //    Room Room = FirewindEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

        //    //if (Room == null || Room.IsPublic || (!Room.AllowPets && !Room.CheckRights(Session, true)))
        //    if (Room == null)
        //    {
        //        return;
        //    }


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

        //    uint PetId = Request.ReadUInt32();
        //    // true = RWUAM_MOUNT_PET, false = RWUAM_DISMOUNT_PET
        //    bool mountOn = Request.ReadBoolean();
        //    RoomUser Pet = Room.GetRoomUserManager().GetPet(PetId);

        //    //if (Pet == null || Pet.PetData == null || Pet.PetData.OwnerId != Session.GetHabbo().Id)
        //    if (Pet == null || Pet.PetData == null || !Pet.PetData.HaveSaddle)
        //    {
        //        return;
        //    }

        //    // GET TO DA CHO-- ..HORSE!
        //    if (mountOn)
        //    {
        //        if (User.isMounted == true || Pet.isMounted)
        //        {
        //            string[] Speech2 = PetLocale.GetValue("pet.alreadymounted");
        //            Random RandomSpeech2 = new Random();
        //            Pet.Chat(null, Speech2[RandomSpeech2.Next(0, Speech2.Length - 1)], false);
        //        }
        //        else
        //        {
        //            Pet.Statusses.Remove("sit");
        //            Pet.Statusses.Remove("lay");
        //            Pet.Statusses.Remove("snf");
        //            Pet.Statusses.Remove("eat");
        //            Pet.Statusses.Remove("ded");
        //            Pet.Statusses.Remove("jmp");
        //            int NewX2 = User.X;
        //            int NewY2 = User.Y;
        //            Pet.PetData.AddExpirience(10); // Give XP
        //            Room.SendMessage(Room.GetRoomItemHandler().UpdateUserOnRoller(Pet, new Point(NewX2, NewY2), 0, Room.GetGameMap().SqAbsoluteHeight(NewX2, NewY2)));
        //            Room.GetRoomUserManager().UpdateUserStatus(Pet, false);
        //            Room.SendMessage(Room.GetRoomItemHandler().UpdateUserOnRoller(User, new Point(NewX2, NewY2), 0, Room.GetGameMap().SqAbsoluteHeight(NewX2, NewY2) + 1));
        //            Room.GetRoomUserManager().UpdateUserStatus(User, false);
        //            Pet.ClearMovement(true);
        //            User.isMounted = true;
        //            Pet.isMounted = true;
        //            Pet.mountID = (uint)User.VirtualId;
        //            User.mountID = Convert.ToUInt32(Pet.VirtualId);
        //            User.ApplyEffect(77);
        //            User.MoveTo(NewX2 + 1, NewY2 + 1);
        //        }
        //    }
        //    else
        //    {
        //        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.isMounted = false;
        //        User.mountID = 0;
        //        Pet.isMounted = false;
        //        Pet.mountID = 0;
        //        User.MoveTo(User.X + 1, User.Y + 1);
        //        User.ApplyEffect(-1);
        //    }
        //}

        internal void GetPetCommands()
        {
            uint PetID = Request.ReadUInt32();
            Room Room  = FirewindEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            PetBot pet = Room.GetRoomUserManager().GetPet(PetID);

            if (pet == null)
            {
                return;
            }

            GetResponse().Init(Outgoing.PetCommands);
            GetResponse().AppendUInt(PetID); // petId

            int level = pet.PetData.Level;

            GetResponse().AppendInt32(18); // allCommands count
            for (int i = 0; i < 18; i++)
            {
                GetResponse().AppendInt32(i);
            }

            GetResponse().AppendInt32(Math.Min(level, 18)); // enabledCommands count
            for (int i = 0; i < Math.Min(level, 18); i++)
            {
                GetResponse().AppendInt32(i);
            }

            SendResponse();
        }
        internal PetBot DeployPet(Pet pet)
        {
            PetBot bot = new PetBot(primaryPrivateUserID++, pet, room);

            UnitList.Add(bot.VirtualID, bot);
            return(bot);
        }
Exemple #3
0
        internal void RespectPet()
        {
            Room Room = FirewindEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null || (!Room.AllowPets))
            {
                return;
            }

            uint   PetId = Request.ReadUInt32();
            PetBot pet   = Room.GetRoomUserManager().GetPet(PetId);

            if (pet == null)
            {
                return;
            }

            pet.PetData.OnRespect();
            Session.GetHabbo().DailyPetRespectPoints--;

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                //dbClient.addParameter("userid", Session.GetHabbo().Id);
                dbClient.runFastQuery("UPDATE users SET daily_pet_respect_points = daily_pet_respect_points - 1 WHERE id = " + Session.GetHabbo().Id);
            }
        }
        /// <summary>
        /// Called when an unit is removed from UnitList dictionary.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void UnitList_onRemove(object sender, EventArgs args)
        {
            try
            {
                KeyValuePair <int, RoomUnit> removedPair = (KeyValuePair <int, RoomUnit>)sender;
                RoomUnit unit = removedPair.Value;

                RoomUser user = unit as RoomUser;

                if (user == null)
                {
                    return;
                }
                GameClient session = user.GetClient();

                int key = removedPair.Key;
                //freeIDs[key] = null;

                // make sure to bring any pets the user might have left
                List <PetBot> petsToRemove = new List <PetBot>();
                foreach (RoomUnit unit2 in UnitList.Values)
                {
                    RoomAI bot = unit2 as RoomAI;
                    if (bot == null)
                    {
                        continue;
                    }

                    bot.BaseAI.OnUserLeaveRoom(session);

                    PetBot pet = bot as PetBot;
                    if (pet != null && pet.OwnerID == user.ID)
                    {
                        petsToRemove.Add(pet);
                    }
                }

                foreach (PetBot toRemove in petsToRemove)
                {
                    if (user.GetClient() == null || user.GetClient().GetHabbo() == null || user.GetClient().GetHabbo().GetInventoryComponent() == null)
                    {
                        continue;
                    }

                    user.GetClient().GetHabbo().GetInventoryComponent().AddPet(toRemove.PetData);
                    RemoveRoomUnit(toRemove);
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException(e.ToString());
            }
        }
Exemple #5
0
        internal void GetPetInfo()
        {
            if (Session.GetHabbo() == null || Session.GetHabbo().CurrentRoom == null)
            {
                return;
            }

            PetBot pet = Session.GetHabbo().CurrentRoom.GetRoomUserManager().GetPet(Request.ReadUInt32());

            if (pet == null || pet.PetData == null)
            {
                Session.SendNotif(LanguageLocale.GetValue("user.petinfoerror"));
                return;
            }

            Session.SendMessage(pet.PetData.SerializeInfo());
        }
Exemple #6
0
        internal void PickUpPet()
        {
            Room Room = FirewindEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

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

            if (Room == null || (!Room.AllowPets && !Room.CheckRights(Session, true)))
            {
                return;
            }

            uint   PetId = Request.ReadUInt32();
            PetBot pet   = Room.GetRoomUserManager().GetPet(PetId);

            if (pet == null)
            {
                return;
            }

            //if (pet.isMounted == true)
            //{
            //    RoomUser usuarioVinculado = Room.GetRoomUserManager().GetRoomUserByVirtualId(Convert.ToInt32(pet.mountID));
            //    if (usuarioVinculado != null)
            //    {
            //        usuarioVinculado.isMounted = false;
            //        usuarioVinculado.ApplyEffect(-1);
            //        usuarioVinculado.MoveTo(new Point(usuarioVinculado.X + 1, usuarioVinculado.Y + 1));
            //    }
            //}

            if (pet.PetData.DBState != DatabaseUpdateState.NeedsInsert)
            {
                pet.PetData.DBState = DatabaseUpdateState.NeedsUpdate;
            }
            pet.PetData.RoomId = 0;

            Session.GetHabbo().GetInventoryComponent().AddPet(pet.PetData);
            Session.GetHabbo().GetInventoryComponent().RunDBUpdate();

            Room.GetRoomUserManager().RemoveRoomUnit(pet);
            Session.SendMessage(Session.GetHabbo().GetInventoryComponent().SerializePetInventory());
        }
Exemple #7
0
        //internal void KickBot()
        //{
        //    Room Room = FirewindEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

        //    if (Room == null || !Room.CheckRights(Session, true))
        //    {
        //        return;
        //    }

        //    RoomUser Bot = Room.GetRoomUserManager().GetRoomUserByVirtualId(Request.ReadInt32());

        //    if (Bot == null || !Bot.IsBot)
        //    {
        //        return;
        //    }

        //    Room.GetRoomUserManager().RemoveBot(Bot.VirtualId, true);
        //}

        internal void PlacePet()
        {
            Room Room = FirewindEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null || (!Room.AllowPets && !Room.CheckRights(Session, true)) || !Room.CheckRights(Session, true))
            {
                return;
            }
            //if (Room.GetRoomUserManager().GetPetCount() >= 10) // TODO: Not hardcoded message and amount + placepetfailed message
            //{
            //    Session.SendNotif("You can't put down any more pets!");
            //    return;
            //}

            uint PetId = Request.ReadUInt32();

            Pet Pet = Session.GetHabbo().GetInventoryComponent().GetPet(PetId);

            if (Pet == null || Pet.PlacedInRoom)
            {
                return;
            }

            int X = Request.ReadInt32();
            int Y = Request.ReadInt32();

            if (!Room.GetGameMap().CanWalk(X, Y))
            {
                return;
            }

            //if (Room.GetRoomUserManager().PetCount >= RoomManager.MAX_PETS_PER_ROOM)
            //{
            //    Session.SendNotif(LanguageLocale.GetValue("user.maxpetreached"));
            //    return;
            //}

            PetBot oldPet = Room.GetRoomUserManager().GetPet(PetId);

            if (oldPet != null)
            {
                Room.GetRoomUserManager().RemoveRoomUnit(oldPet);
            }

            Pet.PlacedInRoom = true;
            Pet.RoomId       = Room.RoomId;
            Pet.X            = X;
            Pet.Y            = Y;
            Pet.DBState      = DatabaseUpdateState.NeedsUpdate;

            Session.GetHabbo().GetInventoryComponent().RunDBUpdate();

            Session.GetHabbo().GetInventoryComponent().RemovePet(Pet.PetId);

            //List<RandomSpeech> RndSpeechList = new List<RandomSpeech>();
            //List<BotResponse> BotResponse = new List<BotResponse>();

            PetBot PetUser = Room.GetRoomUserManager().DeployPet(Pet);

            Session.SendMessage(Session.GetHabbo().GetInventoryComponent().SerializePetInventory());
        }
 internal PetBot DeployPet(Pet pet)
 {
     PetBot bot = new PetBot(primaryPrivateUserID++, pet, room);
     UnitList.Add(bot.VirtualID, bot);
     return bot;
 }