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!
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 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.
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.