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.

Overload

For this week’s state, I’m providing a much more basic ability than usual. Overload, when active,  causes skills that belong to a certain skilltype to deal 1.8 times normal damage. It also causes those same skills to deal 15% of the dealt damage back to the caster. As a passive ability, it can cause a mage-type character to turn into a true glass cannon, and as a toggleable ability, gives the player an extra strategic choice, in deciding if dealing that massive damage is worth healing the actor later (or possible).

What do we need?

  • The usual plugins
  • A way to have this state applied
  • The state.

Our paste code is quite simple. For this example, I have created the state as a passive, in that anyone who will make use of it will do so passively. In my project this is to allow players to ‘equip’ passive skills to the actors, to further customize them.

<Custom Confirm Effect>
if (this.isMagical() && this._item.isSkill() && $dataSkills[this._item._itemId].stypeId == 12 && value !== 0) {
value = Math.ceil(value * 1.8)
user.gainHp(-Math.floor(Math.abs(value * 0.15)))
}
</Custom Confirm Effect>

Our If condition is checking for the following:

  • Was this a magical skill
  • Was this a skill
  • Does the skill belong to sType 12?
  • Did the skill deal more than 0 damage?

These checks can be further modified to your liking, of course. When all checks are passed, damage is multiplied by 1.8, and 15% of that is dealt to the caster.

 

That’s all for now.

Enflame

This week I am showcasing a special type of states, the added effect. These states are special in that they cause an effect to happen after another action has taken place. The state this week is enflame, a single target buff spell that causes extra fire damage on a foe after being attacked.

This state is surprisingly technical, and I’ve already found a non-yanfly plugin that broke compatibility with it (an outdated plugin that I’m still using in my project), so it’s possible it might not entirely work for you. Let me know if there are any issues on your end.

How Does it Work?

This particular skill can be cast by one actor to affect another actor. When the affected actor makes a physical attack, the conditions for this state become true, and some extra fire elemental damage is dealt to the target. This has a separate animation, and a separate damage popup.

What you Need:

  • The usual plugins
  • A skill to apply the state
  • One state

Bonus:

I will include a more in depth explanation of the spaghetti code I’ve used and what each part of it does, to facilitate more easily using it for your own states.

The skill:

For this effect, I have a single target buff spell that can be used on the caster’s allies. It doesn’t really have anything special in it, aside from giving the state to the ally.

enflameskill

Next we need to make our state.

enflamestate

This state expires after a number of turns, like a lot of my states. Otherwise, the state itself does basically nothing. All of the effect is held in the note tags below:

<Custom Apply Effect>
target.enflameDmg = (origin.mat * 4)
// The above line sets the damage of the added effect
// origin is the caster of the spell, in this way the spell can have its 
// damage be based on the casting stats of the actor who applied it
if (target._name == origin._name){
 target._stateTurns[209] = target._stateTurns[209] + 1
// For this skill, I have made it so that if the caster uses it on himself
// its duration increases by one turn.
// In the CTB battle system, the actor's turn ends as soon as his action is
// over, causing the effect to last one less action than if he'd put it on 
// someone else
}
</Custom Apply Effect>
<Custom Conclude Effect>
if (target.result().isHit() && this.isHpEffect() && this.isPhysical() && target.hp > 0) {
 user.enfOn = true
 user.enfTarget = target
// This if statement is checking to see if the requirements for enflame have 
// been met. Because we can't interrupt the action just yet, this local variable
// is set on the user to denote that the effect will be triggered.
// This also doubles in preventing the effect from happening multiple times on 
// multi-hit skills
}else if (user.enfOn != true){
 user.enfOn = false
 user.enfTarget = null
// This else statement is preventing the added effect from not being applied, 
// if multiple actions had been taken, but the last one didn't meet the requirements
// eg. if a three hit attack had the third hit miss.
}
</Custom Conclude Effect>
<Custom Action End Effect>
if (user.enfOn == true && !user.enfTarget.isDead()) {
// If the effect was triggered, and the intended target isn't dead
  var extraFramesToWaitFor = 15;
  var animFrames = ($dataAnimations[178].frames.length * 4) + 1 + extraFramesToWaitFor;
  var waitSeconds = (animFrames/60) * 1000;
// These variables set up our wait time, which allows the animation to play before
//  the damage popup shows up.
  target.startAnimation(178, false, 0);
//Show the battle animation Id 178
  setTimeout(function () {
// everything below this line happens on a delay equal to waitSeconds above
    var total = Math.floor(user.enflameDmg * user.enftarget.elementRate(2))
// the above line adjusts the damage for elemental resistances
    user.enftarget.gainHp(-total); // deal damage
    user.enftarget.startDamagePopup(); // show the damage being dealt
    user.enftarget.performDamage(); // makes the affected battler do its damage pose
    if (user.enftarget.isDead()) {
        user.enftarget.performCollapse(); // kill the battler if it is now dead
    }
    BattleManager.checkBattleEnd(); // end the fight if this was the last unit alive
       setTimeout(function () {
// this second timeout waits 3 seconds after the damage popup and moves the 
// affected battler back into position after having been hit
        target.performActionEnd()
    }, 180);
  }, waitSeconds);
  BattleManager._logWindow._waitCount += (animFrames + 30);
// the above line makes the entire battle system wait for the specified time
// in this case, we add 30 frames to it, to ensure an enemy doesn't take an action
// while the damage popup is still on screen
  user.enfOn = false
// after the effect is complete, turn the local variable off, so it won't 
// trigger again on the same action.
}
</Custom Action End Effect>

Also, here is an action sequence for the skill, as mine is fancy and I don’t mind sharing it 🙂

<setup action>
camera clamp on
display action
immortal: targets, true
perform start
zoom: 300%
camera focus: user
wait for zoom
motion chant: user
cast animation
wait for animation
</setup action>
<target action>
motion spell: user
camera focus: target
zoom: 250%
wait for camera
motion attack: target
action animation: target
wait for animation
action effect: target
</target action>
<finish action>
perform finish
clear battle log
immortal: targets, false
reset camera
reset zoom
wait for camera
camera clamp on
</finish action>

How it looks:

See for yourself

That’s all for this update.

~Ramza

Edit: October 16, 2016 I have changed the paste code to correct an incorrect target issue, that would cause enflame to always deal damage to the battler who was using it, rather than the target of their attacks. If you were having this issue, please re-copy the code now. Thanks.

Second Chance

My apologies for posting this late, I lost track of what day it was, and had to work, so I didn’t have time to post this until now.

This week’s state is a little favorite of mine, Second Chance, which allows a fallen actor to be resurrected at 50% HP, but only once per battle. This effect will trigger even if the actor who is affected by it is the only actor left alive in the battle, no instant game overs here.

What do we need?

  • The usual plugins
  • The action sequence plugins
  • YEP_X_StateCategories
  • Two passive states, one for the effect and one for the cooldown
  • A skill that will be used on the affected actor when he dies.
  • An animation for the skill to use

We also need to modify your death state to accommodate the second chance ability. You will need a way to apply the passive state to the affected actor as well. You could alternatively not use a passive state, and instead make this effect an active buff with a turn duration.

First, let’s change our death state. We will need to add the following notetags to the death state to make it check for the presence of the second chance state:

<Custom Apply Effect>
if (target.isStateAffected(186)) {
BattleManager.queueForceAction(target, 210, 0);
}
</Custom Apply Effect>

The actor is checked for state 186 when he dies, if found, an action is forced to use skill 210 on that same actor. Skill 210 will be our second chance effect.

resurrectionNote that this skill needs to have its scope set to affect a dead ally, otherwise it will have no effect on the actor. The effects of this skill remove the death trait, and restore a flat 50% HP to the affected actor, as well as add our second state. Here is the action sequence code for this skill:

<setup action>
camera clamp on
display action
zoom: 300%
camera focus: user
wait for zoom
</setup action>
<target action>
camera focus: user
zoom: 250%
wait for camera
action animation: user
animation wait: 20
motion dying: user
wait for animation
action effect: target
motion standby: user
wait: 20
motion spell: user
wait: 25
</target action>
<finish action>
perform finish
clear battle log
reset camera
reset zoom
wait for camera
camera clamp on
</finish action>

Next we will cover the two states we need. The first is the enabler state, which causes the affected actor to resurrect after being afflicted with the death state. There is nothing too special on this state, only the following note tags:

<Category: Bypass Death Removal>
<Custom Passive Condition>
if (user.isStateAffected(187)) {
condition = false;
} else {
condition = true;
}
</Custom Passive Condition>

The above code prevents this passive state from becoming active if state 187 is detected. State 187 is the cooldown state, applied when the resurrection happens to the battler. This prevents the effect from happening more than once during a battle. The bypass death removal tag makes it so that this state is not removed upon death, without this tag, or some other way to make states remain on a battle even through death, the state has no effect.

The second state is the cooldown state, which is applied after an actor is resurrected. This state needs to be removed at battle end, but you could also modify it to last a number of turns as well, if you’d like your auto-resurrection to happen more than once. Without this cooldown state, the effect will happen every time the actor dies, making him functionally immortal. The only note tag for this state is below:

<Category: Bypass Death Removal>

This prevents the state from being removed if the actor dies, which prevents the auto-resurrection from happening every time the actor dies as well.

As said above, this works best as a passive ability, but can be easily modified to be a temporary buff spell as well. That’s all for this update, thanks.

 

~Ramza

 

Overcharge

This week’s state is a lot more simple. Overcharge is a special ability of the wizard class in my project, which allows them to cast a magic spell that deals twice as much damage as normal, while costing double the normal MP cost. This effect is instant cast, and only lasts for the following turn, and also makes use of a skill cooldown to prevent abuse.

Naturally, for the instant cast and cooldown, you will need the YEP Instant Cast and YEP Skill Cooldown plugins.

For this effect, we need a state, and a skill. The skill is used to apply the state to the caster.

overchargeskill

To complete the skill, we also need the following note tags in the note box.

<Instant Cast>
<Cooldown: 2>

Next we need the stateoverchargedstateThe state itself doesn’t really do anything, aside from expire after 1 turn. To get the desired effect, we need to add a few things to affected skills.

First, in order to double the MP cost of an overcharged skill, we need to add the following note tag to ANY skill that will be affected by Overcharged:

<Custom MP Cost>
cost = cost * (1+ user.isStateAffected(43))
</Custom MP Cost>

Note that StateId 43 is our overcharged state. What this does is double the cost of the spell, but only if Overcharged is active.

Next, the easiest way to double the damage of the affected skill is to change its damage formula. We need to add the following bit to the end of the damage formula for our spell.

* (1 + a.isStateAffected(43));

This will double the damage of the skill, only if the user is affected by the overcharged state.

If your damage formula looked like this before:

a.atk * 4 - b.def * 2

It should look like this after:

(a.atk * 4 - b.def * 2) * (1 + a.isStateAffected(43));

Because the state expires after one turn, generally the actor will only be able to use it once before it expires. This will not be the case when using instant cast skills, so keep that in mind when you’re balancing your battles around this mechanic.

 

That’s all for this update, folks.

 

~Ramza

Hurricane

Today’s state is also a bit on the simple side, but it opens the developer up to all kinds of extra things. I present to you Hurricane.

What does it do?

When this state is active, all enemies take damage at the end of the caster’s turn. While this example state is designed to only be usable by an actor, so it will only deal damage to enemies, it is possible to modify it quite easily to make enemies capable of using it as well. The state is applied to the caster, by using a skill. At the end of each of the caster’s turns (including the one he used to apply the state), a storm causes damage to all enemies. I also included an extra effect, that with a 60% chance, a bolt of lightning will also strike a random alive enemy after the wind effect.

What do I need?

For this effect, we only need a couple of animations, a skill, and the usual plugins. The meat of what we’re doing is on the custom state, with the actual skill being just a vessel being used to apply the state to the caster.

Hurricane skillAbove, you can see our skill. It is important that it targets the user, and doesn’t do damage itself. Our action sequence is a little different:

 

<setup action>
eval: user.turns = 0
//This eval is used later to insure the hurricane effect only goes off once per turn
display action
camera focus: user
zoom: 250%, 30
wait: 30
motion chant: user
cast animation: user
animation wait: 12
motion spell: user
wait: 15
</setup action>
<Target Action>
clear battle log
eval: SceneManager._scene._logWindow._lines.push('A storm is brewing...' + '<CENTER>');
eval: SceneManager._scene._logWindow.refresh();
//These two eval codes cause the battle log to show text for the skill.
wait: 60
motion item: user
action effect: user
wait: 60
reset zoom
wait: 30
</Target Action>
<Finish Action>
reset camera
reset zoom
clear battle log
</Finish Action>

The skill itself doesn’t use an animation, and the sequence is brief, showing only some text and slight motion to the character using it.

Next we have our state. This is applied to the actor who casts the above skill on himself. This state is removed after combat, but I did not include a ‘remove after x turns’. This was because I didn’t want the turn counter to show on the state, so the user didn’t know how many turns it would last. The code allows between 4 and 6 turns of storming before being removed. Hurricanestate

And here is the copy paste code for this state:

 

<Custom Apply Effect>
target.hurricaneDmg = 200 + (target.mat * 4)
//The base damage for the effect
target.hurricaneTurns = Math.floor((Math.random() * 4) +3)
//The length of time the effect will last
</Custom Apply Effect>
<Custom Turn Start Effect>
user.turns = 0
//We're using user.turns to make sure the hurricane effect doesn't happen more than once per turn
//This is in case some sort of effect gives him two actions in a turn
</Custom Turn Start Effect>
<Custom Turn End Effect>
if (user.turns == 0) {
 var extraFramesToWaitFor = 15;
 var ele = 7 //The element for the wind effect
 var animFrames = ($dataAnimations[94].frames.length * 4) + 1 + extraFramesToWaitFor;
 var waitSeconds = (animFrames/60) * 1000;
 $gameScreen.startTint([-120,-120,-120,60], 20);
 $gameTroop.members()[0].startAnimation(94, false, 0);
 if ((Math.random()*100) > 60){
  var strike = true
//A strike has happened
  var extra = 120
//This extra value is used to add to the end of the timeout to make the damage show properly
 }else{
//No strike has occurred.
  var strike = false
  var extra = 0
 }
 //The setTimeout function below is used to make the damage popup after the animation finishes
 //This makes the code look confusing, but should be fine as long as you copy-paste it
 setTimeout(function () {
 for (i = 0; i < $gameTroop.members().length; i++) {
 //This for loop is finding valid enemy targets for the hurricane damage
  if (!$gameTroop.members()[i].isDead()){
 //For each alive enemy found, deal hurricane damage.
   var total = Math.floor((user.hurricaneDmg * ((Math.random()*40+80)/100)) * $gameTroop.members()[i].elementRate(ele))
   $gameTroop.members()[i].gainHp(-total);
   $gameTroop.members()[i].startDamagePopup();
   $gameTroop.members()[i].performDamage();
   if ($gameTroop.members()[i].isDead()) {
    $gameTroop.members()[i].performCollapse();
   }
   BattleManager.checkBattleEnd();
   }
  }
 var target = false
if (strike == true) {
 while (target == false) {
  var rnd = Math.floor(Math.random() * $gameTroop.members().length)
  var enemy = $gameTroop.members()
  if (!enemy[rnd].isDead()){
  //find a random alive enemy to hit with lightning
   enemy[rnd].startAnimation(172, false, 0);
   target = true
  }
  if ($gameTroop.isAllDead()) {
   target = true
  }
 }
 setTimeout(function () {
  if (!enemy[rnd].isDead()){
  //Deal damage to enemy struck by lightning
   var total2 = Math.floor((user.hurricaneDmg * ((Math.random()*40+80)/100)) * enemy[rnd].elementRate(4))
   enemy[rnd].gainHp(-total2);
   enemy[rnd].startDamagePopup();
   enemy[rnd].performDamage();
   if (enemy[rnd].isDead()) {
    enemy[rnd].performCollapse();
   }
   BattleManager.checkBattleEnd();
  }
  $gameScreen.startTint([0,0,0,0], 30);
  setTimeout(function () {
   for (i = 0; i < $gameTroop.members().length; i++){
    $gameTroop.members()[i].performActionEnd()
   }
  }, 180);
 }, 1200);
}
if (!strike){
 $gameScreen.startTint([0,0,0,0], 30);
 setTimeout(function () {
 for (i = 0; i < $gameTroop.members().length; i++){
  $gameTroop.members()[i].performActionEnd()
 }
 }, 180);
}
}, waitSeconds);
BattleManager._logWindow._waitCount += (animFrames + extra + 30);
user.turns = 1
//This is used to insure the effect doesn't happen more than once per turn
user.hurricaneTurns = user.hurricaneTurns -1
//lower the turn counter for the state
}
if (user.hurricaneTurns == 0) {
//remove the state if the turn counter is 0
 user.removeState(195)
}
</Custom Turn End Effect>
<Custom Remove Effect>
//If the state is removed at battle-end, remove the turn value
user.hurricaneTurns = undefined
</Custom Remove Effect>

Also, remember that you will need to change the animation numbers and the stateId for this to work in your project.

 

While this effect itself is pretty neat, you can use the framework for this state effect to make states that cause animations before showing the damage. The best part about this implementation is that states made in this way can show a full animation, as if a skill had been used, without forcing an action on the user, which can mess with turn order in a CTB or ATB system.

How does it look?

Check it Out!

That’s all for this update folks.

-Ramza

MP Absorb

This week I have a much more simple state to share, to make up for last week’s being convoluted and confusing. MP Absorb.

What does it do?

MP Absorb is a simple passive ability that is used by wizards in my project. When hit by a single target magical effect, the actor regenerates MP equal to the cost of that attack. This also works with single-target healing spells! As wizards are quite reliant on having lots of MP at all times, this effect is good for helping them maintain a higher amount of MP at all times.

What do I need?

Just the usual plugins. I recommend making this state a passive effect, but even that isn’t necessary.

The Code:

<Custom Respond Effect>
if (this.isHpEffect() && this.isMagical()) {
  var scope = $dataSkills[a._actions[0]._item._itemId].scope
  if (scope != 2 && scope != 8) {
      var cost = $dataSkills[a._actions[0]._item._itemId].mpCost
    if (b.hp != 0){
     b.gainMp(cost)
    }
  }
}
</Custom Respond Effect>

That’s all for this update folks.

~Ramza

Perform

Welcome back. Today I’m going to share a much more advanced state with you all, which requires a lot of description to fully get across what the state is intended to do.

First of all, in order to use this state to its fullest potential, you will need all of the usual plugins, as well as the action sequence plugins, and additionally the Weapon Unleash Plugin. The instant cast plugin is also recommended, though not necessary. I also made use of Yanfly’s Weapon Animation plugin to animate the play skill with a custom weapon graphic.

So first, what is Perform? Perform is an action used by the bard class in my project. When it is the bard’s turn, s/he can choose a song to play from his/her available skills. Choosing the song is an instant cast skill, that replaces the actors attack action with ‘Play’. If the actor doesn’t immediately play the song after choosing it (and does a different action), nothing happens, and the effect is removed. If the actor plays the song after choosing it, the song adds a special buff to all of the actors allies (but not the actor that is performing the skill). On any subsequent turns, an upkeep cost is charged to the bard, if s/he can’t afford this cost, the state is removed, as well as the buff that it gave to the other allies. If the actor continues to play the song on each subsequent action, the buff will remain active, but if they do a different action, the state will run out of turns and remove itself.

As a bonus add-on for this state, I will also include the ‘Lingering Song’ trait, which causes the song state to last one extra turn, allowing the actor to alternate between performing and doing a different action.

What we need for this Effect:

  • A skill for each song.
  • A skill for ‘Playing’ the song.
  • A skill for canceling the song that is being played.
  • A placeholder state for the play skill.
  • A state to change the actor’s weapon graphic to play the song
  • Two states for each song, one for the skill to apply, and one for the effect to each ally.
  • Optional: Yet another state that is provided as a passive effect by an item required to play the song (ex: equipping a harp gives you this state)
  • Bonus an extra state for lingering song effect.

First things first, let’s make our ‘Play’ attack skill.

Play
Play Skill screen

The state that this skill applies is going to be our placeholder state. The action sequence animates the playing of the song. For this sequence, I made a harp weapon sheet, and used a custom state to change the actor’s weapon sprite and motion to match the harp weaponsheet.

<Attack Text: Play>
<Setup Action>
display action
camera focus: user
zoom: 200%, 30
wait: 30
</Setup Action>
<Target Action>
add state 107: user
wait: 10
motion attack: user
ME: Harp1
wait: 15
motion attack: user
wait: 20
motion attack: user
wait: 20
motion attack: user
wait: 30
action effect: user
motion attack: user
wait: 35
remove state 107: user
if user.isStateAffected(168)
 eval: user.addState(168)
end
</Target Action>
<Finish Action>
clear battle log
reset camera
reset zoom
wait: 20
perform finish
</Finish Action>

The action sequence applies state 107, which will be pasted below, whose purpose is to change the weaponsprite and weapon motion of the actor using the skill temporarily to allow the ‘harp’ weapon to be used. After the little animation plays, the state is removed. The sequence then checks for state 168, which is going to be our song state. When it detects state 168, it re-adds the state, which adds one turn to its duration. This is important to the mechanic, as adding a turn to the state is what keeps the song going, and also, the re-application of the song state is what causes the song effect state to trigger.

Here is the paste-code for state 107: Harp Animation (requires weapon animation plugin mentioned above):

<Weapon Image: 30>
<Weapon Motion: missile>

Note that weapon image 30 is the index of my harp weaponsheet, change as needed for your own project.

Weapons3

Note that this harp was pulled from the RMVXAce Iconset, so you legally need to own a copy of RMVXAce to use it.

The placeholder state we add during the Play skill is actually used to apply the lingering song effect, I will cover that in the bonus section below.

Next, we will make our song skill.

ariaofmight

As you can see, this skill applies our ‘song state’. I have a custom show eval in the note tags to make this skill disappear when we are already affected by it, or any other song state (although in this tutorial I’m only sharing the one song). This is an instant cast skill, and the action sequence is basically empty, to ensure the player can quickly select a song without breaking the action too much. The actual song state is what handles most of the work here.

<Custom Show Eval>
if (user.isStateAffected(168)) {
 visible = false;
} else {
 visible = true;
}
</Custom Show Eval>
<Custom Requirement>
if (user.isStateAffected(171)){
 value = true
}else{
 value = false
}
</Custom Requirement>
/* The above custom requirement will prevent the actor from using this
*  skill unless they are affected by state 171. This state is used to
*  prove that the hero is equipped with an instrument. In my project
*  the bard must have a harp equipped to play a song. All harps bestow
*  this state when equipped. You do not need this code for the effect 
*  to work.
*/
<Setup Action>
display action
</Setup Action>
<Target Action>
wait: 10
action effect: user
wait for popups
</Target Action>
<Finish Action>
clear battle log
</Finish Action>

And here is the ‘Use’ state:

ariaofmightstate

It is important that this state end after one turn, otherwise it will not require the actor to immediately ‘play’ to keep the effect going.

<Replace Attack: 192> //This is the skill Id of your play skill made above
<Reapply Add Turns>  //If the affect is re-applied, it's duration increases
<Custom Turn Start Effect>
//This section performs MP upkeep of the song
if (user.mp < 6){
//If the cost cannot be paid, the state is removed
 user.removeState(168)
}else{
 user.gainMp(-6)
}
</Custom Turn Start Effect>
<Custom Apply Effect>
//This checks if the user already had the 'use' effect when it was applied
if (user.isStateAffected(167)){ 
//This is the state Id of the state added by the 'play' skill
//If the state detects it was applied by the play skill, it applies the effect state
 var targ = user.friendsUnit().aliveMembers()
 for (var i = 0; i < targ.length; i++) {
//Since the play skill was used, this adds the effect state to all allies
 user.friendsUnit().aliveMembers()[i].addState(169)
 }
 user.removeState(169)
//It then removes the state from the user, because it doesn't affect them
}
</Custom Apply Effect>
<Custom Remove Effect>
//If the state is removed, it also removes the effect state from all allies
var targ = $gameParty.members()
for (var i = 0; i < targ.length; i++) {
 $gameActors._data[targ[i].actorId()].removeState(169)
}
</Custom Remove Effect>

Next we have the actual state effect. This state is mostly blank, and only contains an attack parameter boost for the target affected. The state doesn’t expire on it’s own, because it is removed when the actor who applied it stops performing.

mightariaeffectstate

It is important that the state is removed at battle end, however, as it might stay up forever if the battle ended while it was active.

Since this is a really confusing state setup, I will do a brief recap before getting to the bonus section.

  • Actor uses our aria of might skill
    • Gains Might Aria use State
    • replaces default attack with ‘play’
  • Actor uses play skill
    • Use state is re-applied, making it last 2 turns instead of one.
    • On re-application Might Aria Effect state is applied to all allies.
    • Actor’s turn ends, reducing the Use state’s duration to 1 turn.
  • If actor chooses not to use Play skill
    • Use state expires naturally, which removes the effect state from all allies.

We also have yet another skill to make. This one stops the current use state from being active, in case the player chose the wrong song, or wanted to cancel the effect prematurely to attack. In my project, because I have the state set up to charge an upkeep cost at the beginning of the actor’s turn, the remove skill also refunds some MP to the user. This skill is only visible if the actor has a songs use state on them.

stopperformskill

Note that the skill simply removes the use state of all songs (I have a few more than might in this screenshot.) The MP recover effect is designed to restore part of the Mp cost of the song. In this example, my custom MP Cost formula is being used. For normal use, you would put a number in the box, like 6 (the cost of Aria of Might).

<EQS Ignore>
<Instant Cast>
<Custom Show Eval>
if (user.isStateAffected(168)) {
 visible = true;
} else {
 visible = false;
}
</Custom Show Eval>
<Setup Action>
display action
</Setup Action>
<Target Action>
wait: 10
action effect: user
wait for popups
</Target Action>
<Finish Action>
clear battle log
</Finish Action>

Bonus:

I promised an extra passive state to increase the duration of the song. We already have the building blocks in place for this state. We’re just going to cause the Use state to be added twice, which will make it last three turns instead of two turns.

First, we’re going to come back to our placeholder state, 167. This state is basically invisible to the player and only lasts one turn. It’s main purpose is for the song use state to check to see if it has been re-applied by the ‘play’ skill, and then add the song effect state to all allies. We’re also going to use it to check for our passive lingering song state, and then re-apply the use state of the song you’re using again. It is applied to the user whenever he uses the ‘Play’ skill.

continueperformstate

<Custom Apply Effect>
if (user.isStateAffected(170) && user.isStateAffected(168)){
// State 170 is our lingering song state
 user.addState(168)
//Re-apply Might Aria Use state if lingering song is detected
}
</Custom Apply Effect>

Because of the way we coded the Might Aria Use state earlier, re-applying it will add another turn to it.

There’s actually nothing special about our lingering song state at all, it’s a passive state, applied by equipment, or as a trait on your actor, or through skill learning if you use that. In this case, I’ve used state 170 for it, but it doesn’t do anything at all on it’s own, and is simply used to determine whether or not to re-apply a song use state a second time or not.

So, in conclusion:

  • Actor picks Might Aria from Skill menu
    • Immediately given one stack of the use song state.
    • Attack becomes ‘Play’
    • Instant cast – actor gets another turn immediately after
    • The song is hidden from the skill menu, preventing the actor from using it multiple times in the same turn
    • The stop performance skill becomes visible in the skill menu, allowing the actor to stop the song and choose another skill, or attack.
  • Actor uses ‘Play’ Skill.
    • Actor has the might aria use state re-applied, increasing duration to 2 turns
      • if actor has lingering song, it is re-applied again, for three turns total
    • When the second stack is applied the Might Aria Effect state is given to all allies
    • The effect state is then removed from the bard, as he cannot be affected by his own song
  • If the Use state runs out of duration, the effect state is removed from everyone
  • Lingering Song allows an extra turn, which lets the actor alternate between using Play and using a different skill
  • The stop performance skill can be used when a performance is happening to cancel it, and refund some or all of the MP cost of the song, allowing the actor access to his attack skill again

But how does it look?

See for yourself