#============================================================================== # ** Teleport (MACKIE) Special Thanks to Yoji Ojima #------------------------------------------------------------------------------ # This script allows you to create skills and items that teleport you to a # specified location. #============================================================================== # Notebox string identifier for the teleport command. # Skills and items with "EXSKL_TELEPORT_SIGNATURE" will teleport the player. # Scope should be "None", and occasion should be "Only from the Menu." EXSKL_TELEPORT_SIGNATURE = "*TELEPORT" # The ID of the switch indicating the permission status of teleportation. # Set to ON when you want to enable teleportation. # Set to OFF while an event is in progress or while in a dungeon. EXSKL_TELEPORT_PERMISSION_SID = 21 # Teleport location table. # [Switch ID, Name, Map ID, X-coordinate, Y-coordinate, Player direction] # Make sure you place the array elements in the correct order. # The player can teleport to any location whose corresponding switch is ON. EXSKL_TELEPORT_PLACES = [ ] # Sound effect during execution # [SE name, volume, pitch] (Use [] for no sound effect) EXSKL_TELEPORT_SE = ["Teleport", 80, 100] #------------------------------------------------------------------------------ class Game_Actor alias _exstlp_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_TELEPORT_SIGNATURE) return false unless $game_party.teleport_can_use? return false if $game_player.in_vehicle? end return _exstlp_skill_can_use?(skill) end end class Game_Party alias _exstlp_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_TELEPORT_SIGNATURE) return false unless teleport_can_use? return false if $game_player.in_vehicle? end return _exstlp_item_can_use?(item) end #-------------------------------------------------------------------------- # * Determine if Teleport can be used #-------------------------------------------------------------------------- def teleport_can_use? return false if EXSKL_TELEPORT_PLACES.empty? return false unless $game_switches[EXSKL_TELEPORT_PERMISSION_SID] for place in EXSKL_TELEPORT_PLACES return true if $game_switches[place[0]] end return false end end #============================================================================== # ** Window_Teleport #------------------------------------------------------------------------------ # This window displays a list of possible teleport locations. #============================================================================== class Window_Teleport < Window_Selectable #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 0, 272, 416) refresh end #-------------------------------------------------------------------------- # * Get Item #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear @data = [] for place in EXSKL_TELEPORT_PLACES if $game_switches[place[0]] @data.push(place) end end @item_max = [@data.size, 1].max create_contents for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # * Draw Item # index : item number #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect(index) rect.x += 4 rect.width -= 8 self.contents.clear_rect(rect) place = @data[index] if place != nil self.contents.draw_text(rect, place[1]) end end end class Scene_Item alias _exstlp_start start unless $@ alias _exstlp_terminate terminate unless $@ alias _exstlp_update update unless $@ alias _exstlp_determine_item determine_item unless $@ #-------------------------------------------------------------------------- # * Start processing (Definition added) #-------------------------------------------------------------------------- def start _exstlp_start @teleport_window = Window_Teleport.new hide_teleport_window end #-------------------------------------------------------------------------- # * Termination Processing (Definition added) #-------------------------------------------------------------------------- def terminate _exstlp_terminate @teleport_window.dispose end #-------------------------------------------------------------------------- # * Update Frame (Definition added) #-------------------------------------------------------------------------- def update teleport_active = @teleport_window.active _exstlp_update @teleport_window.update if teleport_active update_teleport_selection end end #-------------------------------------------------------------------------- # * Confirm Item (Definition added) #-------------------------------------------------------------------------- def determine_item if @item.note.include?(EXSKL_TELEPORT_SIGNATURE) show_teleport_window(@item_window.index % 2 == 0) else _exstlp_determine_item end end #-------------------------------------------------------------------------- # * Show Teleport Window # right : Right justification flag (if false, left justification) #-------------------------------------------------------------------------- def show_teleport_window(right) @item_window.active = false width_remain = 544 - @teleport_window.width @teleport_window.x = right ? width_remain : 0 @teleport_window.visible = true @teleport_window.active = true @teleport_window.index = 0 if right @viewport.rect.set(0, 0, width_remain, 416) @viewport.ox = 0 else @viewport.rect.set(@teleport_window.width, 0, width_remain, 416) @viewport.ox = @teleport_window.width end end #-------------------------------------------------------------------------- # * Hide Teleport Window #-------------------------------------------------------------------------- def hide_teleport_window @item_window.active = true @teleport_window.visible = false @teleport_window.active = false @viewport.rect.set(0, 0, 544, 416) @viewport.ox = 0 end #-------------------------------------------------------------------------- # * Update Teleport Selection #-------------------------------------------------------------------------- def update_teleport_selection if Input.trigger?(Input::B) Sound.play_cancel hide_teleport_window elsif Input.trigger?(Input::C) determine_teleport end end #-------------------------------------------------------------------------- # * Confirm Teleport #-------------------------------------------------------------------------- def determine_teleport place = @teleport_window.item if place == nil Sound.play_buzzer else se = EXSKL_TELEPORT_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[2], place[3], place[4], place[5]) $scene = Scene_Map.new end end end class Scene_Skill alias _exstlp_start start unless $@ alias _exstlp_terminate terminate unless $@ alias _exstlp_update update unless $@ alias _exstlp_determine_skill determine_skill unless $@ #-------------------------------------------------------------------------- # * Start processing (Definition added) #-------------------------------------------------------------------------- def start _exstlp_start @teleport_window = Window_Teleport.new hide_teleport_window end #-------------------------------------------------------------------------- # * Termination Processing (Definition added) #-------------------------------------------------------------------------- def terminate _exstlp_terminate @teleport_window.dispose end #-------------------------------------------------------------------------- # * Update Frame (Definition added) #-------------------------------------------------------------------------- def update teleport_active = @teleport_window.active _exstlp_update @teleport_window.update if teleport_active update_teleport_selection end end #-------------------------------------------------------------------------- # * Confirm Skill (Definition added) #-------------------------------------------------------------------------- def determine_skill if @skill.note.include?(EXSKL_TELEPORT_SIGNATURE) show_teleport_window(@skill_window.index % 2 == 0) else _exstlp_determine_skill end end #-------------------------------------------------------------------------- # * Show Teleport Window # right : Right justification flag (if false, left justification) #-------------------------------------------------------------------------- def show_teleport_window(right) @skill_window.active = false width_remain = 544 - @teleport_window.width @teleport_window.x = right ? width_remain : 0 @teleport_window.visible = true @teleport_window.active = true @teleport_window.index = 0 if right @viewport.rect.set(0, 0, width_remain, 416) @viewport.ox = 0 else @viewport.rect.set(@teleport_window.width, 0, width_remain, 416) @viewport.ox = @teleport_window.width end end #-------------------------------------------------------------------------- # * Hide Teleport Window #-------------------------------------------------------------------------- def hide_teleport_window @skill_window.active = true @teleport_window.visible = false @teleport_window.active = false @viewport.rect.set(0, 0, 544, 416) @viewport.ox = 0 end #-------------------------------------------------------------------------- # * Update Teleport Selection #-------------------------------------------------------------------------- def update_teleport_selection if Input.trigger?(Input::B) Sound.play_cancel hide_teleport_window elsif Input.trigger?(Input::C) determine_teleport end end #-------------------------------------------------------------------------- # * Confirm Teleport #-------------------------------------------------------------------------- def determine_teleport place = @teleport_window.item if place == nil Sound.play_buzzer else se = EXSKL_TELEPORT_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[2], place[3], place[4], place[5]) $scene = Scene_Map.new end end end