Variable One Count Assistance.

Good afternoon Yall,

I'm trying to do something with variables but i'm having a little trouble. Basically, I want to make a variable that keeps track of how many times a party member dies. I want to make a little mechanic where after X amount of deaths, that character is considered permanently dead and is removed from the party.

Lets say party member 2 dies in battle. I want it to add 1 to the variable. You can use an item or visit and Inn to revive but the count stays at 1 but I can't get it to stop adding to the variable. If they are effected by dead it counts about 100 per second. I tried to exit event processing but it still keeps adding to the count. I'm currently using common events to keep track of the variable since that will be a common event lol but yeah. I guess any advice would be appreciated. And thank you
you can use this plugin by Turan and some script calls to add an apply effect to the death state that makes it so that when its added to an actor, the variable gets incremented on their death
For one thing, there are a number of permadeath plugins you should be able to find with a Google - one of them may have this functionality already built-in for you.

Aside from that, using my plugin Robro linked to above, you'd give state 1 the following notetag:
Code:
<State Apply Eval>
if (user.isActor())
{
    $gameVariables.setValue(user.actorId(), $gameVariables.value(user.actorId()) + 1);
    if ($gameVariables.value(user.actorId()) == 10)
       $gameParty.removeActor(user.actorId());
}
</State Apply Eval>

That is using the variable ID that matches the actor ID (e.g. actor 2 is counting in variable 2). If you can't set up your variables' availability that way, you'll have to add math to which variable is being checked and incremented.

It's set up so if the actor dies 10 times they're removed from the party - change that number as you like.
you can use this plugin by Turan and some script calls to add an apply effect to the death state that makes it so that when its added to an actor, the variable gets incremented on their death

Thank you so much for the plug in!
For one thing, there are a number of permadeath plugins you should be able to find with a Google - one of them may have this functionality already built-in for you.

Aside from that, using my plugin Robro linked to above, you'd give state 1 the following notetag:
Code:
<State Apply Eval>
if (user.isActor())
{
    $gameVariables.setValue(user.actorId(), $gameVariables.value(user.actorId()) + 1);
    if ($gameVariables.value(user.actorId()) == 10)
       $gameParty.removeActor(user.actorId());
}
</State Apply Eval>

That is using the variable ID that matches the actor ID (e.g. actor 2 is counting in variable 2). If you can't set up your variables' availability that way, you'll have to add math to which variable is being checked and incremented.

It's set up so if the actor dies 10 times they're removed from the party - change that number as you like.
Thanks so much for the explanation. I just have a quick follow up, (i'm a little slow on the uptake and my coding is a little rusty) If I wanted to add math so to speak, user.isActor(2)) is party member 2. Currently the variable for that character is 21. I had it as a separate page. Where would i add the math to adjust? I can switch around the variables but that would involve switching around quite a lot of common events for other variables.

Edit: Just to clarify something. i want to make permadeath for every party member except the MC. BS blessed by god stuff or whatever. LOL okay thanks again!
user.isActor(2)) is party member 2
all that function checks is if the battler its being ran from is an actor. giving it a number wont make it check if its that actor. In Turan's snippet, the checking of which actor it is is done by looking at their actorId(), since thats a unique value for each actor
Currently the variable for that character is 21. I had it as a separate page. Where would i add the math to adjust?
if actor 2's variable is 21, then you change every use of "user.actorId()" to "user.actorId()+19" except for the one inside the parentheses for removeActor(). keep in mind though, its doing this for every actor. so variable 20 should be reserved for actor 1, as well as every variable up to variable "however many actors you have" +19
Thank you everyone for al the assistance it's greatly appreciated!
Edit: Just to clarify something. i want to make permadeath for every party member except the MC.
Okay, but that doesn't mean anything to us - what actor ID is that?

Presuming it's ID 1, you would change the second line of what I gave you to read
Code:
if (user.isActor() && user.actorId() > 1)

Original thread: https://forums.rpgmakerweb.com/threads/variable-one-count-assistance.171298/