Packets...

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Jasaka
New User
Posts: 9
Joined: Sun Feb 05, 2006 3:49 am

Packets...

Post by Jasaka »

I have a few questions... I started to playing with packets couple of days ago, and i don't understand enythink yet... So if you can, help me.

First thing is...

1. How do i get them? Which 'packet' logger will be the best for pol096 and new series of 5.x.x clients? (i used razor before)

2. How do i get offsets of interesting me things? Like here:

Code: Select all

Packet ID: 0xC0
Packet Name: Graphical Effect
Packet Size: 36 Bytes
Sent By: Server
Submitted: MuadDib

Packet Breakdown
BYTE[1] cmd
BYTE[1] type
BYTE[4] sourceSerial
BYTE[4] targetSerial
BYTE[2] itemID
BYTE[2] xSource
BYTE[2] ySource
BYTE[1] zSource
BYTE[2] xTarget
BYTE[2] yTarget
BYTE[1] zTarget
BYTE[1] speed
BYTE[1] duration
BYTE[2] unk // On OSI, flamestrikes are 0x0100
BYTE[1] fixedDirection
BYTE[1] explodes
BYTE[4] hue
BYTE[4] renderMode

Notes
Packet seems to work fine with even 2.0.0 clients
(from: www.lostsoulsshard.org)
I want to make a fireball animation hued in white color...

Code: Select all

var packet:=CreatePacket(0xC0,36);
  //packet.SetInt8(1,0x0); //cmd
  packet.SetInt32(2,caster.serial); //sourceSerial
  packet.SetInt32(3,cast_on.serial); //targetSerial
  packet.SetInt16(4,0x36D4); //itemID
  packet.SetInt16(5,caster.x); //xS
  packet.SetInt16(6,caster.y); //yS
  packet.SetInt8(7,caster.z); //zS
  packet.SetInt16(8,cast_on.x); //xT
  packet.SetInt16(9,cast_on.y); //yT
  packet.SetInt8(10,cast_on.z); //zT
  packet.SetInt8(11,0x5); //speed
  //packet.SetInt8(12,0x0); //duration
  //packet.SetInt8(13,cast_on.y); //unk
  //packet.SetInt16(14,0x0); //fixedD
  packet.SetInt8(15,0x1); //explodes
  //packet.SetInt32(16,0x482); //hue
  //packet.SetInt16(17,cast_on.y); //renderMode
  packet.SendPacket(caster);
And that doesn't work... Nothing shows on my screen :|
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Re: Packets...

Post by CWO »

Jasaka wrote:

Code: Select all

var packet:=CreatePacket(0xC0,36);
  //packet.SetInt8(1,0x0); //cmd
  packet.SetInt32(2,caster.serial); //sourceSerial
  packet.SetInt32(3,cast_on.serial); //targetSerial
  packet.SetInt16(4,0x36D4); //itemID
  packet.SetInt16(5,caster.x); //xS
  packet.SetInt16(6,caster.y); //yS
  packet.SetInt8(7,caster.z); //zS
  packet.SetInt16(8,cast_on.x); //xT
  packet.SetInt16(9,cast_on.y); //yT
  packet.SetInt8(10,cast_on.z); //zT
  packet.SetInt8(11,0x5); //speed
  //packet.SetInt8(12,0x0); //duration
  //packet.SetInt8(13,cast_on.y); //unk
  //packet.SetInt16(14,0x0); //fixedD
  packet.SetInt8(15,0x1); //explodes
  //packet.SetInt32(16,0x482); //hue
  //packet.SetInt16(17,cast_on.y); //renderMode
  packet.SendPacket(caster);
And that doesn't work... Nothing shows on my screen :|
Thats probably because your offsets are completely off.. (the first param you give to the SetInt*...)

My main example for you would be

packet.SetInt32(2,caster.serial); //sourceSerial
packet.SetInt32(3,cast_on.serial); //targetSerial

You set a 32 bit int on the second byte then another on the third byte. 32 bits is 4 bytes though.

Instead, you would have to set it this way
packet.SetInt32(2,caster.serial); //sourceSerial

Set that on the second byte (the 2 you passed.)

Now the next one should be

packet.SetInt32(6,cast_on.serial); //targetSerial

You set this to the 6th byte, not the third because the second, third, fourth, and fifth are taken by the last 32 bit Int you set (the source serial).

For Int8 you add 1, for Int16 you add 2, for Int32 you add 4.



Now for reading something like this off of MuadDib's site

Code: Select all

Packet Breakdown
BYTE[1] cmd
BYTE[1] type
BYTE[4] sourceSerial
BYTE[4] targetSerial
BYTE[2] itemID
BYTE[2] xSource
BYTE[2] ySource
BYTE[1] zSource
BYTE[2] xTarget
BYTE[2] yTarget
BYTE[1] zTarget
BYTE[1] speed
BYTE[1] duration
BYTE[2] unk // On OSI, flamestrikes are 0x0100
BYTE[1] fixedDirection
BYTE[1] explodes
BYTE[4] hue
BYTE[4] renderMode 
All you need to do is add the bytes up to find out where your next offset is going to be. Do not put cmd at number 1 though since its actually at number 0. Although if you're adding all of the bytes before one thing to get to the correct offset, you'll want it as your placeholder... Example... To get to ySource, You'll add 1 + 1 + 4 + 4 + 2 + 2 = 14.

1 - Type (8 bit int [or 1 byte])
2 - Source Serial (32 bit int [or 4 bytes])
6 - Target Serial (32 bit int [or 4 bytes])
10 - ItemID (16 bit int [or 2 bytes])
12 - xSource (16 bit int [or 2 bytes])
14 - ySource (16 bit int [or 2 bytes])
16 - zSource (8 bit int [or 1 byte])

and so on...
Danielle
Grandmaster Poster
Posts: 104
Joined: Tue Feb 07, 2006 3:32 pm

Post by Danielle »

All you need to do is add the bytes up to find out where your next offset is going to be. Do not put cmd at number 1 though since its actually at number 0. Although if you're adding all of the bytes before one thing to get to the correct offset, you'll want it as your placeholder... Example... To get to ySource, You'll add 1 + 1 + 4 + 4 + 2 + 2 = 14.
I'm not a programmer, just someone who happens to program.. :P .. but wouldn't you want to subtract 1 after, since offsets are 0-based?

So: (1 + 1 + 4 + 4 + 2 + 2) - 1 = 13
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

nope because that extra 1 is a placeholder. Of course its 0 based but if I said dont include the cmd in the math, that makes the first byte (the type) 0. But actually, the cmd is in the packet and its sitting at 0. Its more of trying to explain that if you're not worrying about the cmd because you have CreatePacket(), then its like a 1 based packet without the cmd in the beginning.
Jasaka
New User
Posts: 9
Joined: Sun Feb 05, 2006 3:49 am

Post by Jasaka »

Thank you CWO, that explain me everything (for now).
blah
New User
Posts: 12
Joined: Thu Feb 02, 2006 12:05 pm

Post by blah »

ppl ask for guides, tutorials or anything about packets.
and as the answer they got link to eg. MuadDib's packet guide which for pre-intermidiate escript users who don't know anything about packets (yet), is imo useless. Entry like the above doesn't explain anything at all..
But.
This topic, and any packethook found at custom scripts section explain a lot.
so i suggest: sticky it! :D
Post Reply