How to play text only once without self-switches?

Discussion in 'RPG Maker MV' started by kerb, Jan 25, 2019.

    Tags:
  1. kerb

    kerb Villager Member

    Messages:
    6
    Likes Received:
    0
    First Language:
    english
    Primarily Uses:
    N/A
    So I wish to interact with an npc and have them display a one-time text statement of say:
    TextA: "Hey you!"
    And then have them jump into a conditional branch with an else statement. If the condition is achieved then generally I am going to apply a self-switch and have it jump to a different event page and set of events.

    The problem is when I have the else statement apply. While it works for the initial interaction..... when you interact again and the condition isn't fulfilled it applies the same:
    TextA: "Hey you!"

    I basically want to set the TextA as an initial greeting that only plays one time, and never ever again. This can be done by creating a self-switch, but that is ridiculous to me given there are only 4 self-switches available alongside the amount of work of setting up another page and toggling between them for a simple operation. It just doesn't seem efficient to me, so I'm wondering if there is another way I'm not seeing? Or is there a plugin/addon to fix this problem so you can create more interactive/dynamic chats with npc?

    For example if I wanted to make an npc say something different every-time i talked to them....how would you do that in an efficient and effective manner? I mean we could do 1 self-switch and 1 event page PER interaction.....and then switch over to normal switches once we fufill the 4 max....but that doesn't seem right to me given the sheer number of pages and busywork of sorting through them.

    I know there's an addon for increasing self-switches, but this doesn't change the initial problem of the process being inefficient. And if the game is designed to avoid interactive conversations...it would give me an idea of how it will treat similar operations.
     
    #1
  2. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    12,303
    Likes Received:
    12,515
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    You can use a variable instead. Increase it by 1 every time an interaction is done, and use a new page. Or you set it up to cycle through the text in order based on the variable, and just increase it by one.
     
    #2
  3. Andar

    Andar Veteran Veteran

    Messages:
    28,637
    Likes Received:
    6,578
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    you need something to store the info that the text was already used.
    You don't have to use self-switches, but some storage has to be used - either self-switches or regular switches or variables. Or you could give hidden items as markers (that would also double as some fraction reaction, having several NPCs react when one of them gave a hidden item "friend of .." or "enemy of ...".

    You don't need new event pages for each interaction as you could check that storage option with a conditional branch on a single event page
     
    #3
    Prescott likes this.
  4. kerb

    kerb Villager Member

    Messages:
    6
    Likes Received:
    0
    First Language:
    english
    Primarily Uses:
    N/A
    Okay I was able to get the many paged method to work fine. So that will be useful, but in terms of....

    Based on what you said, below in the image is the best I could figure out. The main problem is I can't figure out how to stop the interaction after the control variable gains +1. So basically he just goes down the entire list of text options in a single interaction. So my questions are twofold:

    1. What command do I use to cease an interaction at a certain time in my script? (I'd want a stop after the variable gains +1 each time). I tried 'break loop' and 'exit event processing', but both of these allowed the first interaction to work but no subsequent ones.
    2. If I just want an npc to respond 10 different ways with a single line of text when interacted with 10 different times...Is the method outlined below, once corrected, the most efficient way to go about doing this?


    EDIT: Putting the +1 variable and then a loop break WITHIN each if statement got it working properly. I'm having a hard time knowing when to place things within vs after arguments I guess. Even with self-switches I don't understand why I have to turn A off when specifying B to be turned on.

    Untitled.jpg
     
    Last edited: Jan 25, 2019
    #4
  5. Shaz

    Shaz Veteran Veteran

    Messages:
    37,806
    Likes Received:
    11,511
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    The above won't work, because you're incrementing the variable outside of the loop, and multiple times in the event.

    So first time you talk to him, the variable will be 0, so "first thing" will be the text shown. Then you're immediately incrementing the variable, which will set it to 1, so the next condition will be true, so he'll also say "second thing". Then you're incrementing the variable again, setting it to 2, so the next condition will be true, and he'll say "third" thing. Then you're incrementing the variable again, so the >= 3 condition will be true, and he'll say "fourth and last thing".

    So you speak to him once, and he will say all 4 lines.

    Instead, you should do something like this:
    Code:
    If redguy = 0
      Text: first thing
    Else
      If redguy = 1
        Text: second thing
      Else
        If redguy = 2
          Text: third thing
        Else
          Text: fourth and last thing
        End
      End
    End
    Variable redguy += 1
    So you're only incrementing the variable once each time you talk to him, and he's only going to say one line.

    This is probably the best method to use if you have a reasonably small number of options. It will make sure only one thing is said and the loop is exited, incrementing the variable once. You might find the indenting a bit hard to follow if you have too many. 10 is probably do-able, but it's just going to get messy, the more options you add.

    An alternative might be something like this:
    Code:
    If redguy = 0
      Text: first thing
      Jump to Label: All Done
    End
    
    If redguy = 1
      Text: second thing
      Jump to Label: All Done
    End
    
    If redguy = 2
      Text: third thing
      Jump to Label: All Done
    End
    
    (and repeat as many times as you like)
    
    Label: All Done
    Variable redguy += 1
    This isn't efficient though, as if you have 10 options, and your variable has reached 10, each time you talk to him, it's going to do a variable test 9 times before it finds the one that's true. If you're going to be able to talk to him as many times as you want, and he'll always say the same thing at the end, it would be more efficient to put them in the opposite order, so each time you talk to him, there'll be one less condition to check before it finds the 'true' one.

    Either way is probably not going to show a difference that's noticeable to the player though.
     
    #5
  6. Bex

    Bex Veteran Veteran

    Messages:
    1,267
    Likes Received:
    300
    First Language:
    German
    Primarily Uses:
    RMMV
    Pseudo Eventcode:
    Code:
    Conditional Branch Self Switch A is OFF?
    If yes: Turn Self Switch A to On and TextA: "Hey you!"
    end
    rest of your code
    Thisway you have it on the same Eventpage and its only executed one time.

    For random speech you need a Variable.
    Here is a simple example, but to make sure the NPC never says same thing twice, we would need to implement some more conditions, but not to much at once.
    Code:
    Control Variable X = Random 1 to 4
    If VarX = 1
    TextA: "Not long till Food break" ; end
    If VarX = 2
    TextA: "Why wont this work" ; end
    If VarX = 3
    TextA: "Yes i see you" ; end
    If VarX = 4
    TextA: "What a nice Day" ; end
    Here the edited code so he does not say the same twice after another.
    Code:
    Label "Again"
    Control Variable X = Random 1 to 4
    IF VarX equals VarY
     Jump to Label "Again"
    ELSE
     Control VarY set to VarX
     If VarX = 1
     TextA: "Not long till Food break" ; end
     If VarX = 2
     TextA: "Why wont this work" ; end
     If VarX = 3
     TextA: "Yes i see you" ; end
     If VarX = 4
     TextA: "What a nice Day" ; end
    END 
    VarX is the current random number
    VarY is the previous random number
    Comparing both allows us to make sure the Event doesnt say the same twice after another.
    Eventcode is normaly executed Line by Line, command for command, not sure if that helps.

    Edit:
    I would do for example 4 Text Options which appear in random order but always a different one until all 4 are used, than it will be shuffled again. Thatway the Player can get all NPC sayings and he will notice when it starts to repeat. In my Above Code example that is sadly not the case.
    Iam to lazy to find/write the code for that at the moment =)...that can change if you need it.
     
    Last edited: Jan 25, 2019
    #6

Share This Page