[Question] about the mount/movement

07/14/2013 08:49 pounder#1
this is the video

this is my char/entity.cs
Code:
public bool Move(Enums.ConquerAngle Direction)
        {
            ushort _X = X, _Y = Y;
            Facing = Direction;
            sbyte xi = 0, yi = 0;
            switch (Direction)
            {
               case Enums.ConquerAngle.North: xi = -1; yi = -1; break;
                case Enums.ConquerAngle.South: xi = 1; yi = 1; break;
                case Enums.ConquerAngle.East: xi = 1; yi = -1; break;
                case Enums.ConquerAngle.West: xi = -1; yi = 1; break;
                case Enums.ConquerAngle.NorthWest: xi = -1; break;
                case Enums.ConquerAngle.SouthWest: yi = 1; break;
                case Enums.ConquerAngle.NorthEast: yi = -1; break;
                case Enums.ConquerAngle.SouthEast: xi = 1; break;
            }
            _X = (ushort)(X + xi);
            _Y = (ushort)(Y + yi);
            Game.Map Map = null;
            if (ServerBase.Kernel.Maps.TryGetValue(MapID, out Map))
            {
                if (Map.Floor[_X, _Y, MapObjType, this])
                {
                    if (MapObjType == MapObjectType.Monster)
                    {
                        Map.Floor[_X, _Y, MapObjType, this] = false;
                        Map.Floor[X, Y, MapObjType, this] = true;
                    }

                    X = _X;
                    Y = _Y;
                    return true;
                }
                else
                {
                    if (Mode == Enums.Mode.None)
                    {
                        if (EntityFlag != EntityFlag.Monster)
                            Teleport(MapID, X, Y);
                        else
                            return false;
                    }
                }
            }
            else
            {
                if (EntityFlag != EntityFlag.Monster)
                    Teleport(MapID, X, Y);
                else
                    return false;
            }
            return true;
        }
This is my Packet
Code:
static void PlayerGroundMovment(GroundMovement groundMovement, Client.GameState client)
if (client.Entity.ContainsFlag(Update.Flags.Ride))
                client.Entity.Vigor -= 1;
           // client.Entity.PX = client.Entity.X;
            //client.Entity.PY = client.Entity.Y;*/


            if (groundMovement.Direction > Enums.ConquerAngle.South)
            {
                groundMovement.Direction = (JudeProject.Game.Enums.ConquerAngle)((byte)groundMovement.Direction % 8);
            }
			
            client.Entity.Move(groundMovement.Direction);
            if (groundMovement.GroundMovementType == 9)
            {
                client.Entity.Move(groundMovement.Direction);

            }
           
			
            client.SendScreen(groundMovement, true);
            client.Screen.Reload(groundMovement);
My Groundmovement
Code:
namespace JudeProject.Network.GamePackets
{
    using JudeProject;
    using JudeProject.Client;
    using JudeProject.Game;
    using JudeProject.Interfaces;
    using JudeProject.Network;
    using System;

    public class GroundMovement : Writer, IPacket
    {
        private byte[] Buffer;
        public const uint Run = 1;
        public const uint TwoCoordonates = 9;
        public const uint Walk = 0;

        public GroundMovement(bool CreateInstance)
        {
            if (CreateInstance)
            {
                this.Buffer = new byte[32];
                Writer.WriteUInt32(24, 0, this.Buffer);
                Writer.WriteUInt32(10005, 2, this.Buffer);
            }
        }

        public void Deserialize(byte[] buffer)
        {
            this.Buffer = buffer;
        }

        public void Send(GameState client)
        {
            client.Send(this.Buffer);
        }

        public byte[] ToArray()
        {
            return this.Buffer;
        }

        public Enums.ConquerAngle Direction
        {
            get
            {
                return (Enums.ConquerAngle)((byte)(this.Buffer[4] % 8));
            }
            set
            {
                this.Buffer[4] = (byte)value;
            }
        }
       

        public uint GroundMovementType
        {
            get
            {
                return JudeProject.BitConverter.ToUInt32(this.Buffer, 12);
            }
            set
            {
                Writer.WriteUInt32(value, 12, this.Buffer);
            }
        }

        public uint MapID
        {
            get
            {
                return JudeProject.BitConverter.ToUInt32(this.Buffer, 20);
            }
            set
            {
                Writer.WriteUInt32(value, 20, this.Buffer);
            }
        }

        public uint TimeStamp
        {
            get
            {
                return JudeProject.BitConverter.ToUInt32(this.Buffer, 0x10);
            }
            set
            {
                Writer.WriteUInt32(value, 0x10, this.Buffer);
            }
        }

        public uint UID
        {
            get
            {
                return JudeProject.BitConverter.ToUInt32(this.Buffer, 8);
            }
            set
            {
                Writer.WriteUInt32(value, 8, this.Buffer);
            }
        }
    }
}
my movement angle
Code:
public enum ConquerAngle : byte
        {
			East = 5,
            North = 3,
            NorthEast = 4,
            NorthWest = 2,
            South = 7,
            SouthEast = 6,
            SouthWest = 0,
            West = 1
}
how do i fix my walking problem? does anyone know how? thanks
my bad for duplicating threads.
07/14/2013 09:40 pro4never#2
Your walk code is incorrect for steed mode.

Code:
 dir = (int) receive.Direction % 24;
                                        newX = user.X + Common.DeltaMountX[dir];
                                        newY = user.Y + Common.DeltaMountY[dir];
Where delta mount x/y are
Code:
    DeltaMountX = new sbyte[] { 0, -2, -2, -2, 0, 2, 2, 2, 1, 0, -2, 0, 1, 0, 2, 0, 0, -2, 0, -1, 0, 2, 0, 1, 0 };
            DeltaMountY = new sbyte[] { 2, 2, 0, -2, -2, -2, 0, 2, 2, 0, -1, 0, -2, 0, 1, 0, 0, 1, 0, -2, 0, -1, 0, 2, 0 };
07/15/2013 06:57 pounder#3
Quote:
Originally Posted by pro4never View Post
Your walk code is incorrect for steed mode.

Code:
 dir = (int) receive.Direction % 24;
                                        newX = user.X + Common.DeltaMountX[dir];
                                        newY = user.Y + Common.DeltaMountY[dir];
Where delta mount x/y are
Code:
    DeltaMountX = new sbyte[] { 0, -2, -2, -2, 0, 2, 2, 2, 1, 0, -2, 0, 1, 0, 2, 0, 0, -2, 0, -1, 0, 2, 0, 1, 0 };
            DeltaMountY = new sbyte[] { 2, 2, 0, -2, -2, -2, 0, 2, 2, 0, -1, 0, -2, 0, 1, 0, 0, 1, 0, -2, 0, -1, 0, 2, 0 };

would you mind telling me in what file should i change it?
07/15/2013 07:35 pro4never#4
I explained one way to handle walking. You need to re-write your walking handler to behave in a similar fashion.
07/15/2013 08:16 Spirited#5
It might not help with your case, but it might help the majority of members wondering where Chris's logic comes from. Below was the diagram I created to figure it out (back in the day). It might also help the next person who wants to help you locate where the code is in your source to change. Cheers.

[Only registered and activated users can see links. Click Here To Register...]
07/15/2013 08:18 pounder#6
Quote:
Originally Posted by pro4never View Post
I explained one way to handle walking. You need to re-write your walking handler to behave in a similar fashion.
is this right sir pro?
Code:
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JudeProject.Game
{
    
	
	public class Misc
    {
        public static bool ChanceSuccess(double percent)
        {
            return ((percent * 10000.0) >= Program.Random.Next(0xf4240));
        }
        private static sbyte[] _walkXCoords = new sbyte[8] { 0, -1, -1, -1, 0, 1, 1, 1 };
        private static sbyte[] _walkYCoords = new sbyte[8] { 1, 1, 0, -1, -1, -1, 0, 1 };
        private static sbyte[] _rideXCoords = new sbyte[24] { 0, -2, -2, -2, 0, 2, 2, 2, -1, -2, -2, -1, 1, 2, 2, 1, -1, -2, -2, -1, 1, 2, 2, 1 };
        private static sbyte[] _rideYCoords = new sbyte[24] { 2, 2, 0, -2, -2, -2, 0, 2, 2, 1, -1, -2, -2, -1, 1, 2, 2, 1, -1, -2, -2, -1, 1, 2 };
		

        static Misc()
        {
        }

        public static int JumpSpeed(int distance, ushort movespeed = (ushort) 400)
        {
            return (int)Math.Floor((double)movespeed * Math.Floor((double)distance / 10.0));
        }

        public static int Distance(ushort x, ushort y, ushort x2, ushort y2)
        {
            return Math.Max(Math.Abs((int)x - (int)x2), Math.Abs((int)y - (int)y2));
        }

        public static byte Angle(ushort x, ushort y, ushort x2, ushort y2)
        {
            return (byte)((uint)(byte)(7.0 - Math.Floor(Misc.PointDirecton((double)x, (double)y, (double)x2, (double)y2) / 45.0 % 8.0) - 1.0) % 8U);
        }

        public static double PointDirecton(double x1, double y1, double x2, double y2)
        {
            double x = x2 - x1;
            double num = Math.Atan2(y2 - y1, x);
            if (num < 0.0)
                num += 2.0 * Math.PI;
            return Math.Ceiling(360.0 - num * 180.0 / Math.PI);
        }


        public static void IncXY(byte Facing, ref ushort x, ref ushort y, bool Riding = false)
        {
            sbyte num1;
            sbyte num2;
            if (!Riding)
            {
                num1 = Misc._walkXCoords[(int)Facing % 8];
                num2 = Misc._walkYCoords[(int)Facing % 8];
            }
            else
            {
                num1 = Misc._rideXCoords[(int)Facing % 24];
                num2 = Misc._rideYCoords[(int)Facing % 24];
            }
            x = (ushort)((uint)x + (uint)num1);
            y = (ushort)((uint)y + (uint)num2);
        }


    }
}
07/15/2013 08:18 pro4never#7
Quote:
Originally Posted by Fаng View Post
Old reference I made a year ago:

[Only registered and activated users can see links. Click Here To Register...]
good reference to have as I feel like I copied my post out of an incomplete/old source that has some wrong values ahaha.
07/16/2013 01:29 pounder#8
Quote:
Originally Posted by pro4never View Post
good reference to have as I feel like I copied my post out of an incomplete/old source that has some wrong values ahaha.
Code:
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JudeProject.Game
{
    
	
	public class Misc
    {
        public static bool ChanceSuccess(double percent)
        {
            return ((percent * 10000.0) >= Program.Random.Next(0xf4240));
        }
        private static sbyte[] _walkXCoords = new sbyte[8] { 0, -1, -1, -1, 0, 1, 1, 1 };
        private static sbyte[] _walkYCoords = new sbyte[8] { 1, 1, 0, -1, -1, -1, 0, 1 };
        private static sbyte[] _rideXCoords = new sbyte[24] { 0, -2, -2, -2, 0, 2, 2, 2, -1, -2, -2, -1, 1, 2, 2, 1, -1, -2, -2, -1, 1, 2, 2, 1 };
        private static sbyte[] _rideYCoords = new sbyte[24] { 2, 2, 0, -2, -2, -2, 0, 2, 2, 1, -1, -2, -2, -1, 1, 2, 2, 1, -1, -2, -2, -1, 1, 2 };
		

        static Misc()
        {
        }

        public static int JumpSpeed(int distance, ushort movespeed = (ushort) 400)
        {
            return (int)Math.Floor((double)movespeed * Math.Floor((double)distance / 10.0));
        }

        public static int Distance(ushort x, ushort y, ushort x2, ushort y2)
        {
            return Math.Max(Math.Abs((int)x - (int)x2), Math.Abs((int)y - (int)y2));
        }

        public static byte Angle(ushort x, ushort y, ushort x2, ushort y2)
        {
            return (byte)((uint)(byte)(7.0 - Math.Floor(Misc.PointDirecton((double)x, (double)y, (double)x2, (double)y2) / 45.0 % 8.0) - 1.0) % 8U);
        }

        public static double PointDirecton(double x1, double y1, double x2, double y2)
        {
            double x = x2 - x1;
            double num = Math.Atan2(y2 - y1, x);
            if (num < 0.0)
                num += 2.0 * Math.PI;
            return Math.Ceiling(360.0 - num * 180.0 / Math.PI);
        }


        public static void IncXY(byte Facing, ref ushort x, ref ushort y, bool Riding = false)
        {
            sbyte num1;
            sbyte num2;
            if (!Riding)
            {
                num1 = Misc._walkXCoords[(int)Facing % 8];
                num2 = Misc._walkYCoords[(int)Facing % 8];
            }
            else
            {
                num1 = Misc._rideXCoords[(int)Facing % 24];
                num2 = Misc._rideYCoords[(int)Facing % 24];
            }
            x = (ushort)((uint)x + (uint)num1);
            y = (ushort)((uint)y + (uint)num2);
        }


    }
}
it still doesnt work..
07/27/2013 18:29 pounder#9
BUMP
08/09/2013 06:45 pounder#10
BUMP
08/09/2013 08:25 Spirited#11
Quote:
Originally Posted by pounder View Post
BUMP
Why exactly are you bumping this? All of the answers for how this feature works has been posted above. What exactly do you need that hasn't been posted already? You posted the implementation.
08/09/2013 14:01 Super Aids#12
Code:
/// <summary>
		/// Handles the movement packet.
		/// </summary>
		/// <param name="client">The client.</param>
		/// <param name="packet">The packet.</param>
		public static void Handle(Entities.GameClient client, DataPacket packet)
		{
			client.Action = Enums.ActionType.None;
			client.AttackPacket = null;
			client.LastMoveJump = false;
			using (var move = new MovementPacket(packet))
			{
				if (move.EntityUID != client.EntityUID)
					return;
				
				int NewX = 0, NewY = 0;
				int NewDir = 0;
				switch (move.WalkMode)
				{
					case Enums.WalkMode.Run:
					case Enums.WalkMode.Walk:
						{
							NewDir = (int)move.Direction % 8;
							NewX = client.X + DeltaX[NewDir];
							NewY = client.Y + DeltaY[NewDir];
							break;
						}
					case Enums.WalkMode.Mount:
						{
							NewDir = (int)move.Direction % 24;
							NewX = client.X + DeltaMountX[NewDir];
							NewY = client.Y + DeltaMountY[NewDir];
							break;
						}
				}
				
				if (client.Map.ValidCoord(NewX, NewY))
				{
					client.LastMovement = DateTime.Now;
					client.X = (ushort)NewX;
					client.Y = (ushort)NewY;
					client.Direction = (byte)NewDir;
					client.SendToScreen(move, true);
				}
			}
		}