Help-me please

Status
Not open for further replies.

Hahn

Member
Jan 7, 2017
44
7
Help-me, I have this bug in my emulator.
I use Plus emulator
 

Hypothesis

Programmer
Jan 6, 2019
524
361
I'm confused on what the "bug" is, just looks like you and someone else clicking and going through each other. If you mean how can you make it so you don't go through each other, that's not a bug, it's a room setting, its called user walk through disabled in the settings tab, put the check mark on it.
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
I'm confused on what the "bug" is, just looks like you and someone else clicking and going through each other. If you mean how can you make it so you don't go through each other, that's not a bug, it's a room setting, its called user walk through disabled in the settings tab, put the check mark on it.
Actually the walk through is for walking through users who aren't moving. He's right, this is a "bug" I guess because what it actually is plus emu doesn't actively check if there is a user moving and you are moving through each other to stop both users.
 

Hypothesis

Programmer
Jan 6, 2019
524
361
Actually the walk through is for walking through users who aren't moving. He's right, this is a "bug" I guess because what it actually is plus emu doesn't actively check if there is a user moving and you are moving through each other to stop both users.
Is it really a bug though or is it just how the pathfinder works?..Because I've never heard of this "bug," or any complaints about this.
 

griimnak

You're a slave to the money then you die
Jul 20, 2013
955
794
Is it really a bug though or is it just how the pathfinder works?..Because I've never heard of this "bug," or any complaints about this.
Definitely a bug because if you setup a line (like for falling furni or whatever), people can just ghost through eachother which doesn't seem practical.
But now that i think about it, I think retros might have always been like that. I know real Habbo isn't because i remember entering rooms where the line is full and you have to stay stuck at the room entrance/spawn
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
Definitely a bug because if you setup a line (like for falling furni or whatever), people can just ghost through eachother which doesn't seem practical.
But now that i think about it, I think retros might have always been like that. I know real Habbo isn't because i remember entering rooms where the line is full and you have to stay stuck at the room entrance/spawn
So the way retros Pathfinder work (most, some of the new emulators fix this) is when you click to walk it scans the whole path one time then says you're good to move. It needs to check on every iteration but also needs to be a fast enough check that doesn't cause a stop and go affect.
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
Modify this code
You post on this forum seeking help. Then when you get to a solution, you are now telling other people who are having the same issue to pretty much figure it out? A little hypocritical.

Problem was resolved though so maybe the thread should get closed.
 

Hahn

Member
Jan 7, 2017
44
7
You post on this forum seeking help. Then when you get to a solution, you are now telling other people who are having the same issue to pretty much figure it out? A little hypocritical.

Problem was resolved though so maybe the thread should get closed.
Sorry, only replace with this code:

C#:
public void OnCycle()
        {
            int userCounter = 0;

            try
            {

                List<RoomUser> ToRemove = new List<RoomUser>();

                foreach (RoomUser User in GetUserList().ToList())
                {
                    if (User == null)
                        continue;

                    if (!isValid(User))
                    {
                        if (User.GetClient() != null)
                            RemoveUserFromRoom(User.GetClient(), false, false);
                        else
                            RemoveRoomUser(User);
                    }

                    if (User.NeedsAutokick && !ToRemove.Contains(User))
                    {
                        ToRemove.Add(User);
                        continue;
                    }

                    bool updated = false;
                    User.IdleTime++;
                    User.HandleSpamTicks();
                    if (!User.IsBot && !User.IsAsleep && User.IdleTime >= 1200)
                    {
                        User.IsAsleep = true;
                        _room.SendMessage(new SleepComposer(User, true));
                    }

                    if (User.CarryItemID > 0)
                    {
                        User.CarryTimer--;
                        if (User.CarryTimer <= 0)
                            User.CarryItem(0);
                    }

                    if (_room.GotFreeze())
                        _room.GetFreeze().CycleUser(User);

                    bool InvalidStep = false;

                    if (User.isRolling)
                    {
                        if (User.rollerDelay <= 0)
                        {
                            UpdateUserStatus(User, false);
                            User.isRolling = false;
                        }
                        else
                            User.rollerDelay--;
                    }

                    if (User.SetStep)
                    {
                      

                        if (this._room.GetGameMap().IsValidWalk(User, new Vector2D(User.X, User.Y), new Vector2D(User.SetX, User.SetY), User.AllowOverride) || User.RidingHorse)
                        {
                            if (!User.RidingHorse)
                                _room.GetGameMap().UpdateUserMovement(new Point(User.Coordinate.X, User.Coordinate.Y), new Point(User.SetX, User.SetY), User);

                            List<Item> items = _room.GetGameMap().GetCoordinatedItems(new Point(User.X, User.Y));
                            foreach (Item Item in items.ToList())
                            {
                                Item.UserWalksOffFurni(User);
                            }

                            if (!User.IsBot)
                            {
                                User.X = User.SetX;
                                User.Y = User.SetY;
                                User.Z = User.SetZ;
                            }
                            else if (User.IsBot && !User.RidingHorse)
                            {
                                User.X = User.SetX;
                                User.Y = User.SetY;
                                User.Z = User.SetZ;
                            }

                            if (!User.IsBot && User.RidingHorse)
                            {
                                RoomUser Horse = GetRoomUserByVirtualId(User.HorseID);
                                if (Horse != null)
                                {
                                    Horse.X = User.SetX;
                                    Horse.Y = User.SetY;
                                }
                            }

                            if (User.X == _room.GetGameMap().Model.DoorX && User.Y == _room.GetGameMap().Model.DoorY && !ToRemove.Contains(User) && !User.IsBot)
                            {
                                ToRemove.Add(User);
                                continue;
                            }

                            List<Item> Items = _room.GetGameMap().GetCoordinatedItems(new Point(User.X, User.Y));
                            foreach (Item Item in Items.ToList())
                            {
                                Item.UserWalksOnFurni(User);
                            }

                            UpdateUserStatus(User, true);
                        }
                        else
                            InvalidStep = true;
                        User.SetStep = false;
                    }

                    if (User.IsWalking && !User.Freezed)
                    {
                        SquarePoint point = DreamPathfinder.GetNextStep(User, new Vector2D(User.X, User.Y), new Vector2D(User.GoalX, User.GoalY), this._room.GetGameMap());
                        if (InvalidStep || (point.X == User.X) && (point.Y == User.Y) || (User.GoalX == User.X && User.GoalY == User.Y)) //No path found, or reached goal (:
                        {
                            User.IsWalking = false;
                            User.RemoveStatus("mv");
                            User.handelingBallStatus = 0;

                            if (User.Statusses.ContainsKey("sign"))
                                User.RemoveStatus("sign");

                            if (User.IsBot && User.BotData.TargetUser > 0)
                            {
                                if (User.CarryItemID > 0)
                                {
                                    RoomUser Target = _room.GetRoomUserManager().GetRoomUserByHabbo(User.BotData.TargetUser);

                                    if (Target != null && Gamemap.TilesTouching(User.X, User.Y, Target.X, Target.Y))
                                    {
                                        User.SetRot(Rotation.Calculate(User.X, User.Y, Target.X, Target.Y), false);
                                        Target.SetRot(Rotation.Calculate(Target.X, Target.Y, User.X, User.Y), false);
                                        Target.CarryItem(User.CarryItemID);
                                    }
                                }

                                User.CarryItem(0);
                                User.BotData.TargetUser = 0;
                            }

                            if (User.RidingHorse && User.IsPet == false && !User.IsBot)
                            {
                                RoomUser mascotaVinculada = GetRoomUserByVirtualId(User.HorseID);
                                if (mascotaVinculada != null)
                                {
                                    mascotaVinculada.IsWalking = false;
                                    mascotaVinculada.RemoveStatus("mv");
                                    mascotaVinculada.UpdateNeeded = true;
                                }
                            }
                        }
                        else
                        {
                            int nextX = point.X;
                            int nextY = point.Y;

                            double nextZ = _room.GetGameMap().SqAbsoluteHeight(nextX, nextY);

                            if (!User.IsBot)
                            {
                                if (User.isSitting)
                                {
                                    User.Statusses.Remove("sit");
                                    User.Z += 0.35;
                                    User.isSitting = false;
                                    User.UpdateNeeded = true;
                                }
                                else if (User.isLying)
                                {
                                    User.Statusses.Remove("sit");
                                    User.Z += 0.35;
                                    User.isLying = false;
                                    User.UpdateNeeded = true;
                                }
                            }
                            if (!User.IsBot)
                            {
                                User.Statusses.Remove("lay");
                                User.Statusses.Remove("sit");
                            }

                            if (!User.IsBot && !User.IsPet && User.GetClient() != null)
                            {
                                if (User.GetClient().GetHabbo().IsTeleporting)
                                {
                                    User.GetClient().GetHabbo().IsTeleporting = false;
                                    User.GetClient().GetHabbo().TeleporterId = 0;
                                }
                                else if (User.GetClient().GetHabbo().IsHopping)
                                {
                                    User.GetClient().GetHabbo().IsHopping = false;
                                    User.GetClient().GetHabbo().HopperId = 0;
                                }
                            }

                            if (!User.IsBot && User.RidingHorse && User.IsPet == false)
                            {
                                RoomUser Horse = GetRoomUserByVirtualId(User.HorseID);
                                if (Horse != null)
                                    Horse.AddStatus("mv", nextX + "," + nextY + "," + TextHandling.GetString(nextZ));

                                User.AddStatus("mv", +nextX + "," + nextY + "," + TextHandling.GetString(nextZ + 1));

                                User.UpdateNeeded = true;
                                Horse.UpdateNeeded = true;
                            }
                            else
                                User.AddStatus("mv", nextX + "," + nextY + "," + TextHandling.GetString(nextZ));

                            int newRot = Rotation.Calculate(User.X, User.Y, nextX, nextY, User.moonwalkEnabled);

                            User.RotBody = newRot;
                            User.RotHead = newRot;

                            User.SetStep = true;
                            User.SetX = nextX;
                            User.SetY = nextY;
                            User.SetZ = nextZ;
                            UpdateUserEffect(User, User.SetX, User.SetY);

                            updated = true;

                            if (User.RidingHorse && User.IsPet == false && !User.IsBot)
                            {
                                RoomUser Horse = GetRoomUserByVirtualId(User.HorseID);
                                if (Horse != null)
                                {
                                    Horse.RotBody = newRot;
                                    Horse.RotHead = newRot;

                                    Horse.SetStep = true;
                                    Horse.SetX = nextX;
                                    Horse.SetY = nextY;
                                    Horse.SetZ = nextZ;
                                }
                            }

                            _room.GetGameMap().GameMap[User.X, User.Y] = User.SqState; // REstore the old one
                            User.SqState = _room.GetGameMap().GameMap[User.SetX, User.SetY]; //Backup the new one

                            if (_room.RoomBlockingEnabled == 0)
                            {
                                _room.GetGameMap().GameMap[nextX, nextY] = 0;
                            }
                            else
                                _room.GetGameMap().GameMap[nextX, nextY] = 1;

                        }
                        if (!User.RidingHorse)
                            User.UpdateNeeded = true;

                        if (_room.GotSoccer())
                            _room.GetSoccer().OnUserWalk(User);
                    }
                    else
                    {
                        if (User.Statusses.ContainsKey("mv"))
                        {
                            User.RemoveStatus("mv");
                            User.UpdateNeeded = true;

                            if (User.RidingHorse)
                            {
                                RoomUser Horse = GetRoomUserByVirtualId(User.HorseID);
                                if (Horse != null)
                                {
                                    Horse.RemoveStatus("mv");
                                    Horse.UpdateNeeded = true;
                                }
                            }
                        }
                    }

                    if (User.RidingHorse)
                        User.ApplyEffect(77);

                    if (User.IsBot && User.BotAI != null)
                        User.BotAI.OnTimerTick();
                    else
                        userCounter++;

                    if (!updated)
                    {
                        UpdateUserEffect(User, User.X, User.Y);
                    }
                }

                foreach (RoomUser toRemove in ToRemove.ToList())
                {
                    GameClient client = OreoServer.GetGame().GetClientManager().GetClientByUserID(toRemove.HabboId);
                    if (client != null)
                    {
                        RemoveUserFromRoom(client, true, false);
                    }
                    else
                        RemoveRoomUser(toRemove);
                }

                if (UserCount != userCounter)
                    UpdateUserCount(userCounter);
            }
            catch (Exception e)
            {
                int rId = 0;
                if (_room != null)
                    rId = _room.Id;

                Logging.LogCriticalException("Affected Room - ID: " + rId + " - " + e.ToString());
            }
        }
 
Status
Not open for further replies.

Users who are viewing this thread

Top