Skip to content

How to restrict the use of item groups not specified by itemtype

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

Comments

  • ArunsunArunsun Member Posts: 1,592
    edited March 2018
    There you go:
    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_CHANGES
    Just keep in mind that bits are read from right to left.
    Post edited by Arunsun on
  • fortysevenfortyseven Member Posts: 96
    Wow thanks! So does this essentially amend each magically flagged item to exclude the 319 opcode named kit? Do I just include this in the Kit WeiDU file?
  • ArunsunArunsun Member Posts: 1,592

    Wow thanks! So does this essentially amend each magically flagged item to exclude the 319 opcode named kit? Do I just include this in the Kit WeiDU file?

    That's it. It checks every item file, and if they are flagged as magical OPcode 319 is added to restrict the item from your kit.

    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 :cry:
  • The user and all related content has been deleted.
  • ArunsunArunsun Member Posts: 1,592

    Arunsun said:

    Just keep in mind that bits are read from left to right.

    You mean from right to left...?
    Yes I do... Let's pretend right and left is a relative concept, this is embarassing that I still confuse them at times :smiley:
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    edited March 2018
    @Arunsun What about preventing a kit from using shields and armors? The following piece of code is not working:

    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_MATCH animation WITH 
    		3A    4A  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_MATCH animation WITH 
    		D1    D2    D3      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_CHANGES
  • ArunsunArunsun Member Posts: 1,592
    I am not very familiar with PATCH_MATCH, but try PATCH_MATCH %animation% or PATCH_MATCH "%animation%" and "D1", "D2", "D3" and "D4". If that still doesn't work, there might be a type issue, things labeled as "values" in the WeiDu documentation are numbers. Try this code instead:

    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_CHANGES
  • GwendolyneGwendolyne Member Posts: 461
    Luke93 said:

    @Arunsun What about preventing a kit from using shields and armors? The following piece of code is not working:

    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_MATCH animation WITH 
    		3A    4A  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_MATCH animation WITH 
    		D1    D2    D3      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_CHANGES
    Try this:
    PATCH_MATCH ~%animation%~ WITH
    	3A    4A  BEGIN
    		  LPF ADD_ITEM_EQEFFECT
    			INT_VAR
    			  opcode = 319
    			  target = 1
    			  parameter1 = (ARARCH)
    			  parameter2 = 9
    			  timing = 2
    			  special = RESOLVE_STR_REF (@5)
    		  END
    	END
    	D1    D2    D3      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
    
    I did not check the function parameters, but I would have favored parameter1 = IDS_OF_SYMBOL (kit ~name of your kit~)
  • fortysevenfortyseven Member Posts: 96
    edited May 2018
    @Arunsun, I have recently been experimenting with the Weidu code you posted here intially about restricting a kit from using magical items. However, it is giving me a fatal parsing error. The error code reads as follows:

    In 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?
    Post edited by fortyseven on
  • ArunsunArunsun Member Posts: 1,592
    edited May 2018

    @Arunsun, I have recently been experimenting with the Weidu code you posted here intially about restricting a kit from using magical items. However, it is giving me a fatal parsing error. The error code reads as follows:

    In 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?

    Parsing error comes from the third END that indeed had nothing to do here.

    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
  • fortysevenfortyseven Member Posts: 96
    Thank you Arunsun, that really makes it clear how it works! Your help once again has been invaluble. The code works now as intended without issue!
Sign In or Register to comment.