PenUltima Online

It is currently Sat Aug 30, 2008 5:33 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: How to get speech from 0xAD packet
PostPosted: Sun Apr 08, 2007 9:00 pm 
Offline

Joined: Thu Jan 18, 2007 2:34 am
Posts: 91
Can anyone explain where the characters input is in this packet and how to convert it to text i can read?

I just cant get my head around this packet :/ An example would be ideal. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 08, 2007 9:20 pm 
Offline

Joined: Sat Feb 04, 2006 5:49 pm
Posts: 745
Location: Chicago, IL USA
Its a pain to get text from this because it all depends on if they have speech.mul or not and if so, how many tokens from speech.mul they're using. If GetInt8(3) != 0xC0 then its at offset 12 as a Unicode string.

if GetInt8(3) == 0xC0 then...
the number of speech.mul triggers is the last 4 BITS of GetInt8(12) and the first 4 bits of GetInt8(13) the last 4 bits of 13 is 1/3 of the first trigger. Each trigger is 1 1/2 bytes.

Not gonna guarantee this code since I tested it only a little bit but it would be something like...
Code:
   var speech := "";
   var speechstart := 12;
   if (packet.GetInt8(3) == 0xC0)
      var triggers := packet.GetInt16(12)/16;
      var bytes := CInt(triggers*1.5 + 2);
      speechstart := CInt(speechstart + bytes);
      var speechlen := packet.GetInt16(1) - 1 - speechstart;
      speech := CStr(packet.GetString(speechstart, speechlen));
   else
      var speechlen := (packet.GetInt16(1) - 13)/2;
      speech := CChrZ(packet.GetUnicodeString(speechstart, speechlen));
   endif
   SendSysMessage(character, speech);


Last edited by CWO on Mon Apr 09, 2007 4:47 am, edited 4 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 08, 2007 10:29 pm 
Offline

Joined: Thu Jan 18, 2007 2:34 am
Posts: 91
ah perfect. exactly what i was after. Thanks a lot for that :)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 08, 2007 10:30 pm 
Offline

Joined: Sat Feb 04, 2006 5:49 pm
Posts: 745
Location: Chicago, IL USA
updated it a tiny bit. Nothing thats broken in the last code, just tweaked it a tiny bit and took out my testvar.

Edit: Also just got rid of the sendsysmessage from when I was testing the packet.getstring


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

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users 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