Jump to content

Help with short Weidu .tp2 script


Recommended Posts

Hi all,

I installed an immensely modded EET playthrough, but accidentally applied an option from cdtweaks I didn't mean to, and was hopeing to roll it back without doing my whole 4 hour installation process all over again. I spent some time reading the weidu documentation, and took the existing code and modified it.

I applied a level requirement to all scrolls, so this snippet of code should go back through all scroll items and set their level requirement to one. 

However, when I run the script using weidu, it gives me a parse error. Any suggestions?

*Edit*  Resolved! thank you everyone for the assistance!

 

BEGIN ~Fixthisthing~
COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~
  READ_SHORT 0x1c type
  READ_SHORT 0x24 level
  PATCH_IF (type = 11) BEGIN // Mycomment: Patches all scroll items, including those with existing levels
    READ_LONG  0x64 abil_off ELSE 0
    READ_SHORT 0x68 abil_num ELSE 0
    READ_LONG  0x6a fx_off   ELSE 0
    FOR (index = 0 ; index < abil_num ; ++index) BEGIN
      READ_SHORT  (abil_off + 0x1e + (0x38 * index)) abil_fx_num
      READ_SHORT  (abil_off + 0x20 + (0x38 * index)) abil_fx_idx
      FOR (index2 = 0 ; index2 < abil_fx_num ; ++index2) BEGIN
        READ_SHORT (fx_off +        (0x30 * (abil_fx_idx + index2))) opcode
        PATCH_IF ((opcode = 146) OR (opcode = 148)) BEGIN // cast spell
          READ_ASCII (fx_off + 0x14 + (0x30 * (abil_fx_idx + index2))) spell
          PATCH_IF (("%spell%" STRING_COMPARE_REGEXP ~^[Ss][Pp][Ww][Ii][3-9][0-9][0-9]$~ = 0) OR
                    ("%spell%" STRING_COMPARE_REGEXP ~^[Ss][Pp][Pp][Rr][3-7][0-9][0-9]$~ = 0)) BEGIN // levels 1&2 usable by level 0/1, so no need for level requirements: Left alone
            PATCH_IF ("%spell%" STRING_COMPARE_REGEXP ~^[Ss][Pp][Ww][Ii][3-9][0-9][0-9]$~ = 0) BEGIN SET level_break = 11 END ELSE BEGIN SET level_break = 13 END // account for extra level for priest 6>7 and wizard 5>6: Left Alone
            READ_BYTE  (fx_off + 0x18 + (0x30 * (abil_fx_idx + index2))) level
            SET level = 1 // Setting level to one, to fix the problem
            PATCH_IF level < level_break BEGIN
              SET level = 1 // Setting level to one here as well, didn't want to mess up the loops
            END
          END
        END
      END
    END
    WRITE_SHORT 0x24 level // still 0 if no match found, otherwise new value
  END
BUT_ONLY

 

 

Edited by Coldaine
Link to comment
4 minutes ago, Dan_P said:

Ran this in a test mod and it installs fine. Did you put the backup and author stuff at the top? You need something like this:

BACKUP ~testmod~
AUTHOR ~~
VERSION ~0.1~

Of course! absolutely silly of me, I was missing the "BACKUP" at the top.

 

Thank all of you for the help.

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