Editing process_defeat to change game over functions

Hi all,

So right now I've been working with this snippet which is found in BattleManager Line 244:

Code:
  def self.process_defeat
    #$game_message.add(sprintf(Vocab::Defeat, $game_party.name))
    #wait_for_message
    if @can_lose
      revive_battle_members
      replay_bgm_and_bgs
      SceneManager.return
    else
      SceneManager.goto(Scene_Gameover)
    end
    battle_end(2)
    return true
  end

As you can see, I commented out the first two lines to effectively remove the "Your party was defeated" line, which works. The issue is that I'm trying to make it so that @can_lose causes an "Exit Event Processing" command. This is because all of my battles take place inside events, so the first step to incorporating my custom gameover system is by exiting the event commands so that a reserved common event can be called (which transports the player to a "checkpoint" of sorts).

I'm still pretty foggy on how methods function as lists of commands (but unlike events), so I tried adding the following code:

Code:
$game_interpreter.command_115

This calls the method from Game_Interpreter which exits event processing. Doing so, however, gives me an "undefined method 'command_115' for nil:Class" error. I can only guess that's because this method is being called from within battle processing and not event processing, which is a whole can of worms I have no idea how to deal with.

So to summarize, the goal is to create a method that exits the event processing of the event which called the battle. If anyone has any ideas on how to do this, I would be more than grateful!
Of course because there is no such variable as $game_interpreter. The interpreter is located within Game_Map. So what you're suppose to do is $game_map.interpreter instead
Huh. I thought calling $game_x referred to a method from a certain class, which is why I used game_interpreter. And I'm guessing then that game_interpreter comes from this line?

Code:
def initialize
    @screen = Game_Screen.new
    @interpreter = Game_Interpreter.new
    @map_id = 0
    @events = {}
    @display_x = 0
    @display_y = 0
    create_vehicles
    @name_display = true
  end

If that's the case, is there a way to know what classes are called from inside other classes? You don't have to answer because the problem is fixed and using $game_map.interpreter.command_115 works perfectly. I'm just asking out of my own curiosity, I'm obviously still very new at this haha.
Yeah, not all Game_Object class referenced as $game_object variable.
If you're curious on where they're created, you can always search all sections by pressing CTRL + SHIFT + F, then write "Game_Interpreter.new" for example, it will direct you to various locations
Okay, thanks for the help Theo!

Original thread: https://forums.rpgmakerweb.com/threads/editing-process_defeat-to-change-game-over-functions.90705/