Page 1 of 1

How to get speech from 0xAD packet

Posted: Sun Apr 08, 2007 9:00 pm
by mr bubbles
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.

Posted: Sun Apr 08, 2007 9:20 pm
by CWO
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: Select all

	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);

Posted: Sun Apr 08, 2007 10:29 pm
by mr bubbles
ah perfect. exactly what i was after. Thanks a lot for that :)

Posted: Sun Apr 08, 2007 10:30 pm
by CWO
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