Conditional Branch for MP Regen is dysfunctional. Please help!

Discussion in 'RPG Maker VX Ace' started by Cuddlebuns, Nov 17, 2019.

Thread Status:
Not open for further replies.
    Tags:
  1. Cuddlebuns

    Cuddlebuns Veteran Veteran

    Messages:
    30
    Likes Received:
    4
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    I have this common event running as a parallel process.

    Screenshot (105).png

    The common event is a very simple, three-step process:

    Step 1: Define the variable "Joy" as the player's MP.
    Step 2: If "Joy" is greater than 0, heal the player's MP by 1 every 120 frames; otherwise move on to Step 3.
    Step 3: If "Joy" is equal to 0, damage the player's HP by 1 every 60 frames.

    The conditional branch in Step 2 seemingly ignores the variable it is meant to check and heals the player's MP every 120 frames regardless of whether "Joy" is equal to 0. At absolutely no point in this common event does it say to keep healing MP even when "Joy" is equal to zero. This is the first and only common event I currently have in this project, and already it has become painstakingly inviting of my singular derision.

    I am so infuriated with this, I am just about ready to explode in a fiery fit of rage and break everything around me. I need help!
     
    #1
  2. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    12,417
    Likes Received:
    12,650
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    You may have other MP regeneration items, which will kick in every so many steps. However, to test your event, add a text box in each of the conditions, which say:

    This is the first case: \V[2]

    For the else, have the test box say:

    This is the 2nd case: \V[2].

    This will tell it to output the value of the variable, and you will know which loop is being run.

    Also you should really name the actor, as it is saying [].mp, so you might be getting garbage input. And you also have an extra set variable command in the last loop which is redundant, and would mess up error checking too.

    One last thing: Check all scripts. Some use variable 2 for the coding. If that happens you will get unpredictable results. You may need to change to variable 22, as 1 - 20 get used by many scripts if you don't remember to configure them first.
     
    #2
  3. Cuddlebuns

    Cuddlebuns Veteran Veteran

    Messages:
    30
    Likes Received:
    4
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    I have no items, armours, weapons, or parameters which cause MP regeneration. I conducted two tests. In both tests, the actor's name was aptly changed to "Yellow Dot".

    The first test was done with the variable identification number unchanged.
    Screenshot (106).png

    The result of the first test indicated the first case was triggering every 120 frames, with "Joy" equal to the player's MP. Aside from the text, there was no change.

    The second test was done with the variable identification number changed to 22.
    Screenshot (107).png

    The result of the second test indicated the first case was triggering every 120 frames, but "Joy" was shown to be 0 regardless of the player's MP.

    Edit: I just noticed that I made an error in the second test. I forgot to change the variables within the text. Upon fixing this, the result of the second test is the same as the result of the first test.
     
    Last edited: Nov 17, 2019
    #3
  4. Wavelength

    Wavelength Pre-Merge Boot Moderator

    Messages:
    4,518
    Likes Received:
    3,771
    Location:
    Florida, USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    I don't think your event's logic is solid. You are continually setting Joy to MP, then if Joy is greater than 0, you increase MP. Therefore, if Joy is ever greater than 0, it will continue to grow to infinity unless you specifically do something to set it all the way back to zero.

    A good way to debug this is to set a "test" variable equal to the Joy, and directly set another "test" variable equal to the player's MP, and then print them both out in a message box (example: "Joy is \V[28] and Player's MP is \V[29] ") after every instance where you change either MP or the original Joy variable.

    The one other thing that could be screwing you up is if you are referencing the wrong actor's MP. I see "[]'s MP" in your event and, without any other info, I become suspicious that you might be referencing an actor that doesn't exist or an actor you don't mean to.
     
    #4
  5. Andar

    Andar Veteran Veteran

    Messages:
    28,703
    Likes Received:
    6,600
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    Please name all your actors (and other database items), NEVER let them without a name like you did with your main actor.
    Even if the player is to name that actor, it needs to have a default name.

    After that, check your common event again if you selected the correct actor for the control variables.
    Because if you have several unnamed actors, you'll never know whose MP you have read - that name is supposed to be inside the brackets.
     
    #5
  6. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,504
    Likes Received:
    5,111
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    Of course, it's because you put 120 frames wait inside IF statement.
     
    #6
    Wavelength and Cuddlebuns like this.
  7. Cuddlebuns

    Cuddlebuns Veteran Veteran

    Messages:
    30
    Likes Received:
    4
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    I only have one actor in this project, so there is absolutely zero chance that I am referencing a nonexistent or incorrect actor. Also, the MP healing targets the entire party anyway.

    Edit: TheoAllen's suggestion solved the issue immediately. You are a hero!
     
    #7
  8. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    12,417
    Likes Received:
    12,650
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    Also if you use \V code, the [] in there is the # of the variable. So if you change the variable to 22, you need to change the call to \V[22] also. Something you'll want to keep track of for future debugging.
     
    #8
  9. Wavelength

    Wavelength Pre-Merge Boot Moderator

    Messages:
    4,518
    Likes Received:
    3,771
    Location:
    Florida, USA
    First Language:
    English
    Primarily Uses:
    RMVXA

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #9
Thread Status:
Not open for further replies.

Share This Page