Jump to content

Question to Changing Item Usability via WRITE_BYTE


Recommended Posts

In Jarl's Tweak Pack, one of the components offers to make Jaheira's alignment Neutral Good.

 

This comes along with it:

 

COPY_EXISTING ~misc5x.itm~ ~override~
READ_BYTE 0x1e "use1"
READ_BYTE 0x21 "use2"
WRITE_BYTE 0x1e (("%use1%" BOR 0b00001000) BAND 0b11111011)
WRITE_BYTE 0x21 ("%use2%" BOR 0b10000000)
BUT_ONLY_IF_IT_CHANGES

 

"Misc5X.itm" is the Harper's Pin which originally is only usable by True Neutral Fighter-Druids.

 

The above code changes this to Neutal Good Fighter-Druids, which is great. My questions:

 

-is the above code the optimum if it comes to tp2 coding or is there a potential compatibility issue with other possible tweaks? What I mean is, what exactly does the code do, does it only change the True Neutral to Neutral Good or does it overwrite something else, meaning would this still work if another tweak changes Jaheira's kit or even class including the appropriate usability flags of the Harper Pin, too?

 

EDIT: I am aware that this is for BGII/BGT only, as the item is resctricted to Jaheira only for BGII:EE via some opcode not available for BGII: Am I assuming correctly that this resctriction in BGII:EE is independent on the NPC's alignment and thus not affected by alignment tweaks?

Edited by jastey
Link to comment

That two initial read operations are not strictly needed, because WeiDU automatically reads the content into the variable THIS for each write operation.

The logic of the write operations looks correct though. With the hint from above and the use of some helpful WeiDU constants it would result in:

COPY_EXISTING ~misc5x.itm~ ~override~
  WRITE_BYTE 0x1e ((THIS BOR BIT3) BAND BNOT BIT2)
  WRITE_BYTE 0x21 (THIS BOR BIT7)
 BUT_ONLY

Or combined into a single write operation:

COPY_EXISTING ~misc5x.itm~ ~override~
  WRITE_LONG 0x1e ((THIS BOR BIT3 BOR BIT31) BAND BNOT BIT2)
 BUT_ONLY

You can optionally replace BOR by |, BAND by & and BNOT by ` (back quote sign) to reduce code length.

Btw, the code makes "...Neutral" and "Half-Orc" unusable and "Good" usable. And yes, NPC-specific restrictions in EE games are only tied to creature (script) name. Alignment, race, etc. doesn't matter.

Link to comment

Thank you! That was very helpful.

I wonder what the bit 31 is for, actually. As I see it,

 

COPY_EXISTING ~misc5x.itm~ ~override~
WRITE_BYTE 0x1e ((THIS BOR BIT3) BAND BNOT BIT2)
BUT_ONLY

 

would do the trick for Jaheira's alignment change to Neutral Good just fine because it's already unusable by half-orcs and that's nothing to do with an alignment change, I would say.

Link to comment

EDIT: I am aware that this is for BGII/BGT only, as the item is resctricted to Jaheira only for BGII:EE via some opcode not available for BGII: Am I assuming correctly that this resctriction in BGII:EE is independent on the NPC's alignment and thus not affected by alignment tweaks?

According to some testing done by earlier me, restrictions to specific characters via the EE opcode are cumulative with restrictions in the item header. For example, if the item was restricted to Jaheira, but something made it unusable by fighter/druids, she wouldn't be able to use it.

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...