Jump to content


Photo

Patch item flag with tp2


8 replies to this topic

#1 StrongArmand

StrongArmand
  • Members
  • 64 posts
  • Gender:Male

Posted 24 February 2012 - 03:44 PM

I would like to uncheck an item's flag by tp2 but i've found structur in iesdp a litlle strange. Flags is in extended header yes but in the same adress (0x0026) several values are possible. How can I edit just one value without erase other value ? Have I missed something ?

#2 plainab

plainab

    Sasha al'Therin

  • Members
  • 1717 posts
  • Gender:Male
  • Location:Lost on the Sword Coast

Posted 24 February 2012 - 05:15 PM

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
My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altheri...s.com/index.htm

#3 StrongArmand

StrongArmand
  • Members
  • 64 posts
  • Gender:Male

Posted 25 February 2012 - 12:29 AM

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 ?

Edited by StrongArmand, 25 February 2012 - 12:43 AM.


#4 Wisp

Wisp
  • Modders
  • 968 posts
  • Gender:Male

Posted 25 February 2012 - 02:56 AM

This is binary. There is no such thing as 2.
Assuming you want to set bit 2 on the item, you can use
WRITE_SHORT 0x26 THIS BOR BIT2 //BIT2 is 0b100


#5 StrongArmand

StrongArmand
  • Members
  • 64 posts
  • Gender:Male

Posted 25 February 2012 - 03:24 AM

What is BIT2 ? A key word from weidu read me ?


Assuming you want to set bit 2 on the item, you can use


Not exactly. I try to erase bit 2 in fact... Any idea ?

Edited by StrongArmand, 25 February 2012 - 04:12 AM.


#6 Wisp

Wisp
  • Modders
  • 968 posts
  • Gender:Male

Posted 25 February 2012 - 04:48 AM

What is BIT2 ? A key word from weidu read me ?

BIT2 is a predefined WeiDU constant with the value 0b100 (more info).

Not exactly. I try to erase bit 2 in fact... Any idea ?


WRITE_SHORT 0x26 THIS BAND 0b11111011
will unset bit 2 but leave everything else as it was.

#7 plainab

plainab

    Sasha al'Therin

  • Members
  • 1717 posts
  • Gender:Male
  • Location:Lost on the Sword Coast

Posted 25 February 2012 - 05:44 AM

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...
My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altheri...s.com/index.htm

#8 StrongArmand

StrongArmand
  • Members
  • 64 posts
  • Gender:Male

Posted 19 March 2012 - 09:30 AM

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....

#9 Miloch

Miloch

    Barbarian

  • Modders
  • 4715 posts
  • Gender:Male
  • Location:At Large

Posted 19 March 2012 - 05:32 PM

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.
Mod Contributions
Aurora (new release!) * BG1 NPC * Gnomes * Haiass * Level 1 NPCs * Lost Items * P5Tweaks
PnP Free Action * Thrown Hammers * Unique Containers * In Progress: Adjusted Portraits * DSotSC (Tutu)
================================================================
Player & Modder Resources
BAM Batcher * Creature Lister * PSPad Highlighters * Tutu/BGT Area Map & List * Tutu Mod List
================================================================
"Wherefore do ye toil; is it not that ye may live and be happy? And if ye toil only that ye may toil more,
when shall happiness find you?" -H.P. Lovecraft, The Quest of Iranon



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users