Absorption Shield

I'm looking to create a damage absorption effect, but I'm having some trouble figuring out the execution.

It would be a state that would need to be applied to an actor that would reduce PDR and MDR to 0%, but it would have to wear off after the actor would otherwise have taken x amount of damage. I'm not sure how to keep track of how much damage an attack *would've* done before reducing its damage to 0.

Maybe something in the troop events or common events or something that uses a variable that tracks the difference in actor current HP, then HP after an attack, but I don't even really know where to start with that - first, how I could take a variable before and after an attack, second, how I could do so without making pretty much every single damaging skill call said common event and variables or...

Well, I'm pretty well stumped.

I found this thread which has a script that apparently can drain physical attacks from the actor's MP total, but it's about the closest I've been able to find. It looks like someone else was trying to find the same thing I'm looking for, but never received an answer to their question. http://forums.rpgmakerweb.com/index.php?/topic/17089-shield-spell/?hl=%2Babsorb+%2Bshield#entry166892
Can you not set this to be an applicable state? I believe you can set states to be removed after a certain amount of damage
You can set a state to be removed by damage with a certain probability - that is, you can set a state to have a 50% chance to be removed whenever the actor is damaged or something like that, but you can't set a state to be removed after a certain percentage of damage.
Well, if your MDR and PDR are at 0%, you wouldnt - to my knowledge - be able to track "damage dealt" because there WOULD be none. One thing you could do I think, is have a condition where state 1 would be applied when a low damage enemy is present, and have the MDR/PDR be applied for more turns in that case, and state 2 (shorter duration) when heavier hitting mobs are present.

Mind you, that's what I would do, and I place every one of my encounters on the map as events, not using any random encounters.
What I'm trying to do is have a state that replicates the effects of MDR/PDR at 0% - that is, when the user has the state on them, they don't take any damage - but it's removed after taking a certain amount of damage, not after a certain amount of turns or having a chance to be removed on any damage. Like, "absorb shield is applied to actor Y." Then, the next 500 damage actor Y takes is reduced to 0. So, if they take a hit that would normally do 600 damage, they instead only take 100 damage and the state is removed. Or, let's say they take 200 damage over 3 hits. The first two hits will do 0 damage, then the third hit will do 100 damage and the state will be removed.
Hmmm. I'm honestly not sure how you would go about this without some kind of scripting...sorry I can't be more help
The scripts you want to look at are in Game_Battler. Specifically add_buff and make_damage_value. You may need to change a line or two in another method but those are the main two: you can trace it out from there.

You want to add a buff, then have that buff checked for AFTER damage is calculated but BEFORE it is applied.

Set up a variable to store 'shield value'. When the buff is active, compare damage calculated vs damage left in shield. If shield is greater, apply zero damage and knock the shield value down by damage taken. If calculated damage is greater, subtract the points remaining in the shield, add_debuff to remove the shield, and apply the rest of the damage.
I don't really know how to do any of that, I'm not familiar with scripting beyond perhaps changing a couple values or doing basic script calls within events - are there any resources you can maybe point me towards, or do you have any ideas on how to do any of that with common events or something?

Original thread: https://forums.rpgmakerweb.com/threads/absorption-shield.25687/