Setting states on enemies

Is there any way to set a state on an enemy based on it's hp.
  • I want the state to only apply when the enemy is within a range of HP eg. 75% to 50%.
  • It could shift in and out of this state through out the battle related to healing.
I have tried to use VisuStella but I don't really know how to use any of it as the only example refers to a states being applied to party members.
http://www.yanfly.moe/wiki/Skills_and_States_Core_VisuStella_MZ#Passive_State_Clarification

Is this possible easily with or without this plugin?
Make a passive state with notetag:

<JS Passive Condition>
condition = user.hp > 0.5*user.mhp && user.hp < 0.75*user.mhp;
</JS Passive Condition>

And then give the enemy a passive state note tag for that state.
<Passive State: XXXX>

That should work?
Without plugins, I believe you can do this in troop events. Quickly tested the below example, and [ゾンビ] (zombie) gets [HP再生] (HP regen) whenever it drops below 50 HP, and loses it after he recovers to above 50 HP.

1689155870179.png
Thanks for sharing, I tried that just now with a passive state:


<JS Passive Condition>

condition = user.hp > 0.5*user.mhp && user.hp < 0.75*user.mhp;

</JS Passive Condition>

1689158369462.png


And I gave the enemy the note below (also using an image control plugin, that's what the 'weak' text is for). Didn't work for me though unfortunately.

1689158473438.png

Make a passive state with notetag:

<JS Passive Condition>
condition = user.hp > 0.5*user.mhp && user.hp < 0.75*user.mhp;
</JS Passive Condition>

And then give the enemy a passive state note tag for that state.
<Passive State: XXXX>

That should work?
Without plugins, I believe you can do this in troop events. Quickly tested the below example, and [ゾンビ] (zombie) gets [HP再生] (HP regen) whenever it drops below 50 HP, and loses it after he recovers to above 50 HP.

View attachment 269139
Thanks for the suggestion.

I've tried this and it works ok, it's just that I really want it to be immediately responsive. That way if an enemy takes damage and gets healed, or takes damage enough to push it through multiple thresholds it can gain the benefit of the state before it may be hit with another attack etc.

Not sure if it's possible in a troop event, but I've only had MZ for 2 days so I'm no expert clearly.
Heya,

One thing I can see is that you have a leading 0 in your passive tag on the enemy. That'll often mess things up in a large amount of cases, so to be safe, make it <Passive State: 101> and see if that solves things!
Heya,

One thing I can see is that you have a leading 0 in your passive tag on the enemy. That'll often mess things up in a large amount of cases, so to be safe, make it <Passive State: 101> and see if that solves things!
Thanks for thinking of that, I didn't realise that could be an issue. Unfortunately it didn't seem to work still.
Try putting a space in the passive state notetag, between the colon and your state number.
Thanks for thinking of that, I didn't realise that could be an issue. Unfortunately it didn't seem to work still.
Does a different approach for checking the HP within the conditions work?

Say, if we used [this post for reference], since I don't want to claim that I knew the code or anything, haha.

Code:
<JS Passive Condition>
 condition = (user.hpRate() <= 0.75 && user.hpRate() >= 0.5);
</JS Passive Condition>

Where it would activate if the HP was lower or equal to 75% and higher or equal to 50%, using hpRate to get the percentage.

That should work based on my quick testing just to make sure I didn't get any syntax wrong, haha. And as rpgLord says, ensure there's a space after the : when adding in the passive state notetag, like my previous example. Hopefully that all helps!
You guys are amazing, by dropping the 0 AND including the space it works like a charm. Thanks so much for this, makes my day!

Original thread: https://forums.rpgmakerweb.com/threads/setting-states-on-enemies.159240/