Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[RMXP] Common event before battle

I'm trying to make it so that every time a random battle occurs a common event is called before the the scene shifts to a battle. I want to do this so that I can add a pause and alert emoticon over the player's head (using animations) before the actual transition to battle, I think it's a relatively simple thing to do but so far I've had no luck with my extremely limited knowledge of RGSS. So I'm requesting a script for this function. There's one for RPG Maker VX here, but I need one for RPG Maker XP. Thanks in advance to anyone who can figure this out.
 
Here you go, I pretty much translated the one from that guy, so you can credit whoever you want or you don't even have to credit me lol but here's the script: (Set the common event ID at the top of the script)

[rgss]#==============================================================================
# Title: Common Event Before Battle
# Version: 1.0
#==============================================================================
 
#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
# Common Event ID to run before a battle starts
Common_Event_ID = 1
 
 
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs the map screen processing.
#==============================================================================
 
class Scene_Map
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------  
  alias law_ce_before_battle_scene_map_cb  call_battle  
  #--------------------------------------------------------------------------
  # * Switch to Battle Screen
  #--------------------------------------------------------------------------
  def call_battle
    # Call a battle common event
    $game_system.map_interpreter.battle_common_event(Common_Event_ID)    
    # Update Game Map Interpreter
    $game_system.map_interpreter.update
    # Call original method
    law_ce_before_battle_scene_map_cb
  end
end
 
 
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
 
class Interpreter
  #--------------------------------------------------------------------------
  # * Call Battle Common Event
  #--------------------------------------------------------------------------
  def battle_common_event(id)
    common_event = $data_common_events[id]
    if common_event != nil
      @child_interpreter = Interpreter.new(@depth + 1)
      @child_interpreter.setup(common_event.list, @event_id)
    end
    return true
  end
end
 
#==============================================================================
#
# *** END OF SCRIPT ***
#
#==============================================================================
[/rgss]
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top