argent77 Posted September 3, 2020 Share Posted September 3, 2020 What exactly fails? Should only one of the two responses be patched? I think that could be solved with an UNLESS or IF condition. Quote Link to comment
jastey Posted September 3, 2020 Author Share Posted September 3, 2020 No, both should be patched. Since the reply option index is stored in a variable called "responses_%statenumber%" I though it can't be used for patching two reply options in one dialogue state. Quote Link to comment
jastey Posted September 5, 2020 Author Share Posted September 5, 2020 I would need help to adjust this structure so it also can store several reply option indexes for one dialogue state, and would be very happy for help. // List of all potential response strrefs to check ACTION_DEFINE_ASSOCIATIVE_ARRAY response_strrefs BEGIN 43058 => 1 49175 => 1 END COPY_EXISTING ~aran.dlg~ ~override~ // scanning listed dialog states PATCH_FOR_EACH state IN 39 70 BEGIN LPF GET_RESPONSE_STRREFS INT_VAR state RET strrefs RET_ARRAY strrefs END TEXT_SPRINT indices ~~ // a temporary variable for building the index list FOR (i = 0; i < strrefs; ++i) BEGIN SET value = $strrefs(~%i%~) // Include index only if strref is listed in the response_strrefs array PATCH_IF (VARIABLE_IS_SET $response_strrefs(~%value%~)) BEGIN TEXT_SPRINT indices ~%indices% %i%~ // building list of indices END END // prevent adding a trigger if index list is empty PATCH_IF (~%indices%~ STR_EQ ~~) BEGIN TEXT_SPRINT indices "IF ~a_nonexisting_trigger()~" END // initialize variables responses_39, responses_40, ... // EVAL is used to create the variable name dynamically TEXT_SPRINT EVAL ~responses_%state%~ ~%indices%~ PATCH_PRINT ~Variable %state%: %indices%~ END BUT_ONLY Quote Link to comment
argent77 Posted September 5, 2020 Share Posted September 5, 2020 4 hours ago, jastey said: I would need help to adjust this structure so it also can store several reply option indexes for one dialogue state, and would be very happy for help. That example code (together with the function GET_RESPONSE_STRREFS I posted in an earlier comment) should work fine with multiple responses in individual states. Have you encountered any problems? Quote Link to comment
jastey Posted September 5, 2020 Author Share Posted September 5, 2020 Sorry for being daft. I don't see how I would call several reply option indeces in the same state. Currently, I get one idex per state. E.g. for state 39, the reply option index with the matching string is stored in %responses_39%. I call it inside the d with: ADD_TRANS_TRIGGER ARAN 39 ~Global("C#IM_ImoenStays","GLOBAL",0)~ DO %responses_39% For calling more than one I would need several variables for the different reply option indeces of one state which I do not see in the current version of the code. Quote Link to comment
argent77 Posted September 5, 2020 Share Posted September 5, 2020 There is no need to call ADD_TRANS_TRIGGER multiple times for the same state. All responses that should be updated are listed in the variable following the DO keyword. For example, this code ADD_TRANS_TRIGGER ARAN 39 ~Global("C#IM_ImoenStays","GLOBAL",0)~ DO %responses_39% will be resolved as ADD_TRANS_TRIGGER ARAN 39 ~Global("C#IM_ImoenStays","GLOBAL",0)~ DO 1 3 if the code structure from your earlier comment found matching strrefs in response entries 1 and 3. This .d command will then add the trigger "Global("C#IM_ImoenStays","GLOBAL",0)" to both response entries in one go. Quote Link to comment
jastey Posted September 6, 2020 Author Share Posted September 6, 2020 Oooooh. Nice. I didn't understand that's how this works. Awesome! Thanks for your patience. Quote Link to comment
jastey Posted September 6, 2020 Author Share Posted September 6, 2020 I hit one problem I am sure is on my side. If I use an OUTER_SPRINT for the stringref numbers, e.g. %63960% => 1. Is there anything obvious why it would work for SoD, but not for EET? This is what I use for both games inside a tpa: Spoiler /* ADD_TRANS_TRIGGER for specific reply options for Imoen_in_group_KD.d */ <<<<<<<< .../inlined/i4e_BDIMOEN.d /* #63960 ~I'm more concerned about you. How have you been doing these last few weeks?~ */ ADD_TRANS_TRIGGER BDIMOEN 9 ~!InParty("%IMOEN_DV_SOD%")~ DO %responses_9% //9 /* #65051 ~How have you been doing these last few weeks?~ */ ADD_TRANS_TRIGGER BDIMOEN 12 ~!InParty("%IMOEN_DV_SOD%")~ DO %responses_12% //9 /* #70436 ~Duke Jannath sent you here seeking magical papers or books, did she not? I found these in Korlasz's room.~ */ ADD_TRANS_TRIGGER BDIMOEN 33 ~!InParty("%IMOEN_DV_SOD%")~ DO %responses_33% //1 >>>>>>>> // List of all potential response strrefs to check ACTION_DEFINE_ASSOCIATIVE_ARRAY response_strrefs BEGIN %63960% => 1 %65051% => 1 %70436% => 1 END COPY_EXISTING ~BDIMOEN.dlg~ ~override~ // scanning listed dialog states PATCH_FOR_EACH state IN 9 12 33 BEGIN LPF GET_RESPONSE_STRREFS INT_VAR state RET strrefs RET_ARRAY strrefs END TEXT_SPRINT indices ~~ // a temporary variable for building the index list FOR (i = 0; i < strrefs; ++i) BEGIN SET value = $strrefs(~%i%~) // Include index only if strref is listed in the response_strrefs array PATCH_IF (VARIABLE_IS_SET $response_strrefs(~%value%~)) BEGIN TEXT_SPRINT indices ~%indices% %i%~ // building list of indices END END // prevent adding a trigger if index list is empty PATCH_IF (~%indices%~ STR_EQ ~~) BEGIN TEXT_SPRINT indices "IF ~False()~" END // initialize variables responses_39, responses_40, ... // EVAL is used to create the variable name dynamically TEXT_SPRINT EVAL ~responses_%state%~ ~%indices%~ PATCH_PRINT ~Variable %state%: %indices%~ END BUT_ONLY // Variables response_39, response_70 // are now initialized and can be used in the .d file COMPILE EVAL ~.../inlined/i4e_BDIMOEN.d~ /* if Imoen is not in party, the final dialogue should not be triggered by one of the FF soldiers unless Imoen and the PC are at the exit. */ <<<<<<<< .../inlined/i4e_BDFF1000.d /* #69736 ~Thank you. I'm ready to return to the Ducal Palace now.~ */ ADD_TRANS_TRIGGER BDFF1000 0 ~Range("%IMOEN_DV_SOD%",20) !StateCheck("%IMOEN_DV_SOD%",CD_STATE_NOTVALID) !Dead("%IMOEN_DV_SOD%")~ DO%responses_0% //2 >>>>>>>> // List of all potential response strrefs to check ACTION_DEFINE_ASSOCIATIVE_ARRAY response_strrefs BEGIN %69736% => 1 END COPY_EXISTING ~BDFF1000.dlg~ ~override~ // scanning listed dialog states PATCH_FOR_EACH state IN 0 BEGIN LPF GET_RESPONSE_STRREFS INT_VAR state RET strrefs RET_ARRAY strrefs END TEXT_SPRINT indices ~~ // a temporary variable for building the index list FOR (i = 0; i < strrefs; ++i) BEGIN SET value = $strrefs(~%i%~) // Include index only if strref is listed in the response_strrefs array PATCH_IF (VARIABLE_IS_SET $response_strrefs(~%value%~)) BEGIN TEXT_SPRINT indices ~%indices% %i%~ // building list of indices END END // prevent adding a trigger if index list is empty PATCH_IF (~%indices%~ STR_EQ ~~) BEGIN TEXT_SPRINT indices "IF ~False()~" END // initialize variables responses_39, responses_40, ... // EVAL is used to create the variable name dynamically TEXT_SPRINT EVAL ~responses_%state%~ ~%indices%~ PATCH_PRINT ~Variable %state%: %indices%~ END BUT_ONLY // Variables response_39, response_70 // are now initialized and can be used in the .d file COMPILE EVAL ~.../inlined/i4e_BDFF1000.d~ This is from my tp2: Spoiler ALWAYS (snip) ACTION_IF GAME_IS ~bgee~ THEN BEGIN OUTER_SPRINT ~63960~ ~63960~ // OUTER_SPRINT ~65051~ ~65051~ // OUTER_SPRINT ~69736~ ~69736~ // OUTER_SPRINT ~70436~ ~70436~ // END ACTION_IF GAME_IS ~eet~ THEN BEGIN OUTER_SPRINT ~63960~ ~263960~ OUTER_SPRINT ~65051~ ~265051~ OUTER_SPRINT ~69736~ ~269736~ OUTER_SPRINT ~70436~ ~270436~ END END //ALWAYS For SoD, it installs and patches fine. For EET, it does not patch anything in BDIMOEN, and gives error messages for the other dialogue files: Spoiler Installing [Imoen 4 Ever in SoD: Imoen Remains in Group in Korlasz' Dungeon] [v5 pre] [*.IDS] forgotten Appending to files ... Not appending [0x80101FEF CD_STATE_NOTVALID...] to [STATE.IDS] because it DOES contains [CD_STATE_NOTVALID] Extending game scripts ... [./override/BG0123.BCS] loaded, 991 bytes override/BG0123.bcs copied to imoen_forever/backup/10/BG0123.bcs, 991 bytes Extended script [BG0123.bcs] with [.../i4e_sod_detection.baf] Extending game scripts ... [./override/BD0103.BCS] loaded, 75430 bytes override/bd0103.bcs copied to imoen_forever/backup/10/bd0103.bcs, 75430 bytes Extended script [bd0103.bcs] with [.../i4e_sod_detection.baf] Copying and patching 1 file ... [./override/BDIMOEN.dlg] loaded, 28436 bytes Variable 9: IF ~False()~ Variable 12: IF ~False()~ Variable 33: IF ~False()~ Compiling 1 dialogue file ... Processing 1 dialogues/scripts ... [./override/BDIMOEN.DLG] loaded, 28436 bytes [BDIMOEN.DLG] loaded [BDIMOEN.DLG] saved 142 states, 336 trans, 18 strig, 146 ttrig, 73 actions override/BDIMOEN.dlg copied to imoen_forever/backup/10/BDIMOEN.dlg, 28436 bytes Copying and patching 1 file ... [./override/BDFF1000.dlg] loaded, 4795 bytes Variable 0: IF ~False()~ Compiling 1 dialogue file ... Processing 1 dialogues/scripts ... [./override/BDFF1000.DLG] loaded, 4795 bytes [BDFF1000.DLG] loaded ERROR: Cannot resolve internal symbolic label [DOIF] for DLG [BDFF1000] Known labels: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ERROR: processing .D actions [tb#_compile_eval_buffer/.../inlined/i4e_BDFF1000.d]: Failure("cannot resolve label") Stopping installation because of error. Stopping installation because of error. Since the definitions of the OUTER_SETs are set and the structure is completely the same for both games, I am at a loss what the problem for EET would be. Quote Link to comment
argent77 Posted September 6, 2020 Share Posted September 6, 2020 This definition doesn't work as intended: ACTION_DEFINE_ASSOCIATIVE_ARRAY response_strrefs BEGIN %63960% => 1 %65051% => 1 %70436% => 1 END The percent sign is, along with tilde (~) and quotation mark ("), one of several options to enclose strings. The percent sign is special as it has a double meaning depending on context. It can be used to enclose strings as well as evaluate variables inside strings. So in this example you're just using the literal number 63960 as the array index since the percent signs aren't placed inside a string. This code should work as intended: ACTION_DEFINE_ASSOCIATIVE_ARRAY response_strrefs BEGIN ~%63960%~ => 1 ~%65051%~ => 1 ~%70436%~ => 1 END I would generally advise against using the percent sign for enclosing strings. Both tilde and quotation mark are much more readable and less ambiguous. Quote Link to comment
jastey Posted September 6, 2020 Author Share Posted September 6, 2020 Aah, that makes a lot of sense! This is one of the things where I see it clearly afterwards but needed a second pair of eyes to realize. Thank you - again! - for your insight and patience. 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.