Exemplo n.º 1
0
        public virtual void Handle(GameClient session, ClientMessage message)
        {
            RoomUnitUser user = session?.GetHabbo()?.GetRoomSession()?.CurrentRoomRoomUser;

            if (user != null)
            {
                user.Unidle();

                if (this.X != user.X || this.Y != user.Y)
                {
                    user.SetRotation(WalkRotation.Walk(user.X, user.Y, this.X, this.Y), false);
                }
            }
        }
Exemplo n.º 2
0
        public void Handle(GameClient session, ClientMessage message)
        {
            if (session != null && session.GetHabbo() != null && session.GetHabbo().GetRoomSession() != null)
            {
                RoomUnitUser user = session.GetHabbo().GetRoomSession().CurrentRoomRoomUser;
                if (user != null)
                {
                    user.Unidle();

                    int x = message.PopWiredInt32();
                    int y = message.PopWiredInt32();
                    if (x != user.X || y != user.Y)
                    {
                        int rotation = WalkRotation.Walk(user.X, user.Y, x, y);
                        user.SetRotation(rotation, false);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public override void OnUse(GameClient session, RoomItem item, int request, bool userHasRights)
        {
            if (this.ExtraData != "1" && this.GetBaseItem().VendingIds.Length > 0 && this.Interactor == null)
            {
                if (CoordUtilies.InRange(this.X, this.Y, session.GetHabbo().GetRoomSession().GetRoomUser().X, session.GetHabbo().GetRoomSession().GetRoomUser().Y))
                {
                    this.Interactor = session.GetHabbo().GetRoomSession().GetRoomUser();
                    this.Interactor.RestrictMovementType |= RestrictMovementType.Client;
                    this.Interactor.SetRotation(WalkRotation.Walk(this.Interactor.X, this.Interactor.Y, this.X, this.Y), !this.Interactor.Session.GetHabbo().GetRoomSession().GetRoomUser().HasStatus("sit"));

                    this.ExtraData = "1";
                    this.UpdateState(false, true);
                    this.DoUpdate(2);
                }
                else
                {
                    session.GetHabbo().GetRoomSession().GetRoomUser().MoveTo(this.TDC.x, this.TDC.y);
                }
            }
        }
Exemplo n.º 4
0
        public void OnUserSpeak(RoomUnitUser user, string message, bool shout)
        {
            if (!shout)
            {
                if (message == this.PetData.Name)
                {
                    this.SetRotation(WalkRotation.Walk(this.X, this.Y, user.X, user.Y), false);
                }
                else if (message.StartsWith(this.PetData.Name + " ") && user.UserID == this.PetData.OwnerID) //pet commands
                {
                    int random = RandomUtilies.GetRandom(1, 100);
                    if (random <= this.PetData.Happiness)
                    {
                        string command = message.Split(' ')[1];
                        switch (command)
                        {
                        case "free":
                        {
                            this.EndAction();
                        }
                        break;

                        case "sit":
                        {
                            if (this.PetData.Energy >= 10)
                            {
                                this.AddExpirience(10);
                                this.PetData.Energy    -= 10;
                                this.PetData.NeedUpdate = true;
                                this.AddStatus("sit", TextUtilies.DoubleWithDotDecimal(this.Z));

                                this.Moving = false;
                                if (this.HasStatus("mv"))
                                {
                                    this.RemoveStatus("mv");
                                }

                                this.ActionTick = 8;
                                this.Action     = "sit";
                            }
                            else
                            {
                                this.Speak("Too tired! :(", false);
                            }
                        }
                        break;

                        default:
                            this.Speak("*not yet implemented*", false);
                            break;
                        }
                    }
                    else
                    {
                        this.PetData.Energy -= 10;
                        if (this.PetData.Energy < 0)
                        {
                            this.PetData.Energy = 0;
                        }
                        this.PetData.NeedUpdate = true;

                        this.Speak("NO! >:(", false);
                    }
                }
            }
        }
Exemplo n.º 5
0
        public override void DoWiredAction(RoomUnitUser user, HashSet <uint> used)
        {
            foreach (RoomItem item_ in this.SelectedItems)
            {
                if (item_ != null)
                {
                    bool foundUser = false;
                    for (int x = item_.X - 5; x < item_.X + 5; x++)
                    {
                        RoomTile tile = this.Room.RoomGamemapManager.GetTile(x, item_.Y);
                        if (tile != null)
                        {
                            RoomUnitUser user_ = (RoomUnitUser)tile.UsersOnTile.Values.FirstOrDefault(u => u.IsRealUser);
                            if (user_ != null)
                            {
                                int         direction = WalkRotation.Walk(item_.X, item_.Y, user_.X, user_.Y);
                                ThreeDCoord moveTo    = item_.TDCR(direction);

                                if (moveTo.x == user_.X && moveTo.y == user_.Y)
                                {
                                    this.Room.RoomWiredManager.UserCollide(user_, this, used);
                                }
                                else
                                {
                                    int    oldX = item_.X;
                                    int    oldY = item_.Y;
                                    double oldZ = item_.Z;
                                    if (this.Room.RoomItemManager.MoveFloorItemOnRoom(null, item_, moveTo.x, moveTo.y, this.Rot))
                                    {
                                        this.Room.RoomItemManager.MoveAnimation[item_.ID] = new RoomItemRollerMovement(item_.ID, oldX, oldY, oldZ, 0, item_.X, item_.Y, item_.Z);
                                    }
                                }

                                foundUser = true;
                                break;
                            }
                        }
                    }

                    if (!foundUser)
                    {
                        for (int y = item_.Y - 5; y < item_.Y + 5; y++)
                        {
                            RoomTile tile = this.Room.RoomGamemapManager.GetTile(item_.X, y);
                            if (tile != null)
                            {
                                RoomUnitUser user_ = (RoomUnitUser)tile.UsersOnTile.Values.FirstOrDefault(u => u.IsRealUser);
                                if (user_ != null)
                                {
                                    int         direction = WalkRotation.Walk(item_.X, item_.Y, user_.X, user_.Y);
                                    ThreeDCoord moveTo    = item_.TDCR(direction);

                                    if (moveTo.x == user_.X && moveTo.y == user_.Y)
                                    {
                                        this.Room.RoomWiredManager.UserCollide(user_, this, used);
                                    }
                                    else
                                    {
                                        int    oldX = item_.X;
                                        int    oldY = item_.Y;
                                        double oldZ = item_.Z;
                                        if (this.Room.RoomItemManager.MoveFloorItemOnRoom(null, item_, moveTo.x, moveTo.y, this.Rot))
                                        {
                                            this.Room.RoomItemManager.MoveAnimation[item_.ID] = new RoomItemRollerMovement(item_.ID, oldX, oldY, oldZ, 0, item_.X, item_.Y, item_.Z);
                                        }
                                    }

                                    foundUser = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!foundUser) //user STILL not found, lets do random movement
                    {
                        Random random = RandomUtilies.GetRandom();
                        int    x      = item_.X;
                        int    y      = item_.Y;

                        int movement = random.Next(0, 4);
                        if (movement == 0) //up
                        {
                            y--;
                        }
                        else if (movement == 1) //down
                        {
                            y++;
                        }
                        else if (movement == 2) //left
                        {
                            x--;
                        }
                        else if (movement == 3) //right
                        {
                            x++;
                        }

                        int    oldX = item_.X;
                        int    oldY = item_.Y;
                        double oldZ = item_.Z;
                        if (this.Room.RoomItemManager.MoveFloorItemOnRoom(null, item_, x, y, this.Rot))
                        {
                            this.Room.RoomItemManager.MoveAnimation[item_.ID] = new RoomItemRollerMovement(item_.ID, oldX, oldY, oldZ, 0, item_.X, item_.Y, item_.Z);
                        }
                    }
                }
            }
        }