Need some help using a loop or other structure to handle an event after a variable change

ACECORP

Founder & Entrepreneur
Veteran
Joined
Apr 6, 2016
Messages
257
Reaction score
40
First Language
English
Primarily Uses
RMMV
I have an event, we will call it “EVENT MASTER”, that manages everything on the current map screen and is supposed to change a variable value for variable “NPCVAL” that is used to control the behavior of a second event that runs parallel to it.


At the start NPCVAL = 100000


The second event that runs parallel to “EVENT MASTER” is called “EVENT2”.


“EVENT2” contains two event pages.


The first event page of “EVENT2” has no conditions of execution except for a control switch that is always enabled at this part of the game.


The second event page of “EVENT2” has the following conditions:

  • Value for variable “NPCVAL” >= 94999
  • Self-Switch A = ON



My problem is this:


Everything seems to work perfectly up until the variable “NPCVAL” is changed to 95000.


Once that happens, EVENT2 does not successfully switch to the second event page from the first. This means something is either not happening properly on the first event page of “EVENT2” OR something is wrong with the second event page causing it to never take over control from the first event page.


The first event page from “EVENT2” looks like this:


EVENT2_PAGE1_TOP.png


EVENT2_PAGE1_BOTTOM.png


THE second event page from “EVENT2” looks like this:


EVENT2_PAGE2.png


I am thinking that the loop structure on the first event page is the problem.


Within EVENT2, I need the NPC to run around a set path until “NPCVAL” = 95000


At that point, I need EVENT2 to stop doing the first event page and switch to the second event page.


Is there anything I can adjust either on event page 1 or event page 2 that will make it work the way I need it to?


Any help would be greatly appreciated. 
 
Last edited by a moderator:

ACECORP

Founder & Entrepreneur
Veteran
Joined
Apr 6, 2016
Messages
257
Reaction score
40
First Language
English
Primarily Uses
RMMV
I was able to solve the problem using a second "Control Switch" for triggering the second event page, but I don't want to get into the habit of solving this type of issue in that manner because I will run out of control switches really quickly. If there is away to re-tool the logic to be able to utilize the "self-switch" that is what I am looking to do, but can't seem to figure how how to design the loop or conditional branch to do this.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,134
Reaction score
15,532
First Language
English
Primarily Uses
RMMV
It's not a very well designed event.  I think the order of the pages and the conditions, loops and parallel process trigger is making things happen WAY out of your expected order.


On the first page, your condition is "if the variable is > 99999, do some movement stuff, otherwise turn self switch A on".  So the very first time this runs, the variable (I assume) will be less than that, so self switch A will be turned on.  Then as soon as the variable hits the amount required for the Tab 2 condition, that page will be activated.  Since it requires the variable to be lower than 99999, I would expect those movement routes will never be activated.


Not sure why you have 50 movement routes with a single move and a wait after each?  Can't you just put them into a single move route with ALL the movements?  That'd be much easier to make and maintain.


You shouldn't need a loop with a parallel process event, and for page 2 you shouldn't need a parallel process trigger when there are no event commands.  If you just want animation turned on, check the box - you don't need to make it parallel process for that to work.


Can you explain the logic behind this event?  What's the significance of the variable, is it counting up from 0, what should happen when key milestones/numbers are hit?  It seems like you might want the NPC to just stand still until a certain time, then start walking in a set path, and then stand still and animate?  Or are they standing still until a certain time, then standing still and animating, and then walking in a set path?  Are they even visible right from the start (as long as that switch is on)?


I'm sure we can make this a lot better and easier to understand :)
 

ACECORP

Founder & Entrepreneur
Veteran
Joined
Apr 6, 2016
Messages
257
Reaction score
40
First Language
English
Primarily Uses
RMMV
I think its confusing because I need to do this inside of EVENT2 (which is one of many parallel NPC events):

LOOPSTART:


Make NPC Walk Along A Set Route();


if (NPCVAL >= 99,999) goto LOOPSTART;


else Self-Switch A = ON



The problem is, I don't see any construct or mechanism do to that in RPGMaker MV. 


How can I make a while loop so that as long as NPCVAL is >= 99,999, EVENT2 will keep looping and re-running. Then as soon as NPCVAL drops below 99,999, EVENT2 detects that, breaks out of the loop,  and turns self switch A on?


That's what I need to do but don't see any way to do that short of using control switches -- which is the exact thing I want to avoid because I will hit the upper limit real quick and run out of control switches (I will easily exceed 10,000 of them). I need to use variables and counters so that EVENT2 (and other NPC movement events like it) react to values as opposed to needing control switches to be turned on or off. 


In case you read this and say "ah yes, what you want to do cannot be done because there is no combo do/while if/else in RPGMaker MV like what you explained above",  then here is a more detailed explanation of what I am trying to do. 


I have a Management Event which manages all kinds of stuff in a town. I also have 50 separate NPC's (EVENTS) each functioning as parallel events (EVENT2, EVENT3, ETC) in a town setting. Since the behavior of the NPC events is similar, I just pulled one out to use an example. If I get a solution, it will be applied to all 50 because its ultimately the same problem. 


I need certain NPC Events, that are running non-stop as parallel events to "self switch on" when the NPCVAL becomes something specific.  


Each NPC has two event pages, the first is their movement, talk, emotions, and other things, and the second page is when they get hit with a fireball, get consumed by the flames then die. Obviously. Since they stop walking and their image changes from a NPC to a Fire. The second event page contains their fire image. 


Keep in mind that the management event only causes the NPCVAL variable to change, and is managing hundreds of other events that are unrelated to these NPC events, so I don't want to get into unrelated things. Just know that the main management event will eventually set NPCVAL = 95,000 and when that happens, those NPC events that are set to run when NPCVAL >= 99,999 must immediately self-switch A = on and  then the second page of those NPC events must start running. 


An example would be EVENT2 (NBC Becca), EVENT3 (NPC Ruby), and EVENT4 (NPC Cheryl) all run parallel with EVENTMASTER.


When NPCVAL changes from 100,000 to 95,000 EVENT2 (NBC Beca) detects it and then executes SELF SWITCH A = ON.


EVENT3 (NPC Ruby), and EVENT4 (NPC Cheryl)  keep doing their original work because they react to NPCVAL when it equals 90,000 and 85,000 respectively. 


Once NPCVAL is set to 90,000 then EVENT3 (NPC Ruby) executes a self-switch A = on


EVENT2 (NPC Becca) is not impacted because it already switched to page 2 and that page doesn't have any requirements related to NPCVAL. It only required that self-switch A be active from the previous event page. 


Hopefully this makes it much more clear. Having said that, how can I write the following in RPGMaker MV on my NPC Becca EVENT2 event?

LOOPSTART:


Make NPC Walk Along A Set Route();


if (NPCVAL >= 99,999) goto LOOPSTART;


else Self-Switch A = ON
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,134
Reaction score
15,532
First Language
English
Primarily Uses
RMMV
I have not read all of that, but to answer just this might give you a nudge in the right direction:

How can I make a while loop so that as long as NPCVAL is >= 99,999, EVENT2 will keep looping and re-running. Then as soon as NPCVAL drops below 99,999, EVENT2 detects that, breaks out of the loop,  and turns self switch A on?



If NPCVAL is counting down, put the page with NPCVAL >= 99999 second rather than first.  Get rid of the loop, put the movement commands into a custom autonomous move route, and change the trigger back to Action Button.  Then on the first page put what you want to happen when NPCVAL is less than 99999.  Also try not to make it a parallel process event.


So while NPCVAL is higher than 99999, the second page will be active, and the NPC will move in the desired path, without using any event commands or parallel process events.  The moment it drops lower, the conditions for that page are no longer met, so the previous page will become active, as long as its conditions are met.  Self Switch A is not needed ANYWHERE in the event and should not be a condition for either of the pages.


If you have "many parallel NPC events" set up like the one above, your game is going to lag like crazy! 
 

ACECORP

Founder & Entrepreneur
Veteran
Joined
Apr 6, 2016
Messages
257
Reaction score
40
First Language
English
Primarily Uses
RMMV
That sounds like it will work. I'll try that out and confirm. Thanks!
 

ACECORP

Founder & Entrepreneur
Veteran
Joined
Apr 6, 2016
Messages
257
Reaction score
40
First Language
English
Primarily Uses
RMMV
It worked exactly as you suggested! Thanks so much! I am still getting a handle on all the behaviors of the components and such so now I have a much better understanding of things!


Thanks again for all your help!
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,134
Reaction score
15,532
First Language
English
Primarily Uses
RMMV
No probs.  Always nice to see someone learn something new and gain understanding :)
 

Latest Threads

Latest Posts

Latest Profile Posts

FirestormNeos wrote on DarkPlasmaBall's profile.
asking this here instead of the thread in question to avoid derailing it, but I'm curious; is there a particular reason you'd include a "Terms of Use" for an RPG Maker game? Like, are there multiplayer features for the game you're working on?
The holidays are upon us! Everyone search for safety from the grocery store music!
I don't understand people sometime. Walking to work today came across someone walking the opposite way in a nice suit, I politely move to the side into the shrubbery so he doesn't have to get his suit dirty and say "good morning" as he passes me, he turns around glaring daggers and asks "why are you talking to me?" like he's bloody offended by me wishing him a good morning or something. Just, why?
I dreamed about watching Gackt concert live.
He was riding some kind of crescent moon boat.
But his appearance resembled Andhika Kangen Band (Indonesian singer),
and the first song he sang was L'arc en Ciel's Hitomi no Jyuunin.
Weird, but still beautiful though. :D
I've been working on making a simple sprite frame system. And I'm really happy with the progress.
ZAyFw65.gif

Forum statistics

Threads
117,135
Messages
1,104,875
Members
153,195
Latest member
sltcestsab
Top