I need to have a variable count the number of times a specific actor has died in battle, but cannot find how to do this.
Can anyone tell me how this is done?
Thanks.
I would start by counting how many times the death state has been removed, and adding one if the actor is currently dead.
That would be much easier to implement as it requires specific skills or items to remove the death state - much easier than trying to check for all forms of damage or continually checking if the death state is applied or removed.
If the actor is autorevived without specific skill/item use, then you either need a way to count the autorevive or you'll have to add a script changing the death state coding in the default engine.
Basically yes, that is one way to handle it.
It could also be handled with code in the damage formula, but that would be a bit more complex depending on how many actors - but sometimes easier if there is a problem with using common events.
Would be a really easy code snip, but I'm stuck at work for another three hours...
A damage formula isn't very reliable here since other calculations occur after the formula is evaluated. Guard rate, element rate, critical damage...
In battle event that plays during every action, have a variable branch that checks if the actor is knocked out, then another branch within it that checks if death switch is off. If off, turn it on and add +1 to death count. If the actor is not knocked out, turn the switch off.
You would need to make sure b is an actor, and not an enemy.
It would be something like:
onadd: \v[61] += 1 if b.is_actor? && b.actor_id == 5
I'm not sure about the method names or if \v is available in this script (I suspect it is, because I use b.-stuff- in one of the examples and where b is available, \v should be as well)
I'm on my work computer, so I can't check the syntax until a bit later.
okay - seems that was an old version where I had some issues with the order of things. Can you please download and try again?
This is a method in the battler class, so you can use any commands for a battler (ie - leave out the b. - it just works on the target by default).
The correct command to add to the state is:
onadd: $game_variables[61] += 1 if actor? && id == 5
However, in testing, I noticed a weird situation occurs - when the actor is first set up, their HP starts at 0 before it's initialized to the correct value. And the test to "apply the death state if HP is 0" gets run. So as soon as you start a new game, the death state is applied, the onadd script is run and the variable is incremented.
To get around this, you just need to set the variable to 0 at the start of the game (or at the time you add the actor to your party and initialize them).
Seems to work after that.