PenUltima Online

It is currently Sat Sep 06, 2008 7:50 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Packets...
PostPosted: Thu Mar 16, 2006 2:24 pm 
Offline

Joined: Sun Feb 05, 2006 3:49 am
Posts: 9
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:
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:
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 :|


Top
 Profile  
 
 Post subject: Re: Packets...
PostPosted: Thu Mar 16, 2006 2:44 pm 
Offline

Joined: Sat Feb 04, 2006 5:49 pm
Posts: 748
Location: Chicago, IL USA
Jasaka wrote:
Code:
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:
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...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 9:33 pm 
Offline

Joined: Tue Feb 07, 2006 3:32 pm
Posts: 97
Location: Pittsburgh, Pennsylvania
Quote:
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

_________________
Image
Image <-- 50% off setup fees! Use PromoCode "NIGHTSCAPE"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 9:58 pm 
Offline

Joined: Sat Feb 04, 2006 5:49 pm
Posts: 748
Location: Chicago, IL USA
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.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 17, 2006 4:12 am 
Offline

Joined: Sun Feb 05, 2006 3:49 am
Posts: 9
Thank you CWO, that explain me everything (for now).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 3:32 pm 
Offline

Joined: Thu Feb 02, 2006 12:05 pm
Posts: 12
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: OldnGrey and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl