I was wondering if there was a way to stop a battle and teleport to another place once a character has healed themselves a certain number of times. As part of a quest during a battle I wanted it so that when the player heals themselves 10 times, the battle is ended (even if the enemy is alive) and teleported elsewhere. So far I've had no luck, if it's not possible to do this can this be done using skills instead where if a certain skills is used 10 times they teleport?
Stop a battle when a spell is used X amount of times
RPG Maker MZ Supportyes, it can be done
the easiest way would be to attach a common event to the heal skill, and have that common event count its uses as well as abort battle when the trheshold is reached.
the problem with that is that if you only want it for a specific quest, the skill would call the common event every time.
so having a javascript command in the healing formula that counts up a variable, and check that number in a troop event will also work - but that troop event needs to be in every battle where the quest can happen.
there are a few other options as well, but those two are the basics of what is used most often
the easiest way would be to attach a common event to the heal skill, and have that common event count its uses as well as abort battle when the trheshold is reached.
the problem with that is that if you only want it for a specific quest, the skill would call the common event every time.
so having a javascript command in the healing formula that counts up a variable, and check that number in a troop event will also work - but that troop event needs to be in every battle where the quest can happen.
there are a few other options as well, but those two are the basics of what is used most often
I did like a condition where whenever the player has HP regeneration a variable increases, then when the variable equals 10 the player is transported. This didn't work however, I tried changing different the span and condition type but to no avail.
It's not really possible for us to tell you what you did wrong without seeing. But if you post screenshots of the troop event/skill/whatever, we can see what there is.
I would do this how Andar said originally -
- At the beginning of the game, choose a game variable and set it to 0.
- Put a common event on your heal skill. Inside that common event, add 1 to the game variable, then check if it's equal to 10 and turn on a switch.
- Make a troop event triggered by that switch that ends the battle.
I would do this how Andar said originally -
- At the beginning of the game, choose a game variable and set it to 0.
- Put a common event on your heal skill. Inside that common event, add 1 to the game variable, then check if it's equal to 10 and turn on a switch.
- Make a troop event triggered by that switch that ends the battle.
I probably should have done that originally, here is what I tried.
1) transfer might not work on battlescreen, you should abort the battle before transferring
2) you're checking if the player has a state applied. This is something different than the skill use, and it might mean that the state is simply not applied to whatever reason.
If that is the case, please provide screenshots of both the state and the skill that applies it.
2) you're checking if the player has a state applied. This is something different than the skill use, and it might mean that the state is simply not applied to whatever reason.
If that is the case, please provide screenshots of both the state and the skill that applies it.
The state was HP regeneration, whereas the skill applies recovery so I'm assuming why that's why it's not working. There's an If Skill command but that's for if a character learns a skill, not uses one.
Also how do I abort a battle?
So I am very new as well, but I have been having fun trying to figure this out. I think I have this working the way you wanted and I think I am doing what @Andar and @ATT_Turan are suggesting, but I could be wrong. Anyway, here are my screenshots. I show my Heal I skill that calls the Common Event (you would have to all all Healing skills call the CE), I have the Troop event where page 1 turns on a Switch and page 2 does the Abort Battle (sorry that the screenshots are out of order), I have the Map Event Enemy that is the Unique Boss with 3 pages (with the map event doing the transfer), and I have the Common Event.
I used a variable to track the number of times Heal I is used (I set the Abort Battle to 2 uses for quick testing). And I used Text Boxes to show the value of the variable (just for testing purposes so I would know it was doing what I wanted it to do so those Text Boxes would be removed). This helped me trouble shoot some things that didn't work correctly. I also tested to make sure this Common Event doesn't really do anything when you fight a different enemy troop.
Anyway, there is probably an easier way to do this, but I think this works consistently so I learned something. I hope this helps. If not, just disregard.
Thanks, this was fun!







I used a variable to track the number of times Heal I is used (I set the Abort Battle to 2 uses for quick testing). And I used Text Boxes to show the value of the variable (just for testing purposes so I would know it was doing what I wanted it to do so those Text Boxes would be removed). This helped me trouble shoot some things that didn't work correctly. I also tested to make sure this Common Event doesn't really do anything when you fight a different enemy troop.
Anyway, there is probably an easier way to do this, but I think this works consistently so I learned something. I hope this helps. If not, just disregard.
Thanks, this was fun!







1) you cannot check directly if a skill was used, that is why we told you to increase the variable in a common event.
2) with the event command called "abort battle", how else?
I strongly suggest you at least read through the event window what commands exist if you haven't done so yet.
2) with the event command called "abort battle", how else?
I strongly suggest you at least read through the event window what commands exist if you haven't done so yet.
Sorry, I didn't look properly, kept looking in the wrong places.
Thanks for the help, I'll give it a go 🙂
It's close. The reason I suggested turning on a switch is because a switch can be a condition for troop events. You do turn on a Heal switch when it gets to the number you want, but then you don't do anything with it...
I'd make Heal ON be the condition for the troop event, and then it will happen immediately after the user casts the spell the last time, rather than playing out the rest of the battle turn and then doing it divorced from the actual skill use.
(I'm also not certain of the reasoning behind the turn 0 troop event rather than just turning on the boss switch from the starting map event, since that's how you're launching the fight...but that doesn't make much difference)
Thanks for that explanation! I do use the Heal Switch, but only to advance the Map Event enemy to Page 2 so I can Transfer the player from that Map Event. I tried transferring the player from the battle event pages, but that didn't work.
I also tried a variety of things while I was trying to make this work so I could also have left over stuff that isn't necessary.
i used the Turn 0 troop first page to turn the Boss Switch on immediately because the Common Event will be called in any battle that Heal I is used and I wanted a way to make it so the variable didn’t change unless you were in a specific battle. I tried a few different things but it didn’t work exactly right until I did that.
Thanks again!
Original thread: https://forums.rpgmakerweb.com/threads/stop-a-battle-when-a-spell-is-used-x-amount-of-times.146517/