MV Limit Dash (Help)

Hello! For my game, I want to have it so that the player can only dash (or move at a faster speed) for so long before losing stamina and going back to normal speed while it refills.

I also want to have a stamina bar pop up when the player is dashing to let them know how much more they have left.

Any help would be appreciated, thanks!
The way I can think to do this would be to disable dashing and do a conditional branch as follows.

if stamina > 0
if Pressing (whatever button)
Set Move Route: Player: change speed = 6
Stamina -= 1
else
Set Move Route: Player: change speed = 4

For the popup bar, that should be simple. I'm not too familiar with MV script calls, but basically, what you'd want to do is do the scripting equivalent of show picture and set the zoom width equal to your current stamina / max stamina * 100
The way I can think to do this would be to disable dashing and do a conditional branch as follows.

if stamina > 0
if Pressing (whatever button)
Set Move Route: Player: change speed = 6
Stamina -= 1
else
Set Move Route: Player: change speed = 4

For the popup bar, that should be simple. I'm not too familiar with MV script calls, but basically, what you'd want to do is do the scripting equivalent of show picture and set the zoom width equal to your current stamina / max stamina * 100
So, nothing seems to change.

Also, does the stamina continue to decrease by -1 while being held, or will it only decrease -1 once each time I press shift?
Dearg Due - RPG Maker MV 8_11_2021 8_50_42 PM.png
I made a demo a while ago for this kind of thing, in case it helps:
👋 Here's a little demo of a stamina system with a simple picture-based gauge. It's mostly event commands and variables, with a couple of chunky script calls:
(If you want to check it out, remember to right-click > Extract after downloading.)

Here are the event transcripts in case anyone wants those instead:
Spoiler: Text copies of the events
Action Button:
Code:
◆Comment:Call to turn stamina system off if it's on, on if it's off.
:       :Note that standard dashing is disabled in the map properties.
◆Comment:----------------------------------------------------------------------
◆If:Stamina System is ON
  ◆Text:None, Window, Bottom
  :    :Dash stamina system is currently enabled.
  ◆Show Choices:Enable, Disable (Window, Right, #1, #1)
  :When Enable 
    ◆
  :When Disable 
    ◆Control Switches:#0001 Stamina System = OFF
    ◆Comment:Remove gauge and background pictures
    ◆Erase Picture:#5
    ◆Erase Picture:#6
    ◆Text:None, Window, Bottom
    :    :You can no longer dash.
    ◆
  :End
  ◆
:Else
  ◆Text:None, Window, Bottom
  :    :Dash stamina system is currently disabled.
  ◆Show Choices:Enable, Disable (Window, Right, #2, #2)
  :When Enable 
    ◆Comment:Show gauge bar and background
    :       :(My background has a 2 px border, so the bar position is offset by that much)
    ◆Show Picture:#5, gaugeBack, Upper Left (596,20), (100%,100%), 255, Normal
    ◆Show Picture:#6, gauge, Upper Left (598,22), (100%,100%), 255, Normal
    ◆Comment:Initialise stamina variable and switches
    ◆Control Variables:#0001 Stamina = 300
    ◆Control Switches:#0001 Stamina System = ON
    ◆Control Switches:#0002 Breathless = OFF
    ◆Comment:User feedback and instructions for use~
    ◆Text:None, Window, Bottom
    :    :You can now dash!
    ◆Text:None, Window, Bottom
    :    :Dashing will now consume stamina.
    :    :\.Walk or stand still to recover.
    :    :\.If you get out of breath, you'll have to wait a bit
    :    :   until you can dash again.
    ◆
  :When Disable 
    ◆
  :End
  ◆
:End
Parallel:
Code:
◆Comment:Default speed 4.
:       :Set using script call so it doesn't interfere with player movement.
◆Script:$gamePlayer.setMoveSpeed(4);
◆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 ≥ 150
    ◆Control Switches:#0002 Breathless = OFF
    ◆Plugin Command:EnableDashing
    ◆Comment:Undo opacity change (see below)
    ◆Move Picture:#6, Upper Left (598,22), (50%,100%), 255, Normal, 1 frame
    ◆
  :End
  ◆
:End
◆Comment:Update stamina based on current motion.
◆If:Moving is ON
  ◆If:Breathless is OFF
    ◆If:Button [Shift] is pressed down
      ◆Comment:Dashing!
      ◆Script:$gamePlayer.setMoveSpeed(5);
      ◆Control Variables:#0001 Stamina -= 8
      ◆
    :Else
      ◆Comment:Walking!
      ◆Control Variables:#0001 Stamina += 2
      ◆
    :End
    ◆
  :Else
    ◆Comment:Walking! (Out of breath.)
    ◆Control Variables:#0001 Stamina += 2
    ◆
  :End
  ◆
:Else
  ◆Comment:Standing!
  ◆Control Variables:#0001 Stamina += 5
  ◆
:End
◆Comment:Apply min/max stamina
◆If:Stamina ≤ 0
  ◆Control Variables:#0001 Stamina = 0
  ◆Comment:Also become out of breath at zero stamina, which disables dashing
  ◆Control Switches:#0002 Breathless = ON
  ◆Comment:Let's make the gauge 50% transparent while recovering!
  ◆Move Picture:#6, Upper Left (598,22), (0%,100%), 128, Normal, 1 frame
  ◆Comment:And make the player character show some emotion~
  ◆Show Balloon Icon:Player, Sweat
  ◆
:Else
  ◆If:Stamina > 300
    ◆Control Variables:#0001 Stamina = 300
    ◆
  :End
  ◆
:End
◆Comment:Rescale the stamina gauge to reflect current stamina value!
:       :Via script call to avoid a tedious number of branches. >_>
◆Comment:Script vars:
:       : - picId        is the ID of the picture you're using
:       : - duration     is how many frames the picture takes to rescale
:       : - fullScale    is the width scale of the gauge picture when full (100 = "100%")
:       : - staminaVarId is the ID of the game variable used for stamina
:       : - staminaMax   is the maximum value of the stamina variable
◆Script:var picId = 6, duration = 6, fullScale = 100;
:      :var staminaVarId = 1, staminaMax = 300;
:      :// Change the above values as needed //
:      :var scale = $gameVariables.value(staminaVarId) / staminaMax;
:      :var pic = $gameScreen.picture(picId);
:      :pic._duration = duration;
:      :pic._targetScaleX = fullScale * scale;
◆Comment:Repeat again in 1/10 second = 6 frames.
◆Wait:6 frames

Alternatively, you could check out a plugin like Silver's Dash Stamina:
You have the trigger set to none. So that's not getting called. Change it to parallel process.
Thanks everyone, I used the plugin! just what I was looking for!
Moved to: Plugin Requests

Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/limit-dash-help.139507/