Packets

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Tharon
Novice Poster
Posts: 44
Joined: Fri May 15, 2009 2:27 am

Packets

Post 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
phao
Grandmaster Poster
Posts: 129
Joined: Fri Aug 31, 2007 2:25 pm

Re: Packets

Post 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.
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Re: Packets

Post 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.

Code: Select all

Sent By: Client
Tharon
Novice Poster
Posts: 44
Joined: Fri May 15, 2009 2:27 am

Re: Packets

Post 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!
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Re: Packets

Post by CWO »

There is no way I know of to forcefully move a person and have them see the animation.
Tharon
Novice Poster
Posts: 44
Joined: Fri May 15, 2009 2:27 am

Re: Packets

Post 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.
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Re: Packets

Post by CWO »

RunTowardLocation makes it walk?
Tharon
Novice Poster
Posts: 44
Joined: Fri May 15, 2009 2:27 am

Re: Packets

Post 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
User avatar
*Edwards
Forum Regular
Posts: 303
Joined: Fri Dec 28, 2007 11:19 pm

Re: Packets

Post 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..
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Re: Packets

Post 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
Tharon
Novice Poster
Posts: 44
Joined: Fri May 15, 2009 2:27 am

Re: Packets

Post 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.

Code: Select all

Sent By: Client
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? :)
Tharon
Novice Poster
Posts: 44
Joined: Fri May 15, 2009 2:27 am

Re: Packets

Post 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 :(
Post Reply