How to cycle between dialogue each time you speak to the same NPC--but with a catch?

Hello, all. Mulling over how to do something related with quests and changing up dialogue in RPG Maker MV, but I guess this is more a general eventing/scripting question. Regardless, forgive me if my title for this topic is too obtuse or vague.

At any rate, I aim to have a quest station NPC that essentially tells rumors of people needing help (i.e. quest opportunities within the game world). This way if there are out-of-the-way quests or quests that the player may not want to investigate the entire world to find and discover, they can be "guided" towards these quests, and not in a "hit you over the head" sort of way.

Some quick notes on what I'm looking for and wanting--all at once from this NPC:

- I want it to update with new rumors/quest opportunities on a regular basis through story progression.
- I want it to cycle through all available rumors, one rumor given each time the NPC is talked to--thus, once say, all three currently available rumors have been told, it'd cycle back to the first of those three rumors the next time the NPC was talked to.
- I want it to remove rumors when the quest pertaining/related to that rumor is successfully completed by the player.

How would you most efficiently--or since I'm not exactly the brightest with the more technical aspects of eventing/scripting--most easily accomplish such a feat? Thanks for reading! 🙂
This all comes down to conditions. If there is just 1 condition, you can use a switch.

You get a condition like:

If switch Met Before is off:
"Hi, I am polly."
Turn switch on
Else:
"Nice to see you again. Remember me?" I'm Polly!"

If you have more cases, you might want to use a variable.

If var Met Before is 0:
"Hi, I am polly."
If var Met Before is 1:
"Hi, we Met once before, right?"
If var Met before > 2:
"We keer walking into each other. Maybe it's meant to be."
As said above you'll need to use variable - but getting all your conditions in will be much more complex than the example above.

The key is the maximum number of rumors - the higher that is the more problematic this becomes with eventing alone.

the first step would be to make some sort of matrix where every possible rumor gets some sort of storage to decide on "active"/"inactive".
then you'll need a rumor counter - each time you trigger the NPC it would give the rumor assigned to that specific number, then check the matrix and count up to the next active number

and your different quest givers would activate a rumor in the matix when it becomes available and inactivate it when the quest is solved.
for guided info towards a quest, you can check the quest is in progress.
or use a switch and variable.

condition: script: $gameSwitches.value(x) && $gameVariables.value(y) == 1
guide for step 2
else
condition: script: $gameSwitches.value(x) && $gameVariables.value(y) == 0
guide for step 1 if needed
end

keep in mind, the condition is reverse, one its true, you can do it in order as well
for 0, 1, 2, 3 etc as it checks if the value is equal to the number, so it can guide you.

variables are powerful if used correctly, you can also use labels if you want to
to check if a step is completed and jump to the correct label.

depends on the step and complicity, find the best way that suit you.
Just as a quick addendum, I don't see any reason to resort to script calls to check variable values. The regular Conditional Branch allows you to look at a variable's value for a quest being active/at a certain stage.

The tricky/weird part of this is keeping your place in the rumors while completing quests or whatever which might change your place.

To that end, I actually suggest the opposite of what Andar did. Do not have and modify a variable which indicates the maximum number of rumors found. Instead, when you talk to the NPC, it increments your placement in the stack if that rumor isn't pertinent. For example:
At the beginning of the game, set Rumor Count to 1
Then, in the Rumor NPC:
Conditional Branch -> Rumor Count == 1
- Give the first rumor
- Control Variables -> Rumor Count + 1
- Exit Event Processing
Conditional Branch -> Rumor Count == 2
- Control Variables -> Rumor Count + 1
- Conditional Branch -> You have the quest to find the thing
- - Give the rumor about that quest
- - Exit Event Processing
Conditional Branch -> Rumor Count == 3
- If you did not have the quest in the prior conditional, 2 will automatically become 3 and go to this
Seems to me that the easiest way would be to just keep all the rumours in an array, and add or remove from it as necessary. So, when you first start the game, set up a list in one of your variables with the starting rumours (I'm storing mine in variable 3 here):

(All of these are Script event commands)

Code:
const array = ['hint 1', 'hint 2', 'hint 3'];
$gameVariables.setValue(3, array)

Then, when you talk to the NPC, they can have a Script that says:

Code:
$gameMessage.add($gameVariables.value(3)[0]);
$gameVariables.value(3).push($gameVariables.value(3).shift())

Which will display the first message in the list, and then cycle it to the end.

To add new messages to the list, you'd do:

Code:
$gameVariables.value(3).push('hint 4')

And to remove them from the list once you've completed a quest, you'd do:

Code:
const index = $gameVariables.value(3).indexOf('hint 2');
if (index > -1) {
  $gameVariables.value(3).splice(index, 1);
}
@Showsni you could absolutely implement it like that.

I would strongly disagree with it being the simplest way. It's the most efficient, in terms of how long the conversation event will be.

But there are numerous disadvantages to doing it that way, especially the fact that all of the conveniences of the Show Text command are taken away.
- If the event has a face displayed, that's an additional script call the OP has to learn; and if it's a different face for any of the rumors, it's an entire additional chunk of code with an array of which hints have which faces, or turning the array into an array of objects with the face index and the rumor itself...that simple thing can get very messy.

- If the OP isn't using a plugin for word wrapping, they'll have to use another piece of software or keep manual track of the character count and manually insert line breaks. Speaking of:

- Any escape codes will have to be written differently to account for being stored in an external string.

Also, it only works well at all if the extent of the event is literally talk to the NPC, get a rumor, end. If there's anything else that can happen for some of them - multiple messages being shown, or the player getting choices to ask questions in return - it falls apart. Granted, the OP didn't specify anything like that, but it's easily accounted for by the eventing solution above and not really possible in this code version.

Finally, there's a strong disadvantage in that the push() method puts the new hint at the end of the array. So when the player gets a new quest, they won't hear a rumor about it until they've gone all the way through everything else the NPC has to say. You'd need additional code to put the new, pertinent rumor at the beginning.
Using @ATT_Turan ‘s idea:

Code:
◆If:rumortalk = 1
  ◆If:rumor1 is ON
    ◆Text:None, Window, Bottom
    :    :let's talk about rumor #1
    ◆
  :End
  ◆Control Variables:#0001 rumortalk += 1
  ◆Exit Event Processing
  ◆
:End
◆If:rumortalk = 2
  ◆If:rumor2 is ON
    ◆Text:None, Window, Bottom
    :    :let's talk about rumor #2
    ◆
  :End
  ◆Control Variables:#0001 rumortalk += 1
  ◆Exit Event Processing
  ◆
:End
◆If:rumortalk = 3
  ◆If:rumor3 is ON
    ◆Text:None, Window, Bottom
    :    :let's talk about rumor #3
    ◆
  :End
  ◆Control Variables:#0001 rumortalk = 1
  ◆Exit Event Processing
  ◆
:End

Edit* Fixed the last one.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-cycle-between-dialogue-each-time-you-speak-to-the-same-npc-but-with-a-catch.171099/