Random battles based on the number of steps

rpgmakerxp

Veteran
Veteran
Joined
Jun 14, 2015
Messages
85
Reaction score
15
Primarily Uses
Hey, so I was looking into making specific troops appear for the characters when the character is between say lvl 5-10 or 11-15 on the world map.  I was experimenting with ways of doing this.  Here is the one that worked the best, but I'm having an issue with it.

rpg maker xp help.jpg

Don't worry about the self A switches, and on the 2nd event page. It just turns off self switch A off, I just forgot to erase that before posting.

What happens is that it takes approximately 30 steps(yes only moving pressing the right button for now) for the first battle to appear(randomly).  This is good.  Then after that first battle it starts a battle for each step.

I KNOW what the issue is.  The issue is that the steps are accumulating.  After the first battle they were already at or over 30, so now since the game reads me as having over 30 steps after the first battle, it always causes me to be in a battle.  I don't know how to STOP that.  I've tried subtracting the variable steps, dividing by 30, setting it to 0, nothing works( I don't think it's actually changing it at all).

How can I cause the random " battle processing" to occur in increments of 30 or whatever other number?
 

Sky Usanin

deleted
Veteran
Joined
Jun 5, 2015
Messages
115
Reaction score
14
First Language
Unknown
Primarily Uses
N/A
Well, if I got your question right, you can reset the step count (try setting it directly back to zero instead of dividing it by 30), or set a different variable number of steps for each encounter.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
Use variables to record the current number of steps and either the previous number of steps, or the number at which the next battle will trigger. Reset it after every battle.
 

rpgmakerxp

Veteran
Veteran
Joined
Jun 14, 2015
Messages
85
Reaction score
15
Primarily Uses
Use variables to record the current number of steps and either the previous number of steps, or the number at which the next battle will trigger. Reset it after every battle.
That's the part that I'm having an issue with.  How do you reset the variables? When I set the variable equal to the steps to zero, nothing happens.  I also read somewhere that you can't reset steps.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
I don't really know how you want this to run - I assume you only want this to happen on certain maps, so let's go with that.

Allocate two variables. One will be your steps counter and the other will be your steps target (when the next battle will be initiated). And allocate a switch, which will control when the random battles can happen.

Create a common event with no trigger. Add these commands:

Control Variables: [002: Step Target] = Other > StepsControl Variables: [002: Step Target] += 30Control Switches: [001: Enable Random Battles] = ONWhenever you enter a map where you want steps to be counted, call this common event.Now set up a second common event, conditioned by the Enable Random Battles switch. Set it to parallel process. Add these commands:

Control Variables: [001: Step Counter] = Other > StepsConditional Branch: Variable [001: Step Counter] >= [002: Step Target] Battle Processing Call Common Event (the other event you created above, to reset the step target)Branch EndWhen you leave the area where you want random encounters, turn off that switch.Now, if you want to battle different enemies based on what map you're on, instead of the Battle Processing do another Call Common Event to another new event with no trigger. In this event, put the current map number into another variable, then do a series of conditional branches to see which map you're on and call the appropriate troop in battle. You could also avoid this by setting a variable on each map containing the troop id, then using a Script command to initiate the battle, but there's quite a bit of setup involved, and as a new user it's probably better for you to go the longer, but easier-to-understand way.
 

rpgmakerxp

Veteran
Veteran
Joined
Jun 14, 2015
Messages
85
Reaction score
15
Primarily Uses
I don't really know how you want this to run - I assume you only want this to happen on certain maps, so let's go with that.

Allocate two variables. One will be your steps counter and the other will be your steps target (when the next battle will be initiated). And allocate a switch, which will control when the random battles can happen.

Create a common event with no trigger. Add these commands:

Control Variables: [002: Step Target] = Other > StepsControl Variables: [002: Step Target] += 30Control Switches: [001: Enable Random Battles] = ONWhenever you enter a map where you want steps to be counted, call this common event.Now set up a second common event, conditioned by the Enable Random Battles switch. Set it to parallel process. Add these commands:

Control Variables: [001: Step Counter] = Other > StepsConditional Branch: Variable [001: Step Counter] >= [002: Step Target] Battle Processing Call Common Event (the other event you created above, to reset the step target)Branch EndWhen you leave the area where you want random encounters, turn off that switch.Now, if you want to battle different enemies based on what map you're on, instead of the Battle Processing do another Call Common Event to another new event with no trigger. In this event, put the current map number into another variable, then do a series of conditional branches to see which map you're on and call the appropriate troop in battle. You could also avoid this by setting a variable on each map containing the troop id, then using a Script command to initiate the battle, but there's quite a bit of setup involved, and as a new user it's probably better for you to go the longer, but easier-to-understand way.
In my first post I explained that this was for the world map.  So the player is walking around on the world map.  It's just one giant map, so I was going to adjust the specific monsters appearing on the world map to their level.  I'll see how this common event stuff works with what you posted and edit my post later unless you have another idea in mind before I do so. Thanks though.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,018
Messages
1,018,357
Members
137,803
Latest member
andrewcole
Top