A State that Forces an Action

When my Rogue takes damage, I would like him to use his Stealth Skill.

I have tried several different commands, but I do not think I have found the proper ones.

Thank you in advance for any assistance.
I believe the best way to do this would be to use Yanfly's Buffs and States Core, keep a dummy state permanently on the Rogue, and employ a <Custom Respond Effect> tag. This will proc whenever the Rogue takes damage.

There is certainly a way to employ a Force Action command inside this tag but I'm not immediately familiar with the syntax and I'm not entirely sure it would work as another action is being processed (though it very well might!). The other way you could go about it would be to simply play an animation inside this tag as well as perform the effects of the Stealth skill directly. For example, if the Stealth skill was placing the user into a Stealth state, I think the line inside the notetag would be something like self.addState(N); where N is the ID of the Stealth state. I'm a bit rusty on the syntax; Yanfly might use something like "a" or "user" instead of "self", or it might just be a simple addState(N) .
Some examples for what Wavelength suggested...

If you want to simply add a state after getting hit, try this:
JavaScript:
<Custom Respond Effect>
if (value > 0) {  // took damage
  defender.addState(50);  // add state 50
}
</Custom Respond Effect>


If you want to do a force action instead, try something like this instead:
  • With Yanfly's Battle Engine Core:
    JavaScript:
    <Custom Respond Effect>
    if (value > 0) {  // took damage
      var skillId = 50;  // ID of Stealth skill
      var targetIndex = defender.index();  // self index
      BattleManager.queueForceAction(defender, skillId, targetIndex);
    }
    </Custom Respond Effect>
  • Without Yanfly's Battle Engine Core:
    JavaScript:
    <Custom Respond Effect>
    if (value > 0) {  // took damage
      var skillId = 50;  // ID of Stealth skill
      var targetIndex = defender.index();  // self index
      defender.forceAction(skillId, targetIndex);
      BattleManager.forceAction(defender);
    }
    </Custom Respond Effect>
Highly appreciated guys. I would not have thought to use <Custom Respond Effect>

Now knowing what it actually means, I can see so many great abilities out there.

<3
"defender", huh? Looks like I've gotten a bit rusty with those notetags 😀 Very nice work as usual, @caethyril!
You're welcome! 😂

"defender", huh? Looks like I've gotten a bit rusty with those notetags 😀
Just for info, Buffs & States offers multiple variables here: the more usual ones are user (a.k.a. subject) and target. I just prefer attacker and defender because otherwise I'm prone to writing user for the state bearer in situations where they are actually the target. 😴
Just for info, Buffs & States offers multiple variables here: the more usual ones are user (a.k.a. subject) and target. I just prefer attacker and defender because otherwise I'm prone to writing user for the state bearer in situations where they are actually the target. 😴
Ah!! Yes, that makes a lot of sense - our battlers are men (and women) of many names 😀

Original thread: https://forums.rpgmakerweb.com/threads/a-state-that-forces-an-action.130123/