#============================================================================== # ** Escape (MACKIE) #------------------------------------------------------------------------------ # This script allows you to create items and skills that can be used to # "escape" back to the entrance of a dungeon. #============================================================================== # Notebox string identifier for the escape command # Skills and items with "EXSKL_ESCAPE_SIGNATURE" allow the player to escape. # Scope should be "None," and occasion should be "Only from the Menu." EXSKL_ESCAPE_SIGNATURE = "*ESCAPE" # The ID of the switch that allows escaping. # Set to ON when you want to enable escaping. # Set to OFF when an event is in progress or while outside of a dungeon. EXSKL_ESCAPE_PERMISSION_SID = 22 # The IDs of variables that altogether specify the escape location. # Format is [State of the permission switch after escaping (0: OFF; 1: ON), # Map ID, X coordinate, Y coordinate]. (For more information, see below) EXSKL_ESCAPE_VIDS = [21, 22, 23, 24] # Sound effect during execution # [SE name, volume, pitch] (Use [] for no sound effect) EXSKL_ESCAPE_SE = ["Teleport", 80, 100] #------------------------------------------------------------------------------ # The escape location can also be specified using [Script] # Arguments will be passed as coordinate data to the corresponding variables. # # * Setting the coordinates of any location # $game_party.set_escape_place(state of permission switch, Map ID, # X coordinate, Y coordinate) # # * Setting the player's current coordinates # switch = 0 # or 1 # map_id = $game_map.map_id # x = $game_player.x # y = $game_player.y # $game_party.set_escape_place(switch, map_id, x, y) #------------------------------------------------------------------------------ class Game_Actor alias _exsesc_skill_can_use? skill_can_use? unless $@ #-------------------------------------------------------------------------- # * Determine Usable Skills (Definition added) # skill : skill #-------------------------------------------------------------------------- def skill_can_use?(skill) return false unless skill.is_a?(RPG::Skill) if skill.note.include?(EXSKL_ESCAPE_SIGNATURE) return false if $game_party.escape_place[0] == 0 return false unless $game_switches[EXSKL_ESCAPE_PERMISSION_SID] return false if $game_player.in_vehicle? end return _exsesc_skill_can_use?(skill) end end class Game_Party alias _exsesc_item_can_use? item_can_use? unless $@ #-------------------------------------------------------------------------- # * Determine if Item is Usable (Definition added) # item : item #-------------------------------------------------------------------------- def item_can_use?(item) return false unless item.is_a?(RPG::Item) return false if item_number(item) == 0 if item.note.include?(EXSKL_ESCAPE_SIGNATURE) return false if escape_place[0] == 0 return false unless $game_switches[EXSKL_ESCAPE_PERMISSION_SID] return false if $game_player.in_vehicle? end return _exsesc_item_can_use?(item) end #-------------------------------------------------------------------------- # * Get Escape Place #-------------------------------------------------------------------------- def escape_place map_id = $game_variables[EXSKL_ESCAPE_VIDS[1]] x = $game_variables[EXSKL_ESCAPE_VIDS[2]] y = $game_variables[EXSKL_ESCAPE_VIDS[3]] return [map_id, x, y] end #-------------------------------------------------------------------------- # * Set Escape Place # map_id : map ID # x : X coordinate # y : Y coordinate #-------------------------------------------------------------------------- def set_escape_place(switch, map_id, x, y) $game_variables[EXSKL_ESCAPE_VIDS[0]] = switch $game_variables[EXSKL_ESCAPE_VIDS[1]] = map_id $game_variables[EXSKL_ESCAPE_VIDS[2]] = x $game_variables[EXSKL_ESCAPE_VIDS[3]] = y end end class Scene_Item alias _exsesc_determine_item determine_item unless $@ #-------------------------------------------------------------------------- # * Confirm Item (Definition added) #-------------------------------------------------------------------------- def determine_item if @item.note.include?(EXSKL_ESCAPE_SIGNATURE) determine_escape else _exsesc_determine_item end end #-------------------------------------------------------------------------- # * Confirm Escape #-------------------------------------------------------------------------- def determine_escape place = $game_party.escape_place if place == nil Sound.play_buzzer else se = EXSKL_ESCAPE_SE RPG::SE.new(se[0], se[1], se[2]).play unless se.empty? $game_party.last_item_id = @item.id $game_party.consume_item(@item) $game_player.reserve_transfer(place[0], place[1], place[2], 2) if $game_variables[EXSKL_ESCAPE_VIDS[0]] == 0 $game_switches[EXSKL_ESCAPE_PERMISSION_SID] = false else $game_switches[EXSKL_ESCAPE_PERMISSION_SID] = true end $scene = Scene_Map.new end end end class Scene_Skill alias _exsesc_determine_skill determine_skill unless $@ #-------------------------------------------------------------------------- # * Confirm Skill (Definition added) #-------------------------------------------------------------------------- def determine_skill if @skill.note.include?(EXSKL_ESCAPE_SIGNATURE) determine_escape else _exsesc_determine_skill end end #-------------------------------------------------------------------------- # * Confirm Escape #-------------------------------------------------------------------------- def determine_escape place = $game_party.escape_place if place == nil Sound.play_buzzer else se = EXSKL_ESCAPE_SE RPG::SE.new(se[0], se[1], se[2]).play unless se.empty? @actor.last_skill_id = @skill.id @actor.mp -= @actor.calc_mp_cost(@skill) $game_player.reserve_transfer(place[0], place[1], place[2], 2) if $game_variables[EXSKL_ESCAPE_VIDS[0]] == 0 $game_switches[EXSKL_ESCAPE_PERMISSION_SID] = false else $game_switches[EXSKL_ESCAPE_PERMISSION_SID] = true end $scene = Scene_Map.new end end end