PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
How to get speech from 0xAD packet

 
Post new topic   Reply to topic    PenUltima Online Forum Index -> Packet World
Display posts from previous:   

Author Message
mr bubbles



Joined: 18 Jan 2007
Posts: 91

PostPosted: Mon Apr 09, 2007 1:00 am    Post subject: How to get speech from 0xAD packet Reply with quote

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.

Author Message
CWO



Joined: 04 Feb 2006
Posts: 691
Location: Chicago, IL USA

PostPosted: Mon Apr 09, 2007 1:20 am    Post subject: Reply with quote

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 8:47 am; edited 4 times in total

Author Message
mr bubbles



Joined: 18 Jan 2007
Posts: 91

PostPosted: Mon Apr 09, 2007 2:29 am    Post subject: Reply with quote

ah perfect. exactly what i was after. Thanks a lot for that Smile

Author Message
CWO



Joined: 04 Feb 2006
Posts: 691
Location: Chicago, IL USA

PostPosted: Mon Apr 09, 2007 2:30 am    Post subject: Reply with quote

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

Post new topic   Reply to topic    PenUltima Online Forum Index -> Packet World All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty