Getting stuck on npc's

11/15/2013 17:03 hacksaw#1
Been messing with the impulse 5165 source and when mounted on a steed running around town you seem to get stuck when running near npc's causing screen to reload untill you try move somewhere else, occasionally happens when your close to a map boundary also. Anyone know what might be causing this issue?
11/15/2013 18:02 Super Aids#2
Check you screen system and how it updates.
11/15/2013 20:26 Spirited#3
For getting stuck on scenery, one of the problems might be that scene files are loaded in upside-down (they were when I reviewed his 5180 private source). With NPCs, it might be that the server is allocating more tiles around that NPC than it actually requires. Another problem with his source was that steeds were programmed incorrectly. They don't have just 8 directions in which they can move in.

Sorry about the quality, the picture is really old when I just started programming. It should be able to at least illustrate why it's 24 directions and how you can change your handler to work with this.
11/16/2013 00:46 hacksaw#4
Thanks diddnt know about those 3 things, You were right scene and steed directions were incorrect, Have sorted the 2 out but it hasent made a difference, The space allocated round an npc seems to be just 1 space all round them which is correct i think? Uploaded a small video showing both town npc sticking and then map boundary sticking.

11/16/2013 02:26 Spirited#5
Seeing your video now, I see that you're using the horse to walk around the NPCs. Your horse walking calculations are still wrong. What exactly are these fixes you made?
11/16/2013 17:17 hacksaw#6
Thanks Fang you were right, I re-looked over the fixes id made and noticed id missed something out, Works fine now.

For anyone else who needs help with it in future here is what i did:

In packethandler under ground movement i changed it to this:

Code:
if (groundMovement.GroundMovementType == GroundMovement.Steed)
    client.Entity.MoveSteed(groundMovement.Direction);
 else 
    client.Entity.Move(groundMovement.Direction);

And in Entity, Changed Move changed to this:

Code:
        public static sbyte[] XDir = new sbyte[] { 0, -1, -1, -1, 0, 1, 1, 1 };
        public static sbyte[] YDir = new sbyte[] { 1, 1, 0, -1, -1, -1, 0, 1 };
        public static sbyte[] XDirSteed = new sbyte[] { 0, -2, -2, -2, 0, 2, 2, 2, -1, -2, -2, -1, 1, 2, 2, 1, -1, -2, -2, -1, 1, 2, 2, 1 };
        public static sbyte[] YDirSteed = new sbyte[] { 2, 2, 0, -2, -2, -2, 0, 2, 2, 1, -1, -2, -2, -1, 1, 2, 2, 1, -1, -2, -2, -1, 1, 2 };


        public bool MoveSteed(Enums.ConquerAngle Direction)
        {
            ushort _X = X, _Y = Y;

            int dir = ((int)Direction) % XDirSteed.Length;
            Facing = Direction;
            sbyte xi = XDirSteed[dir], yi = YDirSteed[dir];
            _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])
                {
                    if (MapObjType == MapObjectType.Monster)
                    {
                        Map.Floor[_X, _Y, MapObjType] = false;
                        Map.Floor[X, Y, MapObjType] = 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;
        }



        public bool Move(Enums.ConquerAngle Direction)
        {
            ushort _X = X, _Y = Y;
            Facing = Direction;
            int dir = ((int)Direction) % XDir.Length;
            sbyte xi = XDir[dir], yi = YDir[dir];
            _X = (ushort)(X + xi);
            _Y = (ushort)(Y + yi);
            Game.Map Map = null;
            if (ServerBase.Kernel.Maps.TryGetValue(MapID, out Map))
            {
                var objType = MapObjType;
                if (Map.Floor[_X, _Y, objType])
                {
                    if (objType == MapObjectType.Monster)
                    {
                        Map.Floor[_X, _Y, MapObjType] = false;
                        Map.Floor[X, Y, MapObjType] = true;
                    }
                    X = _X;
                    Y = _Y;
                    return true;
                }
                else
                {
                    if (Mode == Enums.Mode.None)
                        if (EntityFlag != EntityFlag.Monster)
                            Teleport(MapID, X, Y);
                        else
                            return false;
                    return false;
                }
            }
            else
            {
                if (EntityFlag != EntityFlag.Monster)
                    Teleport(MapID, X, Y);
                else
                    return false;
            }
            return true;
        }
And in GroundMovement under gamepackets change the directon packet to:

Code:
 public Game.Enums.ConquerAngle Direction
 {
     get { return (Game.Enums.ConquerAngle)(Buffer[4] % 24); }
     set { Buffer[4] = (byte)value; }
}
11/16/2013 19:53 Spirited#7
It's not perfect, but it should fix those errors to some extent. Good job. :p