grogerson Posted January 24, 2012 Share Posted January 24, 2012 Updating BG1 Tweaks, I noticed BG2 Tweaks v9 changed their method. It's cleaner and doesn't require a Description Update component or file, so I've modified it for BG1. From BG2 Tweaks: DEFINE_PATCH_FUNCTION ~REMOVE_MAGE_LINE_FROM_USABILITIES~ INT_VAR offset = 0 // offset to write description to STR_VAR desc = ~~ // original description unusable_regexp = ~~ // regexp that matches the Unusable By/Not Usable By line unusable_replacement = ~~ // replacement for the Unusable By line mage_regexp = ~~ // regexp that matches the Mage line in the usability section class_prefix = ~~ // in the usability section, this precedes all class listings (ex: in english, this is one space) BEGIN INNER_PATCH_SAVE desc ~%desc%~ BEGIN REPLACE_TEXTUALLY ~%unusable_regexp%~ ~%unusable_replacement%~ END PATCH_IF ((~%desc%~ STRING_CONTAINS_REGEXP ~^%unusable_replacement%~) == 0) BEGIN // extract usability info INNER_PATCH_SAVE usab_block ~%desc%~ BEGIN REPLACE_TEXTUALLY ~\(.*[%lnl%%mnl%%wnl%]\)*%unusable_replacement%~ ~~ END // update info INNER_PATCH_SAVE usab_block_new ~%usab_block%~ BEGIN REPLACE_TEXTUALLY ~[%lnl%%mnl%%wnl%][- %tab%]*$~ ~~ // remove any empty lines REPLACE_TEXTUALLY ~^[- %tab%]*~ ~%class_prefix%~ // make sure entries are indented by one space REPLACE_TEXTUALLY ~%mage_regexp%~ ~~ // remove mage line END // replace old usability info with new INNER_PATCH_SAVE desc ~%desc%~ BEGIN REPLACE_TEXTUALLY EXACT_MATCH ~%usab_block%~ ~%usab_block_new%~ END // check if mage was the only thing that couldn't use INNER_PATCH_SAVE compare ~%desc%~ BEGIN REPLACE_TEXTUALLY ~^%unusable_replacement%.*[%lnl%%mnl%%wnl%]%class_prefix%[^- %tab%]~ ~~ END // if it was... PATCH_IF (~%desc%~ STRING_EQUAL ~%compare%~) BEGIN INNER_PATCH_SAVE desc ~%desc%~ BEGIN // remove 'not usable by' line, so it won't be sitting all by its lonesome now REPLACE_TEXTUALLY ~[%lnl%%mnl%%wnl%]%unusable_replacement%.*~ ~~ END END // write changes SAY_EVALUATED ~%offset%~ ~%desc%~ END END PRINT @1 COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~ PATCH_IF (SOURCE_SIZE > 0x71) BEGIN READ_BYTE 0x31 "prof" ELSE 0 PATCH_IF ("%prof%" = 115) BEGIN READ_BYTE 0x1f "fighter" PATCH_IF (("%fighter%" BAND "0b00001000") = "0b00000000") BEGIN // if usable by single-class fighter READ_BYTE 0x20 "mage" WRITE_BYTE 0x20 ("%mage%" BAND "0b11111011") // update descriptions PATCH_FOR_EACH offset IN ~0x50~ ~0x54~ BEGIN READ_LONG ~%offset%~ desc_strref PATCH_IF (desc_strref >= 0 && desc_strref < 2147483646) BEGIN READ_STRREF ~%offset%~ desc // remove mage line from matching english descriptions LAUNCH_PATCH_FUNCTION ~REMOVE_MAGE_LINE_FROM_USABILITIES~ STR_VAR unusable_regexp = EVALUATE_BUFFER ~^[ %tab%]*\(Unusable By\|Not Usable By\).*~ unusable_replacement = ~Not Usable By:~ mage_regexp = EVALUATE_BUFFER ~[%lnl%%mnl%%wnl%].*\bMage.*~ class_prefix = ~ ~ END END END END END END BUT_ONLY_IF_IT_CHANGES COPY_EXISTING ~weapprof.2da~ ~override~ // allows mage proficiency in clubs FOR (column = 22; column < 30; column = column + 1) BEGIN SET_2DA_ENTRY_LATER ~weapprof~ 20 column ~1~ // Specialist Mage END SET_2DA_ENTRY_LATER ~weapprof~ 20 4 ~1~ // Mage SET_2DA_ENTRY_LATER ~weapprof~ 20 53 ~1~ // Wild Mage SET_2DA_ENTRIES_NOW ~weapprof~ 1 BUT_ONLY_IF_IT_CHANGES There's much that doesn't apply to BG1 (no 0x31 "prof" or weapprof.2da), so I've reduced it to this: DEFINE_PATCH_FUNCTION ~REMOVE_MAGE_LINE_FROM_USABILITIES~ INT_VAR offset = 0 // offset to write description to STR_VAR desc = ~~ // original description unusable_regexp = ~~ // regexp that matches the Unusable By/Not Usable By line unusable_replacement = ~~ // replacement for the Unusable By line mage_regexp = ~~ // regexp that matches the Mage line in the usability section class_prefix = ~~ // in the usability section, this precedes all class listings (ex: in english, this is one space) BEGIN INNER_PATCH_SAVE desc ~%desc%~ BEGIN REPLACE_TEXTUALLY ~%unusable_regexp%~ ~%unusable_replacement%~ END PATCH_IF ((~%desc%~ STRING_CONTAINS_REGEXP ~^%unusable_replacement%~) == 0) BEGIN // extract usability info INNER_PATCH_SAVE usab_block ~%desc%~ BEGIN REPLACE_TEXTUALLY ~\(.*[%lnl%%mnl%%wnl%]\)*%unusable_replacement%~ ~~ END // update info INNER_PATCH_SAVE usab_block_new ~%usab_block%~ BEGIN REPLACE_TEXTUALLY ~[%lnl%%mnl%%wnl%][- %tab%]*$~ ~~ // remove any empty lines REPLACE_TEXTUALLY ~^[- %tab%]*~ ~%class_prefix%~ // make sure entries are indented by one space REPLACE_TEXTUALLY ~%mage_regexp%~ ~~ // remove mage line END // replace old usability info with new INNER_PATCH_SAVE desc ~%desc%~ BEGIN REPLACE_TEXTUALLY EXACT_MATCH ~%usab_block%~ ~%usab_block_new%~ END // check if mage was the only thing that couldn't use INNER_PATCH_SAVE compare ~%desc%~ BEGIN REPLACE_TEXTUALLY ~^%unusable_replacement%.*[%lnl%%mnl%%wnl%]%class_prefix%[^- %tab%]~ ~~ END // if it was... PATCH_IF (~%desc%~ STRING_EQUAL ~%compare%~) BEGIN INNER_PATCH_SAVE desc ~%desc%~ BEGIN // remove 'not usable by' line, so it won't be sitting all by its lonesome now REPLACE_TEXTUALLY ~[%lnl%%mnl%%wnl%]%unusable_replacement%.*~ ~~ END END // write changes SAY_EVALUATED ~%offset%~ ~%desc%~ END END PRINT @1 COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~ PATCH_IF (SOURCE_SIZE > 0x71) BEGIN READ_BYTE 0x1f "fighter" PATCH_IF (("%fighter%" BAND "0b00001000") = "0b00000000") BEGIN // if usable by single-class fighter READ_BYTE 0x20 "mage" WRITE_BYTE 0x20 ("%mage%" BAND "0b11111011") // update descriptions PATCH_FOR_EACH offset IN ~0x50~ ~0x54~ BEGIN READ_LONG ~%offset%~ desc_strref PATCH_IF (desc_strref >= 0 && desc_strref < 2147483646) BEGIN READ_STRREF ~%offset%~ desc // remove mage line from matching english descriptions LAUNCH_PATCH_FUNCTION ~REMOVE_MAGE_LINE_FROM_USABILITIES~ STR_VAR unusable_regexp = EVALUATE_BUFFER ~^[ %tab%]*\(Unusable By\|Not Usable By\).*~ unusable_replacement = ~Not Usable By:~ mage_regexp = EVALUATE_BUFFER ~[%lnl%%mnl%%wnl%].*\bMage.*~ class_prefix = ~ ~ END END END END END BUT_ONLY_IF_IT_CHANGES Mage unusability code gets removed, but the descriptions don't get updated. What have I missed? Link to comment
Miloch Posted January 24, 2012 Share Posted January 24, 2012 Offhand, I can't tell just by looking at the code - you'd probably have to run it and check it by looking at some items. The whitespace variables (%WNL%, %LNL%, %MNL%, %TAB%) are all now native in WeiDU, so you don't have to define them previously, but you do have to use uppercase references to them IIRC. Link to comment
Wisp Posted January 24, 2012 Share Posted January 24, 2012 Your mage_regexp does not allow for the leading space: Not Usable By: Mage Also, I do not recall the particulars, but there are caveats to using \b. It does not work as you would expect, IIRC. It may not be relevant to your case, but you should get into the habit of checking for word boundries in other ways. Link to comment
grogerson Posted January 25, 2012 Author Share Posted January 25, 2012 Most of the code is over my head in this. That's why I call myself a scavanger. I still continue to examine it and try different things to make it work, though with only limited success. Thus this thread. Offhand, I can't tell just by looking at the code - you'd probably have to run it and check it by looking at some items. BLUN01 and BLUN10. I've been installing the component and checking the results in NI. Uninstall, change the component, reinstall, check, uninstall... Mage is removed from the unusability line, so they can use them, but the item descriptions continue to fail to update. Your mage_regexp does not allow for the leading space: I've been messing about with the mage_regexp = EVALUATE BUFFER line near the bottom. I'm thinking I'm in the wrong place. Is the leading space problem in the DEFINE_PATCH_FUNCTION section or //update info section? And what is needed to allow for that leading space? Allow since mod added clubs may not have that lead space. Link to comment
Wisp Posted January 25, 2012 Share Posted January 25, 2012 Your mage_regexp does not allow for the leading space: I've been messing about with the mage_regexp = EVALUATE BUFFER line near the bottom. I'm thinking I'm in the wrong place. Is the leading space problem in the DEFINE_PATCH_FUNCTION section or //update info section? And what is needed to allow for that leading space? Allow since mod added clubs may not have that lead space. My mistake. That is not what is wrong at all. The problem is simply that you do not pass the variables offset and desc to the function. Link to comment
grogerson Posted January 25, 2012 Author Share Posted January 25, 2012 Wisp, I'm at a loss here. Two lines were removed because they don't exist in BG: READ_BYTE 0x31 "prof" ELSE 0 PATCH_IF ("%prof%" = 115) BEGIN Apart from this and the weapprof.2da changing the code is exactly the same as BG2 Tweaks. I see the variables defined, set (including the description), and then called. If I'm correct, the problem is in the bottom section, the very last action the component is supposed to accomplish. What should I look for to verify the offsets and description is being passed to the function? Link to comment
Wisp Posted January 25, 2012 Share Posted January 25, 2012 If you swap this in, it should work: LAUNCH_PATCH_FUNCTION ~REMOVE_MAGE_LINE_FROM_USABILITIES~ INT_VAR offset STR_VAR desc unusable_regexp = EVALUATE_BUFFER ~^[ %tab%]*\(Unusable By\|Not Usable By\).*~ unusable_replacement = ~Not Usable By:~ mage_regexp = EVALUATE_BUFFER ~[%lnl%%mnl%%wnl%].*\bMage.*~ class_prefix = ~ ~ END Bear in mind it will make all weapons useable by mages (so long as they are useable by fighters), not just clubs, since you removed that PATCH_IF. If you want to restrict it to just clubs you need some other way of screening out the clubs from the rest. If you can not use category (word at 0x1c) you may need to replace the COPY_EXISTING_REGEXP with an ACTION_FOR_EACH+COPY_EXISTING and a list of club items. Link to comment
skelo Posted August 12, 2012 Share Posted August 12, 2012 The item discription is the problem i have. my game has it all screwed up. is there any way to make all item discriptions go back to default or can someone create a simple mod called restore item descriptions? tha would be a big help! Link to comment
grogerson Posted August 13, 2012 Author Share Posted August 13, 2012 The item discription is the problem i have. my game has it all screwed up. is there any way to make all item discriptions go back to default or can someone create a simple mod called restore item descriptions? tha would be a big help! V4 has been submitted for upload, and the description updates method has been changed. As soon as it's up, you shouldn't have this problem. It's also possible something else screwed up the item descriptions. What mods to you have installed, and have you recently reinstalled one or more of them? Please post your WEIDU.log file (copy/paste from any text editor). Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.