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.

Prayer of Mending/Swiftmend

Good morning everyone, apologies for posting this one a day late, work got in the way.

This week is a double feature. I’m starting to run out of awesome states from my own project to share, so this week I’m going to share a modification of a state that my good pal* yanfly came up with for a tips and tricks video a long time ago (at least I think that’s where I got it from).

*(Disclaimer: yanfly isn’t my good pal)

Prayer of Mending is an active buff spell that causes a small amount of healing when the affected target is hit. After healing, the state ‘jumps’ to another ally. The buff will bounce a number of times before running out. Naturally, given the name, and effect, this is lifted almost entirely from World of Warcraft, where this used to be a staple spell of the Discipline Priest. I’m not even sure if this spell is even still in the game now, mind you.

As a bonus this week, though, I am going to share a second spell, one that consumes the number of ‘jumps’ the state has left on it to cause an active healing effect on the target. This allows the players healer character to give up random, mostly passive healing effects on her allies to cast a giant emergency heal instead.

So let’s get to it.

What You Need:

Here is our state. Note that the turn duration can be anything you want it to be, it will reset when it hops to another actor.

mendingstate

Here is the copy paste code for this effect:

<Custom Apply Effect>
this._mendingCharges = 6;
this._mendingHeal = origin.mat * 4;
this._origin = origin
this.setStateCounter(236, 'x' + 6);
</Custom Apply Effect>
<Custom Remove Effect>
this._mendingCharges = undefined;
this._mendingHeal = undefined;
this._origin = undefined;
</Custom Remove Effect>
<Custom React Effect>
if (this.isHpEffect() && this.isDamage() && target.hp > 0) {
 var heal = Math.floor(target._mendingHeal * (((Math.random()*40)+80)/100)) * target.elementRate(11) || 1;
 target.startAnimation(193);
 target.gainHp(heal);
 target.startDamagePopup();
 target.clearResult();
 var charges = target._mendingCharges - 1;
 var caster = target._origin
 target.removeState(236);
 if (charges > 0) {
  var members = [];
  for (var i = 0; i < target.friendsUnit().aliveMembers().length; ++i) {
   var potential = target.friendsUnit().aliveMembers()[i];
   if (!potential) continue;
   if (potential === target) continue;
   if (potential.isStateAffected(236)) continue;
   if (potential.hp <= 0) continue;
   members.push(potential);
  }
 var member = members[Math.floor(Math.random() * members.length)];
  if (member) {
   member.addState(236);
   member._mendingCharges = charges;
   member._mendingHeal = heal;
   member._origin = caster
   member.setStateCounter(236, 'x' + charges);
  }
 }
}
</Custom React Effect>

Make note that where this state is determining damage, it is using the target’s elementrate for element Id 11. In my project, this element is a healing element. For your own project, you can remove this section, if needed.

The flow for this ability goes as follows:

  • State is applied to target
    • _mendingCharges set to 6
    • _mendingHeal set to 4 * the caster’s mat
    • _origin set to the caster of the state
    • state counter is set to ‘x6’
    • x6
  • Target is hit by an attack of some sort
    • heal is set to 80%-120% of _mendingHeal, and then put through the element resistance of the target
    • animation 193 is shown
    • targeted battler gains hp equal to heal
    • if there is more than 0 charges remaining after this heal, it bounces to another valid target
    • the new target is given a _mendingHeal and _mendingCharge equal to what the current target had (subtracted one charge from this hit)
    • the statecounter is set to ‘x + charges) to show that the number of charges has gone down on the icon.
  • The state is removed
    • _mendingCharge, _mendingHeal and _origin are all cleared up for future use.

There is a tiny mechanic built into this ability, in that the heal from each charge has been randomized for each charge before it. This is difficult to convey properly, so I will try to explain in point form.

  • The caster of the spell has mat = 25
  • The first charge of this mending effect will heal 80-120 HP to the battler, as the effect is randomized with a variance of 20%.
  • The second charge can heal anywhere from 64 to 144, depending on what the value from the first heal was. if it was 80, this would do anywhere from 64 – 96.
  • The third charge does this again, and can vary from 51 to 172, again depending on the previous two charges.
  • This effect is compounded for each additional charge
  • The element rate in the ‘heal’ formula also comes into play. If the initial charge is on someone who has a ‘weakness’ to healing element, the heal will be much stronger on all subsequent charges, as will as the initial charge. If the initial target has an immunity to heal spells, all charges will deal no healing, no matter who they hit after the first one.
    • You can remove this problem by removing the healing element from the formula above, mind you.

Alright, so now that we’ve got that finished, let’s cover Swiftmend. This is an active spell that removes all remaining charges of Prayer of Mending from the target and heals them for equivalent of the remaining charges. This skill makes use of yanfly’s target core and selection control plugins to make sure you can only ever use this spell on a target affected with Prayer of Mending.

swiftmend-skill

This skill is an instant cast, which has a cooldown of three turns (which both require those plugins from yanfly if you want to make use of that), preventing the caster from using this emergency heal multiple times in a row. The the damage formula for this spell is where we get the entire effect from. b._mendingCharges is where the charges from the state are stored. You can also modify the formula to make the ffect stronger or weaker than the individual charges would be. In this case, this will do healing as if each remaining charge had been used, but you can also make it slightly stronger or weaker by changing the first part of the formula. By removing the state afterward, the charges, and healing are also cleared, so the effect is gone. Also worth noting, the extra variance effect from the actual state doesn’t apply to this skill, as it only goes through random variance once.

 

That’s all for today’s update.

 

~Ramza

 

Touch of Death

Welcome to this weeks state shop update. I’d like to start by apologizing for missing the update last week. I was at a wedding on the weekend, and then some health stuff happened that wasn’t pleasant the result was some missed work, and unfortunately, a missed update. Apologies.

 

Alright, with that out of the way, let’s talk about today’s state, Touch of Death. Inspired by a similar skill of the same name in Final Fantasy XIV, touch of death is a damage over time effect that gets stronger the longer it is on the target. My example lasts 12 turns, and the damage it deals doubles each turn it is active. This effect is possible thanks to state counters, a feature of yanfly’s Buffs and States Core plugin (which we always use already).

What you need:

  • A state, and a skill to apply it.
  • The usual plugins

First, here’s a screen grab of our state. Note the turn duration, and remove at battle end.

touchofdeathstate

Now, to keep with our other damage over time states, this state will also take into account the element of it when it deals damage. In my example, I have created a variable to reduce the damage from the state as if it were a physical attack. This is the default formula that Yanfly’s Armor Scaling plugin uses. You can also change this to just about anytghing to make it work in your project, but remember that damage reduction from the armor scaling plugin doesn’t take effect on damage dealt by states in this way. It is also important to note, that because by the last turn of this state, it will be doing 12x more damage than it did on the first turn, the base damage of the state should be very low. In this example, the state deals damage equal to the actor’s attack parameter.

Here is the paste code:

<Custom Turn End Effect>
this.addStateCounter(29, 1);
if (this.getStateCounter(29) > 12) {
 this.setStateCounter(29, 12)
}
var ele = 1
var reduction = (100 / (100 + (this.def / 2)))
var formula = Math.round((origin.atk * this.getStateCounter(29)) * reduction);
var total = (Math.floor(formula * ((Math.random()*40)+80)/100) * this.elementRate(ele))
this.gainHp(-total);
this.startDamagePopup();
if (this.isDead()) {
 this.performCollapse();
}
</Custom Turn End Effect>
<Custom Leave Effect>
var ele = 1
var reduction = (100 / (100 + (this.def / 2)))
var formula = Math.round((origin.atk * 12) * reduction);
var total = (Math.floor(formula * ((Math.random()*40)+80)/100) * this.elementRate(ele))
this.gainHp(-total);
this.startDamagePopup();
if (this.isDead()) {
 this.performCollapse();
}
</Custom Leave Effect>

Note that the state Id we’re working with is 29, and this will need to updated in your own project. Also note the Math.random function is being used to add variance to the damage of the skill, in this case, 20%. When the state first does damage, it is at one stack, so it will deal 1x damage. Every turn end after, it gains one more stack, dealing more damage each turn, until it falls off on the 12th turn, dealing 12x damage. The state is designed to never exceed twelve stacks, but you can adjust that to your liking. See below for a possible strategy tip regarding this state, and others like it.

Bonus: Strategy:

This effect is mostly only useful for the start of a fight, as if the enemy dies early after receiving it, it will not have done much damage. However, as scripted, if someone re-applies the state, the turn counter will remain where it was when the state is re-applied, allowing someone to refresh the highly stacked state with a fresh 12 turn duration. This results in a Damage over time type strategy, where applying this state, and keeping it on the target becomes a very high source of damage.

 

If you don’t want this to happen in your project, you can add the line <Reapply Ignore Turns>, which will causes a skill that re-applies this state to have no effect on it. This would prevent the damage stacking of the above tip.

 

That’s all for this update folks.

 

~Ramza

Lightning Shield

This week I’m going with another added effect state. Lightning shield is an active buff state that causes the affected battler to discharge lightning to all enemies when hit by a physical attack.

This state paste code will make use of our new plugin that I just released earlier today, which will make the copy + paste code for it much simpler to use and read. The plugin handles the calculations of the waiting and does the damage popups automatically based on the animation Id used.

So lets just jump into it.

What you need:

Our first state is the shield state. This is the state that is applied to the target when the lightning shield spell is cast on them. It has a turn duration, and some info in the note box.

lightningshieldstate

Here is the copy-paste code for this state:

<Custom React Effect>
if (this.isHpEffect() && this.isPhysical() && !target.isStateAffected(27)){
 user.addState(27)
 target.startAnimation(77, false, 0)
 for (i = 0; i < $gameTroop.members().length; i++){
  if (!$gameTroop.members()[i].isDead()){
   $gameTroop.members()[i].shddmg = origin.mat * 2
   target.addState(27)
   performStateAnimationDmg2(76, $gameTroop.members()[i], (Math.floor(($gameTroop.members()[i].shddmg) * ((Math.random()*40)+80)/100)), 4);
   $gameTroop.members()[i].shddmg = undefined
  }
 }
}
</Custom React Effect>
<Custom Deselect Effect>
target.removeState(27)
</Custom Deselect Effect>

StateId 27 is used as a fail safe to make sure that a lightning shield doesn’t trigger multiple times on the same action. Without it being applied and checked for, an attack that hit’s three times would trigger the shield three times as well.

The results?:

Have a look for yourself.

Added Effect Plugin

As I said when I first created this blog a little over two months ago, occasionally I will release plugins here as well as state codes.

With this weeks state, I have made the paste code simpler by including a function that performs the state animations, and calculates the amount of time waited before the damage popup automatically. It contains a couple of different versions of the same thing, which react differently when multiple animations are played, or when there are multiple targets of a state animation.

The idea of this plugin is simply to make the paste codes easier to read. It adds the following functions to the game engine, and can either be loaded as it’s own plugin, or have the code below pasted into a .js file of your own to add the functions to the game.

performStateAnimationDmg(animationId, target, damage, ele)

  • Takes the animation number provided and calculates the number of wait frame for the animation.
  • Shows the damage popup for damage, and does the elemental resistance calculation for the element on the target.
  • causes the enemy to do it’s flinch/damage pose after being hit
  • checks after damage if the target is dead, and performs collapse if so
  • checks after collapse if the enemy was the last one, and then ends the battle if true
  • if not, waits a short period and makes the target move back to position after flinching
  • Waits an extra 30 frames after the animation before the battle system continues

performStateAnimationDmg2(animationId, target, damage, ele)

  • Useful for state animations that affect multiple targets at the same time
  • Does the same thing as listed above with the following difference:
    • The waiting 30 extra frames at the end doesn’t happen, as it stacks in an aoe situation where the same animation is played on several battlers simultaneously, causing a huge wait after damage is dealt where the engine appears to hang.

performStateAnimationDmg3(animationId, target, damage, ele)

  • This version is the same as the first function, but doesn’t cause the flinching on the target, which is useful for states that do not cause damage, but still have a state animation, or for states that heal an ally using the same function, which should cause flinching.

All of this information is also in the help description of the javascript file. Please note that with the release of this plugin I will no longer be manually showing the settimeout functions used to delay the damage popup in any new added effect states, they will all make use of this plugin from today forward.

This plugin can be found here. Make sure that the filename does not change.