Add State if item is used in Battle

Im trying to create an item that heals for X value,  but if it is used during a battle, on top of the healing it also adds Y state (or more states). 


I had this done in Ace and I`m trying to create this effect on MV but I cant seem to make it work, can anyone help with the formula?


Thanks.
 
cant you just make the item add the state and make the state expire after battle end or 1 step?
I can't see any clean way (not involving a parallel process common event and/or a battle event at turn 0 that turns a switch on) besides javascript, so try this.


SceneManager._scene instanceof Scene_Battle ? b.addstate(stateid); healAmount


SceneManager._scene instanceof Scene_Battle ? a.addState(1); Math.randomInt(8) + 1




This damage formula should do the trick. (Heal amount is to be replaced by your heal formula)


It works as advertised in my blank project 🙂


Happy making!
I can't see any clean way (not involving a parallel process common event and/or a battle event at turn 0 that turns a switch on) besides javascript, so try this.


SceneManager._scene instanceof Scene_Battle ? b.addstate(stateid); healAmount


This damage formula should do the trick. (Heal amount is to be replaced by your heal formula)


It works as advertised in my blank project 🙂


Happy making!



For some reason my formula always returns 0.


SceneManager._scene instanceof Scene_Battle ? b.addstate(32); Math.randomInt(8) + 1


32 = State
I'm at work so this is untested... but try this:


c=Math.randomInt(8) + 1; if ($gameParty.inBattle()) {b.addState(32);c} else {c}
I'm at work so this is untested... but try this:


c=Math.randomInt(8) + 1; if ($gameParty.inBattle()) {b.addState(32);c} else {c}



Yay it's working!


Thanks alot for all the helps.

Original thread: https://forums.rpgmakerweb.com/threads/add-state-if-item-is-used-in-battle.70260/