Conditional Branch to check whether in battle?

Yeah the title explains it all, but is there a conditoinal branch script call or something to check whether you are in a battle or not? 


-worked around the problem with events & switches : ) Thanks for your help! 
Not that I'm aware of, but I also don't speak Java. What are you trying to do with this branch, exactly? There is might be an eventing workaround that I could attempt to figure out for you if I knew the goal you had in mind. I mean, from the sounds of it, you could just use troop commands (Or Yanfly's Base Troop Commands plugin), but I can't say too much without knowing what you're going for.
Oh, I'm sorry that I wasn't clear XD


Um, I'm making an invisibility item. You can comsume it and you become invisible for 1 minute so the enemies can't see you. I'm using a common event with conditional branches to check the timer and just disable random encounters when you use it and when the timer's up turn them back on. 


However, if you have a battle inside an event and the item wears of you will be aborted from the battle which is very inconvenient for boss fights etc! 


...and I can't find a solution. Yet. 
The common event called by the item should also switch on some switch "invisibility" (if it doesn't do that already) and switch it off when it wears off (when you switch on the encounters again.


In every event, then make a conditional branch checking that switch around the battle processing command - if the player is still invisible when that event is processed, you can do any code around the boss fight neccessary to counter the effect (including ending it before its regular time with a message "the boss dispelled your invisibility" or so).


If that doesn't work, we need to see how your invisible event is structured to give more detailed help.
I'm not entirerly sure how you want your invisible mechanic to work, but as to answering your question about checking if you are in battle or not. Why not just make the invisible mechanic inside a common event, and then add a switch at the start of every encounter window that will turn on as soon as you enter the battle, then use that switch to fulfill what you want to do with your common event.
The common event called by the item should also switch on some switch "invisibility" (if it doesn't do that already) and switch it off when it wears off (when you switch on the encounters again.


In every event, then make a conditional branch checking that switch around the battle processing command - if the player is still invisible when that event is processed, you can do any code around the boss fight neccessary to counter the effect (including ending it before its regular time with a message "the boss dispelled your invisibility" or so).


If that doesn't work, we need to see how your invisible event is structured to give more detailed help.



Hmm, I hadn't thought of editing the boss event instead of the invisibility event! This works, thank you very much! 


^ and thank you both for helping find the solution! I appreciate it  : ) 
$gameParty.inBattle()


Checks if you are in battle. For future reference, I guess. You'll have to stick it in the conditional script call option.

Original thread: https://forums.rpgmakerweb.com/threads/conditional-branch-to-check-whether-in-battle.61170/