Bug with the Wired Chase (MoveFurniToUserBox)

N30_C0R73X

New Member
Aug 1, 2019
8
0
Hello, my users complain a lot about the Wired of hunting users, he only follows the user if he is 1 square away from him, I have already looked at all the code I could not find anything, does anyone have the fix for that problem? When it is not close to the user, it randomly turns around the room.

I use the UFO.Server

Code MoveFurniToUserBox:
C++:
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Collections.Concurrent;

using Yezz.Communication.Packets.Incoming;
using Yezz.HabboHotel.Rooms;
using Yezz.HabboHotel.Users;
using System.Drawing;
using System.Security.Cryptography;
using Yezz.Communication.Packets.Outgoing.Rooms.Engine;
using Yezz.Utilities;


namespace Yezz.HabboHotel.Items.Wired.Boxes.Effects
{
    internal class MoveFurniToUserBox : IWiredItem, IWiredCycle
    {
        public Room Instance { get; set; }
        public Item Item { get; set; }

        public WiredBoxType Type
        {
            get { return WiredBoxType.EffectMoveFurniToNearestUser; }
        }

        public ConcurrentDictionary<int, Item> SetItems { get; set; }
        public string StringData { get; set; }
        public bool BoolData { get; set; }

        public int Delay
        {
            get { return this._delay; }
            set
            {
                this._delay = value;
                this.TickCount = value + 1;
            }
        }

        public int TickCount { get; set; }
        public string ItemsData { get; set; }
        private bool Requested;
        private int _delay = 0;
        private long _next = 0;

        public MoveFurniToUserBox(Room Instance, Item Item)
        {
            this.Instance = Instance;
            this.Item = Item;
            this.SetItems = new ConcurrentDictionary<int, Item>();
            this.TickCount = Delay;
            this.Requested = false;
        }

        public void HandleSave(ClientPacket Packet)
        {
            int Unknown = Packet.PopInt();
            string Unknown2 = Packet.PopString();

            if (this.SetItems.Count > 0)
                this.SetItems.Clear();

            int FurniCount = Packet.PopInt();
            for (int i = 0; i < FurniCount; i++)
            {
                Item SelectedItem = Instance.GetRoomItemHandler().GetItem(Packet.PopInt());

                if (SelectedItem != null && !Instance.GetWired().OtherBoxHasItem(this, SelectedItem.Id))
                    SetItems.TryAdd(SelectedItem.Id, SelectedItem);
            }

            int Delay = Packet.PopInt();
            this.Delay = Delay;
            TickCount = Delay / 2;
        }

        public bool Execute(params object[] Params)
        {
            if (this.SetItems.Count == 0)
                return false;


            if (this._next == 0 || this._next < YezzEnvironment.Now())
                this._next = YezzEnvironment.Now() + this.Delay;

            if (!Requested)
            {
                this.TickCount = this.Delay;
                this.Requested = true;
            }
            return true;
        }

        public bool OnCycle()
        {
            if (Instance == null || !Requested || _next == 0)
                return false;

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

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

                    Item toRemove = null;

                    if (Instance.GetWired().OtherBoxHasItem(this, Item.Id))
                        this.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;
                        Boolean 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.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;
        }
    }
}
 

Joe

Well-Known Member
Jun 10, 2012
4,088
1,915
If this is Plus or a Plus edit then the wired in most builds is pretty broken, including this one.

I would recommend redoing the whole of the wired in Plus, or looking into Arcturus where there’s active development going on.
Post automatically merged:

There was a thread about this the other week, we couldn’t get to the bottom of it.
 

Joe

Well-Known Member
Jun 10, 2012
4,088
1,915
Sorry, I don't know much about code

Yes, this is supposed to be a fixed version of the PLUS Emulator. But if I switch to the Arcturus I will not lose the users and the rooms of my retro ??
The feature simply isn’t coded, like most of the wired in released Plus emulators.

I’d just start over with Arcturus or Morningstar if you’re so bothered, there’s tons of features and all of the wired is up to date and working.
 

tyutu

Member
Oct 25, 2016
110
8
Sorry, I don't know much about code

Yes, this is supposed to be a fixed version of the PLUS Emulator. But if I switch to the Arcturus I will not lose the users and the rooms of my retro ??
You can migrate accounts, badges and other data, but I think furnis will be difficult, but not impossible.
 

Users who are viewing this thread

Top