Stamina Bar Event Tutorial for RPG Maker Vx Ace


Hello everyone, this is Saturn. This is the
first “serious” video on my channel. I have been using it for a long time now just to
post random and silly stuff so at this point I have absolutely no idea what I am doing
so bear with me if I get sidetracked. Anyways, today I’m gonna teach you how to
make a rather simple, event based, stamina bar that shows on the screen and depletes
itself as the player runs, on RPG Maker Vx Ace. You can download the demo in the description box. Later on, since it was also requested, we’re going to make one of these for HP, that starts getting depleted if the staminas value reaches zero. So, for making this happen we are going to
use two common events: one for the actual process of depleting and regenerating stamina,
that will be called ‘Stamina Calc’ in this example, and another for the graphical display,
or the “HUD” if you prefer, called ‘Stamina Bar’. We are also going to need a way of globally
turning dashing off, without messing with the map settings, and for that I have found
a simple solution. It requires a bit of scripting, but it’s literally just one line of code.
If you don’t feel confident to follow these steps, you can also get the script by following
the link in the description. It is a little bit longer than what we’re going to do here,
but that’s because I’ve made it in a way that lets you customise it without having to deal
with any code at all. We need to go to the Game_Player
page in the Game Objects category, find the line 137, add a line below it, and write return
false if $game_switches[NUMBER]. In this example we’re going to use the Switch number 2. If
you prefer, you can copy it over to a new page, in the Materials section. Also, remember
to delete the new line from the other page. After doing that, though, it’s also needed
to copy the line 9 from the Game_Player page, paste it above everything, and type ‘end’
below everything. Now all the scripting required is done.
Let’s move on. Starting with the Stamina Bar event, we have
to set it as a parallel process, with a condition switch of your liking. For the tutorials sake
we’re just going to call it “Stamina”. Also a variable will be needed for this.
We’re going to use the number 1. We need two pictures, one for the HUD and
one for the bar. We’re adding the HUD first, with a Show Picture
command. Be sure to set its position properly. The bar picture is a little different – we’re
going to make it appear with a script call so we can set it’s size to be relative to
the stamina variable. You can just copy it from the screen and change
the numbers as you need it. Now that we are done with the Stamina Bar,
we need to make an event on the map to turn the Stamina switch on. In your game, you can
just sneak that right at the end of the intro cutscene for example. Gonna keep it very simple
here, just set it to Autorun, make it set the value of the Stamina variable to 100 so
we start the game with it full, turn the Stamina switch on, self switch A on, and a new blank
page for when the self switch A is on so the event doesn’t repeat itself and freezes the game. At this point we might want to test it just
to see if the stamina bar shows up. It won’t do anything yet besides, well, being there,
but it’s important to check it’s position to adjust if necessary. Since that’s good, we can get to the
main eventing now. In the Stamina Calculation event, after setting
it to parallel process with the Stamina switch, the first thing we have to do is set two conditions
up, one to check is the player is dashing, and another one to check movement, both using
simple script calls that you can copy from the screen. Inside the movement condition, let’s set up
the depletion of stamina, making it decrease the variable by the percentage you want, then
wait a frame so it doesn’t consume all at once. At this point the stamina goes down, but doesn’t
stop at zero, nor regenerates. To fix that, let’s continue the event, first
by setting a condition that says if the stamina is zero or below, the dash is disabled. If
not, it keeps going down – we do that by moving the subtraction and wait inside the else part
of the branch. We also add a wait command after disabling the dashing to avoid spam. Now, if the player isn’t moving nor dashing,
the stamina should regenerate. In the else section of the dashing condition, we create
a label named Regen and create a condition that checks if the stamina is equal or above 100.
If it’s equal to 100 or above, it does nothing. If it’s less, it waits a little, increases the value and enables the dashing again by turning the switch 2 off. If the player is moving, but the dash is disabled, the event jumps back to the Regen label. Now let’s test the game and see if it works! After testplaying and setting the values to your liking,
we can make the HP related events. One will be called HP Deplete and the other HP Bar. The HP Bar event is pretty much the same as the Stamina Bar one, just changing the HUDs position a little and, instead of using the stamina variable to determine the bar size, we’re going to use a script call called hp_rate, that is the number resulting from diving the current HP for the Max HP. Also, we’re going to multiply it by 100 so it looks like a percentage. If you need to, just copy it from the screen. Also, do not forget to change the pictures indexes. On the HP Deplete event, we’re going to set a wait command, and a condition checking if the stamina variable is equal or below zero. If it’s not, the event doesn’t do anything. If it is, the HP of the first actor is decreased. We can also add an effect, so the player knows their HP is being drained. Let’s playtest. Looks alright so far, it just needs a few touches and it’s done. So, as I said before, this was my first attempt ever at a decent video. I tried to make it understandable enough but, if it’s not, you’re always free to ask questions in the comments. I hope you enjoyed! Thanks for watching! Bye~

7 Replies to “Stamina Bar Event Tutorial for RPG Maker Vx Ace”

  1. This… is a gem! A must-have for every game! (Things like these makes the experience so much more engaging.)
    Now… what other jewels like this one, are you keeping from us? (ᄑ_ᄑ)

  2. EDIT:
    You might want to add a condition that checks if the "dash blocked" switch is off, and just then turns it on, and vice versa… That's to stop the event from spamming the switch on/off command, then avoiding lag!
    (Click on Read More for adaptation to RPG Maker MV)

    =======================================================
    ADAPTING TO RPG MAKER MV
    I do not own RPG Maker MV, but since it was requested I looked up a way of "porting" the guide to it.
    Now, since I've never used it, the calls might be wrong or need adaptation. If you try it out, please tell!

    Disable dash for MV, by Yanfly (might need core engine to work – be sure to learn how to use it since it's not the same way as I show in the video)
    http://yanfly.moe/2016/03/03/yep-77-dash-toggle/

    Show Picture script call:
    $gameScreen.showPicture(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode)

    STA bar scaleX call:
    $game_variables[NUMBER]

    HP bar scaleX call (you might want to make another event that calculates that if it doesn't work):
    ($gameActors.actor(actorId).hp/$gameActors.actor(actorId).mhp)*100

    Script calls for checking dashing and movement:
    $game_player.dash?
    $game_player.moving?
    =======================================================

  3. Ola, no meu jogo esta ocorrendo um problema…
    A barra de stamina esta esvaziando e regenerando corretamente porem quando chega no 0 e a barra fica vazia ele não reduz a velocidade . AJUDA PLS!!!

Leave a Reply

Your email address will not be published. Required fields are marked *