[FIX] Soccer.cs Plus Emulator

AllanS

New Member
Sep 9, 2013
18
1
Does anyone help me solve the ball problem?
He stomps on the ball.
Print:
yz18J6v.gif

url:
 

JayC

Always Learning
Aug 8, 2013
5,493
1,398
Does anyone help me solve the ball problem?
He stomps on the ball.
Print:
yz18J6v.gif

url:
I believe I solved this in my plusemu edit, go ahead and try this and see if it is indeed different:

Replace this method in your Soccer.cs file
Code:
public void OnUserWalk(RoomUser User)
        {
            if (User == null)
                return;

            foreach (Item item in this._balls.Values.ToList())
            {
                int NewX = 0;
                int NewY = 0;
                int differenceX = User.X - item.GetX; //Gets the difference between the item X and user X coordinates
                int differenceY = User.Y - item.GetY; //Gets the difference between the item Y and user Y coordinates

                if (differenceX == 0 && differenceY == 0) //If user is on top of the ball
                {
                    if (User.RotBody == 4) //SOUTH
                    {
                        NewX = User.X;
                        NewY = User.Y + 2;

                    }
                    else if (User.RotBody == 6) //WEST
                    {
                        NewX = User.X - 2;
                        NewY = User.Y;

                    }
                    else if (User.RotBody == 0) //NORTH
                    {
                        NewX = User.X;
                        NewY = User.Y - 2;

                    }
                    else if (User.RotBody == 2) //EAST
                    {
                        NewX = User.X + 2;
                        NewY = User.Y;

                    }
                    else if (User.RotBody == 1) //NORTH-EAST
                    {
                        NewX = User.X + 2;
                        NewY = User.Y - 2;

                    }
                    else if (User.RotBody == 7) //NORTH-WEST
                    {
                        NewX = User.X - 2;
                        NewY = User.Y - 2;

                    }
                    else if (User.RotBody == 3) //SOUTH-EAST
                    {
                        NewX = User.X + 2;
                        NewY = User.Y + 2;

                    }
                    else if (User.RotBody == 5)//SOUTH-WEST
                    {
                        NewX = User.X - 2;
                        NewY = User.Y + 2;
                    }

                    //new x and y is +2 tiles in the direction the user is facing.


                    //The next tile is not valid, so lets not move the ball.
                    if (!this._room.GetRoomItemHandler().CheckPosItem(User.GetClient(), item, NewX, NewY, item.Rotation, false, false))
                    {
                        if (User.RotBody == 4) //SOUTH
                        {
                            NewX = User.X;
                            NewY = User.Y + 1;

                        }
                        else if (User.RotBody == 6) //WEST
                        {
                            NewX = User.X - 1;
                            NewY = User.Y;

                        }
                        else if (User.RotBody == 0) //NORTH
                        {
                            NewX = User.X;
                            NewY = User.Y - 1;

                        }
                        else if (User.RotBody == 2) //EAST
                        {
                            NewX = User.X + 1;
                            NewY = User.Y;

                        }
                        else if (User.RotBody == 1) //NORTH-EAST
                        {
                            NewX = User.X + 1;
                            NewY = User.Y - 1;

                        }
                        else if (User.RotBody == 7) //NORTH-WEST
                        {
                            NewX = User.X - 1;
                            NewY = User.Y - 1;

                        }
                        else if (User.RotBody == 3) //SOUTH-EAST
                        {
                            NewX = User.X + 1;
                            NewY = User.Y + 1;

                        }
                        else if (User.RotBody == 5)//SOUTH-WEST
                        {
                            NewX = User.X - 1;
                            NewY = User.Y + 1;
                        }

                        if (!this._room.GetRoomItemHandler().CheckPosItem(User.GetClient(), item, NewX, NewY, item.Rotation, false, false))
                        {
                        if (User.RotBody == 4) //SOUTH
                        {
                            NewX = User.X;
                            NewY = User.Y - 1;

                        }
                        else if (User.RotBody == 6) //WEST
                        {
                            NewX = User.X + 1;
                            NewY = User.Y;

                        }
                        else if (User.RotBody == 0) //NORTH
                        {
                            NewX = User.X;
                            NewY = User.Y + 1;

                        }
                        else if (User.RotBody == 2) //EAST
                        {
                            NewX = User.X - 1;
                            NewY = User.Y;

                        }
                        else if (User.RotBody == 1) //NORTH-EAST
                        {
                            NewX = User.X - 1;
                            NewY = User.Y + 1;

                        }
                        else if (User.RotBody == 7) //NORTH-WEST
                        {
                            NewX = User.X + 1;
                            NewY = User.Y + 1;

                        }
                        else if (User.RotBody == 3) //SOUTH-EAST
                        {
                            NewX = User.X - 1;
                            NewY = User.Y - 1;

                        }
                        else if (User.RotBody == 5)//SOUTH-WEST
                        {
                            NewX = User.X + 1;
                            NewY = User.Y - 1;
                        }
                    }
                    }
                }

                if (item.GetRoom().GetGameMap().ValidTile(NewX, NewY))
                {
                    MoveBall(item, NewX, NewY, User);
                }
            }
        }
Rooms -> Games -> Football -> Soccer

To save you time, this is mine:


Mine still "stomps" the ball. This is because this test is after the user completes his walk. "OnUserWalk" is called when the user reaches the destination.
 
Last edited:

Users who are viewing this thread

Top