#============================================================================== # ** ExCommand_Battle (MACKIE) #------------------------------------------------------------------------------ # This script allows you to start a random battle when running # [Battle Processing], as well as designate enemy groups as "rare" or "hidden". #============================================================================== # The ID of the switch used to override [Battle Processing]. # When set to ON, [Battle Processing] will start a random battle, regardless # of the enemy group originally specified. EXCMD_BATTLE_SID = 28 # Override reset flag. # Specifies whether to set switch [EXCMD_BATTLE_SID] to OFF after executing # [Battle Processing] (0: no reset; 1: reset) EXCMD_BATTLE_RESET = 1 # Notebox string identifier for enemy groups treated as "HIDDEN". # Enemy groups with "EXCMD_BATTLE_HIDDEN_SIGNATURE" will be added to the # encounter list only when switch [EXCMD_BATTLE_SID] is ON. EXCMD_BATTLE_HIDDEN_SIGNATURE = "*HIDDEN" # Notebox string identifier for enemy groups treated as "RARE". # Enemy groups with "EXCMD_BATTLE_RARE_SIGNATURE [switch ID]" will be added to # the encounter list only when switch [switch ID] is ON. # (Example) *RARE[30] => the enemy group will only appear when switch 30 is ON EXCMD_BATTLE_RARE_SIGNATURE = "*RARE" #------------------------------------------------------------------------------ class Game_Player #-------------------------------------------------------------------------- # * Create Group ID for Troop Encountered (Redefined) #-------------------------------------------------------------------------- def make_encounter_troop_id encounter_list = $game_map.encounter_list.clone for area in $data_areas.values encounter_list += area.encounter_list if in_area?(area) end remove_troops = [] sig1 = EXCMD_BATTLE_RARE_SIGNATURE sig2 = EXCMD_BATTLE_HIDDEN_SIGNATURE for i in encounter_list if $data_troops[i].name[/#{Regexp.quote sig1}\[(\d+)\]/].to_a[0] remove_troops.push(i) unless $game_switches[$1.to_i] end next if $game_switches[EXCMD_BATTLE_SID] remove_troops.push(i) if $data_troops[i].name.include?(sig2) end for i in remove_troops encounter_list.delete(i) end if encounter_list.empty? make_encounter_count return 0 end return encounter_list[rand(encounter_list.size)] end end class Game_Interpreter #-------------------------------------------------------------------------- # * Battle Processing (Redefined) #-------------------------------------------------------------------------- def command_301 return true if $game_temp.in_battle if $game_switches[EXCMD_BATTLE_SID] # Designation from the map troop_id = $game_player.make_encounter_troop_id $game_switches[EXCMD_BATTLE_SID] = false if EXCMD_BATTLE_RESET == 1 elsif @params[0] == 0 # Direct designation troop_id = @params[1] else # Designation with variables troop_id = $game_variables[@params[1]] end if $data_troops[troop_id] != nil $game_troop.setup(troop_id) $game_troop.can_escape = @params[2] $game_troop.can_lose = @params[3] $game_temp.battle_proc = Proc.new { |n| @branch[@indent] = n } $game_temp.next_scene = "battle" end @index += 1 return false end end