How to Store Previous Attack's Damage in Variable

Hello, I want to add an achievement that's given when 10,000 cumulative damage is outputted by actors. To do this, for every attack that is done by an actor, I need to add the damage that was done in that attack to a "totalDamage" variable. How would I receive the damage value of an attack using scripts?
You could do it a complex way with events:
- Make a troop event that runs every turn and saves the current HP of each enemy into a variable
- Have every damage skill call a common event that checks those variables, adds any difference to your achievement-tracking variable, and modifies the HP variable to be current again

Or an easy way with plugins:
- Give every actor the same passive state using VisuStella Skills and States
- In the passive state, put a notetag from VisuStella Battle Core:
Code:
<JS Post-Damage as User>
$gameVariables.setValue(X, $gameVariables.value(X)+value);
</JS Post-Damage as User>
where X is the ID of your achievement-tracking variable. Make sure to initialize it to 0 at the beginning of the game.
You could do it a complex way with events:
- Make a troop event that runs every turn and saves the current HP of each enemy into a variable
- Have every damage skill call a common event that checks those variables, adds any difference to your achievement-tracking variable, and modifies the HP variable to be current again

Or an easy way with plugins:
- Give every actor the same passive state using VisuStella Skills and States
- In the passive state, put a notetag from VisuStella Battle Core:
Code:
<JS Post-Damage as User>
$gameVariables.setValue(X, $gameVariables.value(X)+value);
</JS Post-Damage as User>
where X is the ID of your achievement-tracking variable. Make sure to initialize it to 0 at the beginning of the game.
Thanks for the quick response and for providing two solutions!

Original thread: https://forums.rpgmakerweb.com/threads/how-to-store-previous-attacks-damage-in-variable.153631/