HELP - Event-based Stamina Battle System

Hi everyone,

I'm beginning to learn how to use RMMV and I'm currently working on creating an event-based battle system; atm, the only rules of my battle system are as follows:

My hero and enemies only have 4 parameters: HP / ATK / DEF / STAMINA

The turn are based on the character's stamina; at the beginning of the battle, the hero starts with a stamina value of 8 which allows him to attack straight away; the enemy starts with a random value of stamina between 1 and 8 and must wait until it reaches 8 to counter attack. I have no idea how it would develop in practice, but that is what I'm aiming to create for now.

However, I'm already stuck after 2 days of creation.

I'm using 2 common events; The first one I managed to create is the one that makes the battle menu appear on the map, with 2 options: Attack / Leave battle. The menu is working fine, I can move from one choice to the next, then the second common events that is supposed to handle the stamina system is launched when I press on "ok" while on the "Attack" button.

Here is the common event I use to display the menu, move through it, and press "ok"; it is working but if you see things that I could do differently, more efficiently with the same results, don't hesitate, I'm here to improve:

Spoiler: Show Battle Menu - Commont Event
For it to work, I must have one event on the playable map, and one on the battle map, so that I can start the battle menu when transferring the player on the battle map, and hide it when the player comes back on a playable map; here they are:

Playable map event on parallel:
1646781812738.png


Battle map event on parallel:
1646781836401.png


The Battle Menu common event that is started when the player is transferred on a Battle Map:
1646781902127.png

1646781935605.png

1646781978500.png

The real problem comes with the common event : Battle Stamina that starts when I press "OK"; 2 scenarios for now:
1 It allows me to attack and decrease the enemy's HP (as a side note, I use actors to represent my enemies), until the enemy is knocked out, then it makes me win the battle and go back to the next playable map.
2 it allows me to leave the battle if I choose to do so.

However, now that I want to add a condition to the ATTACK choice, namely, the hero can attack only as long as his stamina is bigger than 1; otherwise, the hero must wait for the enemy to attack, which allows him to recover as much stamina as was used by the enemy. i just can't find a way to make it work.

Right now, the code I'll show you allows me to have the stamina decrease by 2 everytime I attack; but when I reach a stamina value of 1; I'm still able to keep attacking. My additional condition that is supposed to prevent me from attacking is not taken into account. However, I noticed that if I win the first battle, with my stamina stuck to 1 (because it's the minimum); when I will start the next battle, my additional condition is the one taking into account and I really cannot attack during that second battle.

I hope you can picture my problem properly, so here is the 2nd common event that I use to handle attacking, decreasing HP, decreasing stamina and so on...:

Spoiler: Stamina Battle System Common Event
Here is the comon event:

1646782573727.png

1646782609287.png

I've tried to mix up or change the conditions around in many ways, but the best result I get is the one I described above. If you manage to understand my issue and come up with solutions I could try to implement; I'd be happy to learn from you all.

Thanks a lot!
You seem to be using Luck as the stamina stat, but are using a variable for the stamina value. The problem is that after you subtract 2 from luck, you aren't updating the variable. That's why it lets you keep attacking; the value never stops being its starting value until the next battle when its value is reset to luck again (which is why you can't attack in the next one, because at that point you start out without enough stamina)
Thanks for the fast answer Trihan!

Yes, you are right, I'm using Luck as the stamina stat indeed; then takes that number at the beginning of the battle as my stamina value.

I had guessed that indeed the decrease in the stamina variable was not taken into account during the battle, but only once the whole common event was started again at the beginning of the next battle. However, I cannot come up with a solution to "update the variable" during the battle, that is after every attack. Do you know how I should go about doing that in a common event?

I'm going to dig that idea of "updating" on my own in the mean time! Thanks again!
I only added this control variables to replicate the change in parameter, and it is working as I wanted. Just in case, is that what you meant by "updating the variable"?

1646783732589.png


If that is all, I guess you have offered me a pretty swift solution to my issue. Thanks a lot!
I only added this control variables to replicate the change in parameter, and it is working as I wanted. Just in case, is that what you meant by "updating the variable"?

View attachment 218967
That's exactly what I meant. Though if you're using luk as stamina anyway, why bother with a variable at all? Just edit your conditional branch that checks variable 12's value to check the actor's luck value instead.
That's exactly what I meant. Though if you're using luk as stamina anyway, why bother with a variable at all? Just edit your conditional branch that checks variable 12's value to check the actor's luck value instead.
I think that was the idea at first, but I think the conditional branch menu didn't offer the possibility to the check the parameter's values (unless I missed it).

1646784337820.png


So I tried to work around that issue by using variables. I suppose it is possible to use a script code to tell the conditional branch to check the actor's luck value parameter straight away, but I have no idea how to write this kind of code. I will look into this direction again; I found a place at the time where many script calls were gathered but I remember I couldn't make use of these correctly to get what I wanted.

Thanks Trihan!
I think that was the idea at first, but I think the conditional branch menu didn't offer the possibility to the check the parameter's values (unless I missed it).

View attachment 218968

So I tried to work around that issue by using variables. I suppose it is possible to use a script code to tell the conditional branch to check the actor's luck value parameter straight away, but I have no idea how to write this kind of code. I will look into this direction again; I found a place at the time where many script calls were gathered but I remember I couldn't make use of these correctly to get what I wanted.

Thanks Trihan!
Tab 4, script.

$gameParty.leader().luk >= 1
Tab 4, script.

$gameParty.leader().luk >= 1

Thanks!

I had just tried with this:

"If Script: $gameActors.actor(1).luk == 1;

Unable to attack

Else ..."

And it did work as intended too.

Are there any important differences if I use $gameParty.leader().luk instead? Or do they relate to the same thing exactly?

Thanks anyway for all the help, I can continue implementing the rest of the system hopefully now! =D
$gameParty.leader() returns the actor object in the first party slot, so if that's the first actor from the database it'll be exactly the same object as $gameActors.actor(1).
Ok, I understand. This is supposed to be a one playable character only little game so I guess it doesn't make a big difference, but I'll keep the difference in mind in the future!

Thanks for everything Trihan!

Original thread: https://forums.rpgmakerweb.com/threads/help-event-based-stamina-battle-system.145576/