Page 1 of 1
Packets
Posted: Tue Jan 05, 2010 3:45 pm
by Tharon
Hallo, I want to move a player. I have to handle with packet 0x97, but how can I use this Information:
Code: Select all
Packet Name: Move Player
Packet: 0x97
Sent By: Client
Size: 2 Bytes
Packet Build
BYTE[1] cmd
BYTE[1] direction
Subcommand Build
N/A
Notes
N/A
Re: Packets
Posted: Tue Jan 05, 2010 4:31 pm
by phao
Hi dude.
I've never worked much with packets, but I did it once one year ago or so.
I don't know how you can use this, but there are some configurations you must do in order to use a packet.
In the main folder of your pol, you'll find a file called packets.txt or something similar. Read that file and you'll learn how to use it.
But, basically, you have to set the second byte of this packet to be the integer that specifies a direction.
If I recall correctly it's
1, southwest
2, south
3, southeast
6, east
9, northeast
8, north
7, northwest
4, west
I may be confusing those numbers with facing related stuff.
Start with what I've told you. Test those things and see what you get. After that you'll have an idea of where to go.
Re: Packets
Posted: Wed Jan 06, 2010 11:08 pm
by CWO
Are you trying to get a script to move a player? Because according to the info, this is sent by the client, not the server so this will have no effect if you try to send it from a script.
Re: Packets
Posted: Thu Jan 07, 2010 4:14 am
by Tharon
Yes i try it, but if I use MoveObjectToLocation I can not see the animation. I am facing the char to the way I move. But other player see the animation!
Re: Packets
Posted: Sat Jan 09, 2010 2:21 am
by CWO
There is no way I know of to forcefully move a person and have them see the animation.
Re: Packets
Posted: Sat Jan 09, 2010 6:34 am
by Tharon
I could move a npc with the graphic of a player and teleport the player(MoveObjectToLocation an invis- graphic) to the walking npc.
But I do not know how to move a npc

. I have to do this in the AI, but i do not realy know how it works
I try it with pathfindig( not in the ai) and the the npc walks, but he only walks and i want that he runs. I changed the speed in the npcdesc.cfg, but it has no effect.
Re: Packets
Posted: Sat Jan 09, 2010 6:39 am
by CWO
RunTowardLocation makes it walk?
Re: Packets
Posted: Sat Jan 09, 2010 8:21 am
by Tharon
I script it not in the ai, because i do not no how to do that. I do it as a command:
Code: Select all
program test(who)
SendSysMessage (who, "Welches Tier soll bewegt werden?");
var npc:= Target(who);
SendSysMessage (who, "Wohin das Tier bewegen?");
var tgt := target (who);
if (tgt != 0)
var skirt := -1;
var path;
repeat
skirt := skirt + 1;
path := FindPath (npc.x, npc.y, npc.z, tgt.x, tgt.y, tgt.z, _DEFAULT_REALM, FP_IGNORE_MOBILES, skirt);
until (skirt >= 20 || path != error);
if (path != error)
var pathElem;
var oldX := who.x;
var oldY := who.y;
var oldZ := who.z;
PrintTextAbove (who, who.x + ":" + who.y + ":" + who.z + " -> " + tgt.x + ":" + tgt.y + ":" + tgt.z + ", required skirt: " + skirt);
foreach pathElem in path
MoveObjectToLocation (npc, pathElem.x, pathElem.y, pathElem.z, _DEFAULT_REALM, MOVEOBJECT_FORCELOCATION);
sleepms (300);
endforeach
MoveObjectToLocation (npc, oldX, oldY, oldZ, _DEFAULT_REALM, MOVEOBJECT_FORCELOCATION);
else
SendSysMessage (who, "no path found from " + who.x + ":" + who.y + ":" + who.z + " to " + tgt.x + ":" + tgt.y + ":" + tgt.z);
SendSysMessage (who, "Reason: " + path);
endif
endif
endprogram
Re: Packets
Posted: Sat Jan 09, 2010 9:16 am
by *Edwards
Find FantasiaShard-7.0 project download and take a look in pkg/system/brainAI/include/movement.inc. You will get working version of pathfinding if it's your goal... I don't really get the idea you want to use... but sure you won't need to work with the movement packet posted above... You already have a lot of core functions to handle any kind of situations..
Re: Packets
Posted: Sun Jan 10, 2010 7:20 am
by CWO
Now that I ran the sysmessages through the translator I can tell what you're trying to do. ("which animal do you want to move", "where do you want to move it") This is actually done by events in the NPC's AI. You would have a custom event set up in the AI script then in the command you're making, send that event to the AI script. This way you get the full AI capabilities of npc.em.
This is just a rough outline but it would go something like this...
Code: Select all
program test(who)
SendSysMessage (who, "Welches Tier soll bewegt werden?");
var npc:= Target(who);
SendSysMessage (who, "Wohin das Tier bewegen?");
var tgt := target (who);
var event := struct{};
event.+type := "movecmd";
event.+x := tgt.x;
event.+y := tgt.y;
event.+z := tgt.z;
event.+realm := who.realm;
event.+source := who;
npc.process.sendevent(event);
endprogram
then in the NPC AI script (and includes), look around for wait_for_event
there should be a case(ev.type) or something like that after it. Append this code to the case statement:
Code: Select all
"movecmd":
path := FindPath (ev.x, ev.y, ev.z, ev.x, ev.y, ev.z, who.realm, FP_IGNORE_MOBILES, 20);
if (path)
foreach pathElem in path
RunTowardLocation (pathElem.x, pathElem.y)
sleepms (300);
endforeach
else
SendSysMessage (ev.source, "no path found from " + ev.source.x + ":" + ev.source.y + ":" + ev.source.z + " to " + ev.x + ":" + ev.y + ":" + ev.z);
SendSysMessage (ev.source, "Reason: " + path.errortext);
endif
Re: Packets
Posted: Sun Sep 19, 2010 10:38 am
by Tharon
CWO wrote:Are you trying to get a script to move a player? Because according to the info, this is sent by the client, not the server so this will have no effect if you try to send it from a script.
Packet Name: Move Player
Last Modified: 2010-02-04 01:29:27
Modified By: Turley
Packet: 0x97
Sent By: Server
Size: 2 Bytes
Packet Build
BYTE[1] cmd
BYTE[1] direction
Subcommand Build
N/A
Notes
N/A
Is it a mistake or can i do this now?

Re: Packets
Posted: Sun Sep 19, 2010 1:50 pm
by Tharon
Code: Select all
var movepacket:="9700";
SendPacket(who,movepacket);
It works, but the char do only one step and if i do a loop it looks bad
