Need Help Finishing Some States (using Yanfly plugins)

Gray96

Veteran
Veteran
Joined
Jan 4, 2018
Messages
33
Reaction score
5
First Language
English
Primarily Uses
RMMV
Hello everyone. I'm interested in making some states that have on-contact effects. For example, one state I would like to make is a physical taunt effect that has a small chance (15%) to paralyze any foes that make contact with the taunter. I believe I can make this effect with a combinations of Yanfly's taunt plugin, buffs and states core, skill core, and damage core. Here's what I have so far:

<Physical Taunt>

<Custom Respond Effect>
if (this.isPhysical() && this.isHpEffect() && value > 0) {

}
</Custom Respond Effect>

I think the first part is right, I'm just not sure how to add in the possible paralysis chance. Anyone know how to do this?

Bonus: Anyone know how to make a similar effect that deals damage to attackers that make contact? Something similar to the "Iron Barbs" ability from Pokémon.

Thanks in advance!
 

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
444
Reaction score
208
First Language
English
Primarily Uses
RMMV
To add paralysis:

<Custom Respond Effect>
if (this.isPhysical() && this.isHpEffect() && value > 0) {
if (Math.random() < 0.15) {
user.addState(ParaID);
}
}
</Custom Respond Effect>

Math.random returns a number between 0 and 1, so it's ideal for chance checks like this. As for damage effects (actually, if the circumstances are the same, this can be done in the same tag):

<Custom Respond Effect>
if (this.isPhysical() && this.isHpEffect() && value > 0) {
if (Math.random() < 0.15) {
user.addState(ParaID);
}
var dmg = Math.round(value * 0.10);
user.gainHp(-dmg);
user.startDamagePopup();
user.clearResult();
if (user.isDead()) {
user.performCollapse();
}
}
</Custom Respond Effect>
 

Gray96

Veteran
Veteran
Joined
Jan 4, 2018
Messages
33
Reaction score
5
First Language
English
Primarily Uses
RMMV
To add paralysis:

<Custom Respond Effect>
if (this.isPhysical() && this.isHpEffect() && value > 0) {
if (Math.random() < 0.15) {
user.addState(ParaID);
}
}
</Custom Respond Effect>

Math.random returns a number between 0 and 1, so it's ideal for chance checks like this. As for damage effects (actually, if the circumstances are the same, this can be done in the same tag):

<Custom Respond Effect>
if (this.isPhysical() && this.isHpEffect() && value > 0) {
if (Math.random() < 0.15) {
user.addState(ParaID);
}
var dmg = Math.round(value * 0.10);
user.gainHp(-dmg);
user.startDamagePopup();
user.clearResult();
if (user.isDead()) {
user.performCollapse();
}
}
</Custom Respond Effect>
Hello again Shockra! You've solved my problem once again, thanks! Fortunately this one was much easier, heh.
 

Gray96

Veteran
Veteran
Joined
Jan 4, 2018
Messages
33
Reaction score
5
First Language
English
Primarily Uses
RMMV
To add paralysis:

<Custom Respond Effect>
if (this.isPhysical() && this.isHpEffect() && value > 0) {
if (Math.random() < 0.15) {
user.addState(ParaID);
}
}
</Custom Respond Effect>

Math.random returns a number between 0 and 1, so it's ideal for chance checks like this. As for damage effects (actually, if the circumstances are the same, this can be done in the same tag):

<Custom Respond Effect>
if (this.isPhysical() && this.isHpEffect() && value > 0) {
if (Math.random() < 0.15) {
user.addState(ParaID);
}
var dmg = Math.round(value * 0.10);
user.gainHp(-dmg);
user.startDamagePopup();
user.clearResult();
if (user.isDead()) {
user.performCollapse();
}
}
</Custom Respond Effect>
I'm still messing around with these kinds of effects and am currently playing around with the idea of a "fire rune" state. For this effect, the caster places a fire rune on themselves or an ally. The idea is that it explodes (thus removing the state) when an enemy makes physical contact with that ally, dealing damage to and burning the enemy in the process.

I'm able to get the state to remove properly, but my question for this type of effect is with the "var dmg" portion. What code would I need to use for the damage to be calculated based on the original caster of the state's magic attack? I tried var dmg = Math.round(origin.mat);, but that uses the magic attack of the actor that actually has the state on them at the time rather than the original caster's magic attack. Is there a line of code (I'm thinking in the skill's notebox rather than the state's notebox?) that can store the caster's magic attack as a variable to be used when the state is eventually removed? As usual, your input is very much appreciated!
 

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
444
Reaction score
208
First Language
English
Primarily Uses
RMMV
I feel like origin.mat does get the magic attack of the character that applied the state. The magic attack can be applied via a skill, but removing the effect can be tricky afterwards, which can cause issues later on.

Maybe the problem is that the variable needs to be applied as the state is added. It may not recognize the origin at the point of attack. Try adding these tags:

<Custom Apply Effect>
user._firePower = Math.round(origin.mat);
</Custom Apply Effect>

<Custom Remove Effect>
user._firePower = undefined;
</Custom Remove Effect>

And change the respond effect to:

<Custom Respond Effect>
if (this.isPhysical() && this.isHpEffect() && value > 0) {
if (Math.random() < 0.15) {
user.addState(ParaID);
}
if (target._firePower) {
var dmg = target._firePower;
user.gainHp(-dmg);
user.startDamagePopup();
user.clearResult();
if (user.isDead()) {
user.performCollapse();
}
}
}
</Custom Respond Effect>

You obviously have some interesting ideas for techniques. What I did to learn these kinds of tricks was study a bunch of Yanfly's Tips and Tricks videos. If you want to expand your knowledge, that's a good place to go.
 

Gray96

Veteran
Veteran
Joined
Jan 4, 2018
Messages
33
Reaction score
5
First Language
English
Primarily Uses
RMMV
I feel like origin.mat does get the magic attack of the character that applied the state. The magic attack can be applied via a skill, but removing the effect can be tricky afterwards, which can cause issues later on.

Maybe the problem is that the variable needs to be applied as the state is added. It may not recognize the origin at the point of attack. Try adding these tags:

<Custom Apply Effect>
user._firePower = Math.round(origin.mat);
</Custom Apply Effect>

<Custom Remove Effect>
user._firePower = undefined;
</Custom Remove Effect>

And change the respond effect to:

<Custom Respond Effect>
if (this.isPhysical() && this.isHpEffect() && value > 0) {
if (Math.random() < 0.15) {
user.addState(ParaID);
}
if (target._firePower) {
var dmg = target._firePower;
user.gainHp(-dmg);
user.startDamagePopup();
user.clearResult();
if (user.isDead()) {
user.performCollapse();
}
}
}
</Custom Respond Effect>

You obviously have some interesting ideas for techniques. What I did to learn these kinds of tricks was study a bunch of Yanfly's Tips and Tricks videos. If you want to expand your knowledge, that's a good place to go.
Had to make a couple of adjustments but this set me on the right track, and it works now! Here's the notebox that seems to do the trick:

<Custom Apply Effect>
user._firePower = Math.round(origin.mat);
</Custom Apply Effect>

<Custom React Effect>
if (this.isPhysical() && this.isHpEffect()) {
user.addState(12);
target.removeState(59);
}
if (target._firePower) {
var dmg = target._firepower;
user.gainHp(-dmg);
user.startDamagePopup();
user.clearResult();
if (user.isDead()) {
user.performCollapse();
}
}
</Custom React Effect>

Had to remove a bracket at the end, change "Custom Respond Effect" to "Custom React Effect" and take out the "Custom Remove Effect" portion (may need to do more testing to make sure there's no bugs when stuff like magic attack buffs are applied... edit: this seems to be working correctly). For this particular state I also removed the math.random bit, but that was just preference for the effect since it only lasts for 1 physical hit rather than over several turns. In any case, it seems to work for the moment! I'll let you know if any issues come up, but thanks again! I'll try to look more into reading Yanfly's tips and Tricks codes, it is indeed a learning process :)
 
Last edited:

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
444
Reaction score
208
First Language
English
Primarily Uses
RMMV
It may work as you have it, but the big issue is that the _firePower variable is still attached to the character. That needs to be made undefined somehow, or it could cause issues later on somehow. I'm guessing that when the state was removed before, it was disrupting the rest of the effect because _firePower didn't exist anymore, so maybe moving the Remove State line down lower will fix that.

<Custom React Effect>
if (this.isPhysical() && this.isHpEffect() && value > 0) {
user.addState(12);
}
if (target._firePower) {
var dmg = target._firepower;
user.gainHp(-dmg);
user.startDamagePopup();
user.clearResult();
if (user.isDead()) {
user.performCollapse();
}
target.removeState(59);
}
</Custom React Effect>

<Custom Remove Effect>
user._firePower = undefined;
</Custom Remove Effect>

Apply should be fine as is.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top