Exemplo n.º 1
0
        public bool OnCycle()
        {
            if (this.SetItems.Count == 0 || !Requested)
            {
                return(false);
            }

            long Now = RavenEnvironment.Now();

            if (_next < Now)
            {
                foreach (Item Item in this.SetItems.Values.ToList())
                {
                    if (Item == null)
                    {
                        continue;
                    }

                    if (!Instance.GetRoomItemHandler().GetFloor.Contains(Item))
                    {
                        Item n = null;
                        SetItems.TryRemove(Item.Id, out n);
                        continue;
                    }

                    Item.Interactor.OnWiredTrigger(Item);
                }

                Requested = false;

                this._next     = 0;
                this.TickCount = Delay;
            }
            return(true);
        }
Exemplo n.º 2
0
        public bool Execute(params object[] Params)
        {
            if (string.IsNullOrEmpty(StringData))
            {
                return(false);
            }

            var user = Instance.GetRoomUserManager().GetBotByName(StringData);

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

            var rand  = new Random();
            var items = SetItems.Values.ToList();

            items = items.OrderBy(x => rand.Next()).ToList();
            if (items.Count == 0)
            {
                return(false);
            }

            var 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 (Instance.GetGameMap() == null)
            {
                return(false);
            }

            Instance.GetGameMap().TeleportToItem(user, item);
            Instance.GetRoomUserManager().UpdateUserStatusses();
            return(true);
        }
Exemplo n.º 3
0
        private void TeleportUser(Habbo Player)
        {
            if (Player == null)
            {
                return;
            }

            Room Room = Player.CurrentRoom;

            if (Room == null)
            {
                return;
            }

            RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username);

            if (User == null)
            {
                return;
            }

            if (Player.IsTeleporting || Player.IsHopping || Player.TeleporterId != 0)
            {
                return;
            }

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

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

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

            Item Item = Items.First();

            if (Item == null)
            {
                return;
            }

            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;
                }

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

            if (Room.GetGameMap() == null)
            {
                return;
            }

            Room.GetGameMap().TeleportToItem(User, Item);

            Room.GetRoomUserManager().UpdateUserStatusses();

            if (Player.Effects() != null && Player.LastEffect == 0 || Player.LastEffect == 4)
            {
                Player.Effects().ApplyEffect(0);
            }
            else
            {
                Player.Effects().ApplyEffect(Player.LastEffect);
            }
        }
Exemplo n.º 4
0
        public bool OnCycle()
        {
            if (Instance == null || !Requested || _next == 0)
            {
                return(false);
            }

            long Now = PlusEnvironment.Now();

            if (_next < Now)
            {
                foreach (Item Item in SetItems.Values.ToList())
                {
                    if (Item == null)
                    {
                        continue;
                    }

                    if (!Instance.GetRoomItemHandler().GetFloor.Contains(Item))
                    {
                        continue;
                    }

                    Item toRemove = null;

                    if (Instance.GetWired().OtherBoxHasItem(this, Item.Id))
                    {
                        SetItems.TryRemove(Item.Id, out toRemove);
                    }

                    Point Point = Instance.GetGameMap().GetChaseMovement(Item);

                    Instance.GetWired().OnUserFurniCollision(Instance, Item);

                    if (!Instance.GetGameMap().ItemCanMove(Item, Point))
                    {
                        continue;
                    }

                    if (Instance.GetGameMap().CanRollItemHere(Point.X, Point.Y) && !Instance.GetGameMap().SquareHasUsers(Point.X, Point.Y))
                    {
                        Double NewZ        = Item.GetZ;
                        bool   CanBePlaced = true;

                        List <Item> Items = Instance.GetGameMap().GetCoordinatedItems(Point);
                        foreach (Item IItem in Items.ToList())
                        {
                            if (IItem == null || IItem.Id == Item.Id)
                            {
                                continue;
                            }

                            if (!IItem.GetBaseItem().Walkable)
                            {
                                _next       = 0;
                                CanBePlaced = false;
                                break;
                            }

                            if (IItem.TotalHeight > NewZ)
                            {
                                NewZ = IItem.TotalHeight;
                            }

                            if (CanBePlaced == true && !IItem.GetBaseItem().Stackable)
                            {
                                CanBePlaced = false;
                            }
                        }

                        if (CanBePlaced && Point != Item.Coordinate)
                        {
                            Instance.SendPacket(new SlideObjectBundleComposer(Item.GetX, Item.GetY, Item.GetZ, Point.X,
                                                                              Point.Y, NewZ, 0, 0, Item.Id));
                            Instance.GetRoomItemHandler().SetFloorItem(Item, Point.X, Point.Y, NewZ);
                        }
                    }
                }

                _next = 0;
                return(true);
            }
            return(false);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        public bool Execute(params object[] Params)
        {
            if (Params == null || Params.Length == 0 || string.IsNullOrEmpty(StringData))
            {
                return(false);
            }

            var user = Instance.GetRoomUserManager().GetBotByName(StringData);

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

            var rand  = new Random();
            var items = SetItems.Values.ToList();

            items = items.OrderBy(x => rand.Next()).ToList();
            if (items.Count == 0)
            {
                return(false);
            }

            var 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 (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);
        }
Exemplo n.º 7
0
        public bool Execute(params object[] Params)
        {
            if (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);
            }

            this.Instance.GetGameMap().TeleportToItem(User, Item);
            this.Instance.GetRoomUserManager().UpdateUserStatusses();


            return(true);
        }
Exemplo n.º 8
0
        public bool OnCycle()
        {
            if (Instance == null || !Requested || _next < 1)
            {
                return(false);
            }
            var time = RavenEnvironment.GetUnixTimestamp();

            if (_next <= time)
            {
                foreach (
                    var Item in
                    SetItems.Values
                    .Where(Item => Instance.GetRoomItemHandler().GetFloor.Contains(Item)))
                {
                    Item toRemove;

                    if (Instance.GetWired().OtherBoxHasItem(this, Item.Id))
                    {
                        SetItems.TryRemove(Item.Id, out toRemove);
                    }

                    var Point = Instance.GetGameMap().GetChaseMovement(Item);

                    Instance.GetWired().onUserFurniCollision(Instance, Item);

                    if (!Instance.GetGameMap().ItemCanMove(Item, Point))
                    {
                        continue;
                    }

                    if (Instance.GetGameMap().CanRollItemHere(Point.X, Point.Y) &&
                        !Instance.GetGameMap().SquareHasUsers(Point.X, Point.Y))
                    {
                        var NewZ        = Instance.GetGameMap().SqAbsoluteHeight(Point.X, Point.Y);
                        var CanBePlaced = true;

                        var Items = Instance.GetGameMap().GetCoordinatedItems(Point);
                        foreach (var IItem in Items.Where(IItem => IItem != null && IItem.Id != Item.Id))
                        {
                            if (!IItem.GetBaseItem().Walkable)
                            {
                                _next       = 0;
                                CanBePlaced = false;
                                break;
                            }

                            if (CanBePlaced && !IItem.GetBaseItem().Stackable)
                            {
                                CanBePlaced = false;
                            }
                        }

                        if (CanBePlaced && Point != Item.Coordinate)
                        {
                            Instance.SendMessage(new SlideObjectBundleComposer(Item.GetX, Item.GetY, Item.GetZ, Point.X,
                                                                               Point.Y, NewZ, 0, 0, Item.Id));
                            Instance.GetRoomItemHandler().SetFloorItem(Item, Point.X, Point.Y, NewZ);
                        }
                    }
                }

                _next = 0;
                return(true);
            }
            return(false);
        }