public void OnTrigger(int TriggerId, Item Item, VirtualRoomUser User)
 {
     if (User.Point.Compare(Item.FontPoint))
     {
         User.GetClient().Notif("Teleporters are disabled.", false);
     }
 }
        public void OnTrigger(int TriggerId, Item Item, VirtualRoomUser User)
        {
            int CurrentState = 0;

            int.TryParse(Item.ExtraData, out CurrentState);

            CurrentState++;

            if (CurrentState > Item.GetBaseItem().InteractorAmount)
            {
                CurrentState = 0;
            }

            Item.ExtraData = BrickEngine.GetConvertor().ObjectToString(CurrentState);

            User.GetRoom().GetRoomEngine().BroadcastResponse(Item.GetTriggerResponse());

            // Update Info & MySQL
            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE items SET extra_data = @extra WHERE id = @itemid LIMIT 1");
                Reactor.AddParam("itemid", Item.Id);
                Reactor.AddParam("extra", CurrentState);
                Reactor.ExcuteQuery();
            }
        }
 public void OnPointInteract(Item Item, VirtualRoomUser User)
 {
     if (!User.IsPet)
     {
         if (BrickEngine.GetEffectsHandler().UserHasRunningEffect(User.HabboId))
         {
             BrickEngine.GetEffectsHandler().RunFreeEffect(User.GetClient(), -1);
         }
     }
 }
Example #4
0
 public void OnPointInteract(Item Item, VirtualRoomUser User)
 {
     if (User.IsPet)
     {
         User.AddStatus("swm", string.Empty);
     }
     else
     {
         if (Item.GetBaseItem().InternalName.EndsWith("_1"))
         {
             BrickEngine.GetEffectsHandler().RunFreeEffect(User.GetClient(), 30);
         }
         else if (Item.GetBaseItem().InternalName.EndsWith("_2"))
         {
             BrickEngine.GetEffectsHandler().RunFreeEffect(User.GetClient(), 29);
         }
     }
 }
 public void OnRemove(Item Item, VirtualRoomUser User)
 {
 }
 public void OnPlace(Item Item, VirtualRoomUser User)
 {
 }
Example #7
0
 public void OnTrigger(int TriggerId, Item Item, VirtualRoomUser User)
 {
 }
        public VirtualRoomUser GenerateRoomUser(Client Client)
        {
            if (!Client.IsValidUser)
            {
                return null;
            }

            VirtualRoomUser User = new VirtualRoomUser(VirtualIdCounter.Next, Client.GetUser().HabboId, RoomId, GetRoom().GetRoomModel().DoorRot);
            User.UpdatePoint(GetRoom().GetRoomModel().Door);

            Response EnterMessage = new Response(28);
            EnterMessage.AppendInt32(1); // Amount, just 1
            User.GetResponse(EnterMessage);
            BroadcastResponse(EnterMessage);

            User.GetClient().GetUser().AtEnterRoom(RoomId);

            lock (RoomUsers)
            {
                RoomUsers.Add(User.VirtualId, User);
            }

            return User;
        }
 public void OnPointInteract(Item Item, VirtualRoomUser User)
 {
 }
 public void HandleIncomingTrigger(VirtualRoomUser User, Item Item, int TriggerId)
 {
     Item.GetTrigger().OnTrigger(TriggerId, Item, User);
 }
        // Already Updated @cache
        public void HandleIncomingItemUpdate(Item Item, string WallPos, VirtualRoomUser User)
        {
            // Handling Messages (FIRST, to avoid laggys)
            Response Response = new Response(85);
            Item.GetRoomResponse(Response);
            BroadcastResponse(Response);

            Item.GetTrigger().OnUpdate(Item, User);

            // Update Info & MySQL
            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE items SET point_wall = @point_wall WHERE id = @itemid LIMIT 1");
                Reactor.AddParam("itemid", Item.Id);
                Reactor.AddParam("point_wall", WallPos);
                Reactor.ExcuteQuery();
            }
        }
        // Already Updated @cache
        public void HandleIncomingItemUpdate(Item Item, iPoint OldPlace, iPoint NewPlace, int OldRotation, int Rotation, VirtualRoomUser User)
        {
            // Handling Messages (FIRST, to avoid laggys)
            Response Response = new Response(95);
            Item.GetRoomResponse(Response);
            BroadcastResponse(Response);

            GenerateMatrix();

            UpdateUsersOnPoint(OldPlace);

            foreach (iPoint Point in BrickEngine.GetItemReactor().GetAffectedPoints(OldPlace, Item.GetBaseItem().LengthY, Item.GetBaseItem().LengthX, OldRotation))
            {
                UpdateUsersOnPoint(Point);
            }

            UpdateUsersOnPoint(NewPlace);

            foreach (iPoint Point in BrickEngine.GetItemReactor().GetAffectedPoints(NewPlace, Item.GetBaseItem().LengthY, Item.GetBaseItem().LengthX, Rotation))
            {
                UpdateUsersOnPoint(Point);
            }

            Item.GetTrigger().OnUpdate(Item, User);

            // Update Info & MySQL
            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE items SET point_x = @x, point_y = @y, point_z = @z, rotation = @rot WHERE id = @itemid LIMIT 1");
                Reactor.AddParam("itemid", Item.Id);
                Reactor.AddParam("x", NewPlace.X);
                Reactor.AddParam("y", NewPlace.Y);
                Reactor.AddParam("z", NewPlace.Z.ToString().Replace(',', '.'));
                Reactor.AddParam("rot", Rotation);
                Reactor.ExcuteQuery();
            }
        }
        public void HandleIncomingItemPickUp(Item Item, VirtualRoomUser User)
        {
            // Handling Messages (FIRST, to avoid laggys)
            Response Response = new Response();

            if (Item.GetBaseItem().InternalType.ToLower().Equals("s"))
            {
                Response.Initialize(94);
            }
            else
            {
                Response.Initialize(84);
            }

            Response.AppendRawInt32(Item.Id);
            Response.AppendChar(2);
            Response.AppendBoolean(false);

            BroadcastResponse(Response);

            Item.GetTrigger().OnRemove(Item, User);

            if (Item.GetBaseItem().ExternalType.ToLower().Equals("default"))
            {
                Item.ExtraData = "0";

                // Update Info & MySQL
                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    Reactor.SetQuery("UPDATE items SET room_id = '0', extra_data = '0',point_wall = '' WHERE id = @itemid LIMIT 1");
                    Reactor.AddParam("itemid", Item.Id);
                    Reactor.ExcuteQuery();
                }
            }
            else
            {
                // Update Info & MySQL
                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    Reactor.SetQuery("UPDATE items SET room_id = '0', point_wall = '' WHERE id = @itemid LIMIT 1");
                    Reactor.AddParam("itemid", Item.Id);
                    Reactor.ExcuteQuery();
                }
            }
        }
        public void HandleIncomingItemPickUp(Item Item, iPoint OldPlace, iPoint NewPlace, int OldRotation, int Rotation, VirtualRoomUser User)
        {
            // Handling Messages (FIRST, to avoid laggys)
            Response Response = new Response();

            if (Item.GetBaseItem().InternalType.ToLower().Equals("s"))
            {
                Response.Initialize(94);
            }
            else
            {
                Response.Initialize(84);
            }

            Response.AppendRawInt32(Item.Id);
            Response.AppendChar(2);
            Response.AppendBoolean(false);

            BroadcastResponse(Response);

            GenerateMatrix();

            UpdateUsersOnPoint(OldPlace);

            foreach (iPoint Point in BrickEngine.GetItemReactor().GetAffectedPoints(OldPlace, Item.GetBaseItem().LengthY, Item.GetBaseItem().LengthX, OldRotation))
            {
                UpdateUsersOnPoint(Point);
            }

            Item.GetTrigger().OnRemove(Item, User);

            if (Item.GetBaseItem().ExternalType.ToLower().Equals("default"))
            {
                Item.ExtraData = "0";

                // Update Info & MySQL
                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    Reactor.SetQuery("UPDATE items SET room_id = '0', extra_data = '0', point_x = @x, point_y = @y, point_z = @z, rotation = @rot WHERE id = @itemid LIMIT 1");
                    Reactor.AddParam("itemid", Item.Id);
                    Reactor.AddParam("x", NewPlace.X);
                    Reactor.AddParam("y", NewPlace.Y);
                    Reactor.AddParam("z", NewPlace.Z.ToString().Replace(',', '.'));
                    Reactor.AddParam("rot", Rotation);
                    Reactor.ExcuteQuery();
                }
            }
            else
            {
                // Update Info & MySQL
                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    Reactor.SetQuery("UPDATE items SET room_id = '0', point_x = @x, point_y = @y, point_z = @z, rotation = @rot WHERE id = @itemid LIMIT 1");
                    Reactor.AddParam("itemid", Item.Id);
                    Reactor.AddParam("x", NewPlace.X);
                    Reactor.AddParam("y", NewPlace.Y);
                    Reactor.AddParam("z", NewPlace.Z.ToString().Replace(',', '.'));
                    Reactor.AddParam("rot", Rotation);
                    Reactor.ExcuteQuery();
                }
            }
        }
Example #15
0
 public void OnUpdate(Item Item, VirtualRoomUser User)
 {
 }
Example #16
0
        public void DoActions(PetInterAction Action, VirtualRoomUser Pet)
        {
            if (Pet.ContainsStatus("lay"))
            {
                Pet.RemoveStatus("lay");
            }

            if (Action.Equals(PetInterAction.Progressing))
            {
                this.Action = PetInterAction.Progressing;
            }

            if (Energy <= 15 && !this.Action.Equals(PetInterAction.Sleeping))
            {
                if (Happiness > 0)
                {
                    Happiness--;
                    UpdateHappiness();
                }

                Pet.AddStatus("lay", string.Empty);
                Pet.UpdateStatus(true);

                this.Action = PetInterAction.Sleeping;
            }
            else
            {
                if (this.Action.Equals(PetInterAction.Sleeping))
                {
                    if (Energy < PetReactor.MAX_ENERGY(Level) && Energy + 2 <= PetReactor.MAX_ENERGY(Level))
                    {
                        Energy += 2;
                        UpdateEnergy();
                    }
                    else
                    {
                        Energy = PetReactor.MAX_ENERGY(Level);
                    }

                    if (Energy >= PetReactor.MAX_ENERGY(Level))
                    {
                        Pet.Talk("Welcome back!", SpeechType.Talk, 0, string.Empty);
                        Pet.RemoveStatus("lay");

                        if (Happiness < PetReactor.MAX_HAPPINESS)
                        {
                            Happiness++;
                            UpdateHappiness();
                        }

                        this.Action = PetInterAction.Interactive;
                    }
                    else
                    {
                        Pet.AddStatus("lay", string.Empty);
                    }

                    Pet.UpdateStatus(true);

                    if (Action.Equals(PetInterAction.Chatting))
                    {
                        Pet.Talk("*Sleeping Zzz..*", SpeechType.Talk, 0, string.Empty);
                    }
                }
                else
                {
                    if (this.Action.Equals(PetInterAction.Progressing))
                    {
                        if (GetRoom().GetRoomEngine().GetPetToys().Count > 0)
                        {
                            foreach (Item Toy in GetRoom().GetRoomEngine().GetPetToys())
                            {
                                if (GetRoomUser().Point.Compare(Toy.Point))
                                {
                                    if (Toy.ExtraData == "0")
                                    {
                                        Pet.RotBody = 2;
                                        Pet.RotHead = 2;

                                        Pet.AddStatus("pla", string.Empty);
                                        Pet.UpdateStatus(true);

                                        Toy.ExtraData = "1";

                                        if (Happiness < PetReactor.MAX_HAPPINESS && Happiness + 3 <= PetReactor.MAX_HAPPINESS)
                                        {
                                            Happiness += 3;
                                            UpdateHappiness();
                                        }

                                        GetRoom().GetRoomEngine().BroadcastResponse(Toy.GetTriggerResponse());
                                    }
                                    else
                                    {
                                        if (!EndPlaying)
                                        {
                                            EndPlaying = true;
                                        }
                                        else
                                        {
                                            Toy.ExtraData = "0";
                                            GetRoom().GetRoomEngine().BroadcastResponse(Toy.GetTriggerResponse());
                                            EndPlaying = false;

                                            Pet.RemoveStatus("pla");
                                            Pet.UpdateStatus(true);

                                            this.Action = PetInterAction.Interactive;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (Action.Equals(PetInterAction.Walking))
                        {
                            if (Energy > 0)
                            {
                                if (Pet.IsWalking)
                                {
                                    Pet.PathPoints = new List<Rooms.Pathfinding.iPoint>();
                                    Pet.UpdateStatus(true);
                                }

                                Pet.UnhandledGoalPoint = GetRoom().GetRoomEngine().GetRandom();

                                Energy--;
                                UpdateEnergy();

                                if (Happiness < PetReactor.MAX_HAPPINESS && Happiness + 3 <= PetReactor.MAX_HAPPINESS)
                                {
                                    Happiness += 3;
                                    UpdateHappiness();
                                }

                                this.Action = Action;
                            }
                        }
                        else if (Action.Equals(PetInterAction.Chatting) && !Muted)
                        {
                            var Speeches = BrickEngine.GetPetReactor().GetSpeechesForType(Type);

                            PetSpeech Speech = null;

                            if (Speeches.Count > 0)
                            {
                                Speech = Speeches[Random.Next(0, Speeches.Count - 1)];
                            }

                            if (Speech != null)
                            {
                                Pet.Talk(Speech.Speech, Speech.Shout ? SpeechType.Shout : SpeechType.Talk, 0, string.Empty);
                            }

                            if (Happiness < PetReactor.MAX_HAPPINESS && Happiness + 5 <= PetReactor.MAX_HAPPINESS)
                            {
                                Happiness += 5;
                                UpdateHappiness();
                            }

                            this.Action = Action;
                        }
                        else if (Action.Equals(PetInterAction.Action) && !GetRoomUser().IsWalking)
                        {
                            if (Pet.GetRoom().GetRoomEngine().GetPetToys().Count > 0 && Random.Next(0, 5) == 2)
                            {
                                Pet.AddStatus("gst", "plf");
                                Pet.UpdateStatus(true);

                                Pet.UnhandledGoalPoint = Pet.GetRoom().GetRoomEngine().GetPetToys()[Random.Next(0, Pet.GetRoom().GetRoomEngine().GetPetToys().Count - 1)].Point;
                                DoActions(PetInterAction.Progressing, Pet);
                            }
                            else
                            {
                                var Actions = BrickEngine.GetPetReactor().GetActionsForType(Type);

                                PetAction doAction = null;

                                if (Actions.Count > 0)
                                {
                                    doAction = Actions[Random.Next(0, Actions.Count - 1)];
                                }

                                if (doAction != null)
                                {
                                    Pet.AddStatus(doAction.Key, doAction.Value);
                                    Pet.UpdateStatus(true);
                                }

                                if (Energy > 0)
                                {
                                    Energy--;
                                    UpdateEnergy();
                                }

                                if (Happiness < PetReactor.MAX_HAPPINESS && Happiness + 5 <= PetReactor.MAX_HAPPINESS)
                                {
                                    Happiness += 5;
                                    UpdateHappiness();
                                }

                                this.Action = Action;
                            }
                        }
                        else
                        {
                            this.Action = PetInterAction.Interactive;
                        }
                    }
                }
            }
        }
        public VirtualRoomUser GenerateRoomPet(int PetId, iPoint Place, int Rot)
        {
            VirtualRoomUser User = new VirtualRoomUser(VirtualIdCounter.Next, PetId, RoomId, Rot);
            User.UpdatePoint(Place);

            User.Point.Z = GetTileHeight(Place);

            Response EnterMessage = new Response(28);
            EnterMessage.AppendInt32(1); // Amount, just 1
            User.GetResponse(EnterMessage);
            BroadcastResponse(EnterMessage);

            lock (RoomPets)
            {
                RoomPets.Add(User.VirtualId, User);
            }

            BrickEngine.GetPetReactor().GetPetInfo(PetId).X = Place.X;
            BrickEngine.GetPetReactor().GetPetInfo(PetId).Y = Place.Y;
            BrickEngine.GetPetReactor().GetPetInfo(PetId).Rot = Rot;

            return User;
        }