Variable going down with every step?

I'm trying to make it so that a variable is going down every time Player moves, and if it reaches 0, Player goes back to the beginning. It doesn't seems to be working though. After one step, it takes all the Variable points at once.

fau2YW5.png

XeXv8q1.png


Not sure what Im doing wrong.
Can you take a screenshot of the event? Might help a lot more
But for now what i can tell is that you made the change variable to set instead of add
My bad, screenshot didnt load for me

So from what im seeing is that the script doesnt count each step but instead every frame when the player moves in any direction
What it does is basically repeats the whole event every single frame until it meets the 0 hp condition while the player moves

What you can alternatively do is check whenever the player presses an arrow key then you decrease the variable
Which event do you mean? This is all there is.
I switched SET to ADD but it didn't help 🙁
Which event do you mean? This is all there is.
I switched SET to ADD but it didn't help 🙁
Read the lower ones, i didnt see your screenshot at first.
Im talking about the 2nd page with the conditonal branch, the script Player.IsMoving makes it so it counts every frame when the player moves
As in, if one step takes 60 frames then it'll repeat the event 60 times for each step
Sorry, didn't see the edit 😀

Unfortunately it didn't work either, it does the same thing (i take one step and it takes all the variable). Youre right that it keeps executing the action every frame instead of every press of the button
There's a step count already implemented in game.
Why not set the variable to the step count in your first page and then check when step count has grown by whatever amount you want to in your second page?

It can be found in Control variables -> Game Data -> Other -> Steps
Sorry, didn't see the edit 😀

Unfortunately it didn't work either, it does the same thing (i take one step and it takes all the variable). Youre right that it keeps executing the action every frame instead of every press of the button
There's an easier solution by using a wait timer after decreasing the variable, you could estimate how many frames it takes for one step and use it as your wait frame, just remember that running and walking takes different amount of frames to execute
Note that the above solution is a terrible workaround, because if your game framerate changes for whatever reasons the calculations will be off.

I'm having a hard time figuring out why you couldn't use the ready made steps counter for this, though.
Using this step counter will also allow you to not check every frame, and add a wait in your parallel process which is good practice because too many parallell processes running each frame will make your framerate tank.
I didn't know there was a step counter built in, thanks 🙂 I'm not sure if it works in my case though.
It does kill the player after taking a certain amount of steps, so that's good, but is there any way to give player more steps on the way?

For example:
Player can only take 6 steps, and then he dies. But after taking 3 steps, theres an NPC that gives him additional 6 steps, so he can walk further.

I connected Hero HP variable to Steps, made it so that the player dies after taking 6 steps, and made an NPC on the way that takes 3 Hero HP. But the Player still dies after taking 6 steps, instead of 9.
Just use a variable and increment it instead of using a fixed reference point for your comparison.
Let's say you store the starting steps in variable 1
In your second event instead of checking [current steps > variable 1 + 6], check for [current steps > variable 1 + variable 2]
Then you only have to change variable 2 to change how many steps the player can take.
i just remembered the damage floor feature that barely anyone uses. it literally does the same thing but it does it directly to the players HP. that method might be simpler then using the steps counter or the other method
@Astfgl66, I tried to make it but I don't think I understand what am I supposed to do :LZSsad:

@ChipTato, That's how I did it at first :LZSsmile: I gave the Player a Poison status, so he took dmg every step. The problem is, I want different events to happen depending on players HP, so I thought it would be easier to do it with variables (but I guess not). Also, I didn't want player to be Knocked Out and go back to the menu. I have a plugin that starts a Common Event after player dies, so that would solve the problem, if it wasnt for the fact that I need the player to have a different death depending on what Event triggered it.

Not sure if I explained it well, English is not my first language 😛
If you want different events to happen on certain hp then you could just set a variable for the hero's hp in
game data - actor - hp
On default the player wouldnt die from poison, it's probably because you checked the knockout from slip/floor damage box in systems.
But im still not sure what you mean by different deaths.
You could probably use switches to get different death endings by turning them on right before death.
It should look something like this:

1st page, set variable 1 to current steps, this is the fixed number of reference, set variable 2 to 6, this is the difference in steps, then self switch a to on to switch pages.
2nd page, compare if current steps > variable 1 + variable 2 and do your things when the player has run out of steps.

If you need to modify the difference in steps before things happen, you just have to modify variable 2.

If you need something to happen at specific steps use current steps - starting steps (var 1) as a condition.

Original thread: https://forums.rpgmakerweb.com/threads/variable-going-down-with-every-step.115860/