From 21450179c631d5347b2a466948c840b7d798b28c Mon Sep 17 00:00:00 2001 From: Mathew Velasquez Date: Thu, 25 Feb 2016 18:40:07 -0500 Subject: [PATCH] Fast travel more or less finished --- scripts/Data_FastTravel.rb | 1 + scripts/Ed_Message.rb | 2 +- scripts/FastTravel.rb | 27 ++++++++++++++++++++++++++- scripts/Game_Event.rb | 2 ++ scripts/Game_FastTravel.rb | 20 +++++++++++++++++--- scripts/Scene_Map.rb | 18 +++++++++--------- scripts/Script.rb | 25 +++++++++++++++++++------ scripts/Window_MainMenu.rb | 14 -------------- 8 files changed, 75 insertions(+), 34 deletions(-) diff --git a/scripts/Data_FastTravel.rb b/scripts/Data_FastTravel.rb index 4a8706e..7bb0736 100644 --- a/scripts/Data_FastTravel.rb +++ b/scripts/Data_FastTravel.rb @@ -15,6 +15,7 @@ class FastTravel :apartments => tr("apartments"), :cafe => tr("cafe"), :office => tr("office"), + :obsdeck => tr("observation deck"), }), :green => Zone.new(tr("The Glen"), { :whatever => tr(""), diff --git a/scripts/Ed_Message.rb b/scripts/Ed_Message.rb index 0e02e00..e2c8838 100644 --- a/scripts/Ed_Message.rb +++ b/scripts/Ed_Message.rb @@ -214,7 +214,7 @@ class Ed_Message end if visible - if Input.trigger?(Input::ACTION) + if Input.trigger?(Input::ACTION) || Input.trigger?(Input::CANCEL) terminate_message @fade_out_text = true end diff --git a/scripts/FastTravel.rb b/scripts/FastTravel.rb index 378f49d..b145d95 100644 --- a/scripts/FastTravel.rb +++ b/scripts/FastTravel.rb @@ -37,7 +37,15 @@ class FastTravel self.visible = true self.opacity = 0 @fade_in = true - @data = $game_fasttravel.unlocked_maps.sort + @data = $game_fasttravel.unlocked_maps.keys.sort + + # Set cursor to current map + @data.each_with_index do |map, i| + if $game_fasttravel.unlocked_maps[map].id == $game_map.map_id + @index = i + break + end + end zone = ZONES[$game_fasttravel.zone] # Create title @@ -119,6 +127,23 @@ class FastTravel $game_system.se_play($data_system.cursor_se) end + if Input.trigger?(Input::ACTION) + $game_system.se_play($data_system.decision_se) + choice = $game_fasttravel.unlocked_maps[@data[@index]] + if choice.id != $game_map.map_id + $game_temp.player_transferring = true + $game_temp.player_new_map_id = choice.id + $game_temp.player_new_x = choice.x + $game_temp.player_new_y = choice.y + $game_temp.player_new_direction = choice.dir + Graphics.freeze + $game_temp.transition_processing = true + $game_temp.transition_name = "travel" + end + @fade_out = true + return + end + if Input.trigger?(Input::CANCEL) $game_system.se_play($data_system.cancel_se) @fade_out = true diff --git a/scripts/Game_Event.rb b/scripts/Game_Event.rb index d52aafa..982cf3e 100644 --- a/scripts/Game_Event.rb +++ b/scripts/Game_Event.rb @@ -14,6 +14,8 @@ class Game_Event < Game_Character attr_reader :list # list of event commands attr_reader :starting # starting flag attr_reader :collision # collision array + attr_reader :x + attr_reader :y #-------------------------------------------------------------------------- # * Object Initialization # map_id : map ID diff --git a/scripts/Game_FastTravel.rb b/scripts/Game_FastTravel.rb index 41c45d5..8e3f946 100644 --- a/scripts/Game_FastTravel.rb +++ b/scripts/Game_FastTravel.rb @@ -3,20 +3,34 @@ class Game_FastTravel attr_accessor :enabled alias :enabled? :enabled + class Map + attr_reader :id + attr_reader :x + attr_reader :y + attr_reader :dir + + def initialize(id, x, y, dir) + @id = id + @x = x + @y = y + @dir = dir + end + end + def initialize @unlocked = {} @zone = nil @enabled = false end - def unlock(map) - @unlocked[@zone] << map + def unlock(map, id, x, y, dir) + @unlocked[@zone][map] = Map.new(id, x, y, dir) end def zone=(zone) @zone = zone unless @unlocked.include? zone - @unlocked[zone] = [] + @unlocked[zone] = {} end end diff --git a/scripts/Scene_Map.rb b/scripts/Scene_Map.rb index 7efe8c3..36cae24 100644 --- a/scripts/Scene_Map.rb +++ b/scripts/Scene_Map.rb @@ -124,8 +124,6 @@ class Scene_Map end # Hide icon when item menu is visible @item_icon.visible = !@item_menu.visible - # Update fast travel - @fast_travel.update # If game over if $game_temp.gameover # Switch to game over screen @@ -150,6 +148,8 @@ class Scene_Map $game_temp.transition_name) end end + # Update fast travel + @fast_travel.update # If showing message window if $game_temp.message_window_showing || @ed_message.visible return @@ -342,13 +342,13 @@ class Scene_Map # Update map (run parallel process event) $game_map.update @spriteset.update - # If processing transition - if $game_temp.transition_processing - # Clear transition processing flag - $game_temp.transition_processing = false - # Execute transition - Graphics.transition(20) - end + # # If processing transition + # if $game_temp.transition_processing + # # Clear transition processing flag + # $game_temp.transition_processing = false + # # Execute transition + # Graphics.transition(20) + # end # Run automatic change for BGM and BGS set on the map $game_map.autoplay # Frame reset diff --git a/scripts/Script.rb b/scripts/Script.rb index ccd40b5..dd8efd7 100644 --- a/scripts/Script.rb +++ b/scripts/Script.rb @@ -122,15 +122,28 @@ def enable_travel end def disable_travel - $game_fasttravel.disabled = true + $game_fasttravel.enabled = false end -def set_zone(zone) +def unlock_map(zone, map, dir) + # Find the coordinate of the calling event + e = $game_map.events.values.find { |e| e.name == 'FAST TRAVEL' } + raise 'could not find event named FAST TRAVEL' if !e + case dir + when :down + newdir = 2 + when :left + newdir = 4 + when :right + newdir = 6 + when :up + newdir = 8 + else + raise "invalid direction: #{dir}" + end + $game_fasttravel.enabled = true $game_fasttravel.zone = zone -end - -def unlock_map(map) - $game_fasttravel.unlock(map) + $game_fasttravel.unlock(map, $game_map.map_id, e.x, e.y, newdir) end # Misc diff --git a/scripts/Window_MainMenu.rb b/scripts/Window_MainMenu.rb index f7f0344..03054cd 100644 --- a/scripts/Window_MainMenu.rb +++ b/scripts/Window_MainMenu.rb @@ -97,20 +97,6 @@ class Window_MainMenu < Window_Selectable return end - # Update subwindows - #if @item_window.active - # @item_window.update - # if Input.trigger?(Input::CANCEL) - # $game_system.se_play($data_system.cancel_se) - # self.active = true - # self.opacity = 255 - # @item_window.visible = false - # @item_window.active = false - # @item_help_window.visible = false - # return - # end - #end - # Don't do anything if not active if !self.active return