Difficulty finding function and script locations

I am digging into the scripting trying to figure out how the system works and I am having a really hard time following the paths that connect the scripts. For example, I want to have complete control over how my game reacts to battles but I am having the hardest time finding where the battle scripts are initiated. Which script calls them? I also find functions being called in condition branches but I have no idea where that function is being stored in order to be called. The bottom line is that I am trying to figure out where functions and variables are being stored because I want to make my own and use them freely. I just need to grasp the context. If anyone can help me out with this that would be great! Thanks!

I've moved this thread to Learning Ruby and RGSS. Thank you.


For those who want to help, this is for XP.
OK in XP...
Scene_Map calls a variable, namely $game_temp.battle_calling, once it sets its value to true, it will call the call_battle that set its value back to false and at the end it changes the current scene with the following call.

Code:
$scene = Scene_Battle.new

Original thread: https://forums.rpgmakerweb.com/threads/difficulty-finding-function-and-script-locations.125210/