[RMMV] Storing damage in variable

Hello,

I found different posts about that subject but I still can't find a way to do it. I'm lacking of knowledge.

As the title says, I'd like to store the damage I deal in combat into a variable.
That variable must increment after each fight

Fight 1 = 150 dmg dealt
Fight 2 = 100 dmg dealt => overal dmg = 250 (that's what i want to store)

I tried doing this code in the damage formula :
Code:
r=a.atk * 4 - b.def * 2; if (b.isEnemy) {$gameVariables.setValue(20, r);}; if (b.isActor) {$gameVariables.setValue(19, r);}; r

with common event :
1583253905213.png


But when i check my variable value I have unprobable values.

Can anyone help me about this please?

Thanks 🙂

NOTE : I'm Using YEP_damage core
Tech Support is for when you can't get the engine to run.

As you are using a plugin for this...
Moved to: JavaScript/Plugin Support
But when i check my variable value I have unprobable values.
what exactly do you mean by that? To really help we would have to get a better description...

That said, what you do is to store the current skill's damage into the variable - overwriting any previous value from it (because you set the value, ignoring what was before).
So it completely depends on when and how you add that skill damage to the total value variable.
If that addition is done in a way that skips an action/skill/turn, then of course the damage from that skill will be missing from the total.

So please show us where and how you add all those results together.
what exactly do you mean by that? To really help we would have to get a better description...
I have something like 2536 or 3472 or 4099. These values are everytime after a single fight, it's never the same. And my damage are around 100~

That said, what you do is to store the current skill's damage into the variable - overwriting any previous value from it (because you set the value, ignoring what was before).
So it completely depends on when and how you add that skill damage to the total value variable.
If that addition is done in a way that skips an action/skill/turn, then of course the damage from that skill will be missing from the total.
Oh I see, that's the part missing I guess.

So please show us where and how you add all those results together.
Everything I did is shown in the 1st post.
then yes, you're missing the part where the skill damage is correctly added.
However that does not entirely fit with your numbers - if every skill only does around 100 damage, then the numbers you would get should be around 100 as well.

there has to be some other use of those specific variables if no skill does a four-digit damage and you still get those numbers inside that variable. You need to find that other place that modifies the variable or you'll never get it working.
this can either be another event (easy to find through search) or it can be a plugin that has this variable configured inside itself for some other use (then you have to check every property of every plugin to see where the IDs 19&20 are used for variable definitions).

Original thread: https://forums.rpgmakerweb.com/threads/rmmv-storing-damage-in-variable.118794/