Mobspeed?

05/07/2010 10:08 NeoN[PM]#1
There is no1 looking at my last post about changing mobspeed, well like 1 each day :s weird..


Well to the problem..


The mobs (ALL mobs) walk very slow. Like when you have walk mode with your character, i changed mobspeed in both mobinfo.txt and mob.cs but still no change =/

Can someone help me? :)
05/08/2010 07:26 -Spirits-#2
BUMP. SOMEONE PLEASE HELP US SOLVE THIS.
THIS IS DRIVING ME CRAZY TOO.
05/08/2010 07:41 DarkMessiah#3
i've only just started coding my private server, but if i remember correctly, there's a speed byte in the packet for entity movement. (0 = walk, 1 = run)
05/08/2010 13:16 Korvacs#4
Yeah, the movement packet has a bool in it at offset 9.

Its all on the wiki you know?
05/08/2010 14:10 NeoN[PM]#5
Quote:
Originally Posted by Korvacs View Post
Yeah, the movement packet has a bool in it at offset 9.

Its all on the wiki you know?

And thats mean?

Sorry im not a supercoder ^^

Can you tell me what to do please? :)
05/08/2010 16:45 -Spirits-#6
EntityMove doesn't exist.
This is what 5165 has:
Code:
public static COPacket Movement(uint UID, byte Dir)
        {
            byte[] Packet = new byte[8 + 16];
            COPacket P = new COPacket(Packet);

            P.WriteInt16((ushort)(Packet.Length - 8));
            P.WriteInt16((ushort)10005);
            P.WriteInt32((byte)(Dir + 8 * Program.Rnd.Next(7)));
            P.WriteInt32(UID);            
            P.WriteInt32((uint)Environment.TickCount);

            return P;
        }
This is the mob movement problem...
It's highlighted in red
Code:
#region Player Target
                    if (PlayerTarget != null && (PlayerTarget.CanBeMeleed || AtkType != AttackType.Melee) && PlayerTarget.Alive && PlayerTarget.MyClient != null && MyMath.PointDistance(Loc.X, Loc.Y, PlayerTarget.Loc.X, PlayerTarget.Loc.Y) < Math.Max(15, (int)AttackDist) && (Type != MobBehaveour.HuntMobsAndBlue || PlayerTarget.BlueName))
                    {
                        if (MyMath.PointDistance(Loc.X, Loc.Y, PlayerTarget.Loc.X, PlayerTarget.Loc.Y) >= AttackDist)
                        {
                            byte ToDir = (byte)(7 - (Math.Floor(MyMath.PointDirecton(Loc.X, Loc.Y, PlayerTarget.Loc.X, PlayerTarget.Loc.Y) / 45 % 8)) - 1 % 8);
                            Direction = (byte)((int)ToDir % 8);

                            Location eLoc = Loc;
                            eLoc.Walk(Direction);
                            System.Collections.Hashtable H = (System.Collections.Hashtable)World.H_Mobs[Loc.Map];
                            bool PlaceFree = true;
                            if (DMaps.Loaded)
                            {
                                if (((DMap)DMaps.H_DMaps[Loc.Map]).GetCell(eLoc.X, eLoc.Y).NoAccess) PlaceFree = false;

                            }

                            foreach (Mob M in H.Values)
                                if (M != this && M.Loc.X == eLoc.X && M.Loc.Y == eLoc.Y && M.Alive)
                                {
                                    PlaceFree = false;
                                    break;
                                }
                            if (PlaceFree)
                            {
                                World.Action(this, Packets.Movement(EntityID, Direction).Get);
                                World.Spawn(this, true);
                                Loc.Walk(Direction);
                            }
                            else
                            {
                                for (int i = 0; i < 7; i++)
                                {
                                    PlaceFree = true;
                                    eLoc = Loc;
                                    Direction = (byte)((Direction + 1) % 8);
                                    eLoc.Walk(Direction);

                                    if (DMaps.Loaded)
                                        if (((DMap)DMaps.H_DMaps[Loc.Map]).GetCell(eLoc.X, eLoc.Y).NoAccess) PlaceFree = false;

                                    foreach (Mob M in H.Values)
                                        if (M != this && M.Loc.X == eLoc.X && M.Loc.Y == eLoc.Y && M.Alive)
                                        {
                                            PlaceFree = false;
                                            break;
                                        }
                                    [COLOR="Red"]if (PlaceFree)
                                    {
                                        World.Action(this, Packets.Movement(EntityID, Direction).Get);
                                        World.Spawn(this, true);
                                        Loc.Walk(Direction);
                                        break;
                                    }[/COLOR]
                                }
                            }
                        }
                        else
                        {
                            if (MyMath.ChanceSuccess(15) || Type == MobBehaveour.HuntMobsAndBlue)
                                PlayerTarget.TakeAttack(this, PrepareAttack(), AtkType);
                            else
                                PlayerTarget.TakeAttack(this, 0, AtkType);
                        }
                    }
                    else PlayerTarget = null;
                    #endregion
that's how they move.
If you double the code, the mob will walk twice in a row.
I'm still working on it running.

EDIT:
It's also here:
Code:
if (Alive && DateTime.Now > LastMove.AddMilliseconds(1000))
                {
                    LastMove = DateTime.Now;
                    if ((Type == MobBehaveour.HuntPlayers || Type == MobBehaveour.HuntMobsAndBlue) && PlayerTarget == null && MobTarget == null)
                    {
                        byte NDist = 10; // Distance they can see you by
                        byte MaxDist = 10;
                        foreach (Character C in World.H_Chars.Values)
                        {
                            if (C.Loc.Map == Loc.Map)
                            {
                                if (C.Alive)
                                {
                                    if (C.CanBeMeleed || AtkType != AttackType.Melee)
                                    {
                                        byte Dst = (byte)MyMath.PointDistance(Loc.X, Loc.Y, C.Loc.X, C.Loc.Y);
                                        if (Dst <= MaxDist && Dst < NDist)
                                        {
                                            if (Type != MobBehaveour.HuntMobsAndBlue || C.BlueName)
                                            {
                                                NDist = (byte)MyMath.PointDistance(Loc.X, Loc.Y, C.Loc.X, C.Loc.Y);
                                                PlayerTarget = C;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
05/08/2010 18:58 NeoN[PM]#7
Quote:
Originally Posted by -Spirits- View Post
EntityMove doesn't exist.
This is what 5165 has:
Code:
public static COPacket Movement(uint UID, byte Dir)
        {
            byte[] Packet = new byte[8 + 16];
            COPacket P = new COPacket(Packet);

            P.WriteInt16((ushort)(Packet.Length - 8));
            P.WriteInt16((ushort)10005);
            P.WriteInt32((byte)(Dir + 8 * Program.Rnd.Next(7)));
            P.WriteInt32(UID);            
            P.WriteInt32((uint)Environment.TickCount);

            return P;
        }
This is the mob movement problem...
It's highlighted in red
Code:
#region Player Target
                    if (PlayerTarget != null && (PlayerTarget.CanBeMeleed || AtkType != AttackType.Melee) && PlayerTarget.Alive && PlayerTarget.MyClient != null && MyMath.PointDistance(Loc.X, Loc.Y, PlayerTarget.Loc.X, PlayerTarget.Loc.Y) < Math.Max(15, (int)AttackDist) && (Type != MobBehaveour.HuntMobsAndBlue || PlayerTarget.BlueName))
                    {
                        if (MyMath.PointDistance(Loc.X, Loc.Y, PlayerTarget.Loc.X, PlayerTarget.Loc.Y) >= AttackDist)
                        {
                            byte ToDir = (byte)(7 - (Math.Floor(MyMath.PointDirecton(Loc.X, Loc.Y, PlayerTarget.Loc.X, PlayerTarget.Loc.Y) / 45 % 8)) - 1 % 8);
                            Direction = (byte)((int)ToDir % 8);

                            Location eLoc = Loc;
                            eLoc.Walk(Direction);
                            System.Collections.Hashtable H = (System.Collections.Hashtable)World.H_Mobs[Loc.Map];
                            bool PlaceFree = true;
                            if (DMaps.Loaded)
                            {
                                if (((DMap)DMaps.H_DMaps[Loc.Map]).GetCell(eLoc.X, eLoc.Y).NoAccess) PlaceFree = false;

                            }

                            foreach (Mob M in H.Values)
                                if (M != this && M.Loc.X == eLoc.X && M.Loc.Y == eLoc.Y && M.Alive)
                                {
                                    PlaceFree = false;
                                    break;
                                }
                            if (PlaceFree)
                            {
                                World.Action(this, Packets.Movement(EntityID, Direction).Get);
                                World.Spawn(this, true);
                                Loc.Walk(Direction);
                            }
                            else
                            {
                                for (int i = 0; i < 7; i++)
                                {
                                    PlaceFree = true;
                                    eLoc = Loc;
                                    Direction = (byte)((Direction + 1) % 8);
                                    eLoc.Walk(Direction);

                                    if (DMaps.Loaded)
                                        if (((DMap)DMaps.H_DMaps[Loc.Map]).GetCell(eLoc.X, eLoc.Y).NoAccess) PlaceFree = false;

                                    foreach (Mob M in H.Values)
                                        if (M != this && M.Loc.X == eLoc.X && M.Loc.Y == eLoc.Y && M.Alive)
                                        {
                                            PlaceFree = false;
                                            break;
                                        }
                                    [COLOR="Red"]if (PlaceFree)
                                    {
                                        World.Action(this, Packets.Movement(EntityID, Direction).Get);
                                        World.Spawn(this, true);
                                        Loc.Walk(Direction);
                                        break;
                                    }[/COLOR]
                                }
                            }
                        }
                        else
                        {
                            if (MyMath.ChanceSuccess(15) || Type == MobBehaveour.HuntMobsAndBlue)
                                PlayerTarget.TakeAttack(this, PrepareAttack(), AtkType);
                            else
                                PlayerTarget.TakeAttack(this, 0, AtkType);
                        }
                    }
                    else PlayerTarget = null;
                    #endregion
that's how they move.
If you double the code, the mob will walk twice in a row.
I'm still working on it running.

EDIT:
It's also here:
Code:
if (Alive && DateTime.Now > LastMove.AddMilliseconds(1000))
                {
                    LastMove = DateTime.Now;
                    if ((Type == MobBehaveour.HuntPlayers || Type == MobBehaveour.HuntMobsAndBlue) && PlayerTarget == null && MobTarget == null)
                    {
                        byte NDist = 10; // Distance they can see you by
                        byte MaxDist = 10;
                        foreach (Character C in World.H_Chars.Values)
                        {
                            if (C.Loc.Map == Loc.Map)
                            {
                                if (C.Alive)
                                {
                                    if (C.CanBeMeleed || AtkType != AttackType.Melee)
                                    {
                                        byte Dst = (byte)MyMath.PointDistance(Loc.X, Loc.Y, C.Loc.X, C.Loc.Y);
                                        if (Dst <= MaxDist && Dst < NDist)
                                        {
                                            if (Type != MobBehaveour.HuntMobsAndBlue || C.BlueName)
                                            {
                                                NDist = (byte)MyMath.PointDistance(Loc.X, Loc.Y, C.Loc.X, C.Loc.Y);
                                                PlayerTarget = C;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
Yeah, double the code makes the mob lag forward once they move :p
But actually, the running problem is it somewhere in mob.cs or? ^^

Ya im working on it too
05/08/2010 19:20 -Spirits-#8
Quote:
Originally Posted by NeoN[PM] View Post
Yeah, double the code makes the mob lag forward once they move :p
But actually, the running problem is it somewhere in mob.cs or? ^^

Ya im working on it too
No, i think it's the packet.
I have no idea tho.
I'm looking into it. =[
05/08/2010 23:36 Korvacs#9
[Only registered and activated users can see links. Click Here To Register...]

All on there.
05/09/2010 01:05 NeoN[PM]#10
Quote:
Originally Posted by Korvacs View Post
[Only registered and activated users can see links. Click Here To Register...]

All on there.

Like i said, im not a super coder and i have no clue what i am supposed to do with that packet_entitymove thingy :p

Would you like to help? :)
05/09/2010 02:49 -Spirits-#11
Quote:
Originally Posted by Korvacs View Post
[Only registered and activated users can see links. Click Here To Register...]

All on there.
You know I'm trying to learn how to create packets right now.
If you would help me make my weather packet and explain to me why the values are such that in the code then maybe I could help other people?
05/09/2010 13:01 Korvacs#12
Alright heres your standard Entity Movement Packet:

Code:
public static COPacket Movement(uint UID, byte Dir)
        {
            byte[] Packet = new byte[8 + 16];
            COPacket P = new COPacket(Packet);

            P.WriteInt16((ushort)(Packet.Length - 8));
            P.WriteInt16((ushort)10005);
            P.WriteInt32((byte)(Dir + 8 * Program.Rnd.Next(7)));
            P.WriteInt32(UID);            
            P.WriteInt32((uint)Environment.TickCount);

            return P;
        }
What you basically need to do is to modify the packet so that you can optionally make the mob walk or run, please note that making this change will require alot of changes to the source wherever this packet is created.

Code:
public static COPacket Movement(uint UID, byte Dir, bool Running)
        {
            byte[] Packet = new byte[8 + 16];
            COPacket P = new COPacket(Packet);

            P.WriteInt16((ushort)(Packet.Length - 8));
            P.WriteInt16((ushort)10005);
            P.WriteByte((byte)(Dir + 8 * Program.Rnd.Next(7)));
            P.WriteByte((byte)Running ? 0 : 1);
            P.WriteInt32(UID);            
            P.WriteInt32((uint)Environment.TickCount);

            return P;
        }
Ok so what ive done is ive added a bool which allows you to set if the entity is running or walking, the ? 0 : 1 basically says that the value will be converted to either 0 or 1 depending on if the bool is true or false.

It turns out that the 5165 movement packet is different from the 5100 packet, so ill have to make changes to the wiki to reflect that.

As for learning packet structures i created a page on the wiki about understand what an offset is, and that should hopefully help you to understand how packets are layed out the way they are:

[Only registered and activated users can see links. Click Here To Register...]
05/09/2010 14:18 NeoN[PM]#13
Quote:
Originally Posted by Korvacs View Post
Alright heres your standard Entity Movement Packet:

Code:
public static COPacket Movement(uint UID, byte Dir)
        {
            byte[] Packet = new byte[8 + 16];
            COPacket P = new COPacket(Packet);

            P.WriteInt16((ushort)(Packet.Length - 8));
            P.WriteInt16((ushort)10005);
            P.WriteInt32((byte)(Dir + 8 * Program.Rnd.Next(7)));
            P.WriteInt32(UID);            
            P.WriteInt32((uint)Environment.TickCount);

            return P;
        }
What you basically need to do is to modify the packet so that you can optionally make the mob walk or run, please note that making this change will require alot of changes to the source wherever this packet is created.

Code:
public static COPacket Movement(uint UID, byte Dir, bool Running)
        {
            byte[] Packet = new byte[8 + 16];
            COPacket P = new COPacket(Packet);

            P.WriteInt16((ushort)(Packet.Length - 8));
            P.WriteInt16((ushort)10005);
            P.WriteByte((byte)(Dir + 8 * Program.Rnd.Next(7)));
            P.WriteByte((byte)Running ? 0 : 1);
            P.WriteInt32(UID);            
            P.WriteInt32((uint)Environment.TickCount);

            return P;
        }
Ok so what ive done is ive added a bool which allows you to set if the entity is running or walking, the ? 0 : 1 basically says that the value will be converted to either 0 or 1 depending on if the bool is true or false.

It turns out that the 5165 movement packet is different from the 5100 packet, so ill have to make changes to the wiki to reflect that.

As for learning packet structures i created a page on the wiki about understand what an offset is, and that should hopefully help you to understand how packets are layed out the way they are:

[Only registered and activated users can see links. Click Here To Register...]
Sweet thank you :)


Edit: Still have no clue :o
05/09/2010 22:35 -Spirits-#14
Don't you mean ..
Code:
public static COPacket Movement(uint UID, byte Dir, byte Running)
        {
            byte[] Packet = new byte[8 + 16];
            COPacket P = new COPacket(Packet);

            P.WriteInt16((ushort)(Packet.Length - 8));
            P.WriteInt16((ushort)10005);
            P.WriteByte((byte)(Dir + 8 * Program.Rnd.Next(7)));
            P.WriteByte((byte)Running);
            P.WriteInt32(UID);
            P.WriteInt32((uint)Environment.TickCount);

            return P;
        }
?

And how the hell does it see Running and make it run?
I don't get how that's supposed to work at all.
05/10/2010 00:43 Korvacs#15
The TQ official packet has a slot for a running bool, the client picks it up and shows either a mob walking, or a mob running, the same is true of when a character moves.

The packet in the 5165 source just didnt include it.

And no i meant for it to be a bool, so that you can go:

Code:
new Movement(1000001, 2, true);