Item that heals HP and causes Sleep

I made a berry that causes the Sleep Status effect but also heals HP. You can use it during battle or outside.

But if you use them twice the game breaks

Any idea around this?
What does the console say?

Maybe the engine assigns a variable to the sleep status and subtracts 1 from the variable when it's activated. And then the engine reads "if (variable) = -1 then "player status=sleep". But when it's subtracted again the engine doesn't know what you mean by -2.

Aside from that, copy your project, turn all the plugins off in that copy and see if it still happens. If not it's isolation time.
I have no plugins. So there should be no isolation time lol

If you use the item twice it breaks the game
then please give us a screenshot of the item (and state or common event or howevery you did the sleep) so we can see what you have done here.
And give a better error description than "breaks the game" - what exactl< happens if you use it twice? Is the actor now extremely powerfull or how is the game broken after that?

Our crystal balls are currently out of order, we can neither read your mind nor see what is on your computer's screen...
Does it only "break the game" if you use it twice when in battle? Or when out of battle? Or both? Is it when used twice in the same battle, or even if you use it once in one battle then again in another?

Ditto - what does "break the game" actually mean - do you get an error? If so, what's in the console when you get the error?
As far as I know, it was only twice outside of battle. I changed it to decrease HP instead. Thanks anyway. ^^;
I just recreated your berry and started using it in the menu on my party members, and while at first it simply wouldn't let me use it again, a bug then occurred:



Was this the same bug? Or a completely different one? Just trying to shed some light on this in case someone else encounters the same problem!
This had me curious, so I tried making my own "Evberry" just for fun. Turns out the problem happens when everyone is asleep or otherwise incapacitated. Here's what I came up with:

Spoiler
Tt4SFFX.png
  • Image 1: I can use it freely on anyone as long as at least one party member is awake (In this case, "Thunder") Note that the amount this item heals really doesn't matter, whether it be 100% or 1.
  • Image 2: Now that Thunder is asleep, if I try to use it on anyone else again, even if their HP is all full...
  • Image 3: Game explodes because nobody is awake/alive/available to "use" the item.
So basically, I'd consider the following options:
  1. Make the item only usable in battle.
  2. Remove the sleep component from the Effects box and instead, add this to the formula box:
Code:
if ($gameParty.inBattle()) b.addState(9); AMOUNT_HEALED_HERE

Of course, replacing AMOUNT_HEALED_HERE with however much your thing is supposed to restore, and replace the "9" in addState with whatever id corresponds to your sleep state. This will cause it to NOT sleep targets outside of battle, which honestly should be fine.

PS: If you're also using the Effects box to apply healing, remove that as well and instead use the formula box. (Necessary because we're also using the formula box to conditionally apply the state only when in combat.
Ahh, that makes sense! Thanks for getting to the bottom of this!

Original thread: https://forums.rpgmakerweb.com/threads/item-that-heals-hp-and-causes-sleep.113213/