Rhastor Posted January 21, 2022 Share Posted January 21, 2022 I just loaded up IWD:EE for the first time (a new game to me as I have only played BG 1&2) and I noticed that Beamdog has changed the stacking to 80 for arrows and bullets. I'd rather it be 20 as in original BG. It seems that this is an unpopular opinion, because I notice the Tweaks Anthology only provides options to increase stacking, not reduce it. How hard would it be, as a first time modder, to reduce the stackability of all items in the game? Quote Link to comment
subtledoctor Posted January 21, 2022 Share Posted January 21, 2022 Ripped off from CDTweaks: COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~ // looking for ammo READ_SHORT 0x1C "type" ELSE 0 READ_SHORT 0x38 "max" ELSE 0 PATCH_IF ("%max%" > 1) AND // if item can already stack and is of the type... ( ("%type%" = 5) OR // arrows, ("%type%" = 14) OR // bullets, ("%type%" = 16) OR // dagger ("%type%" = 21) OR // hammer (iwd2) ("%type%" = 24) OR // darts, ("%type%" = 25) OR // axe, ("%type%" = 29) OR // spears, ("%type%" = 31) ) // bolts, BEGIN WRITE_SHORT 0x38 20 END BUT_ONLY Quote Link to comment
Rhastor Posted January 21, 2022 Author Share Posted January 21, 2022 (edited) Excellent! I assume that I can just change 20 to whatever number I want and re-run cdtweaks - assuming I can edit this. Forgive my noob question but how do I do that? Edit: I think I get it - go to github, download source, edit tpa files manually, re-compile, and run the new tweaked cdtweaks. Edited January 21, 2022 by Rhastor Quote Link to comment
Jarno Mikkola Posted January 21, 2022 Share Posted January 21, 2022 (edited) That's weidu code. Aka, a .tp2 code, that you can put in a normal .txt file, that you just rename as modname.tp2, add in this code above the above code for it to be a typical weidu code: BACKUP ~modname/backup~ AUTHOR ~Rhastor~ VERSION ~v1~ //README you don't need this line but its commented out if you want to eventually add it in And then you just copy one of the other setup-*modname*.exe's, rename it as the setup-modname.exe, and save the file. and then you can run the file in the game directory and you are done with your first self made weidu mod. And yes, you can edit any .tp2 file with Notepad, you just need to assign the Notepad as the opener program. And you can dio that with either right click or really, double left click too,m as it then asks .... Edited January 21, 2022 by Jarno Mikkola Quote Link to comment
Rhastor Posted January 22, 2022 Author Share Posted January 22, 2022 (edited) You guys are awesome. Just to make sure I have got this right, I put the below code in a file called mytweak.tp2, which sits in C:\game folder]\mytweak\ and in C:\[game folder] I have a file called setup-mytweak.exe that I am running. BACKUP ~mytweak/backup~ AUTHOR ~Rhastor~ VERSION ~v1~ //README you don't need this line but its commented out if you want to eventually add it in BEGIN COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~ // looking for ammo READ_SHORT 0x1C "type" ELSE 0 READ_SHORT 0x38 "max" ELSE 0 PATCH_IF ( ("%max%" > 1) AND // if item can already stack and is of the type... ( ("%type%" = 5) OR // arrows, ("%type%" = 14) OR // bullets, ("%type%" = 31) // bolts, ) ) BEGIN READ_SHORT 0x38 current BEGIN WRITE_SHORT 0x38 20 END COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~ // looking for ammo READ_SHORT 0x1C "type" ELSE 0 READ_SHORT 0x38 "max" ELSE 0 PATCH_IF ( ("%max%" > 1) AND // if item can already stack and is of the type... ( ("%type%" = 16) OR // dagger ("%type%" = 24) OR // darts, ) ) BEGIN READ_SHORT 0x38 current BEGIN WRITE_SHORT 0x38 10 END COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~ // looking for ammo READ_SHORT 0x1C "type" ELSE 0 READ_SHORT 0x38 "max" ELSE 0 PATCH_IF ( ("%max%" > 1) AND // if item can already stack and is of the type... ( ("%type%" = 21) OR // hammer (iwd2) ("%type%" = 25) OR // axe, ("%type%" = 29) OR // spears, ) ) BEGIN READ_SHORT 0x38 current BEGIN WRITE_SHORT 0x38 5 END COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~ // looking for potions READ_SHORT 0x1c type ELSE 0 READ_SHORT 0x38 max ELSE 0 PATCH_IF ((max > 1) AND // if potion can already stack... (5 < max) AND // and we would actually reduce the stack size... ((type = 9) OR // and it's actually a potion... ((type = 71) AND (check_food = 1)))) BEGIN // or iwd2 food WRITE_SHORT 0x38 5 END Edited January 22, 2022 by Rhastor Quote Link to comment
Rhastor Posted January 22, 2022 Author Share Posted January 22, 2022 Well, I got the following. Probably a really stupid problem. Quote [C:\Icewind Dale Enhanced Edition\setup-mytweak.exe] WeiDU version 24600 In state 220, I expected one of these tokens: [2] ~~ [4] # [5] @ [6] ! [281] LPAREN Parse error (state 220) at COPY_EXISTING_REGEXP [MYTWEAK/MYTWEAK.TP2] PARSE ERROR at line 8 column 1-20 Near Text: COPY_EXISTING_REGEXP GLR parse error [MYTWEAK/MYTWEAK.TP2] ERROR at line 8 column 1-20 Near Text: COPY_EXISTING_REGEXP Parsing.Parse_error ERROR: parsing [MYTWEAK/MYTWEAK.TP2]: Parsing.Parse_error ERROR: problem parsing TP file [MYTWEAK/MYTWEAK.TP2]: Parsing.Parse_error FATAL ERROR: Parsing.Parse_error Press ENTER to exit. Quote Link to comment
Jarno Mikkola Posted January 22, 2022 Share Posted January 22, 2022 (edited) Ouh, you didn't name the mod component... Change the first: BEGIN To be: BEGIN ~ammo component~ .. or what ever you want to the mod component as... Edited January 22, 2022 by Jarno Mikkola Quote Link to comment
jmerry Posted January 22, 2022 Share Posted January 22, 2022 Parse error. Most of the time, that means you made a syntax mistake - a missing ~, or a missing ), or something of that ilk. Look at wherever it says the error is (line 8 in this case), then step back to whatever's immediately before it. Hmm. You seem to have a BEGIN (nothing) command there. Try naming your component; for example, change line 6 to BEGIN ~Reduce ammo stacking~ Quote Link to comment
Rhastor Posted January 22, 2022 Author Share Posted January 22, 2022 (edited) After trying many variants, I always get a parse error. Adding a name like ~thismodmod~ after "BEGIN" results in it moving down to the next "BEGIN" but adding a name there does nothing. Does every "BEGIN" need a name? Edit: Regardless of whether the other BEGINs are named or not, the next parse error is near line 19 "READ_SHORT 0x38 current". Edit2: Removing that (which is unnecessary to the code as it defines a variable which I am not using) just moves the parse error to the next line with WRITE_SHORT. No matter what there always seems to be a parse error. Edit3: I gave up on running a separate mini-mod and basically took care of this by just changing numbers and setting certain conditionals to true in the original cdtweaks files, and it works. Thanks for your help. I am still a little curious how to write mini-mods like this but it's not necessary for my current purpose anymore. Edited January 22, 2022 by Rhastor Quote Link to comment
subtledoctor Posted January 22, 2022 Share Posted January 22, 2022 (edited) Parse error at line 19 means there is a parse error somewhere before line 19. In this case my guess would be something to do with those flocks of parentheses (EDIT - nope, found it, see below). I would simplify to make it easier to see what needs to be fixed: get rid of the line you don’t need, as mentioned get rid of the quotes and percent signs around “type” and “max” get rid of the ELSE 0 Clean up the parenthesis mess by giving the “max > 1” condition its own PATCH_IF line, and deleting the AND every _IF clause needs an END after it (this is your parse error btw) get rid of the mid-stream untethered BEGINs (this is also your parse error) A ‘BEGIN’ by itself is only used at the beginning - it signifies the beginning of a component (the part where Weidu asks “would you like to install ____?”) Mid-stream in the code, BEGIN should only be next to something like PATCH_IF or ACTION_IF, and those BEGINs should always be followed by a matching END, like so BEGIN ~component 1: change stack sizes~ ACTION_IF [condition] BEGIN COPY ~[file]~ ~override~ READ_BYTE [offset] value PATCH_IF (VARIABLE_IS_SET %value) BEGIN PATCH_IF (value = 1) OR (value > 5) BEGIN WRITE_BYTE [offset] new_value END END BUT_ONLY END See how every IF is paired with a BEGIN, and followed by a corresponding END? The indentation conventions are basically there to make it easy to match them, so you can spot any errors. (Likewise the BUT_ONLY lines up with the COPY command… BUT_ONLY is sometimes unnecessary but I always include it just so that I can match things up more easily.) Also note that my nested PATCH_IF lines are logically equivalent to an AND, just easier to read and with no need for all the parentheses to ensure the OR logic is right.) Edited January 22, 2022 by subtledoctor Quote Link to comment
Recommended Posts
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.