Aditya_Himarwan

Villager
Member
Joined
Sep 19, 2019
Messages
14
Reaction score
3
First Language
Indonesia
Primarily Uses
RMMV
Hi guys! So, in this game I'm making, I try to reduce variable energy if the player walk or dash. I use this command in my common event while walking.png
However, when I test the game, each step decreases CurrentEnergy variable by 30. Can someone help me out? Maybe it is related with my scriptcall? Thanks in advance!
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
8,260
Reaction score
5,433
First Language
Dutch
Primarily Uses
RMXP

I've moved this thread to MV Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
3,585
Reaction score
1,347
First Language
Dutch
Primarily Uses
RMMV
as it states atm, it should work, however, it keeps going, event if
the variable = 0 to -1, -2 etc and you can keep running.

there is no failsave for it like:
fi: var 2 <= 0
var 2 = 0
end

but still, you need to stop this or set movement also to something else
or no movement untill player can move.

another option is aslo, that something else is using variable 2?
or it should work normally.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,339
Reaction score
8,076
First Language
German
Primarily Uses
RMMV
your problem is that the parallel is executed once per frame, that is sixty times per second.
"is moving" only checks if the actor is moving, not how many steps were taken.
since it needs about half a second to complete the step, that costs you many points.

you basically need to check the position and remember the last position - if the coordinates have changed, then count for full step and update old position to not count again until next step.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,365
Reaction score
1,775
First Language
EN
Primarily Uses
RMMZ
Like Andar says, your Parallel event will process once per frame while switch 1 is turned on. Times taken for various move speeds are noted in this thread: link. The default player move speed is 4 (16 frames per step); if moving at speed 3, 1 tile of movement will take 32 frames and make $gamePlayer.isMoving() be true for 31 frames (final frame is at destination).

If you'd like to run something once per step instead, you can do a step count check each frame, e.g.
Code:
◆Comment:Get difference between stored step count and current step count
◆Control Variables:#0015 Step Count -= Steps
◆Comment:Has it changed since last check?
◆If:Step Count ≠ 0
  ◆Comment:It has changed!
  ◆Comment:Do things here that happen once per step
  ◆Show Balloon Icon:Player, Light Bulb
  ◆
:End
◆Comment:Store current step count in variable for next check~
◆Control Variables:#0015 Step Count = Steps
◆Comment:Check again in 6 frames
◆Wait:6 frames
[Edit: Steps can be found under Game Data > Other > Steps.]

...or you could use a plugin like this to toggle a parallel event's switch on step:
In case it helps, I made a concept demo for a no-plugin stamina system a while ago, here's a link:
 
Last edited:

Aditya_Himarwan

Villager
Member
Joined
Sep 19, 2019
Messages
14
Reaction score
3
First Language
Indonesia
Primarily Uses
RMMV
as it states atm, it should work, however, it keeps going, event if
the variable = 0 to -1, -2 etc and you can keep running.

there is no failsave for it like:
fi: var 2 <= 0
var 2 = 0
end

but still, you need to stop this or set movement also to something else
or no movement untill player can move.

another option is aslo, that something else is using variable 2?
or it should work normally.
I'm sorry for not understanding this. If you could explain it to me again, that would be very much appreciated.
your problem is that the parallel is executed once per frame, that is sixty times per second.
"is moving" only checks if the actor is moving, not how many steps were taken.
since it needs about half a second to complete the step, that costs you many points.

you basically need to check the position and remember the last position - if the coordinates have changed, then count for full step and update old position to not count again until next step.
Oh i see, the problem is on the framerate. It would be very great if you can explain how to check and remember the last position. Thank you Andar!
Like Andar says, your Parallel event will process once per frame while switch 1 is turned on. Times taken for various move speeds are noted in this thread: link. The default player move speed is 4 (16 frames per step); if moving at speed 3, 1 tile of movement will take 32 frames and make $gamePlayer.isMoving() be true for 31 frames (final frame is at destination).

If you'd like to run something once per step instead, you can do a step count check each frame, e.g.
Code:
◆Comment:Get difference between stored step count and current step count[/INDENT][/INDENT]
[INDENT][INDENT]◆Control Variables:#0015 Step Count -= Steps[/INDENT][/INDENT]
[INDENT][INDENT]◆Comment:Has it changed since last check?[/INDENT][/INDENT]
[INDENT][INDENT]◆If:Step Count ≠ 0[/INDENT][/INDENT]
[INDENT][INDENT]  ◆Comment:It has changed![/INDENT][/INDENT]
[INDENT][INDENT]  ◆Comment:Do things here that happen once per step[/INDENT][/INDENT]
[INDENT][INDENT]  ◆Show Balloon Icon:Player, Light Bulb[/INDENT][/INDENT]
[INDENT][INDENT]  ◆[/INDENT][/INDENT]
[INDENT][INDENT]:End[/INDENT][/INDENT]
[INDENT][INDENT]◆Comment:Store current step count in variable for next check~[/INDENT][/INDENT]
[INDENT][INDENT]◆Control Variables:#0015 Step Count = Steps[/INDENT][/INDENT]
[INDENT][INDENT]◆Comment:Check again in 6 frames[/INDENT][/INDENT]
[INDENT][INDENT]◆Wait:6 frames
...or you could use a plugin like this to toggle a parallel event's switch on step:
In case it helps, I made a concept demo for a no-plugin stamina system a while ago, here's a link:
Thanks for your detailed response! Sadly, somehow the plugin freeze my game immediately. I tried to copy and paste your stamina common event system, and adjust the variables and switches accordingly, but it also freeze my game. For your posted parallel common event, I don't understand how these lines of algorithm can check my step count. And as I would expect, the value of variable 'CurrentEnergy' did not decrease at all. Would you be so kind to explain it to me in detail?

Edit : Just found out the 'steps' in control variables -> game data. I thought it was another variable altogether. Sorry for being dumb
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,365
Reaction score
1,775
First Language
EN
Primarily Uses
RMMZ
Oh yes, sorry, I should have mentioned it's in Game Data > Other > Steps. I'll edit that in for future readers, good to hear you found it~ :kaothx:

When you say "freeze", do you mean:
  1. The game stopped visually updating or responding to any input (0 framerate)?
    • This sounds like a Loop without a Wait or Break Loop command, i.e. the game is trying to complete infinite commands in one frame. Check your project's events: you might have a problematic event that you forgot about that is linked to the switch you're using.

  2. The game stopped responding to user input (movement, menu, etc) but otherwise seemed OK?
    • This sounds like an Autorun event: again, check the events on that map and/or all your common events. Autorun will suspend player input and trigger repeatedly while active; use Parallel for background tasks.
Also, did it freeze as soon as the map loaded, or only when you moved to another tile? You can show a framerate widget by pressing F2 during play, in case that helps.

The freezing is probably worth investigating even if your original problem is solved. :kaoswt:
 

Latest Threads

Latest Profile Posts

unknown.png

Been feeling that my characters spent too much time exploring caves, so I figured it was time to explore abandoned keeps instead.
Did you had some minor hitches with RMMZ? Come report to my topic where I did the same! [Just another rant from a RM veteran + Suggestions and Solutions] All opinions are welcome!
Squashing some bugs before releasing plugin :LZScool:The testing phase is taking more time than what I expected...

Forum statistics

Threads
110,325
Messages
1,052,358
Members
143,361
Latest member
tenjung
Top