Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Help ending loop in Event

ooryl2

Member

Howdy :)

I'm just getting back into RPG Maker VX after a few years off (only really dabbled in it before though). I'm trying to make a little program for my step-son's birthday that's basically a little carnival with some mini games to it.

I'm trying to do a Bet on a Race minigame (similar to the one at the beginning of Chrono Trigger for the SNES if anyone remembers that. I have three events, with graphics of the three racers each moving around the outside of a rectangular area in their own lane (staggered starts of course for the extra distances needed).

I have the events set up for each so that every 10 frames they randomly change their speed, so it's always random who wins. My problem is that I can't figure out how to break the loops once one of the events reaches the "finish line."

Once the player talks to the race starter, the racers proceed along a Custom Autonomous Movement course.

The following is the Race Starter's Event Page 2 (which is triggered upon speaking to him):
(note that 18:13 is the Human racer's finishing coordinates and that I've only added the check for the Human racer to end the loop at the moment)

Code:
 

Control Switches: [0500:Race Start]= ON

Loop

   Control Variables: [0492:Human X] = [Human Racer]'s Map X

   Control Variables: [0493:Human Y] = [Human Racer]'s Map Y

   Conditional Branch: Variable [0492: Human X] == 18

      Conditional Branch: Variable [0493: Human Y] == 13

         Text: -,-, Normal, Bottom

          :        : end!

         Break Loop

 

      Else

 

      Branch End

 

   Else

 

   Branch End

   Wait: 10 frame(s)

   Control Variables: [0499:Cat Speed] = Random No. (1...3)

   Control Variables: [0498:Human Speed] = Random No. (1...3)

   Control Variables: [0497:Ogre Speed] = Random No. (1...3)

   Conditional Branch: Variable [0499:Cat Speed] == 1

      Set Move Route: [Cat Racer] (Wait)

                             $>Change Speed:2

 

   Else

      Conditional Branch Variable [0499:Cat Speed] == 2

         Set Move Route: [Cat Racer] (Wait)

                                $>Change Speed:3

 

      Else

         Set Move Route: [Cat Racer] (Wait)

                                $>Change Speed: 4

 

      Branch End

 

   Branch End

   Conditional Branch: Variable [0498:Human Speed] == 1

      Set Move Route: [Human Racer] (Wait)

                             $>Change Speed:2

 

   Else

      Conditional Branch Variable [0498:Human Speed] == 2

         Set Move Route: [Human Racer] (Wait)

                                $>Change Speed:3

 

      Else

         Set Move Route: [Human Racer] (Wait)

                                $>Change Speed: 4

 

      Branch End

 

   Branch End

   Conditional Branch: Variable [0500:Ogre Speed] == 1

      Set Move Route: [Ogre Racer] (Wait)

                             $>Change Speed:2

 

   Else

      Conditional Branch Variable [0500:Ogre Speed] == 2

         Set Move Route: [Ogre Racer] (Wait)

                                $>Change Speed:3

 

      Else

         Set Move Route: [Ogre Racer] (Wait)

                                $>Change Speed: 4

 

      Branch End

 

   Branch End

 

Repeat Above

 

 

Using F9 to check the variables, almost everything is working as it should. If the random number for an event is 1, the speed is set to 2, if it's 2 the speed is set to 3, if it's 3 the speed is set to 4.

The problem comes when the Human Racer reaches the finish line, the loop does not stop. I put the text "end!" in there to test to make sure the finish line was triggering both levels of that Condition. The text pops up when the Human Racer event reaches 18:13, but it continues to do so after the player hits the Z key to close the text window. It seems that the loop isn't breaking as it should.

Once that two-level Condition properly breaks the loop, I'd like to add in checks for both the others so that when the first event reaches the finish line, the loop breaks and the Race Starter announces the winner (while the other two events finish the race).

What am I missing here? Is it because the Racer events have a finite route in which they move?

Any help or suggestions would be greatly appreciated. Thanks!
 

ooryl2

Member

I think this might have been a case of late night coding...

Well, I just tested taking out the Text pop up, and it appears that maybe the loop is indeed ending, as the speed variables no longer change once the Human hits the finish line.

The Race Starter event Page 2 is a Parallel Process so the player can move and watch the race unfold. Seems like that might have been my issue.


This is final code I came up with that seems to work for the Race Starter

Page 1 is Action Button Triggered and turns on the switch Race Start


Page 2 is Parallel Process with the Condition that Race Start is on, the code is the same as above, except removes the "End!" Text. Once the loop is broken, Race End switch is turned on and Race Start switch is turned off.

Page 3 is Action Button Triggered with the Condition that the Race End is On. It turns off Race End, resets the Racers and turns Race Start back on the restart the race.

Seems to be working ok now.

Any suggestions though on tidying up the code would still be appreciated :)
 
If the race is linear, i.e. left to right, you don't need to check Y, only X.

Checking the events is the same as checking the player...

If Event(4) X > 17

....


Looks pretty "tidy" to me. limitations on statements & levels of indirection make event code bulky. THat's just the way it goes.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top