A Plugin!?

Hello everyone. I haven’t had much of a chance to check yet, but I suspect there are still very few of you reading this. I apologize once again for my absence, I’m not quite ready to return yet, but I made a new plugin and figured I should show it off!

This plugin actually builds upon my very first state, the block chance. What it does, is it solidifies Block Chance (blk) as an xparam in the engine, allowing states and armors to add to it, and actors to display it as a parameter in the status screen, with some coaxing of course.

 

With this plugin, the parameter blk can be used in the same way that att, or mat, or cev, or acc can be used. In damage formulas, or evals, or enemy ai evals or whatever you want. In order to make use of it, you’ll need some other plugins that can work with custom parameters. Yanfly’s buffs/states core is what we use all the time here, and it works perfectly for this as well.

The plugin gives us the following note tag, which can be placed on an armor or on a state:

<BLOCK CHANCE: X>

X is equal to the percent chance you want the block to happen. Eg: <Block Chance: 15> will give a 15% chance to block.

We also have two other note tags that can only be placed on an armor:

<BLOCK ANIMATION: X>

<SLAM ANIMATION: X>

These tags take the id in X and show the respective animation when a shield block or a shield slam occurs. You’ll need an action sequence plugin to make use of the slam animation, but the block animation is built into our new and improved Shield Block State:

<Custom React Effect>
if (value > 0 && this.isHpEffect() && this.isPhysical()) {
  var rnd = (Math.floor(Math.random() * 99 + 1))
  var shd = target.blk
  if (rnd < shd){  
    value -= value;
      target.startAnimation(target.equips()[1].blockAnimation, true, 0);
  }
}
</Custom React Effect>

The plugin can be downloaded here. Happy building.

Block Chance

Greetings.

For my first state copy paste, I figured I’d go for one of the first custom states I’d made, Block Chance. In my project, a hero who has a shield equipped has a chance to block when taking physical damage. This chance is different depending on what type of shield the actor has, with a buckler being the least effective, at a 1% chance, and a heavy shield offering a 15% chance to block.

When a block occurs, an animation is shown on the actor, and he takes no damage from the attack. This animation can also be different based on the type of shield, or, if you’re willing to put in some effort, the individual shield equipped can show different animations as well.

What do you need to set this up?

Setup Steps:

  • Create an animation to show on an actor that has blocked. I used a shield image from the RMVXA iconset, of which there are a large number of shield icons. You can do the same if you also own a copy of RMVXA.
  • Create a passive state for the block chance trait. We will go over what needs to be in the state’s note box shortly. For now, since this is passive, we won’t need an icon, or removal conditions. Make sure that all shields that can block in your project bestow this state passively using the below note tag note that text in red will need to have its value changed to work in your project):
    <Passive State: 37>  // where 37 is your state ID for the block state
  • As a bonus add-on we will include two ways to increase your actors block chance as well, I will explain them in the section near the end, so don’t panic when I don’t go over everything in the note tag right away.

The Code

This is the copy-paste text that needs to go in your note box for the block chance state.

<Custom React Effect>  
//this section occurs when the afflicted target is hit by an attack
if (value > 0 && this.isHpEffect() && this.isPhysical()) {
  // checking if this was a valid physical attack to block
  var rnd = (Math.floor(Math.random() * 99 + 1)) // random value from 1-100
  var imp = target.isStateAffected(36);          // see bonus section
  var sng = target.isStateAffected(179);         // see bonus section
  var shd = $dataArmors[$gameActors._data[target.actorId()]._equips[1]._itemId].atypeId
  // the above variable is storing what armor type the equipped shield is
  var per = 0 // the default chance to block
  if (shd == 1)  { // if the shield is type 1 (common) it is a buckler
    per = 1  // base block chance of buckler = 1%
  }
  if (shd == 5) { // type 5 for my project is light shield
    per = 10 // base block chance of light shield is 10%
  }
  if (shd == 6) { //type 6 for my project is heavy shield
    per = 15 // base block chance of heavy shield is 15%
  }
  per = per + (imp * 10) + (sng * 30) 
  // the above line is adding bonus for block chance based on other states
  // I will cover this below in more detail.
  if (rnd < per){  
  // if the random number we generated is within the value of 'per' a block has
  // occurred
    value -= value; // makes the attack do no damage
    if (target.equips()[1].baseItemId == 7){ 
  //this if statement is checking for a specific shield to be equipped
  //it then shows the specific animation for that shield.
      target.startAnimation(165, true, 0);
   }else if (shd == 6) {
  // if you have a heavy shield, show the heavy shield animation
      target.startAnimation(131, true, 0);
   }else if (shd == 5) {
  // if you have a light shield, show the light shield animation
      target.startAnimation(163, true, 0);
   }else{
  // if you don't have either heavy or light, you must be using a buckler show that
      target.startAnimation(161, true, 0);
   }
  }
}
</Custom React Effect>

Bonus

In the above code we have two states that increase the block chance by 10% and 30% respectively. The first is labeled ‘imp’, and is short for improved block, or shield mastery. My project makes use of an ‘equip skills’ system to allow a lot of depth in customizing the actors, one such skill learned from a shield bearing class increases their base chance to block by 10%. This was simple enough to put into the state, as seen. The second state, ‘sng’, is short for song, and is an active buff that my bard characters can place on allies, which increases block chance by 30%. You can add as many of these states as you like, to increase block chance more and more, but be sure you add in some extra math to make sure the value doesn’t exceed 100%, or the block may actually fail when the value rolls over.

You can also add in some extra if…else checks to look for specific shields to set the base block to be per shield, instead of per type. If you’re familiar with javascript, you can even add these values to shields themselves, and use this react effect to simply pull the values from the item directly, instead of manually in the note tag like we’ve done here.

How does it look?

See for yourself

 

That’s all for today.

~Ramza