Pre-calculating damage

Hello people

Is it possible to pre-calculate the damage that would happen in a turn?

I'm recreating the Hexdrinker effect from Yanfly's Tipps and Tricks.
However, there is a glaring issue with Yanfly's implementation. For example, imagine your actor has 100 HP. Then an attack hits for 100 damage, essentially one-shotting you.

What happens:
Actor will take 100 damage, then die, while generating a shield for 50 hp.

What should happen:

Actor will generate a shield, then subtract the shield value from the damage and then take 50 damage - death averted.

Why not change it to a custom react effect, instead of respond effect?
As no damage calculation happens, the game can not know whether or not the actor will fall below 30% health, which is a condition for the shield to pop off, meaning it will only pop once you are already at 30% or below resulting in nothing that happens, when you get hit from above 30% and then die.
Why not change it to a custom react effect, instead of respond effect?
As no damage calculation happens, the game can not know whether or not the actor will fall below 30% health, which is a condition for the shield to pop off, meaning it will only pop once you are already at 30% or below resulting in nothing that happens, when you get hit from above 30% and then die.
😅 Um, I'm pretty sure this is wrong. I tested to confirm, using this notetag:
Code:
<Custom React Effect>
console.info(target.name(), 'is about to take', value, 'damage!');
</Custom React Effect>
If it's not working out for you, I suspect the problem lies elsewhere, maybe with the absorption barrier plugin?

Also, because I feel like it's more beneficial to link directly to the full article rather than just the video~
😅 Um, I'm pretty sure this is wrong. I tested to confirm, using this notetag:
Code:
<Custom React Effect>[/INDENT][/INDENT]
[INDENT][INDENT]console.info(target.name(), 'is about to take', value, 'damage!');[/INDENT][/INDENT]
[INDENT][INDENT]</Custom React Effect>

This is really interesting. See, the reason why it doesn't work, is because for the shield to pop off, the attack needs the actor to go to 30% or below hp. but at this react step, the game doesn't know whether the actor will be at 30% or not.

But if your proposed code really is a thing, then I could theoretically store this damage value, subtract it with the remaining hp of the actor and then determine, whether the actor's HP will be below 30% or not and then eventually pop the shield. This seems like a big workaround, but I'll do anything to make my effect happen! Thanks for the input.

Edit: This made it work! Big thanks!
Could this also be used if say I want a tooltip that shows expected damage to be dealt? Like you select your skill/spell and then during target selection have something say how much damage it will do, which changes as you toggle thru the various targets.
Could this also be used if say I want a tooltip that shows expected damage to be dealt? Like you select your skill/spell and then during target selection have something say how much damage it will do, which changes as you toggle thru the various targets.

That depends entirely on when the variable "value" is instantiated. I can look into this.

The second issue is displaying the damage as text. Thanks to caethyril, we now know we have a console.log equivalent for MV. But iirc there should be a function that displays battle messages on the top of the screen, which is normally used for "Actor used X".
@staf00 It does not work. React is the earliest step you can use "value" as a variable.

While digging deeper into this, I found out that this is not a default variable provided by RPG Maker. This is actually a custom yanfly variable and in the documentation of the buffs & states core, he even documented as much. He said that you can use the value variable in both the react and respond steps. Ugh, how did I not catch this...
Damn, that's a shame... there goes my hopes for a much needed damage preview feature that's pretty much a staple of tactical RPGs.

Or wut if we just made a formula that mirrors the skills dmg formula to spit out a value, and not directly use the value variable provided by buffs & states core?
Damn, that's a shame... there goes my hopes for a much needed damage preview feature that's pretty much a staple of tactical RPGs.
You could request a plugin for this, if you haven't already. 🙂 I feel like I've seen such a plugin before (displays expected damage, hit chance, etc on hovering a target), but I checked various places and couldn't find it... 😔

Original thread: https://forums.rpgmakerweb.com/threads/pre-calculating-damage.122559/