Hello everyone. Previously caethyril made me the algorithm on how to decrease variable while walking in MV, as shown in this thread https://forums.rpgmakerweb.com/index.php?threads/decrease-variable-while-walking.134143/. I used this for stamina and energy system in MV.
Aaaaand, since that steam winter sale (yea I'm a cheapskate lol), I've used MZ instead of MV and consequently apply the algorithm caethyril used before with some modification since I used VisuStella movement plugin instead of Yanfly/YEP.
I thought I was writing it off completely right, but of course I had a hard time, silly ol' me. When I don't move at the start of the game, the energy variable was decreasing, but after I walked off, it stops decreasing when I stopped again, and start decreasing again on walking. (In short, it only worked after I walk). Aaaaaand, I can't dash. At all. T_T
Here are the algorithm
◆Comment:Check if player is currently moving.
◆If:Script:var p = $gamePlayer, d = p.getInputDirection(); p.isMoving() || (d > 0 && p.canPass(p.x, p.y, d)) || $gameTemp.isDestinationValid()
◆Control Switches:#0003 Moving = ON
◆
:Else
◆Control Switches:#0003 Moving = OFF
◆
:End
◆Comment:Check if breathlessness has worn off.
◆If:Breathless is ON
◆Comment:Re-enable dashing after regaining some stamina
◆If:Stamina ≥ 30
◆Control Switches:#0002 Breathless = OFF
◆Plugin Command:VisuMZ_1_EventsMoveCore, Dash Enable: Toggle
:Plugin Command:Value = Enable
◆
:End
◆
:End
◆Comment:Update stamina based on current motion.
◆If:Moving is ON
◆If:Breathless is OFF
◆Plugin Command:VisuMZ_1_EventsMoveCore, Dash Enable: Toggle
:Plugin Command:Value = Enable
◆
:Else
◆Plugin Command:VisuMZ_1_EventsMoveCore, Dash Enable: Toggle
:Plugin Command:Value = Disable
◆
:End
◆
:Else
◆Control Variables:#0008 Stamina += 0.5
◆
:End
◆Comment:Apply min/max stamina
◆If:Stamina ≤ 0
◆Control Variables:#0008 Stamina = 0
◆Comment:Also become out of breath at zero stamina, which disables dashing
◆Control Switches:#0002 Breathless = ON
◆Comment:And make the player character show some emotion~
◆
:Else
◆If:Script:$gameVariables.value(8) >= ($gameVariables.value(10) * 60)
◆Control Variables:#0008 Stamina = $gameVariables.value(10) * 60
◆
:End
◆
:End
◆If:Script:$gamePlayer.isDashing()
◆Control Variables:#0008 Stamina -= 1
◆Control Variables:#0002 Curr Energy -= 1
◆
:Else
◆If:Script:$gamePlayer.isMoving()
◆Control Variables:#0008 Stamina -= 0.5
◆Control Variables:#0002 Curr Energy -= 0.3
◆
:End
◆
:End
I'm really confused since it worked well in MV but not in MZ. Can someone please guide me? Many thanks in advance 😀
Edit: I checked again by removing all algorithm except the last conditionals. Turns out the variable decreasing constantly even when I'm not doing anything. Is it call script problem? Like, dash-checking always return true while movement-checking are not.
Edit#2: Turns out dash-checking always return true if in the options I set always dash to ON. It works fine if I turn it OFF. Bug, maybe? I don't want to be confused alone, so please give me response(s) and let's be confused together 😛
Aaaaand, since that steam winter sale (yea I'm a cheapskate lol), I've used MZ instead of MV and consequently apply the algorithm caethyril used before with some modification since I used VisuStella movement plugin instead of Yanfly/YEP.
I thought I was writing it off completely right, but of course I had a hard time, silly ol' me. When I don't move at the start of the game, the energy variable was decreasing, but after I walked off, it stops decreasing when I stopped again, and start decreasing again on walking. (In short, it only worked after I walk). Aaaaaand, I can't dash. At all. T_T
Here are the algorithm
◆Comment:Check if player is currently moving.
◆If:Script:var p = $gamePlayer, d = p.getInputDirection(); p.isMoving() || (d > 0 && p.canPass(p.x, p.y, d)) || $gameTemp.isDestinationValid()
◆Control Switches:#0003 Moving = ON
◆
:Else
◆Control Switches:#0003 Moving = OFF
◆
:End
◆Comment:Check if breathlessness has worn off.
◆If:Breathless is ON
◆Comment:Re-enable dashing after regaining some stamina
◆If:Stamina ≥ 30
◆Control Switches:#0002 Breathless = OFF
◆Plugin Command:VisuMZ_1_EventsMoveCore, Dash Enable: Toggle
:Plugin Command:Value = Enable
◆
:End
◆
:End
◆Comment:Update stamina based on current motion.
◆If:Moving is ON
◆If:Breathless is OFF
◆Plugin Command:VisuMZ_1_EventsMoveCore, Dash Enable: Toggle
:Plugin Command:Value = Enable
◆
:Else
◆Plugin Command:VisuMZ_1_EventsMoveCore, Dash Enable: Toggle
:Plugin Command:Value = Disable
◆
:End
◆
:Else
◆Control Variables:#0008 Stamina += 0.5
◆
:End
◆Comment:Apply min/max stamina
◆If:Stamina ≤ 0
◆Control Variables:#0008 Stamina = 0
◆Comment:Also become out of breath at zero stamina, which disables dashing
◆Control Switches:#0002 Breathless = ON
◆Comment:And make the player character show some emotion~
◆
:Else
◆If:Script:$gameVariables.value(8) >= ($gameVariables.value(10) * 60)
◆Control Variables:#0008 Stamina = $gameVariables.value(10) * 60
◆
:End
◆
:End
◆If:Script:$gamePlayer.isDashing()
◆Control Variables:#0008 Stamina -= 1
◆Control Variables:#0002 Curr Energy -= 1
◆
:Else
◆If:Script:$gamePlayer.isMoving()
◆Control Variables:#0008 Stamina -= 0.5
◆Control Variables:#0002 Curr Energy -= 0.3
◆
:End
◆
:End
I'm really confused since it worked well in MV but not in MZ. Can someone please guide me? Many thanks in advance 😀
Edit: I checked again by removing all algorithm except the last conditionals. Turns out the variable decreasing constantly even when I'm not doing anything. Is it call script problem? Like, dash-checking always return true while movement-checking are not.
Edit#2: Turns out dash-checking always return true if in the options I set always dash to ON. It works fine if I turn it OFF. Bug, maybe? I don't want to be confused alone, so please give me response(s) and let's be confused together 😛