Limit steps in any direction.

Hello!


So this issue on MV has me completely stumped! I'm making a game that is based on dice movement; so, I've got the dice working, it's simply a variable rolling a random value of 1-6 on call HOWEVER I'm struggling to get the system to acknowledge steps being taken. Once the dice has been rolled, I tell the system to call the common event; "Step Counter"

Inside Step Counter, each roll of the dice I want to be equal to ten steps -- so if you roll a 1, the players gets 10 steps, 2, the players gets 20 steps etc etc. I've tried making a conditional branch for each individual result, setting the step variable to 10, 20, 30, 40, 50 and 60 followed by the conditional branch: 


$gamePlayer.isMoving()


If not, I jump to a label set before the check so it checks again and again and again. If the player is moving, then I tell the system to -1 from the step variable with a conditional branch following checking if it has hit 0 and if so, to end the turn and recall the dice roll event; if not I tell it to go back to a label right before the script call...But for some reason RPG MV just isn't acknowledging the movement. If I set it as a loop, the game just crashes or grinds down to a halt.


The dice and the step counter are both individual common events.


Am I doing something completely stupid? Any help would be appreciated! 
Please show screenshots of your events, it depends on the exact logic and timing used.


For example, the moving of a single step takes more than one frame, and a parallel process would be called once per frame (sixty times per second), most likely substracting several times until the move is completed.
The dice and the step counter are both individual common events.


Am I doing something completely stupid? Any help would be appreciated! 

something like this at 2:00min ? is my dice system with commun event
something like this at 2:00min ? is my dice system with commun event



Exactly like that! I even love the animation you have showing the numbers rolling! Mine just presented the result.
Very cool stuff, @Jonforum


@GiddyPeak, definitely show us the full setup of your event.  In general, I have found Loops to be a lot less finicky than Labels & Jump-Tos when I do complex eventing.
@Wavelength & @Andar


Sorry for the slow reply; I was at work. 🙁  


Attached is my current step counter event for 10 steps which is currently just causing a freeze:


10 steps.png 
Alright, so I didn't test your exact code, but I just did some playing around with a Parallel Process event that uses the Conditional Code $gamePlayer.isMoving() and what I found is that moving a single step on the map will trigger it a whole bunch of times - my variable was over 100 by the time I had moved 15 steps (and it makes sense because a PP event will check every frame if it can).


You might want to alias/modify the game's increaseSteps method instead - every time the player takes a step, increment a variable, and (for example) have a Parallel Process event check whether that variable is equal to or greater than ten times the die roll.  Here is the current increaseSteps method to make it easier for you to find:


Game_Party.prototype.increaseSteps = function() {
this._steps++;
};




My guess is that your "freeze" is caused by using an Autorun trigger for your event without turning the event off (with an Erase Event, or turning a required Switch OFF, etc.).

Original thread: https://forums.rpgmakerweb.com/threads/limit-steps-in-any-direction.63323/