MV State expires immediately after use

Hello Makers! 🙂

For my game, I created a state that gives complete immunity to physical attacks and skill that grants that state to allies in an area. And here comes the problem. If I set it to last 1 turn, the user loses the state after using the skill. Remove by damage doesn't work since actors don't take any damage. The most ideal situation would be that any physical attack removes the state.

I'm using Yanfly's Engine plugins and there is this plugin: Buffs and States Core. There are a few note tags that I think may help me - like Custom Turn Modifier or Custom Timing Effects, but since my JavaScript knowledge is close to zero, I can't really figure it out. Is there a way to make it work somehow?
Moved to: Plugin Support

I am not sure if your issue is happening because of a plugin, or if you need a plugin to fix it, but since you mentioned a plugin and are asking for help with it, I'll move it there.
@Shaz Sorry for the inconvenience.

I tested the skill with no plugins at all. After using the skill, the state remains until the next action, so that's ok. Then I think the problem comes from the battle system plugin or Battle Engine core?
Hi, I'm new here and with rpgmaker, but will try to help based on the little I've seen of the codebase.
Try dropping this plugin in. It's a sloppy hack, but basically it works by setting the percent chance on Remove By Damage to 0%.

//============================================================================= // RemoveOnHit.js //============================================================================= /*: * @plugindesc Hijacks Remove By Damage status removal to treat 0% chance as automatic * @author frogs * */ function removeStatesByPhysicalHit(target) { target.states().forEach(function (state) { if (state.chanceByDamage === 0) target.removeState(state.id); }); } (function overwriteApply() { Game_Action.prototype.apply = function (target) { var result = target.result(); this.subject().clearResult(); result.clear(); result.used = this.testApply(target); result.missed = result.used && Math.random() >= this.itemHit(target); result.evaded = !result.missed && Math.random() < this.itemEva(target); result.physical = this.isPhysical(); result.drain = this.isDrain(); if (result.isHit()) { if (result.physical) { removeStatesByPhysicalHit(target); } if (this.item().damage.type > 0) { result.critical = Math.random() < this.itemCri(target); var value = this.makeDamageValue(target, result.critical); this.executeDamage(target, value); } this.item().effects.forEach(function (effect) { this.applyItemEffect(target, effect); }, this); this.applyItemUserEffect(target); } }; })();
Here's an actual file
@frogs_r_cool Thank you for your help. I tested it in a few different ways. It is working in a sense that it removes the state, but some other issues appeared like the user not being affected by the skill and actors taking full damage even though they're affected by the state.
It's probably the case that the other plugins you're using are commandeering the same functions. There's probably a way to do it with some scripting but I don't know the API well yet. If you're still searching for a solution tomorrow afternoon I'll help out
yanfly has two similar tips, hope to help you 🙂
Kyrie Eleison
Bubble Wrap
Don't give the state any auto-removal timing. Add a <Custom React Effect> notetag to the state, and in the code for that call target.removeState(stateId).
@41728280 Thank you. That Kyrie Eleison is actually quite fun.

@Trihan That works perfectly. Thanks ^_^
Oooh I've been looking for something like this too, thank you!

Original thread: https://forums.rpgmakerweb.com/threads/state-expires-immediately-after-use.136544/