jastey Posted January 22, 2019 Share Posted January 22, 2019 I am working on (another version of) a stutter debug tool that patches all scripts, which is much easier for players (in comparison to the version where you have to insert the scripts in question manually). This is the main code for this, and it works: Spoiler COPY_EXISTING_REGEXP ~.*\.bcs$~ ~override~ SET x = 0 - 1 DECOMPILE_BCS_TO_BAF REPLACE_EVALUATE ~\(RESPONSE #[0-9]+\)~ BEGIN x += 1 END ~~~~~\1 ActionOverride(Player1,DisplayString(Myself,~Running block %x% of %SOURCE_RES%.BCS~)) ActionOverride(Player1,DisplayStringHead(Myself,~Running block %x% of %SOURCE_RES%.BCS~))~~~~~ COMPILE_BAF_TO_BCS BUT_ONLY Problem is: there are quite a few scripts e.g. in BG:EE that have NoAction() scriptblocks in them (e.g. ACT03.bcs) - which trigger every time they are called, obviously. This clutters the text output up to a point where it's nearly impossible to determine the stutter script call. How would I patch every scriptblock in every script except for the ones where there is a "NoAction()" after the "RESPONSE #[0-9]+"? Coding help would be much appreciated. Quote Link to comment
Jarno Mikkola Posted January 22, 2019 Share Posted January 22, 2019 (edited) 1 hour ago, jastey said: Problem is: there are quite a few scripts e.g. in BG:EE that have NoAction() scriptblocks in them (e.g. ACT03.bcs) - which trigger every time they are called, obviously. This clutters the text output up to a point where it's nearly impossible to determine the stutter script call. Nope. Not in BG:EE, this could be the case with BG:EE+SotD, but not natively in BG:EE. And the usability of the debug function was/is that it shows all... you can pause the game and just look at the output and save that information, so you can look it up in the scripts later, look at everyone of the actions that the scripts ran and find the things that missfire. Or that prevent the other portions of the scripts from running... like for example a NoAction() . Also there's the DECOMPILE_BCS_TO_BAF ... COMPILE_BAF_TO_BCS which is no longer recommended as it can leave uncompiled file into the override folder... The suggestion is to use the DECOMPILE_AND_PATCH BEGIN ... END instead. You could possibly just ... COPY_EXISTING_REGEXP ~.*\.bcs$~ ~override~ DECOMPILE_BCS_TO_BAF REPLACE ~RESPONSE #100 NoAction()~ BEGIN ~~ COMPILE_BAF_TO_BCS BUT_ONLY .. before the above. Yes, it enlongers the install time... but, whatever. And besides, you break the game when you install the debug mod, so not gaining all the information, could be as hazzardious as gaining too much ! Uuh, that's so devastating. Another possibility would be to use the replace a with b without compilation in between, and then back the b with a, after the above, but thats install time ... is less than desirable I bet. Well a being ij#z in this case... ij# being my prefix. Spoiler COPY_EXISTING_REGEXP ~.*\.bcs$~ ~override~ SET x = 0 - 1 DECOMPILE_AND_PATCH BEGIN REPLACE ~RESPONSE #100 NoAction()~ BEGIN ~ij#z~ REPLACE_EVALUATE ~\(RESPONSE #[0-9]+\)~ BEGIN x += 1 END ~~~~~\1 ActionOverride(Player1,DisplayString(Myself,~Running block %x% of %SOURCE_RES%.BCS~)) ActionOverride(Player1,DisplayStringHead(Myself,~Running block %x% of %SOURCE_RES%.BCS~))~~~~~ REPLACE ~ij#z~ BEGIN ~RESPONSE #100 NoAction()~ END BUT_ONLY Edited January 22, 2019 by Jarno Mikkola Yes, this was edited dozen times... so there. Quote Link to comment
jastey Posted January 22, 2019 Author Share Posted January 22, 2019 Yes, it is BG:EE with SoD. Still, my question stands. Just to clearify: the debug tool would offer two install choices: one without the NoAction so an unexperienced player has a chance of identify the stuttering script, and for the case the stutter is actually caused by a NoAction script block, one install choice with them included. Quote Link to comment
Jarno Mikkola Posted January 22, 2019 Share Posted January 22, 2019 (edited) 23 minutes ago, jastey said: Just to clearify: the debug tool would offer two install choices: one without the NoAction so an unexperienced player has a chance of identify the stuttering script, and for the case the stutter is actually caused by a NoAction script block, one install choice with them included. This is as likely to interfer with the usability of the tool as the desition of adding a no-G3BG2Fixpack compatible component to the original. Which just skipped the 11 damaged scripts in the original game. Technically it helps... but this is a moding help tool, not a default users intented- install and forget that it even existed -mod, as it breaks the game. Well, it breaks the ingame cinematics. Ouh, and be sure to re-read my original reply, I edited it a lot, so you might have missed out the DECOMPILE_BCS_TO_BAF ... etc stuff. Edited January 22, 2019 by Jarno Mikkola Quote Link to comment
Ardanis Posted January 22, 2019 Share Posted January 22, 2019 COPY_EXISTING_REGEXP GLOB ~.+\.bcs~ override DECOMPILE_AND_PATCH BEGIN x = 0 SPRINT debug ~~ REPLACE_EVALUATE ~\(RESPONSE #[0-9]+[%WNL%%LNL%%MNL%][ %TAB%]+\([^ %TAB%%WNL%%LNL%%MNL%]+\)\)~ BEGIN PATCH_IF ~%MATCH2%~ STR_CMP ~NoAction()~ BEGIN x += 1 SPRINT debug ~~~~~ActionOverride(Player1,DisplayString(Myself,~Running block %x% of %SOURCE_RES%.BCS~)) ActionOverride(Player1,DisplayStringHead(Myself,~Running block %x% of %SOURCE_RES%.BCS~))~~~~~ END END ~\1 %debug%~ END BUT_ONLY Quote Link to comment
jastey Posted January 22, 2019 Author Share Posted January 22, 2019 @Ardanis Thank you very much! I moved the "SPRINT debug ~~" so it doesn't patch the NoAction() blocks with the former block number. What does ~%MATCH2%~ mean and is there a list of these (weidu) variables and functions somewhere? Spoiler COPY_EXISTING_REGEXP GLOB ~.+\.bcs~ override DECOMPILE_AND_PATCH BEGIN x = 0 // SPRINT debug ~~ REPLACE_EVALUATE ~\(RESPONSE #[0-9]+[%WNL%%LNL%%MNL%][ %TAB%]+\([^ %TAB%%WNL%%LNL %%MNL%]+\)\)~ BEGIN SPRINT debug ~~ PATCH_IF ~%MATCH2%~ STR_CMP ~NoAction()~ BEGIN x += 1 SPRINT debug ~~~~~ActionOverride(Player1,DisplayString(Myself,~Running block %x% of %SOURCE_RES%.BCS~)) ActionOverride(Player1,DisplayStringHead(Myself,~Running block %x% of %SOURCE_RES%.BCS~))~~~~~ END END ~\1 %debug%~ END BUT_ONLY Quote Link to comment
Ardanis Posted January 22, 2019 Share Posted January 22, 2019 (edited) 9 minutes ago, jastey said: Thank you very much! I moved the "SPRINT debug ~~" so it doesn't patch the NoAction() blocks with the former block number. I'm getting old... 9 minutes ago, jastey said: What does ~%MATCH2%~ mean and is there a list of these (weidu) variables and functions somewhere? Same as \2, i.e. the match to second regular expression (blue) in the string: ~\(RESPONSE #[0-9]+[%WNL%%LNL%%MNL%][ %TAB%]+\([^ %TAB%%WNL%%LNL%%MNL%]+\)\)~ These can be nested, and WeiDU counts them as it reads the string, rather than respecting parentheses. ~\(one \( two\) \(three\) \) \(four\)~ Edited January 22, 2019 by Ardanis Quote Link to comment
jastey Posted January 22, 2019 Author Share Posted January 22, 2019 @Ardanis Thank you! What does STR_CMP mean? Quote Link to comment
Gwendolyne Posted January 22, 2019 Share Posted January 22, 2019 Excerpt from WeiDU doc: Quote You may use STR_CMP as a synonym for STRING_COMPARE. This expression evaluates to 0 if and only if its two string arguments are equal (have the same length and the same contents). Otherwise it will evaluate to a negative or positive integer, depending on whether the first string argument would sort lexicographically before or after the second string argument. variables within the strings (e.g., “%mykit%”) are replaced by their values. Note that variables that you want expanded must be put in %’s, otherwise the raw text will be used Briefly it compares two strings content. Quote Link to comment
Ardanis Posted January 22, 2019 Share Posted January 22, 2019 Think of ~a~ STR_CMP ~b~ as a shorthand for NOT (~a~ STRING_EQUAL ~b~). Quote Link to comment
jastey Posted January 22, 2019 Author Share Posted January 22, 2019 Cool. Thank you for the explanations! @Gwendolyne You mean I should just have looked into the weidu readme?... Quote Link to comment
Gwendolyne Posted January 22, 2019 Share Posted January 22, 2019 @jastey No, but it took me years to understand how it works (in a rather non intuitive way, it is the opposite of STRING_EQUAL) and I have been using it only for a couple of years. Quote Link to comment
Jarno Mikkola Posted January 22, 2019 Share Posted January 22, 2019 7 minutes ago, Gwendolyne said: @jastey No, but it took me years to understand how it works (in a rather non intuitive way, it is the opposite of STRING_EQUAL) and I have been using it only for a couple of years. I am not sure you understand the question there, as it was, the weidu manual has a "clear" definition for the STR_CMP. But then again, we men are of the generation of -nobody reads the manual, it can't be that hard so we just attempt it until our luck gets to us, so to speak. Quote Link to comment
jastey Posted January 22, 2019 Author Share Posted January 22, 2019 1 hour ago, Jarno Mikkola said: we men are of the generation of -nobody reads the manual, it can't be that hard so we just attempt it until our luck gets to us, so to speak. Welllll, that's not worse than the -nobody reads the manual, there is surely a man around who can explain it to me- approach some women are using. Aaaand $5 into the sexism piggybank, both of us! 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.