Clientless "realistic" movement

07/13/2019 16:58 Roxeez#1
Hey, i'm working on some clientless stuff, i've made something to make my character move to X/Y position using walk packet the problem his i currently just move to X position then to Y position that's not really "realistic" and can be a problem in some case, do you have any idea how can i make something more realistic (like moving in diagonal)

Btw is there a way to know if we can walk at a given position (like if there is a wall or something)
07/13/2019 17:41 FI0w#2
Quote:
Originally Posted by Roxeez View Post
Hey, i'm working on some clientless stuff, i've made something to make my character move to X/Y position using walk packet the problem his i currently just move to X position then to Y position that's not really "realistic" and can be a problem in some case, do you have any idea how can i make something more realistic (like moving in diagonal)

Btw is there a way to know if we can walk at a given position (like if there is a wall or something)
with grid given by client and with a Path Finding Algo.
07/13/2019 17:48 Nortank#3
Or if you have to make a simple thing, you can use something like
Code:
if(std::abs(objX-tempX) == std::abs(objY-tempY))
            {
                if(objX-tempX < 0 && objY-tempY < 0)
                {
                    tempX--;
                    tempY--;
                }
                else if(objX-tempX > 0 && objY-tempY > 0)
                {
                    tempX++;
                    tempY++;
                }
                else if(objX-tempX > 0 && objY-tempY < 0)
                {
                    tempX++;
                    tempY--;
                }
                else if(objX-tempX < 0 && objY-tempY > 0)
                {
                    tempX--;
                    tempY++;
                }
            }
            else
            {
                if(std::abs(objY-tempY) > std::abs(objX-tempX))
                {
                    if(objY < tempY)
                    {
                        tempY--;
                    }
                    else {
                        tempY++;
                    }
                }
                else
                {
                    if(objX < tempX)
                    {
                        tempX--;
                    }
                    else
                    {
                        tempX++;
                    }
                }
            }
07/13/2019 18:00 Roxeez#4
Quote:
Originally Posted by FI0w View Post
with grid given by client and with a Path Finding Algo.
That's what you're talking about when you say grid given by client right ?
[Only registered and activated users can see links. Click Here To Register...]
07/13/2019 18:16 FI0w#5
Quote:
Originally Posted by Roxeez View Post
That's what you're talking about when you say grid given by client right ?
[Only registered and activated users can see links. Click Here To Register...]
yes you can get the grid using NosPack all other i think convert it into a Picture.

You can see how to use the grid in OpenNos for example.
07/13/2019 18:17 Nortank#6
Yes he is.
Dark cell : non walkable
White cell : walkable
07/13/2019 22:50 Roxeez#7
Ok so i've implemented the wall detection using NStcData.NOS files and it work fine

That's what i've done
Code:
public async Task Walk(Vector2D target)
{
    var distance = Position.Distance(target);

    bool positiveX = target.X > Position.X;
    bool positiveY = target.Y > Position.Y;

    for (var i = 0; i < distance.X; i++)
    {
        var position = Position.Clone();

        position.X = (positiveX ? 1 : -1) + position.X;

        if (Map.IsWalkable(position))
        {
            await _clientSession.SendPacket(new WalkPacket
            {
                Position = position,
                Speed = Speed
            });

            Position = position;
            await Task.Delay(200);
        }
    }

    for (var i = 0; i < distance.Y; i++)
    {
        var position = Position.Clone();

        position.Y = (positiveY ? 1 : -1) + position.Y;

        if (Map.IsWalkable(position))
        {
            await _clientSession.SendPacket(new WalkPacket
            {
                Position = position,
                Speed = Speed
            });

            Position = position;
            await Task.Delay(200);
        }
    }
}
but i'm still stuck on a wait to make the movement more realistic (like moving on X/Y axis in same time

Ok i've made something else and everything looks fine
Code:
public async Task<bool> Walk(Vector2D destination)
{
    if (!Map.IsWalkable(destination)) return false;

    bool positiveX = destination.X > Position.X;
    bool positiveY = destination.Y > Position.Y;

    var blocked = false;

    while(!Position.Equals(destination) && !blocked)
    {
        var position = Position.Clone();
        var distance = position.Distance(destination);

        int stepX = distance.X >= 5 ? 5 : distance.X;
        int stepY = distance.Y >= 5 ? 5 : distance.Y;

        position.X = (positiveX ? 1 : -1) * stepX + position.X;
        position.Y = (positiveY ? 1 : -1) * stepY + position.Y;

        if (Map.IsWalkable(position))
        {
            await _clientSession.SendPacket(new WalkPacket
            {
                Position = position,
                Speed = Speed
            });

            await Task.Delay((stepX + stepY) * (1000 / Speed));
            Position = position;
        }
        else
        {
            blocked = true;
        }
    }

    return !blocked;
}
I've one last question what's the third parameter of the Walk packet ?
Actually i'm just setting it to 0 but my character looks like i'm lagging (running faster some time) it's because of this parameter ?

I've looked with packet logger but i can't find something logical about this parameter if someone can tell me in which case the value is 1 or 0 thanks alot
07/14/2019 05:48 0Lucifer0#8
Checksum [Only registered and activated users can see links. Click Here To Register...]