How to restrict the use of item groups not specified by itemtype
fortyseven
Member Posts: 96
Hi I'm trying to restrict a new kit from using all items flagged as magical. Does anyone have a creative idea how that could be achieved without having to implement a vast list that covers all magical items in the game via opcode 180? I initially tried to use opcode 181but there is no itemtype i believe that fits my requirements. Maybe opcode 319 could somehow be used for this but I have no idea how. My hunch is this is a dead end but I wanted to ask before writing it off entirely.
0
Comments
COPY_EXISTING_REGEXP GLOB ~.*\.itm~ ~override~ PATCH_IF (SOURCE_SIZE > 0x71) BEGIN READ_BYTE 0x18 flag1 //reads the byte containing the magical flag PATCH_IF ((flag1 BAND 0b00100000) = 0b00100000) BEGIN // check if bit number 6 is equal to 1 LPF ~ADD_ITEM_EQEFFECT~ INT_VAR opcode = 319 target = 1 timing = 2 parameter1 = IDS_OF_SYMBOL (~Kit~ ~Kit internal name~) parameter2 = 9 special = RESOLVE_STR_REF (~Full name of the kit~) END //make the item unusable for your kit, and adds the description note END END END BUT_ONLY_IF_IT_CHANGESJust keep in mind that bits are read from right to left.And yeah all you have to do is including it in your WeiDu file. Make sure to paste the block after the part where you actually add the kit. I put them in the wrong order once and it took me 30min to figure the issue... Kinda felt stupid afterwards
COPY_EXISTING_REGEXP ~.*\.itm~ override // This is needed to add my kit to the "NOT USABLE BY" list of armors READ_ASCII 0x22 animation PATCH_IF ( ("%animation%" STRING_EQUAL_CASE "4A") OR ("%animation%" STRING_EQUAL_CASE "3A")) BEGIN LPF ADD_ITEM_EQEFFECT INT_VAR opcode = 319 target = 1 parameter1 = (ARARCH) parameter2 = 9 timing = 2 special = RESOLVE_STR_REF (@5) END END DEFAULT END BUT_ONLY_IF_IT_CHANGES COPY_EXISTING_REGEXP ~.*\.itm~ override // This is needed to add my kit to the "NOT USABLE BY" list of shields READ_ASCII 0x22 animation PATCH_IF ( ("%animation%" STRING_EQUAL_CASE "D1") OR ("%animation%" STRING_EQUAL_CASE "D2") OR ("%animation%" STRING_EQUAL_CASE "D3") OR ("%animation%" STRING_EQUAL_CASE "D4") ) BEGIN LPF ADD_ITEM_EQEFFECT INT_VAR opcode = 319 target = 1 parameter1 = (ARARCH) parameter2 = 9 timing = 2 special = RESOLVE_STR_REF (@5) END END DEFAULT END BUT_ONLY_IF_IT_CHANGESIn state 961, I expected one of these tokens:
[0] EOF
[48] BEGIN
Parse error (state 961) at END
[MYMOD/SETUP-MYMOD.TP2] PARSE ERROR at line (line of 3rd END) column 1-5
Near Text: END
GLR parse error
[MYMOD/SETUP-MYMOD.TP2] PARSE ERROR at line (line of 3rd END) column 1-5
Near Text: END
Parsing.Parse_error
ERROR: parsing [MYMOD/SETUP-MYMOD.TP2]: Parsing.Parse_error
ERROR: problem parsing TP file [MYMOD/SETUP-MYMOD.TP2]: Parsing.Parse_error
FATAL ERROR: Parsing.Parse_error
I removed the 3rd END and the WeiDU file will execute again and install everything without any error but now the kit has all items restricted irrespective of their magical flag. Any ideas how this could be solved?
This is probably daft, but when you check if bit number 6 is 1 in line 4 of your code, where is 6 represented? the flag reads 1 and then there is 0b0010000 which if binary does not read as 6 more like 16 or 32 maybe?
Bit 6 is represented by the 1 in 0b00100000. They are read right to left, right one being bit 1, all the way up to left one being bit 8. 0b means it's a binary number.
But that's actually where my mistake lies: Magical flag is indeed bit 6, but the rightmost bit is bit 0, not bit 1. So here it was testing the "Not Copyable" flag (bit 5) instead. Replace 0b00100000 by 0b01000000 and you should be fine