- Joined
- Jan 28, 2013
- Messages
- 776
- Reaction score
- 487
- First Language
- English
- Primarily Uses
- RMMV
Welcome, one and all. In this topic I will be periodically posting some lunatic state codes I've been working on. Feel free to use them in your own projects, modify them as you see fit, and post suggestions for new states or ideas you might like to see.
The plan will be to release a new state copy paste once per week, which you can also see on my (probably crappy) wordpress blog! In this topic I will also troubleshoot problems you have with lunatic codes I have provided, accept suggestions for new lunatic states you might want created, and troubleshoot possible issues you might have with your own lunatic states, or suggest different ways to achieve the same effect in game.
Most of my state codes will rely on several yanfly plugins as well. Mainly the Core engine, Battle Engine Core, Buffs/States Core, and Autopassive states plugins. Before I post my release for this week, here's a list of some of the custom states I've already made, with a brief description of each. I will eventually release copy paste code for each of them.
And without further delay, here is my first copy paste state - block chance.
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
If you like what I do, check out my blog. Also, if you feel inclined to, feel free to become my patron on *******, or not, that's cool too.
The plan will be to release a new state copy paste once per week, which you can also see on my (probably crappy) wordpress blog! In this topic I will also troubleshoot problems you have with lunatic codes I have provided, accept suggestions for new lunatic states you might want created, and troubleshoot possible issues you might have with your own lunatic states, or suggest different ways to achieve the same effect in game.
Most of my state codes will rely on several yanfly plugins as well. Mainly the Core engine, Battle Engine Core, Buffs/States Core, and Autopassive states plugins. Before I post my release for this week, here's a list of some of the custom states I've already made, with a brief description of each. I will eventually release copy paste code for each of them.
- MP Absorb: – When hit by a single-target damaging or healing spell, the actor (or enemy) with this state will recover MP equal to the cost of the spell used on them.
- Block Chance: – When wearing a shield, the actor (or enemy) that has this state has a % chance to block. The block chance can be further augmented by other states (passives or active states). When a block occurs, an animation is played on the actor, and the damage from that attack is completely negated.
- Enflame: – When affected by this state, the target will cause extra fire damage after any physical action is performed. This damage plays a separate animation, and does a separate damage pop-up from the original action.
- Hurricane: – The caster casts this spell, and then at the end of every one of the casters turns, the hurricane effect happens. A wind animation is played, damaging all enemies, with a chance for one of them to be randomly struck by lightning for extra damage.
- Bleeding: – An effect that applies a bleed will cause damage over time to the target, based on the damage of the effect that caused the bleed. This damage is spread over multiple turns, and will not be overwritten by a similar effect that would cause it to do less damage per turn.
- Second Chance: – When the actor with this state is killed, he is revived instantly with 50% HP. This effect is complete with action sequence and animation. The effect will only happen once per battle.
- Overcharge: – When active, the MP cost of certain spells is doubled, and the damage from those same spells is also doubled.
- Performance: – A bard selects a song from the skills menu, which replaces his ‘attack’ command with ‘Perform’ which plays the selected song. The song gives a passive buff to all other allies in the battle, so long as the bard continues to ‘perform’ on all of his subsequent turns. If he misses a turn, the effect is removed. There is also a small MP cost per turn for upkeep, which will cancel the effect if the actor is out of MP and cannot pay that cost.
And without further delay, here is my first copy paste state - block chance.
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:
The Code
This is the copy-paste text that needs to go in your note box for the block chance state.
Spoiler
<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>
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?
- YEP Core Engine, YEP Battle Engine Core, YEP Buffs States Core, and YEP Auto Passive States
- Equippable shields in game.
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.
Spoiler
<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
If you like what I do, check out my blog. Also, if you feel inclined to, feel free to become my patron on *******, or not, that's cool too.
