Passive BATTLE-ONLY States

Hello, everyone.


I had a question regarding making a weapon that has a passive HP degeneration percentage, but only inside of battle.


By default, if I give the weapon a passive -3% HP Regeneration, it affects the wielder both in and outside of battle (not what I want).


Using the YEP AutoPassiveStates plugin, if I add a passive state with -3% HP Regeneration and check the "Remove at Battle End" option, is still affects the wielder outside of battle, too.


Is there a way that someone knows of to make a state like that only affect a character inside battle?


Thanks in advance for your help!
It's the third one on the list:
There is a workaround using Yanfly's Buffs & States Core.


Use this snippet in your state's notebox (and don't forget to remove the -3% HP regeneration from the traits list or it will be applied twice)


<Custom Regenerate Effect>
// Only go on if the party is in battle
if ($gameParty.inBattle()) {
// The value to regenerate
value = -(user.mhp * 0.03)
// Heal/Damage user
user.gainHp(Math.floor(value));
};
</Custom Regenerate Effect>


Your state will still be "active" outside of battle but its effects will only work in battle.


In Line 5 you can change the heal/damage value to your liking - "user.mhp * 0.03" equals 3% of the user's MaxHP.
A non-scripting solution would be to have an event run on Turn 0 of each battle to see if each actor has that weapon equipped and apply the degen state to that actor if they do.  Then you can simply check the "Remove at Battle End" property for the state, and it will work perfectly.


The scripting solutions require much less work on your part, though, so use them as long as they're compatible with your project.
It's the third one on the list:

That solved it! Thank you very much!

Original thread: https://forums.rpgmakerweb.com/threads/passive-battle-only-states.63450/