MZ how to show total damage done to enemy as a variable

Looking for a way to store damage done as a variable... trying to use this as a way to print Total damage done in multi hit skills.
Are you using any plugins at the moment?
A ton.. Mostly VisuMZ stuff
At what point in the skill are you trying to print damage? Because in most places in Visu notetags the "value" property already exists.
like... I have a 10 hit skill... I want it to print damage for each hit... then at the end print the total damage that all 10 hits did.
so if all 10 hits did 2 damage I would want the final value to show 20.



a visual example. it does all the hits in the skill. then at the end shows total damage.
like... I have a 10 hit skill... I want it to print damage for each hit... then at the end print the total damage that all 10 hits did.
so if all 10 hits did 2 damage I would want the final value to show 20.



a visual example. it does all the hits in the skill. then at the end shows total damage.

So presumably you'll be doing that in an action sequence, in which case you have the "value" variable available to you.
Do I...?
If you're using an action sequence, yes.
If you're using an action sequence, yes.
I mean.. I see a way to pull up a variable to show up... but I don't see a way to make that variable = the total damage .-.? like the only thing I can think of is to increase the variable by the damage calculation... but that would be off due to the damage variance..
I mean.. I see a way to pull up a variable to show up... but I don't see a way to make that variable = the total damage .-.? like the only thing I can think of is to increase the variable by the damage calculation... but that would be off due to the damage variance..
Have you tried setting it to "value"?
Isn't "value" going to represent the current damage dealt inside of each individual hit?

To do what the OP says, wouldn't you need to do something like:
Code:
<JS Post-Damage as User>
target.damageDealt = target.damageDealt || 0;
target.damageDealt+=value;
</JS Post-Damage as User>

and then when all the hits are done, display a message referencing that .damageDealt variable?
Isn't "value" going to represent the current damage dealt inside of each individual hit?

To do what the OP says, wouldn't you need to do something like:
Code:
<JS Post-Damage as User>
target.damageDealt = target.damageDealt || 0;
target.damageDealt+=value;
</JS Post-Damage as User>

and then when all the hits are done, display a message referencing that .damageDealt variable?
You may be right.

Though since it's MZ you can take advantage of nullish coalescing assignment and do

target.damageDealt ??= 0;
target.damageDealt ??= 0;
Nice, was not familiar with that operator.
<_<... so like... all of that went over my head... am I supposed to run that as script in Variable control???

I know almost nothing about coding
No. Any time you see anything inside of angled brackets that's a notetag that's placed in the notes field and used by a plugin.

If you read the instructions for the VisuStella plugins you've installed into your game, you should've seen tons of references to them.
Isn't "value" going to represent the current damage dealt inside of each individual hit?

To do what the OP says, wouldn't you need to do something like:
Code:
<JS Post-Damage as User>
target.damageDealt = target.damageDealt || 0;
target.damageDealt+=value;
</JS Post-Damage as User>

and then when all the hits are done, display a message referencing that .damageDealt variable?
I've been trying to figure this out. .-. is there a way one of you guys could break this down further.

Like. where is target.damageDealt getting defined? inside the battle core? and do I switch Value with w/e variable I'm trying to use?

I've tried as is. and changing to the variable while in the skill notetag but when I try printing the variable it shows as 0 everytime. =/
I've been trying to figure this out. .-. is there a way one of you guys could break this down further.

Like. where is target.damageDealt getting defined? inside the battle core? and do I switch Value with w/e variable I'm trying to use?

I've tried as is. and changing to the variable while in the skill notetag but when I try printing the variable it shows as 0 everytime. =/
Show us what you've tried so far and we'll be able to help you finetune it.
this is the current attempt. I've tried several other things but didn't try to remember them because they didn't work..

first picture is the Notetag in the skill page.
2nd is where I am trying the variable popup to print total damage. then just for testing I am also printing the variable in a text window.
Isn't "value" going to represent the current damage dealt inside of each individual hit?

To do what the OP says, wouldn't you need to do something like:
Code:
<JS Post-Damage as User>
target.damageDealt = target.damageDealt || 0;
target.damageDealt+=value;
</JS Post-Damage as User>

and then when all the hits are done, display a message referencing that .damageDealt variable?
OOOOOK. I've been trying to learn Javascript... and tell me if I got this right

target.damageDealt = target.damageDealt || 0; This line is making sure the target.damageDealt variable is set to 0?


target.damageDealt+=value; and this one is making it = Value... and I guess Value is an internal number for damage in rpg maker?

... if I'm wrong could you correct me... and could you let me know how I would call a custom variable like target.damageDealt inside RPG maker?
this is the current attempt. I've tried several other things but didn't try to remember them because they didn't work..

first picture is the Notetag in the skill page.
2nd is where I am trying the variable popup to print total damage. then just for testing I am also printing the variable in a text window.
The problem with this is that $gameVariables.setValue sets the variable, you can't add the result of that to anything. You'd use $gameVarables.value instead.

Your interpretation of the code above is correct. And because it's been added as a property of the target, you can reference it anywhere in the code at any time by referencing the same object. So if the target had been party member #2, you could do $gameParty.members()[1].damageDealt

Original thread: https://forums.rpgmakerweb.com/threads/how-to-show-total-damage-done-to-enemy-as-a-variable.154860/