Block damage, like when using a shield

So, i've found this example of block damage using YEP Auto Passive State, but i wanted it to reduce damage instead of setting it to 0.

 

Code:
[COLOR=rgb(0,0,136)]<Custom[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,0,102)]React[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,0,102)]Effect[/COLOR][COLOR=rgb(0,0,136)]>[/COLOR][COLOR=rgb(0,0,0)]
//just replace 50/100 with the percentage. 
if(Math.random()>50/100) {
    target.startAnimation(53);
    value = 0;
}
[/COLOR][COLOR=rgb(0,0,136)]</Custom[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,0,102)]React[/COLOR][COLOR=rgb(0,0,0)] [/COLOR][COLOR=rgb(102,0,102)]Effect[/COLOR][COLOR=rgb(0,0,136)]>[/COLOR]
change the 0...
I did and the actor took damage equals to the value
I use something like this its a bit more elaborate this adds a chance to block, flat value reduction, and a percentage damage reduction; furthermore, I use have it so if user is afflicted with certain other states it modifies those values like say a cripple state reduces block chance and value or something of the sort.


<Custom React Effect>


var roll = Math.randomInt(100) + 1;


var blchance = 25;   // This is the chance for block to occur;


var blvalue = 10;     // This is a flat value reduction


var blred = 0.80;          //This is a percentage based reduction.


if (user.isStateAffected(23) || user.isStateAffected(3) || user.isStateAffected(6) || user.isStateAffected(167)) {


blchance -= 5;               // Reduces block chance


blvalue -= 10;          /// If user has certain states will reduce flat block values


blred += 0.45;             /// Reduces effectiveness damage reduction percentage


}


if (user.isStateAffected(55) || user.isStateAffected(15) || user.isStateAffected(36)) {


blchance  += 15;              // Increasesblock chance


blvalue += 10;                /// If user has certain states will increase block value


blred -= 0.15;               // Increases effectiveness  damage reduction percentage


}


if (roll <= blchance) {


value = value - blvalue;


value = Math.floor(value * blred);


if (value < 0) {


 value = 0    /// prevent value from being less than 0


}


user.startAnimation(256);     ///start animation


}


</Custom React Effect>


Hope this helps or gives you some ideas
This gave me tons of ideas, thx @Quickdraws
Instead of "value = 0" you can do something like "value -= 10" to reduce damage by 10 or "value /= 2" to reduce damage by half.


If you're asking for a "shield" in the sense of LoL where it runs out after you take a certain amount of damage, that requires more complex scripting.
Ofc if you remove 0 it will deal damage equal to value... What I meant was you change it to whatever value you need.

Original thread: https://forums.rpgmakerweb.com/threads/block-damage-like-when-using-a-shield.63811/