Jump to content

Patch item flag with tp2


StrongArmand

Recommended Posts

you need the bitwise stuff from weidu.

 

I'll give ya psuedo code

 

for the example lets say the flag has 3 known entries at bits 0, 1, & 2 and bits 0 and 2 are already set to 'on' or 1 and you want to turn bit 1 on without turning bits 0 & 2 off you would do something like this:

 

copy file override

read offset flags

write offset (%flags% BOR 0b010)

but_only

Link to comment

I've tried this :

 

COPY_EXISTING ~misc5u.itm~ ~override/#VThief.itm~
SAY NAME1 @10000451
SAY NAME2 @10000451
SAY DESC  @10000452
READ_SHORT 0x26 "Flags"
WRITE_SHORT 0x26 (%Flags% BOR 0b00200)
BUT_ONLY 

 

But weidu send me an error. This item has 5 known entries at bits 0, 2,3 and 5. Is it an error with BOR command ?

Link to comment

remember the value you wish to edit is in the extended header. meaning it doesn't have a fixed point in the file. it could fluctuate from file to file. IESDP only lists its offset into the extended header section. You'll need to look up the offset of the extended header in the main header, as well as the number of extended headers (there is 1 per ability). Use that information to pinpoint the specific extended header you wish to edit. so that in the end you'll have something like (in psuedo code)

 

copy file override

read_long 0x64 ext_head_off

read_short 0x68 ext_head_num

for (idx = 0; idx < %ext_head_num%; idx += 1 ) begin

//assuming 1st extended header

patch if (%idx% = 0) begin

read_short (%ext_head_off% + (%idx% * 0x38) + 0x26 ) flags

write_short (%ext_head_off% + (%idx% * 0x38) + 0x26 ) (whatever bitwise method you discover works)

end

end

but_only

 

didn't list it like this before cause you stated you knew it was in the extended header, which meant to me that you knew how to get there...

Link to comment

Ok with several test, i've finally understand this command. Sorry for my bad explanation but I thought to know the right way since I've edit cre files effect with tp2 with some INSERT_BYTE command.

 

However I need more training an more reading. ¨¨ I've read the weidu read me by the bigg more carefuly. Hoping that allow me to learn lesson this time....

Link to comment

Bitwise code can be a bit confusing (to me anyway, but I'm just a half-orc). But basicallly, a byte is 8 bits. When you use 0x## you are writing an entire byte. (two bytes if writing 0x#### etc.). When writing the individual bits within a byte, 0b######## is a single byte, but lets you address the individual bits within that byte. Difference being in the initial "0x" which indicates hexadecimal and "0b" which indicates binary. Not sure if that clarifies things or makes them more confusing. When I code bitwise stuff, I tend to just copy and paste it from existing code I know works.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...