Creating a conditonal damage formula to inflict a State

So I've been messing around for a while with damage formulas for some skills in my game and wanted to get a little creative with them. Some of them I've had deal massive damage, while lowering the users attack afterwards.

That's all fine and dandy, but what I've been trying to get to work is if an enemy is classified as a "Robot" then a character can use a unique skill to inflict a Paralyze like state on it without damaging it. But of course, I'm trying to get it to work solely on enemies that'd be considered a Robot.

The damage formula I've been using to try and make this possible is as so without quotation marks: "dmg = 0; b.elementRate(10) === 1; b.addState(11)"

For the most part this works... But there's a couple of problems. For starters, the state does get applied to the enemy target but it leaves it in a weird zombie like state where it keeps taking 0 damage overtime like a poison effect yet Paralyzed state has no such thing attached to it. Not only that, but using Yanfly's Visual HP Gauge plugin shows that the enemy HP isn't going down even when I hit it with powerful attacks that go over its max HP.

I'm no expert at making these types of damage formulas and I'm pretty sure there's something super obvious here that I'm missing and I'm just not remembering to put in here. not entirely certain if there's an easier way to accomplish this. :hswt:
Firstly, in your damage formula, why did you write dmg = 0;? Also, didn't understand the line b.elementRate(10) === 1; Maybe you're missing an if statement there. Also, from what I understand, you're trying to classify an enemy as 'Robot' using element rates, which isn't the best way to go about it. States would work much better.

Anyways, there's many ways to do what you're trying to do. Some plugins do make it easier (Like Yanfly's Skill Core and Passive States), but I'll go with the default way where no plugins are necessary.

Firstly, in the notebox of the enemy's you want to be robots, use the notetag:

Code:
<robot>
*This is case sensitive

Then, in the damage formula, input this (assuming no other effects of the skill other than what you described):

Code:
if ($dataEnemies[b.enemyId()].meta.robot) b.addState(11);

Make sure the case of 'robot' in the damage formula is the same as that in the notebox.
Firstly, in your damage formula, why did you write dmg = 0;? Also, didn't understand the line b.elementRate(10) === 1; Maybe you're missing an if statement there. Also, from what I understand, you're trying to classify an enemy as 'Robot' using element rates, which isn't the best way to go about it. States would work much better.

Anyways, there's many ways to do what you're trying to do. Some plugins do make it easier (Like Yanfly's Skill Core and Passive States), but I'll go with the default way where no plugins are necessary.

Firstly, in the notebox of the enemy's you want to be robots, use the notetag:

Code:
<robot>
*This is case sensitive

Then, in the damage formula, input this (assuming no other effects of the skill other than what you described):

Code:
if ($dataEnemies[b.enemyId()].meta.robot) b.addState(11);

Make sure the case of 'robot' in the damage formula is the same as that in the notebox.

Had a feeling I was doing something dumb... :hswt: I'll give that a shot and see how it goes.

Edit: Forgot to mention why I had dmg = 0. I actually used that to ensure the skill was still working instead of outright crashing my game. Though in the end it didn't really matter. XD
So after some testing and what not, the problem still persisted. State was applied, but the enemy was still unkillable. From what I tested, doing so makes events that require an the HP of said enemy to be at 0 gets triggered by this. Gonna keep testing some things and see if I can find a work around. (Or I'll just find another method to do this. lol)
You can do what I did for my game, and use Yanfly's CustomPassiveStates and Buff & States Core. Create a state "Robot", and put <passive state: x> in the notebox of all enemies classified as Robots (where x is the state ID for Robot). Then, in the damage formula of your ability, check for the state using:

if (b.isStateAffected(x)) {b.addState(11); dmg = 0;} else {(a.atk * 2) - b.def; }

This should do what you want
You can do what I did for my game, and use Yanfly's CustomPassiveStates and Buff & States Core. Create a state "Robot", and put <passive state: x> in the notebox of all enemies classified as Robots (where x is the state ID for Robot). Then, in the damage formula of your ability, check for the state using:

if (b.isStateAffected(x)) {b.addState(11); dmg = 0;} else {(a.atk * 2) - b.def; }

This should do what you want

Tried this and it worked perfectly! 😀 Thanks for the help! Now I can stop having a headache over this. XD

Original thread: https://forums.rpgmakerweb.com/threads/creating-a-conditonal-damage-formula-to-inflict-a-state.82080/