Actor and Enemy Death Common Events v2.0.1

Created from this thread.

Version 2.0.1: Github Link

Description
This plugin allows the user to run common events after any Actor or Enemy dies.

Installation
Either right click the Github link above and save as "DeathCommonEvent.js", or create a new text file called "DeathCommonEvent.js" and copy-paste the text from the link into it.
Move the file into your project's js/plugins folder.

Instructions
The plugin includes some logic to assign values to game variables that may be useful when writing common events, such as the Id and index of the last battler to act, the Id and index of the battler that just died, and the Id and type of the last skill or item used. By default:

- The Id of the Actor or Enemy that died is variable 1
- The index in either battleMembers or gameTroop of the Actor or Enemy that just died is variable 2
- The array of states the Actor or Enemy that died had before dying is variable 3
- The Id of the last Actor or Enemy to act is variable 4
- The index in either battleMembers or gameTroop of the Actor or Enemy that last acted is variable 5
- The Id of the last skill or item used is variable 6
- The type of the last action ("skill" or "item") is variable 7.

A quirk of common events is that their execution is queued up instead of immediately executed. By default, if you kill the last Enemy or the last Actor dies, then the common event is queued up, but not actually executed until after the battle is over.

There are two parameters you can change to affect this behavior - Run At Battle End will force your common event to be called just before the victory logic runs. Run After Battle will let your common event get called with the default behavior. If you turn both of them off, then the common event will not be called if the Actor or Enemy who dies would trigger the battle to be over.

Example
Spoiler: If skill 10 kills an enemy and the killer has state 4, apply state 11
UyUnwgL.png

Terms of Use
This Plugin is available for commercial and non-commercial use, as long as credit is given to the author listed in the @ author section of the Plugin. Credit must be listed in-game, as well as in any additional credits documentation provided with the game.
This Plugin may be modified in any way by any author, most notably for compatibility fixes with specific projects or other Plugins, as long as credit is provided to the original author and to whichever author made said modifications, according to the above-stated rules.
Seem to be an useful plugin, i was looking for one like this on RVXACE - _ -
@Finnuval Per your request, I've updated this Plugin to be capable of calling common events before the victory logic is processed. You'll need to replace your old version, then open up the Parameters and ensure that "Run At Battle End" is ON. If it is, then death common events will be called just before victory logic is processed.
Thanks! 😀
This is a great help.
Made a small change to the configurable parameters to use a type of variable instead of number for the 7 variables you can set. Now, when you configure them in the Plugin settings, it'll pull open your variable editor instead of requiring you to enter in a number.
Made a small change to the configurable parameters to use a type of variable instead of number for the 7 variables you can set. Now, when you configure them in the Plugin settings, it'll pull open your variable editor instead of requiring you to enter in a number.

Hello. I want to know if this works properly on QABS. I added a plug-in to this post, but it wasn't affected.
I want to know if this works properly on QABS.
I have not tested the Plugin with any ABS battle systems, so I don't know the answer for sure - however, it's very possible that an ABS system might overwrite the death functions, so there could be compatibility issues.

If you're specifically referring to the ability to reference variables in the Plugin's settings instead of entering numbers, that shouldn't be affected by other Plugins (except for them potentially using the same variables).
I have not tested the Plugin with any ABS battle systems, so I don't know the answer for sure - however, it's very possible that an ABS system might overwrite the death functions, so there could be compatibility issues.

If you're specifically referring to the ability to reference variables in the Plugin's settings instead of entering numbers, that shouldn't be affected by other Plugins (except for them potentially using the same variables).
Thank you for your reply! It was helpful for me.

Moved to Plugin Releases

Is there an option to run a common event after the last enemy has died? I only see choices to run a common event after every single enemy death.
Is there an option to run a common event after the last enemy has died? I only see choices to run a common event after every single enemy death.
You could add a conditional in the common event you want to run when an enemy dies that checks how many living troop members are left. I'm not at my computer, so I'm not sure if, at the time the die method is called, the aliveMembers method would return 1 or 0, but something like:
Code:
Conditional: script: $gameTroop.aliveMembers().length === 0
// Whatever you wanted to do when the last enemy dies
Again, it might need to be 1 instead of 0, depends on the timing of when everything is called.

Original thread: https://forums.rpgmakerweb.com/threads/actor-and-enemy-death-common-events-v2-0-1.104429/