I currently have a blueprint for an NPC that is meant to branch between a set set of dialogue lines depending on which item the player is holding when they overlap. Then, once that dialogue is finished, a custom event runs that selects another small dialogue tree at random and runs that as well. Once the random dialogue tree ends the dialogue event that was chosen is logged so that it is not picked again.
The system works the first time through as intended, the player picks up the first item and overlaps the NPC, the dialogue even chain I described runs and the print string nodes I put in are showing that all my variable changes are occurring properly. However, on the second overlap while carrying a different item, the script seems to recognize the new item and run the first line of associated dialogue, before skipping to the random dialogue event chain and running the first line of that. After that bugged random dialogue line appears the remainder of the random dialogue script continues looping and skipping through sections while adding and removing the associated widgets to and from the viewport.
Images of the blueprint nodes I’m troubleshooting:
Part 1:
Part 2:
Part One, The initial overlap script:
Here I check the overlapping actor is the player and prevent the event chain from firing if the player is already overlapping. Then I add the dialogue box and check to see if the player has an item, moving to the associated chain if true and displaying a random line of ‘filler’ dialogue if no item. (the random failure dialogue works perfectly, is unrelated to the aforementioned main random dialogue tree, and continues to work when the other parts of this script break.)
The next section with the dialogue events I just mentioned:
Okay, so here I’m setting the gameplay mode, showing cursor, and destroying the item the player brings to the NPC along with a related barrier in the game world. Once that’s done the first line of dialogue related to the item is displayed letter-by-letter (this is done in the widget) and I make a delay timer set to end shortly after the last letter of the text is displayed. Once the text is done the event graph should be waiting for the player to click on a button that also appears. (some items have an extra line of dialogue but the steps remain the same).
The different initial overlap dialogue branches then converge.
Here it waits for another button press that displays one line of dialogue, and then it’s back to waiting for a button to run the main random dialogue chain (if it isn’t running already).
Part 2 The random dialogue chain selection script:
Starting out I have another string displaying any logged indexes from the random event chain, and setting the bool that the event is running to true so it can’t be called while running. Then I add the dialogue box back and void it in case there is any text still stored inside. Next, I get the random index from a basic integer array with 16 indexes (0-15) before checking to see if this is the first time the random selector has been used. If it is the first use, skip the check against previously used indexes and find the random dialogue event chain to be run (next image). However, if a subsequent call of the event chooses a previously used index, it is supposed to rerun the first section until a new index is chosen.
Then I am getting that random index I selected earlier and run the associated random dialogue chain. If somehow no values match, the last false node runs the event from the beginning.
The comment box contains an example of one of the random dialogue events.
These events function on very similar logic to that used earlier, and considering the ‘skipping’ starts right when each section displays the initial dialogue I suspect the issue may lie there.
At the end of each random dialogue chain a ‘EndEvent’ is called.
Not much new activity there, another dialogue line is shown (this displays pretty reliably even when prior events break oddly enough). This is also where the index that was just used is set for later reference. Finally player movement is re-enabled and the dialogue widgets are removed, ending the interaction.
I have been running myself in circles now to the point that I am probably missing something glaring right in front of me, but at this point any fresh perspective would be appreciated. Thanks!