[THAW] StructItemScript

Tutorials for all THUG+ games goes here.
Forum rules
This forum is only for posting tutorials.
Specify what game it is for, and please take a look at this Template.
Post Reply
Global Moderator
Posts: 390
Joined: Sun Mar 07, 2010 5:12 pm

[THAW] StructItemScript

Post by %.gone. » Fri Oct 29, 2010 4:18 pm

That's right you read the title correctly, these are very much real and I'm going to give you the break down of how they're constructed.

Its a unique data type in the sense that its 2 parts, part one is the data type part 2 is the number of bytes in the script
Code Snip It, includes the next items DataType

Code: Select all

Lets break that code down to better understand a StructItemScript
000F2C00 - this is the DataType, 0x00000F00; Falls perfectly in place with all other structure item DataTypes the only difference is the last 2 bytes are actually the script size. 2C00 = 44 bytes

DB162E35 - The script name - Disqualify_Script
34C30000 - The offset to the start of the script
60C30000 - The offset to the next DataType after the script

The next byte is the start of the script and this is where our byte count starts. These scripts are constructed like THPS3/4 where a new instruction starts with byte 0x02 and is followed by a 4 byte value. The value for a StructItemScript is actually a total item count of the entire script.

02 F0080000 - new instruction + item count
16 0B9D3383 - Translates to: SetPart
16 398FF0B6 07 16 4DF45724 - Translates to: part = body
16 4E08B24B 07 16 1F31FA28 - Translates to: desc_id = MaleBody
02 F1080000 - new instruction + item count
24 - Translates to: endfunction
02 F2080000 - new instruction + item count; This is the count for the next DataType.
00 - padding, all pak scripts are padded by %4 meaning the end of the data ends at either byte 0, 4, 8, C. This is the last byte in our script, byte 44.
001B0000 - New DataType which equals StructItemQbKey

Last edited by %.gone. on Fri Nov 12, 2010 1:55 pm, edited 1 time in total.

Site Admin
Posts: 322
Joined: Mon Mar 01, 2010 2:23 pm
Location: Norway

Re: THAW - StructItemScript

Post by Morten1337 » Sat Oct 30, 2010 9:38 am

Nice :D

Global Moderator
Posts: 390
Joined: Sun Mar 07, 2010 5:12 pm

Re: THAW - StructItemScript

Post by %.gone. » Sat Oct 30, 2010 6:37 pm

To be honest the 2 byte script size doesn't need to be used when reading the data since
60C30000(pointer to the end) - 34C30000(pointer to the beginning) = 2C000000,
but it could be used to validate that the script data size is correct.
And will certainly need to be correct when writing the data back to the file.

I don't know C# but I'll try to incorporate this into QueenBee.

Global Moderator
Posts: 390
Joined: Sun Mar 07, 2010 5:12 pm

Re: THAW - StructItemScript

Post by %.gone. » Fri Nov 12, 2010 1:56 pm

Forum Request perhaps a strike through option?

Anyways the "item count" above has been edited in italic (no strike through feature) because they are NOT counts, if they are I can't figure out what its keeping count of. I did notice it makes no difference what the value is which is a good thing when it comes to compiling these Struct Items because I don't need to know anything more than the fact that after 0x02 there must be a 4 byte value.

Post Reply