I just wanted to share the block mechanic I created for my game. Basically, if a shield is equipped, it grants a passive state that gives the shield bearer a % chance to reduce incoming physical damage by half. The likelihood of this effect scales w/ DEF.
1st add this notetag to the shield in question (or all shields, like I do in my game):
Of course you're gonna want to change "42" to w/e stateID corresponds w/ the block state we're about to make.
Next, create a state w/ the following code for the block effect:
Alternatively, you could give the <Passive State: #> notetag to an actor or class instead, but you'll have to use this line instead:
For my game, shields are classified as a Weapon and is #6 in the database. If your shields fall under the Armor category you're gonna want to use "user.isAtypeEquipped(#)" instead.
Finally, feel free to adjust the formula for blockChance as you see fit. For my game, 1 point of DEF adds 0.1% chance to block plus a 5% base chance. So 100 DEF would mean 15% block chance.
Edit: I had to change "value /= 2;" to "value = Math.round(value / 2);" so we don't get decimal results lol.
1st add this notetag to the shield in question (or all shields, like I do in my game):
Code:
<Passive State: 42>
Next, create a state w/ the following code for the block effect:
Code:
<Custom React Effect>
if (value > 0 && this.isHpEffect() && this.isPhysical()) {
var blockChance = (user.def / 1000) + 0.05;
var blockText = target.name() + ' blocked ';
if (Math.random() < blockChance) {
value = Math.round(value / 2);
blockText = blockText + value + ' damage!';
$gameMessage.add(blockText);
}
}
</Custom React Effect>
Alternatively, you could give the <Passive State: #> notetag to an actor or class instead, but you'll have to use this line instead:
Code:
if (user.isWtypeEquipped(6) && value > 0 && this.isHpEffect() && this.isPhysical()) {
Finally, feel free to adjust the formula for blockChance as you see fit. For my game, 1 point of DEF adds 0.1% chance to block plus a 5% base chance. So 100 DEF would mean 15% block chance.
Edit: I had to change "value /= 2;" to "value = Math.round(value / 2);" so we don't get decimal results lol.