diff --git a/Data/Scripts/002_Switches and Variables/001_Game_Temp.rb b/Data/Scripts/002_Switches and Variables/001_Game_Temp.rb index 727043c2b..2a74211ff 100644 --- a/Data/Scripts/002_Switches and Variables/001_Game_Temp.rb +++ b/Data/Scripts/002_Switches and Variables/001_Game_Temp.rb @@ -5,39 +5,14 @@ # Refer to "$game_temp" for the instance of this class. #=============================================================================== class Game_Temp - attr_accessor :map_bgm # map music (for battle memory) - attr_accessor :message_text # message text - attr_accessor :message_proc # message callback (Proc) - attr_accessor :choice_start # show choices: opening line - attr_accessor :choice_max # show choices: number of items - attr_accessor :choice_cancel_type # show choices: cancel - attr_accessor :choice_proc # show choices: callback (Proc) - attr_accessor :num_input_start # input number: opening line - attr_accessor :num_input_variable_id # input number: variable ID - attr_accessor :num_input_digits_max # input number: digit amount attr_accessor :message_window_showing # message window showing attr_accessor :common_event_id # common event ID attr_accessor :in_battle # in-battle flag - attr_accessor :battle_calling # battle calling flag - attr_accessor :battle_troop_id # battle troop ID - attr_accessor :battle_can_escape # battle flag: escape possible - attr_accessor :battle_can_lose # battle flag: losing possible - attr_accessor :battle_proc # battle callback (Proc) - attr_accessor :battle_turn # number of battle turns - attr_accessor :battle_event_flags # battle event flags: completed attr_accessor :battle_abort # battle flag: interrupt - attr_accessor :battle_main_phase # battle flag: main phase attr_accessor :battleback_name # battleback file name - attr_accessor :forcing_battler # battler being forced into action - attr_accessor :shop_calling # shop calling flag - attr_accessor :shop_goods # list of shop goods - attr_accessor :name_calling # name input: calling flag - attr_accessor :name_actor_id # name input: actor ID - attr_accessor :name_max_char # name input: max character count - attr_accessor :menu_calling # menu calling flag - attr_accessor :menu_beep # menu: play sound effect flag attr_accessor :in_menu # menu is open - attr_accessor :save_calling # save calling flag + attr_accessor :menu_beep # menu: play sound effect flag + attr_accessor :menu_calling # menu calling flag attr_accessor :debug_calling # debug calling flag attr_accessor :player_transferring # player place movement flag attr_accessor :player_new_map_id # player destination: map ID @@ -46,47 +21,25 @@ class Game_Temp attr_accessor :player_new_direction # player destination: direction attr_accessor :transition_processing # transition processing flag attr_accessor :transition_name # transition file name - attr_accessor :gameover # game over flag attr_accessor :to_title # return to title screen flag - attr_accessor :last_file_index # last save file no. - attr_accessor :map_refresh # map needs redrawing + attr_accessor :fadestate # for sprite hashes + attr_accessor :background_bitmap + attr_accessor :message_window_showing + attr_accessor :player_transferring + attr_accessor :transition_processing + attr_accessor :mart_prices #----------------------------------------------------------------------------- # * Object Initialization #----------------------------------------------------------------------------- def initialize - @map_bgm = nil - @message_text = nil - @message_proc = nil - @choice_start = 99 - @choice_max = 0 - @choice_cancel_type = 0 - @choice_proc = nil - @num_input_start = 99 - @num_input_variable_id = 0 - @num_input_digits_max = 0 @message_window_showing = false @common_event_id = 0 @in_battle = false - @battle_calling = false - @battle_troop_id = 0 - @battle_can_escape = false - @battle_can_lose = false - @battle_proc = nil - @battle_turn = 0 - @battle_event_flags = {} @battle_abort = false - @battle_main_phase = false @battleback_name = '' - @forcing_battler = nil - @shop_calling = false - @shop_id = 0 - @name_calling = false - @name_actor_id = 0 - @name_max_char = 0 - @menu_calling = false - @menu_beep = false @in_menu = false - @save_calling = false + @menu_beep = false + @menu_calling = false @debug_calling = false @player_transferring = false @player_new_map_id = 0 @@ -95,10 +48,16 @@ class Game_Temp @player_new_direction = 0 @transition_processing = false @transition_name = "" - @gameover = false @to_title = false - @last_file_index = 0 - @debug_top_row = 0 - @debug_index = 0 + @fadestate = 0 + @background_bitmap = nil + @message_window_showing = false + @player_transferring = false + @transition_processing = false + @mart_prices = [] + end + + def clear_mart_prices + @mart_prices = [] end end diff --git a/Data/Scripts/003_Game classes/002_Game_System.rb b/Data/Scripts/003_Game classes/002_Game_System.rb index 2980e09c0..e384df2aa 100644 --- a/Data/Scripts/003_Game classes/002_Game_System.rb +++ b/Data/Scripts/003_Game classes/002_Game_System.rb @@ -5,7 +5,6 @@ # is managed here as well. Refer to "$game_system" for the instance of # this class. #============================================================================== - class Game_System attr_reader :map_interpreter # map event interpreter attr_reader :battle_interpreter # battle event interpreter diff --git a/Data/Scripts/003_Game classes/006_Game_Event.rb b/Data/Scripts/003_Game classes/006_Game_Event.rb index 970daac66..6bce26910 100644 --- a/Data/Scripts/003_Game classes/006_Game_Event.rb +++ b/Data/Scripts/003_Game classes/006_Game_Event.rb @@ -106,9 +106,20 @@ class Game_Event < Game_Character return elapsed>=days end + def cooledDown?(seconds) + return true if expired?(seconds) && tsOff?("A") + self.need_refresh = true + return false + end + + def cooledDownDays?(days) + return true if expiredDays?(days) && tsOff?("A") + self.need_refresh = true + return false + end + def onEvent? - return @map_id==$game_map.map_id && - $game_player.x==self.x && $game_player.y==self.y + return @map_id == $game_map.map_id && $game_player.x == self.x && $game_player.y == self.y end def over_trigger? diff --git a/Data/Scripts/003_Game classes/011_MapFactory.rb b/Data/Scripts/003_Game classes/011_MapFactory.rb index a72cbc6d2..15bcf59b1 100644 --- a/Data/Scripts/003_Game classes/011_MapFactory.rb +++ b/Data/Scripts/003_Game classes/011_MapFactory.rb @@ -400,8 +400,6 @@ class PokemonMapFactory end end - - #=============================================================================== # Map Factory Helper (stores map connection and size data and calculations # involving them) @@ -506,8 +504,10 @@ module MapFactoryHelper end end - - +#=============================================================================== +# +#=============================================================================== +# Unused def updateTilesets maps = $MapFactory.maps for map in maps diff --git a/Data/Scripts/006_Game processing/001_Interpreter.rb b/Data/Scripts/006_Game processing/001_Interpreter.rb index ec1decbaa..f75a0b91a 100644 --- a/Data/Scripts/006_Game processing/001_Interpreter.rb +++ b/Data/Scripts/006_Game processing/001_Interpreter.rb @@ -13,112 +13,91 @@ class Interpreter def initialize(depth = 0, main = false) @depth = depth @main = main - # Depth goes up to level 100 if depth > 100 print("Common event call has exceeded maximum limit.") exit end - # Clear inner situation of interpreter clear end def clear - @map_id = 0 # map ID when starting up - @event_id = 0 # event ID - @message_waiting = false # waiting for message to end - @move_route_waiting = false # waiting for move completion - @button_input_variable_id = 0 # button input variable ID - @wait_count = 0 # wait count - @child_interpreter = nil # child interpreter - @branch = {} # branch data + @map_id = 0 # map ID when starting up + @event_id = 0 # event ID + @message_waiting = false # waiting for message to end + @move_route_waiting = false # waiting for move completion + @wait_count = 0 # wait count + @child_interpreter = nil # child interpreter + @branch = {} # branch data + @buttonInput = false end #----------------------------------------------------------------------------- # * Event Setup # list : list of event commands # event_id : event ID #----------------------------------------------------------------------------- - def setup(list, event_id, map_id=nil) - # Clear inner situation of interpreter + def setup(list, event_id, map_id = nil) clear - # Remember map ID - @map_id = map_id ? map_id : $game_map.map_id - # Remember event ID + @map_id = map_id || $game_map.map_id @event_id = event_id - # Remember list of event commands @list = list - # Initialize index @index = 0 - # Clear branch data hash @branch.clear end + def setup_starting_event + $game_map.refresh if $game_map.need_refresh + # Set up common event if one wants to start + if $game_temp.common_event_id > 0 + setup($data_common_events[$game_temp.common_event_id].list, 0) + $game_temp.common_event_id = 0 + return + end + # Check all map events for one that wants to start, and set it up + for event in $game_map.events.values + next if !event.starting + if event.trigger < 3 # Isn't autorun or parallel processing + event.lock + event.clear_starting + end + setup(event.list, event.id, event.map.map_id) + return + end + # Check all common events for one that is autorun, and set it up + for common_event in $data_common_events.compact + next if common_event.trigger != 1 || !$game_switches[common_event.switch_id] + setup(common_event.list, 0) + return + end + end + def running? return @list != nil end - - def setup_starting_event - $game_map.refresh if $game_map.need_refresh - # If common event call is reserved - if $game_temp.common_event_id > 0 - # Set up event - setup($data_common_events[$game_temp.common_event_id].list, 0) - # Release reservation - $game_temp.common_event_id = 0 - return - end - # Loop (map events) - for event in $game_map.events.values - # If running event is found - next if !event.starting - # If not auto run - if event.trigger < 3 - # Lock - event.lock - # Clear starting flag - event.clear_starting - end - # Set up event - setup(event.list, event.id, event.map.map_id) #### CHANGED - return - end - # Loop (common events) - for common_event in $data_common_events.compact - # If trigger is auto run, and condition switch is ON - if common_event.trigger == 1 and - $game_switches[common_event.switch_id] == true - # Set up event - setup(common_event.list, 0) - return - end - end - end #----------------------------------------------------------------------------- # * Frame Update #----------------------------------------------------------------------------- def update - # Initialize loop count @loop_count = 0 - # Loop loop do @loop_count += 1 - if @loop_count > 100 - # Call Graphics.update for freeze prevention + if @loop_count > 100 # Call Graphics.update for freeze prevention Graphics.update @loop_count = 0 end - # If map is different than event startup time - if $game_map.map_id != @map_id && - (!$MapFactory || !$MapFactory.areConnected?($game_map.map_id,@map_id)) + # If this interpreter's map isn't the current map or connected to it, + # forget this interpreter's event ID + if $game_map.map_id != @map_id && !$MapFactory.areConnected?($game_map.map_id, @map_id) @event_id = 0 end - if @child_interpreter != nil + # Update child interpreter if one exists + if @child_interpreter @child_interpreter.update - unless @child_interpreter.running? - @child_interpreter = nil - end - return if @child_interpreter != nil + @child_interpreter = nil if !@child_interpreter.running? + return if @child_interpreter end + # Do nothing if a message is being shown return if @message_waiting + # Do nothing if any event or the player is in the middle of a move route if @move_route_waiting return if $game_player.move_route_forcing for event in $game_map.events.values @@ -126,1332 +105,343 @@ class Interpreter end @move_route_waiting = false end - # If waiting for button input - if @button_input_variable_id > 0 - input_button - return - end + # Do nothing while waiting if @wait_count > 0 @wait_count -= 1 return end - # If an action forcing battler exists - return if $game_temp.forcing_battler != nil - # If a call flag is set for each type of screen - if $game_temp.battle_calling or - $game_temp.shop_calling or - $game_temp.name_calling or - $game_temp.menu_calling or - $game_temp.save_calling or - $game_temp.gameover - return - end - # If list of event commands is empty - if @list == nil + # Do nothing if the pause menu is going to open + return if $game_temp.menu_calling + # If there are no commands in the list, try to find something that wants to run + if @list.nil? setup_starting_event if @main - return if @list == nil + return if @list.nil? # Couldn't find anything that wants to run end - # If return value is false when trying to execute event command + # Execute the next command return if execute_command == false - # Advance index + # Move to the next @index @index += 1 end end #----------------------------------------------------------------------------- - # * Button Input + # * Execute script #----------------------------------------------------------------------------- - def input_button - # Determine pressed button - n = 0 - for i in 1..18 - n = i if Input.trigger?(i) - end - # If button was pressed - if n > 0 - # Change value of variables - $game_variables[@button_input_variable_id] = n - $game_map.need_refresh = true - # End button input - @button_input_variable_id = 0 - end - end - #----------------------------------------------------------------------------- - # * Setup Choices - #----------------------------------------------------------------------------- - def setup_choices(parameters) - # Set choice item count to choice_max - $game_temp.choice_max = parameters[0].size - # Set choice to message_text - for text in parameters[0] - $game_temp.message_text += text + "\n" - end - # Set cancel processing - $game_temp.choice_cancel_type = parameters[1] - # Set callback - current_indent = @list[@index].indent - $game_temp.choice_proc = Proc.new { |n| @branch[current_indent] = n } - end - - def pbExecuteScript(script) + def execute_script(script) begin result = eval(script) return result rescue Exception e = $! - raise if e.is_a?(SystemExit) || "#{e.class}"=="Reset" - event = get_character(0) + raise if e.is_a?(SystemExit) || "#{e.class}" == "Reset" + event = get_self s = "Backtrace:\r\n" message = pbGetExceptionMessage(e) if e.is_a?(SyntaxError) script.each_line { |line| - line.gsub!(/\s+$/,"") - if line[/\:\:\s*$/] - message += "\r\n***Line '#{line}' can't begin with '::'. Try putting\r\n" - message += "the next word on the same line, e.g. 'PBSpecies:"+":MEW'" - end + line.gsub!(/\s+$/, "") if line[/^\s*\(/] message += "\r\n***Line '#{line}' shouldn't begin with '('. Try\r\n" message += "putting the '(' at the end of the previous line instead,\r\n" message += "or using 'extendtext.exe'." end + if line[/\:\:\s*$/] + message += "\r\n***Line '#{line}' can't end with '::'. Try putting\r\n" + message += "the next word on the same line, e.g. 'PBSpecies:" + ":MEW'" + end } else - for bt in e.backtrace[0,10] - s += bt+"\r\n" + for bt in e.backtrace[0, 10] + s += bt + "\r\n" end s.gsub!(/Section(\d+)/) { $RGSS_SCRIPTS[$1.to_i][1] } end - message = "Exception: #{e.class}\r\nMessage: "+message+"\r\n" + message = "Exception: #{e.class}\r\nMessage: " + message + "\r\n" message += "\r\n***Full script:\r\n#{script}\r\n" if event && $game_map - mapname = ($game_map.name rescue nil) || "???" - err = "Script error within event #{event.id} (coords #{event.x},#{event.y}), " - err += "map #{$game_map.map_id} (#{mapname}):\r\n#{message}\r\n#{s}" + map_name = ($game_map.name rescue nil) || "???" + err = "Script error in event #{event.id} (coords #{event.x},#{event.y}), map #{$game_map.map_id} (#{map_name}):\r\n" + err += "#{message}\r\n#{s}" if e.is_a?(Hangup) - $EVENTHANGUPMSG = err; raise + $EVENTHANGUPMSG = err + raise end elsif $game_map - mapname = ($game_map.name rescue nil) || "???" - err = "Script error within map #{$game_map.map_id} " - err += "(#{mapname}):\r\n#{message}\r\n#{s}" + map_name = ($game_map.name rescue nil) || "???" + err = "Script error in map #{$game_map.map_id} (#{map_name}):\r\n" + err += "#{message}\r\n#{s}" if e.is_a?(Hangup) - $EVENTHANGUPMSG = err; raise + $EVENTHANGUPMSG = err + raise end else err = "Script error in interpreter:\r\n#{message}\r\n#{s}" if e.is_a?(Hangup) - $EVENTHANGUPMSG = err; raise + $EVENTHANGUPMSG = err + raise end end raise err end end #----------------------------------------------------------------------------- - # * Event Command Execution - #----------------------------------------------------------------------------- - def execute_command - # If last to arrive for list of event commands - if @index >= @list.size - 1 - # End event - command_end - # Continue - return true - end - # Make event command parameters available for reference via @parameters - @parameters = @list[@index].parameters - # Branch by command code - case @list[@index].code - when 101 then return command_101 # Show Text - when 102 then return command_102 # Show Choices - when 402 then return command_402 # When [**] - when 403 then return command_403 # When Cancel - when 103 then return command_103 # Input Number - when 104 then return command_104 # Change Text Options - when 105 then return command_105 # Button Input Processing - when 106 then return command_106 # Wait - when 111 then return command_111 # Conditional Branch - when 411 then return command_411 # Else - when 112 then return command_112 # Loop - when 413 then return command_413 # Repeat Above - when 113 then return command_113 # Break Loop - when 115 then return command_115 # Exit Event Processing - when 116 then return command_116 # Erase Event - when 117 then return command_117 # Call Common Event - when 118 then return command_118 # Label - when 119 then return command_119 # Jump to Label - when 121 then return command_121 # Control Switches - when 122 then return command_122 # Control Variables - when 123 then return command_123 # Control Self Switch - when 124 then return command_124 # Control Timer - when 125 then return command_125 # Change Gold - when 126 then return command_126 # Change Items - when 127 then return command_127 # Change Weapons - when 128 then return command_128 # Change Armor - when 129 then return command_129 # Change Party Member - when 131 then return command_131 # Change Windowskin - when 132 then return command_132 # Change Battle BGM - when 133 then return command_133 # Change Battle End ME - when 134 then return command_134 # Change Save Access - when 135 then return command_135 # Change Menu Access - when 136 then return command_136 # Change Encounter - when 201 then return command_201 # Transfer Player - when 202 then return command_202 # Set Event Location - when 203 then return command_203 # Scroll Map - when 204 then return command_204 # Change Map Settings - when 205 then return command_205 # Change Fog Color Tone - when 206 then return command_206 # Change Fog Opacity - when 207 then return command_207 # Show Animation - when 208 then return command_208 # Change Transparent Flag - when 209 then return command_209 # Set Move Route - when 210 then return command_210 # Wait for Move's Completion - when 221 then return command_221 # Prepare for Transition - when 222 then return command_222 # Execute Transition - when 223 then return command_223 # Change Screen Color Tone - when 224 then return command_224 # Screen Flash - when 225 then return command_225 # Screen Shake - when 231 then return command_231 # Show Picture - when 232 then return command_232 # Move Picture - when 233 then return command_233 # Rotate Picture - when 234 then return command_234 # Change Picture Color Tone - when 235 then return command_235 # Erase Picture - when 236 then return command_236 # Set Weather Effects - when 241 then return command_241 # Play BGM - when 242 then return command_242 # Fade Out BGM - when 245 then return command_245 # Play BGS - when 246 then return command_246 # Fade Out BGS - when 247 then return command_247 # Memorize BGM/BGS - when 248 then return command_248 # Restore BGM/BGS - when 249 then return command_249 # Play ME - when 250 then return command_250 # Play SE - when 251 then return command_251 # Stop SE - when 301 then return command_301 # Battle Processing - when 601 then return command_601 # If Win - when 602 then return command_602 # If Escape - when 603 then return command_603 # If Lose - when 302 then return command_302 # Shop Processing - when 303 then return command_303 # Name Input Processing - when 311 then return command_311 # Change HP - when 312 then return command_312 # Change SP - when 313 then return command_313 # Change State - when 314 then return command_314 # Recover All - when 315 then return command_315 # Change EXP - when 316 then return command_316 # Change Level - when 317 then return command_317 # Change Parameters - when 318 then return command_318 # Change Skills - when 319 then return command_319 # Change Equipment - when 320 then return command_320 # Change Actor Name - when 321 then return command_321 # Change Actor Class - when 322 then return command_322 # Change Actor Graphic - when 331 then return command_331 # Change Enemy HP - when 332 then return command_332 # Change Enemy SP - when 333 then return command_333 # Change Enemy State - when 334 then return command_334 # Enemy Recover All - when 335 then return command_335 # Enemy Appearance - when 336 then return command_336 # Enemy Transform - when 337 then return command_337 # Show Battle Animation - when 338 then return command_338 # Deal Damage - when 339 then return command_339 # Force Action - when 340 then return command_340 # Abort Battle - when 351 then return command_351 # Call Menu Screen - when 352 then return command_352 # Call Save Screen - when 353 then return command_353 # Game Over - when 354 then return command_354 # Return to Title Screen - when 355 then return command_355 # Script - else return true # Other - end - end - - def command_dummy - return true - end - #----------------------------------------------------------------------------- - # * End Event - #----------------------------------------------------------------------------- - def command_end - # Clear list of event commands - @list = nil - # If main map event and event ID are valid - if @main and @event_id > 0 && $game_map.events[@event_id] - # Unlock event - $game_map.events[@event_id].unlock - end - end - #----------------------------------------------------------------------------- - # * Command Skip - #----------------------------------------------------------------------------- - def command_skip - # Get indent - indent = @list[@index].indent - # Loop - loop do - # If next event command is at the same level as indent - if @list[@index+1].indent == indent - # Continue - return true - end - # Advance index - @index += 1 - end - end - #----------------------------------------------------------------------------- # * Get Character # parameter : parameter #----------------------------------------------------------------------------- - def get_character(parameter) - # Branch by parameter + def get_character(parameter = 0) case parameter when -1 # player return $game_player when 0 # this event events = $game_map.events - return events == nil ? nil : events[@event_id] + return (events) ? events[@event_id] : nil else # specific event events = $game_map.events - return events == nil ? nil : events[parameter] + return (events) ? events[parameter] : nil end end - #----------------------------------------------------------------------------- - # * Calculate Operated Value - # operation : operation - # operand_type : operand type (0: invariable 1: variable) - # operand : operand (number or variable ID) - #----------------------------------------------------------------------------- - def operate_value(operation, operand_type, operand) - # Get operand - if operand_type == 0 - value = operand - else - value = $game_variables[operand] - end - # Reverse sign of integer if operation is [decrease] - if operation == 1 - value = -value - end - # Return value - return value + + def get_player + return get_character(-1) + end + + def get_self + return get_character(0) + end + + def get_event(parameter) + return get_character(parameter) end #----------------------------------------------------------------------------- - # * Show Text + # * Freezes all events on the map (for use at the beginning of common events) #----------------------------------------------------------------------------- - def command_101 - # If other text has been set to message_text - if $game_temp.message_text != nil - # End - return false - end - # Set message end waiting flag and callback - @message_waiting = true - $game_temp.message_proc = Proc.new { @message_waiting = false } - # Set message text on first line - $game_temp.message_text = @list[@index].parameters[0] + "\n" - line_count = 1 - # Loop + def pbGlobalLock + $game_map.events.values.each { |event| event.minilock } + end + #----------------------------------------------------------------------------- + # * Unfreezes all events on the map (for use at the end of common events) + #----------------------------------------------------------------------------- + def pbGlobalUnlock + $game_map.events.values.each { |event| event.unlock } + end + #----------------------------------------------------------------------------- + # * Gets the next index in the interpreter, ignoring certain commands between messages + #----------------------------------------------------------------------------- + def pbNextIndex(index) + return -1 if !@list || @list.length == 0 + i = index + 1 loop do - # If next event command text is on the second line or after - if @list[@index+1].code == 401 - # Add the second line or after to message_text - $game_temp.message_text += @list[@index+1].parameters[0] + "\n" - line_count += 1 - # If event command is not on the second line or after + return i if i >= @list.length - 1 + case @list[i].code + when 118, 108, 408 # Label, Comment + i += 1 + when 413 # Repeat Above + i = pbRepeatAbove(i) + when 113 # Break Loop + i = pbBreakLoop(i) + when 119 # Jump to Label + newI = pbJumpToLabel(i, @list[i].parameters[0]) + i = (newI > i) ? newI : i + 1 else - # If next event command is show choices - if @list[@index+1].code == 102 - # If choices fit on screen - if @list[@index+1].parameters[0].size <= 4 - line_count - # Advance index - @index += 1 - # Choices setup - $game_temp.choice_start = line_count - setup_choices(@list[@index].parameters) - end - # If next event command is input number - elsif @list[@index+1].code == 103 - # If number input window fits on screen - if line_count < 4 - # Advance index - @index += 1 - # Number input setup - $game_temp.num_input_start = line_count - $game_temp.num_input_variable_id = @list[@index].parameters[0] - $game_temp.num_input_digits_max = @list[@index].parameters[1] - end - end - # Continue - return true + return i end - # Advance index - @index += 1 end end - #----------------------------------------------------------------------------- - # * Show Choices - #----------------------------------------------------------------------------- - def command_102 - # If text has been set to message_text - if $game_temp.message_text != nil - # End - return false - end - # Set message end waiting flag and callback - @message_waiting = true - $game_temp.message_proc = Proc.new { @message_waiting = false } - # Choices setup - $game_temp.message_text = "" - $game_temp.choice_start = 0 - setup_choices(@parameters) - # Continue - return true - end - #----------------------------------------------------------------------------- - # * When [**] - #----------------------------------------------------------------------------- - def command_402 - # If fitting choices are selected - if @branch[@list[@index].indent] == @parameters[0] - # Delete branch data - @branch.delete(@list[@index].indent) - # Continue - return true - end - # If it doesn't meet the condition: command skip - return command_skip - end - #----------------------------------------------------------------------------- - # * When Cancel - #----------------------------------------------------------------------------- - def command_403 - # If choices are cancelled - if @branch[@list[@index].indent] == 4 - # Delete branch data - @branch.delete(@list[@index].indent) - # Continue - return true - end - # If it doen't meet the condition: command skip - return command_skip - end - #----------------------------------------------------------------------------- - # * Input Number - #----------------------------------------------------------------------------- - def command_103 - # If text has been set to message_text - if $game_temp.message_text != nil - # End - return false - end - # Set message end waiting flag and callback - @message_waiting = true - $game_temp.message_proc = Proc.new { @message_waiting = false } - # Number input setup - $game_temp.message_text = "" - $game_temp.num_input_start = 0 - $game_temp.num_input_variable_id = @parameters[0] - $game_temp.num_input_digits_max = @parameters[1] - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Change Text Options - #----------------------------------------------------------------------------- - def command_104 - # If message is showing - if $game_temp.message_window_showing - # End - return false - end - # Change each option - $game_system.message_position = @parameters[0] - $game_system.message_frame = @parameters[1] - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Button Input Processing - #----------------------------------------------------------------------------- - def command_105 - # Set variable ID for button input - @button_input_variable_id = @parameters[0] - # Advance index - @index += 1 - # End - return false - end - #----------------------------------------------------------------------------- - # * Wait - #----------------------------------------------------------------------------- - def command_106 - # Set wait count - @wait_count = @parameters[0] * Graphics.frame_rate/20 - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Conditional Branch - #----------------------------------------------------------------------------- - def command_111 - # Initialize local variable: result - result = false - case @parameters[0] - when 0 # switch - result = false - switchname=$data_system.switches[@parameters[1]] - if switchname && switchname[/^s\:/] - result = (eval($~.post_match) == (@parameters[2] == 0)) - else - result = ($game_switches[@parameters[1]] == (@parameters[2] == 0)) - end - when 1 # variable - value1 = $game_variables[@parameters[1]] - if @parameters[2] == 0 - value2 = @parameters[3] - else - value2 = $game_variables[@parameters[3]] - end - case @parameters[4] - when 0 # value1 is equal to value2 - result = (value1 == value2) - when 1 # value1 is greater than or equal to value2 - result = (value1 >= value2) - when 2 # value1 is less than or equal to value2 - result = (value1 <= value2) - when 3 # value1 is greater than value2 - result = (value1 > value2) - when 4 # value1 is less than value2 - result = (value1 < value2) - when 5 # value1 is not equal to value2 - result = (value1 != value2) - end - when 2 # self switch - if @event_id > 0 - key = [$game_map.map_id, @event_id, @parameters[1]] - if @parameters[2] == 0 - result = ($game_self_switches[key] == true) - else - result = ($game_self_switches[key] != true) - end - end - when 3 # timer - if $game_system.timer_working - sec = $game_system.timer / Graphics.frame_rate - if @parameters[2] == 0 - result = (sec >= @parameters[1]) - else - result = (sec <= @parameters[1]) - end - end - when 4, 5 # actor, enemy - when 6 # character - character = get_character(@parameters[1]) - if character != nil - result = (character.direction == @parameters[2]) - end - when 7 - if @parameters[2] == 0 - result = ($Trainer.money >= @parameters[1]) - else - result = ($Trainer.money <= @parameters[1]) - end - when 8, 9, 10 # item, weapon, armor - when 11 # button - result = (Input.press?(@parameters[1])) - when 12 # script - result = pbExecuteScript(@parameters[1]) - end - # Store determinant results in hash - @branch[@list[@index].indent] = result - # If determinant results are true - if @branch[@list[@index].indent] == true - # Delete branch data - @branch.delete(@list[@index].indent) - # Continue - return true - end - # If it doesn't meet the conditions: command skip - return command_skip - end - #----------------------------------------------------------------------------- - # * Else - #----------------------------------------------------------------------------- - def command_411 - # If determinant results are false - if @branch[@list[@index].indent] == false - # Delete branch data - @branch.delete(@list[@index].indent) - # Continue - return true - end - # If it doesn't meet the conditions: command skip - return command_skip - end - #----------------------------------------------------------------------------- - # * Loop - #----------------------------------------------------------------------------- - def command_112 - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Repeat Above - #----------------------------------------------------------------------------- - def command_413 - # Get indent - indent = @list[@index].indent - # Loop + + def pbRepeatAbove(index) + index = @list[index].indent loop do - # Return index - @index -= 1 - # If this event command is the same level as indent - if @list[@index].indent == indent - # Continue - return true - end + index -= 1 + return index + 1 if @list[index].indent == indent end end - #----------------------------------------------------------------------------- - # * Break Loop - #----------------------------------------------------------------------------- - def command_113 - # Get indent - indent = @list[@index].indent - # Copy index to temporary variables - temp_index = @index - # Loop + + def pbBreakLoop(index) + indent = @list[index].indent + temp_index = index loop do - # Advance index temp_index += 1 - # If a fitting loop was not found - if temp_index >= @list.size-1 - # Continue - return true - end - # If this event command is [repeat above] and indent is shallow - if @list[temp_index].code == 413 and @list[temp_index].indent < indent - # Update index - @index = temp_index - # Continue - return true - end + return index + 1 if temp_index >= @list.size - 1 + return temp_index + 1 if @list[temp_index].code == 413 && + @list[temp_index].indent < indent + end + end + + def pbJumpToLabel(index, label_name) + temp_index = 0 + loop do + return index + 1 if temp_index >= @list.size - 1 + return temp_index + 1 if @list[temp_index].code == 118 && + @list[temp_index].parameters[0] == label_name + temp_index += 1 end end #----------------------------------------------------------------------------- - # * Exit Event Processing + # * Various methods to be used in a script event command. #----------------------------------------------------------------------------- - def command_115 - # End event - command_end - # Continue - return true + # Helper function that shows a picture in a script. + def pbShowPicture(number, name, origin, x, y, zoomX = 100, zoomY = 100, opacity = 255, blendType = 0) + number = number + ($game_temp.in_battle ? 50 : 0) + $game_screen.pictures[number].show(name, origin, x, y, zoomX, zoomY, opacity, blendType) end - #----------------------------------------------------------------------------- - # * Erase Event - #----------------------------------------------------------------------------- - def command_116 - # If event ID is valid - if @event_id > 0 - # Erase event - $game_map.events[@event_id].erase if $game_map.events[@event_id] + + # Erases an event and adds it to the list of erased events so that + # it can stay erased when the game is saved then loaded again. + def pbEraseThisEvent + if $game_map.events[@event_id] + $game_map.events[@event_id].erase $PokemonMap.addErasedEvent(@event_id) if $PokemonMap end - # Advance index @index += 1 - # End - return false - end - #----------------------------------------------------------------------------- - # * Call Common Event - #----------------------------------------------------------------------------- - def command_117 - # Get common event - common_event = $data_common_events[@parameters[0]] - # If common event is valid - if common_event != nil - # Make child interpreter - @child_interpreter = Interpreter.new(@depth + 1) - @child_interpreter.setup(common_event.list, @event_id) - end - # Continue return true end - #----------------------------------------------------------------------------- - # * Label - #----------------------------------------------------------------------------- - def command_118 - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Jump to Label - #----------------------------------------------------------------------------- - def command_119 - # Get label name - label_name = @parameters[0] - # Initialize temporary variables - temp_index = 0 - # Loop - loop do - # If a fitting label was not found - if temp_index >= @list.size-1 - # Continue - return true - end - # If this event command is a designated label name - if @list[temp_index].code == 118 and - @list[temp_index].parameters[0] == label_name - # Update index - @index = temp_index - # Continue - return true - end - # Advance index - temp_index += 1 - end - end - #----------------------------------------------------------------------------- - # * Control Switches - #----------------------------------------------------------------------------- - def command_121 - shouldRefresh = false - # Loop for group control - for i in @parameters[0] .. @parameters[1] - next if $game_switches[i] == (@parameters[2] == 0) - # Change switch - $game_switches[i] = (@parameters[2] == 0) - shouldRefresh = true - end - # Refresh map - $game_map.need_refresh = true if shouldRefresh - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Control Variables - #----------------------------------------------------------------------------- - def command_122 - # Initialize value - value = 0 - # Branch with operand - case @parameters[3] - when 0 # invariable (fixed value) - value = @parameters[4] - when 1 # variable - value = $game_variables[@parameters[4]] - when 2 # random number - value = @parameters[4] + rand(@parameters[5] - @parameters[4] + 1) -# when 3, 4, 5 # item, actor, enemy - when 6 # character - character = get_character(@parameters[4]) - if character != nil - case @parameters[5] - when 0 then value = character.x # x-coordinate - when 1 then value = character.y # y-coordinate - when 2 then value = character.direction # direction - when 3 then value = character.screen_x # screen x-coordinate - when 4 then value = character.screen_y # screen y-coordinate - when 5 then value = character.terrain_tag # terrain tag - end - end - when 7 # other - case @parameters[4] - when 0 then value = $game_map.map_id # map ID -# when 1, 3 # number of party members, steps - when 2 then value = $Trainer.money # gold - when 4 then value = Graphics.frame_count / Graphics.frame_rate # play time - when 5 then value = $game_system.timer / Graphics.frame_rate # timer - when 6 then value = $game_system.save_count # save count + + # Runs a common event. + def pbCommonEvent(id) + common_event = $data_common_events[id] + return if !common_event + if $game_temp.in_battle + $game_system.battle_interpreter.setup(common_event.list, 0) + else + interp = Interpreter.new + interp.setup(common_event.list, 0) + loop do + Graphics.update + Input.update + interp.update + pbUpdateSceneMap + break if !interp.running? end end - # Loop for group control - for i in @parameters[0] .. @parameters[1] - # Branch with control - case @parameters[2] - when 0 # substitute - next if $game_variables[i] == value - $game_variables[i] = value - when 1 # add - next if $game_variables[i] >= 99999999 - $game_variables[i] += value - when 2 # subtract - next if $game_variables[i] <= -99999999 - $game_variables[i] -= value - when 3 # multiply - next if value == 1 - $game_variables[i] *= value - when 4 # divide - next if value == 1 || value == 0 - $game_variables[i] /= value - when 5 # remainder - next if value == 1 || value == 0 - $game_variables[i] %= value - end - # Maximum limit check - $game_variables[i] = 99999999 if $game_variables[i] > 99999999 - # Minimum limit check - $game_variables[i] = -99999999 if $game_variables[i] < -99999999 - # Refresh map + end + + # Sets another event's self switch (eg. pbSetSelfSwitch(20, "A", true) ). + def pbSetSelfSwitch(eventid, switch_name, value, mapid = -1) + mapid = @map_id if mapid < 0 + old_value = $game_self_switches[[mapid, eventid, switch_name]] + $game_self_switches[[mapid, eventid, switch_name]] = value + if value != old_value && $MapFactory.hasMap?(mapid) + $MapFactory.getMap(mapid, false).need_refresh = true + end + end + + def tsOff?(c) + return get_self.tsOff?(c) + end + alias isTempSwitchOff? tsOff? + + def tsOn?(c) + return get_self.tsOn?(c) + end + alias isTempSwitchOn? tsOn? + + def setTempSwitchOn(c) + get_self.setTempSwitchOn(c) + end + + def setTempSwitchOff(c) + get_self.setTempSwitchOff(c) + end + + def getVariable(*arg) + if arg.length == 0 + return nil if !$PokemonGlobal.eventvars + return $PokemonGlobal.eventvars[[@map_id, @event_id]] + else + return $game_variables[arg[0]] + end + end + + def setVariable(*arg) + if arg.length == 1 + $PokemonGlobal.eventvars = {} if !$PokemonGlobal.eventvars + $PokemonGlobal.eventvars[[@map_id, @event_id]] = arg[0] + else + $game_variables[arg[0]] = arg[1] $game_map.need_refresh = true end - # Continue - return true end - #----------------------------------------------------------------------------- - # * Control Self Switch - #----------------------------------------------------------------------------- - def command_123 - # If event ID is valid - if @event_id > 0 - # Make a self switch key - key = [$game_map.map_id, @event_id, @parameters[0]] - newValue = (@parameters[1] == 0) - if $game_self_switches[key] != newValue - # Change self switches - $game_self_switches[key] = newValue - # Refresh map - $game_map.need_refresh = true + + def pbGetPokemon(id) + return $Trainer.party[pbGet(id)] + end + + def pbSetEventTime(*arg) + $PokemonGlobal.eventvars = {} if !$PokemonGlobal.eventvars + time = pbGetTimeNow + time = time.to_i + pbSetSelfSwitch(@event_id, "A", true) + $PokemonGlobal.eventvars[[@map_id, @event_id]] = time + for otherevt in arg + pbSetSelfSwitch(otherevt, "A", true) + $PokemonGlobal.eventvars[[@map_id, otherevt]] = time + end + end + + # Used in boulder events. Allows an event to be pushed. + def pbPushThisEvent + event = get_self + old_x = event.x + old_y = event.y + # Apply strict version of passable, which treats tiles that are passable + # only from certain directions as fully impassible + return if !event.passableStrict?(event.x, event.y, $game_player.direction) + case $game_player.direction + when 2 then event.move_down + when 4 then event.move_left + when 6 then event.move_right + when 8 then event.move_up + end + $PokemonMap.addMovedEvent(@event_id) if $PokemonMap + if old_x != event.x || old_y != event.y + $game_player.lock + loop do + Graphics.update + Input.update + pbUpdateSceneMap + break if !event.moving? end + $game_player.unlock end - # Continue - return true end - #----------------------------------------------------------------------------- - # * Control Timer - #----------------------------------------------------------------------------- - def command_124 - # If started - if @parameters[0] == 0 - $game_system.timer = @parameters[1] * Graphics.frame_rate - $game_system.timer_working = true - end - # If stopped - $game_system.timer_working = false if @parameters[0] == 1 - # Continue + + def pbPushThisBoulder + pbPushThisEvent if $PokemonMap.strengthUsed return true end - def command_125; command_dummy; end # Change Gold - def command_126; command_dummy; end # Change Items - def command_127; command_dummy; end # Change Weapons - def command_128; command_dummy; end # Change Armor - def command_129; command_dummy; end # Change Party Member - #----------------------------------------------------------------------------- - # * Change Windowskin - #----------------------------------------------------------------------------- - def command_131 - # Change windowskin file name - for i in 0...$SpeechFrames.length - if $SpeechFrames[i]==@parameters[0] - $PokemonSystem.textskin=i - MessageConfig.pbSetSpeechFrame("Graphics/Windowskins/"+$SpeechFrames[i]) - return true - end - end - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Change Battle BGM - #----------------------------------------------------------------------------- - def command_132 - # Change battle BGM - $game_system.battle_bgm = @parameters[0] - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Change Battle End ME - #----------------------------------------------------------------------------- - def command_133 - # Change battle end ME - $game_system.battle_end_me = @parameters[0] - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Change Save Access - #----------------------------------------------------------------------------- - def command_134 - # Change save access flag - $game_system.save_disabled = (@parameters[0] == 0) - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Change Menu Access - #----------------------------------------------------------------------------- - def command_135 - # Change menu access flag - $game_system.menu_disabled = (@parameters[0] == 0) - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Change Encounter - #----------------------------------------------------------------------------- - def command_136 - # Change encounter flag - $game_system.encounter_disabled = (@parameters[0] == 0) - # Make encounter count - $game_player.make_encounter_count - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Transfer Player - #----------------------------------------------------------------------------- - def command_201 - # If in battle - if $game_temp.in_battle - # Continue - return true - end - # If transferring player, showing message, or processing transition - if $game_temp.player_transferring or - $game_temp.message_window_showing or - $game_temp.transition_processing - # End - return false - end - # Set transferring player flag - $game_temp.player_transferring = true - # If appointment method is [direct appointment] - if @parameters[0] == 0 - # Set player move destination - $game_temp.player_new_map_id = @parameters[1] - $game_temp.player_new_x = @parameters[2] - $game_temp.player_new_y = @parameters[3] - $game_temp.player_new_direction = @parameters[4] - # If appointment method is [appoint with variables] - else - # Set player move destination - $game_temp.player_new_map_id = $game_variables[@parameters[1]] - $game_temp.player_new_x = $game_variables[@parameters[2]] - $game_temp.player_new_y = $game_variables[@parameters[3]] - $game_temp.player_new_direction = @parameters[4] - end - # Advance index + def pbSmashThisEvent + event = get_self + pbSmashEvent(event) if event @index += 1 - # If fade is set - if @parameters[5] == 0 - # Prepare for transition - Graphics.freeze - # Set transition processing flag - $game_temp.transition_processing = true - $game_temp.transition_name = "" - end - # End - return false - end - #----------------------------------------------------------------------------- - # * Set Event Location - #----------------------------------------------------------------------------- - def command_202 - # If in battle - if $game_temp.in_battle - # Continue - return true - end - # Get character - character = get_character(@parameters[0]) - # If no character exists - if character == nil - # Continue - return true - end - # If appointment method is [direct appointment] - if @parameters[1] == 0 - # Set character position - character.moveto(@parameters[2], @parameters[3]) - # If appointment method is [appoint with variables] - elsif @parameters[1] == 1 - # Set character position - character.moveto($game_variables[@parameters[2]], - $game_variables[@parameters[3]]) - # If appointment method is [exchange with another event] - else - old_x = character.x - old_y = character.y - character2 = get_character(@parameters[2]) - if character2 != nil - character.moveto(character2.x, character2.y) - character2.moveto(old_x, old_y) - end - end - # Set character direction - case @parameters[4] - when 2 then character.turn_down - when 4 then character.turn_left - when 6 then character.turn_right - when 8 then character.turn_up - end - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Scroll Map - #----------------------------------------------------------------------------- - def command_203 - # If in battle - if $game_temp.in_battle - # Continue - return true - end - # If already scrolling - if $game_map.scrolling? - # End - return false - end - # Start scroll - $game_map.start_scroll(@parameters[0], @parameters[1], @parameters[2]) - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Change Map Settings - #----------------------------------------------------------------------------- - def command_204 - case @parameters[0] - when 0 # panorama - $game_map.panorama_name = @parameters[1] - $game_map.panorama_hue = @parameters[2] - when 1 # fog - $game_map.fog_name = @parameters[1] - $game_map.fog_hue = @parameters[2] - $game_map.fog_opacity = @parameters[3] - $game_map.fog_blend_type = @parameters[4] - $game_map.fog_zoom = @parameters[5] - $game_map.fog_sx = @parameters[6] - $game_map.fog_sy = @parameters[7] - when 2 # battleback - $game_map.battleback_name = @parameters[1] - $game_temp.battleback_name = @parameters[1] - end - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Change Fog Color Tone - #----------------------------------------------------------------------------- - def command_205 - # Start color tone change - $game_map.start_fog_tone_change(@parameters[0], @parameters[1] * Graphics.frame_rate / 20) - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Change Fog Opacity - #----------------------------------------------------------------------------- - def command_206 - # Start opacity level change - $game_map.start_fog_opacity_change(@parameters[0], @parameters[1] * Graphics.frame_rate / 20) - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Show Animation - #----------------------------------------------------------------------------- - def command_207 - # Get character - character = get_character(@parameters[0]) - # If no character exists - if character == nil - # Continue - return true - end - # Set animation ID - character.animation_id = @parameters[1] - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Change Transparent Flag - #----------------------------------------------------------------------------- - def command_208 - # Change player transparent flag - $game_player.transparent = (@parameters[0] == 0) - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Set Move Route - #----------------------------------------------------------------------------- - def command_209 - # Get character - character = get_character(@parameters[0]) - # If no character exists - if character == nil - # Continue - return true - end - # Force move route - character.force_move_route(@parameters[1]) - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Wait for Move's Completion - #----------------------------------------------------------------------------- - def command_210 - # If not in battle - unless $game_temp.in_battle - # Set move route completion waiting flag - @move_route_waiting = true - end - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Prepare for Transition - #----------------------------------------------------------------------------- - def command_221 - # If showing message window - if $game_temp.message_window_showing - # End - return false - end - # Prepare for transition - Graphics.freeze - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Execute Transition - #----------------------------------------------------------------------------- - def command_222 - # If transition processing flag is already set - if $game_temp.transition_processing - # End - return false - end - # Set transition processing flag - $game_temp.transition_processing = true - $game_temp.transition_name = @parameters[0] - # Advance index - @index += 1 - # End - return false - end - #----------------------------------------------------------------------------- - # * Change Screen Color Tone - #----------------------------------------------------------------------------- - def command_223 - # Start changing color tone - $game_screen.start_tone_change(@parameters[0], @parameters[1] * Graphics.frame_rate / 20) - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Screen Flash - #----------------------------------------------------------------------------- - def command_224 - # Start flash - $game_screen.start_flash(@parameters[0], @parameters[1] * Graphics.frame_rate / 20) - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Screen Shake - #----------------------------------------------------------------------------- - def command_225 - # Start shake - $game_screen.start_shake(@parameters[0], @parameters[1], - @parameters[2] * Graphics.frame_rate / 20) - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Show Picture - #----------------------------------------------------------------------------- - def command_231 - # Get picture number - number = @parameters[0] + ($game_temp.in_battle ? 50 : 0) - # If appointment method is [direct appointment] - if @parameters[3] == 0 - x = @parameters[4] - y = @parameters[5] - # If appointment method is [appoint with variables] - else - x = $game_variables[@parameters[4]] - y = $game_variables[@parameters[5]] - end - # Show picture - $game_screen.pictures[number].show(@parameters[1], @parameters[2], - x, y, @parameters[6], @parameters[7], @parameters[8], @parameters[9]) - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Move Picture - #----------------------------------------------------------------------------- - def command_232 - # Get picture number - number = @parameters[0] + ($game_temp.in_battle ? 50 : 0) - # If appointment method is [direct appointment] - if @parameters[3] == 0 - x = @parameters[4] - y = @parameters[5] - # If appointment method is [appoint with variables] - else - x = $game_variables[@parameters[4]] - y = $game_variables[@parameters[5]] - end - # Move picture - $game_screen.pictures[number].move(@parameters[1] * Graphics.frame_rate / 20, - @parameters[2], x, y, - @parameters[6], @parameters[7], @parameters[8], @parameters[9]) - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Rotate Picture - #----------------------------------------------------------------------------- - def command_233 - # Get picture number - number = @parameters[0] + ($game_temp.in_battle ? 50 : 0) - # Set rotation speed - $game_screen.pictures[number].rotate(@parameters[1]) - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Change Picture Color Tone - #----------------------------------------------------------------------------- - def command_234 - # Get picture number - number = @parameters[0] + ($game_temp.in_battle ? 50 : 0) - # Start changing color tone - $game_screen.pictures[number].start_tone_change(@parameters[1], - @parameters[2] * Graphics.frame_rate / 20) - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Erase Picture - #----------------------------------------------------------------------------- - def command_235 - # Get picture number - number = @parameters[0] + ($game_temp.in_battle ? 50 : 0) - # Erase picture - $game_screen.pictures[number].erase - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Set Weather Effects - #----------------------------------------------------------------------------- - def command_236 - # Set Weather Effects - $game_screen.weather(@parameters[0], @parameters[1], @parameters[2]) - # Continue return true end - def command_247 - # Memorize BGM/BGS - $game_system.bgm_memorize - $game_system.bgs_memorize - # Continue - return true - end - #----------------------------------------------------------------------------- - # * Restore BGM/BGS - #----------------------------------------------------------------------------- - def command_248 - # Restore BGM/BGS - $game_system.bgm_restore - $game_system.bgs_restore - # Continue + def pbTrainerIntro(symbol) + return true if $DEBUG && !GameData::TrainerType.exists?(symbol) + tr_type = GameData::TrainerType.get(symbol).id + pbGlobalLock + pbPlayTrainerIntroME(tr_type) return true end - def command_if(value) - if @branch[@list[@index].indent] == value - @branch.delete(@list[@index].indent) - return true - end - return command_skip + def pbTrainerEnd + pbGlobalUnlock + event = get_self + event.erase_route if event end - def command_301; command_dummy; end # Battle Processing - def command_601; command_if(0); end # If Win - def command_602; command_if(1); end # If Escape - def command_603; command_if(2); end # If Lose - def command_302; command_dummy; end # Shop Processing - def command_303; command_dummy; end # Name Processing - def command_311; command_dummy; end # Change HP - def command_312; command_dummy; end # Change SP - def command_313; command_dummy; end # Change State - def command_314; command_dummy; end # Recover All - def command_315; command_dummy; end # Change EXP - def command_316; command_dummy; end # Change Level - def command_317; command_dummy; end # Change Parameters - def command_318; command_dummy; end # Change Skills - def command_319; command_dummy; end # Change Equipment - def command_320; command_dummy; end # Change Actor Name - def command_321; command_dummy; end # Change Actor Class - def command_322; command_dummy; end # Change Actor Graphic - def command_331; command_dummy; end # Change Enemy HP - def command_332; command_dummy; end # Change Enemy SP - def command_333; command_dummy; end # Change Enemy State - def command_334; command_dummy; end # Enemy Recover All - def command_335; command_dummy; end # Enemy Appearance - def command_336; command_dummy; end # Enemy Transform - def command_337; command_dummy; end # Show Battle Animation - def command_338; command_dummy; end # Deal Damage - def command_339; command_dummy; end # Force Action - def command_340; command_dummy; end # Abort Battle - #----------------------------------------------------------------------------- - # * Call Menu Screen - #----------------------------------------------------------------------------- - def command_351 - # Set menu calling flag - $game_temp.menu_calling = true - # Advance index - @index += 1 - # End - return false - end - #----------------------------------------------------------------------------- - # * Call Save Screen - #----------------------------------------------------------------------------- - def command_352 - # Set save calling flag - $game_temp.save_calling = true - # Advance index - @index += 1 - # End - return false - end - #----------------------------------------------------------------------------- - # * Game Over - #----------------------------------------------------------------------------- - def command_353 - # Set game over flag - $game_temp.gameover = true - # End - return false - end - #----------------------------------------------------------------------------- - # * Return to Title Screen - #----------------------------------------------------------------------------- - def command_354 - # Set return to title screen flag - $game_temp.to_title = true - # End - return false - end - #----------------------------------------------------------------------------- - # * Script - #----------------------------------------------------------------------------- - def command_355 - script = @list[@index].parameters[0] + "\n" - loop do - if @list[@index+1].code == 655 || @list[@index+1].code == 355 - script += @list[@index+1].parameters[0] + "\n" - else - break - end - @index += 1 + def setPrice(item, buy_price = -1, sell_price = -1) + item = GameData::Item.get(item).id + $game_temp.mart_prices[item] = [-1, -1] if !$game_temp.mart_prices[item] + $game_temp.mart_prices[item][0] = buy_price if buy_price > 0 + if sell_price >= 0 # 0=can't sell + $game_temp.mart_prices[item][1] = sell_price * 2 + else + $game_temp.mart_prices[item][1] = buy_price if buy_price > 0 end - pbExecuteScript(script) - return true + end + + def setSellPrice(item, sell_price) + setPrice(item, -1, sell_price) end end diff --git a/Data/Scripts/006_Game processing/001b_Interpreter commands.rb b/Data/Scripts/006_Game processing/001b_Interpreter commands.rb new file mode 100644 index 000000000..868fb259d --- /dev/null +++ b/Data/Scripts/006_Game processing/001b_Interpreter commands.rb @@ -0,0 +1,1027 @@ +#=============================================================================== +# ** Interpreter +#------------------------------------------------------------------------------- +# This interpreter runs event commands. This class is used within the +# Game_System class and the Game_Event class. +#=============================================================================== +class Interpreter + #----------------------------------------------------------------------------- + # * Event Command Execution + #----------------------------------------------------------------------------- + def execute_command + # Reached end of list of commands + if @index >= @list.size - 1 + command_end + return true + end + # Make current command's parameters available for reference via @parameters + @parameters = @list[@index].parameters + # Branch by command code + case @list[@index].code + when 101 then return command_101 # Show Text + when 102 then return command_102 # Show Choices + when 402 then return command_402 # When [**] + when 403 then return command_403 # When Cancel + when 103 then return command_103 # Input Number + when 104 then return command_104 # Change Text Options + when 105 then return command_105 # Button Input Processing + when 106 then return command_106 # Wait + when 111 then return command_111 # Conditional Branch + when 411 then return command_411 # Else + when 112 then return command_112 # Loop + when 413 then return command_413 # Repeat Above + when 113 then return command_113 # Break Loop + when 115 then return command_115 # Exit Event Processing + when 116 then return command_116 # Erase Event + when 117 then return command_117 # Call Common Event + when 118 then return command_118 # Label + when 119 then return command_119 # Jump to Label + when 121 then return command_121 # Control Switches + when 122 then return command_122 # Control Variables + when 123 then return command_123 # Control Self Switch + when 124 then return command_124 # Control Timer + when 125 then return command_125 # Change Gold + when 126 then return command_126 # Change Items + when 127 then return command_127 # Change Weapons + when 128 then return command_128 # Change Armor + when 129 then return command_129 # Change Party Member + when 131 then return command_131 # Change Windowskin + when 132 then return command_132 # Change Battle BGM + when 133 then return command_133 # Change Battle End ME + when 134 then return command_134 # Change Save Access + when 135 then return command_135 # Change Menu Access + when 136 then return command_136 # Change Encounter + when 201 then return command_201 # Transfer Player + when 202 then return command_202 # Set Event Location + when 203 then return command_203 # Scroll Map + when 204 then return command_204 # Change Map Settings + when 205 then return command_205 # Change Fog Color Tone + when 206 then return command_206 # Change Fog Opacity + when 207 then return command_207 # Show Animation + when 208 then return command_208 # Change Transparent Flag + when 209 then return command_209 # Set Move Route + when 210 then return command_210 # Wait for Move's Completion + when 221 then return command_221 # Prepare for Transition + when 222 then return command_222 # Execute Transition + when 223 then return command_223 # Change Screen Color Tone + when 224 then return command_224 # Screen Flash + when 225 then return command_225 # Screen Shake + when 231 then return command_231 # Show Picture + when 232 then return command_232 # Move Picture + when 233 then return command_233 # Rotate Picture + when 234 then return command_234 # Change Picture Color Tone + when 235 then return command_235 # Erase Picture + when 236 then return command_236 # Set Weather Effects + when 241 then return command_241 # Play BGM + when 242 then return command_242 # Fade Out BGM + when 245 then return command_245 # Play BGS + when 246 then return command_246 # Fade Out BGS + when 247 then return command_247 # Memorize BGM/BGS + when 248 then return command_248 # Restore BGM/BGS + when 249 then return command_249 # Play ME + when 250 then return command_250 # Play SE + when 251 then return command_251 # Stop SE + when 301 then return command_301 # Battle Processing + when 601 then return command_601 # If Win + when 602 then return command_602 # If Escape + when 603 then return command_603 # If Lose + when 302 then return command_302 # Shop Processing + when 303 then return command_303 # Name Input Processing + when 311 then return command_311 # Change HP + when 312 then return command_312 # Change SP + when 313 then return command_313 # Change State + when 314 then return command_314 # Recover All + when 315 then return command_315 # Change EXP + when 316 then return command_316 # Change Level + when 317 then return command_317 # Change Parameters + when 318 then return command_318 # Change Skills + when 319 then return command_319 # Change Equipment + when 320 then return command_320 # Change Actor Name + when 321 then return command_321 # Change Actor Class + when 322 then return command_322 # Change Actor Graphic + when 331 then return command_331 # Change Enemy HP + when 332 then return command_332 # Change Enemy SP + when 333 then return command_333 # Change Enemy State + when 334 then return command_334 # Enemy Recover All + when 335 then return command_335 # Enemy Appearance + when 336 then return command_336 # Enemy Transform + when 337 then return command_337 # Show Battle Animation + when 338 then return command_338 # Deal Damage + when 339 then return command_339 # Force Action + when 340 then return command_340 # Abort Battle + when 351 then return command_351 # Call Menu Screen + when 352 then return command_352 # Call Save Screen + when 353 then return command_353 # Game Over + when 354 then return command_354 # Return to Title Screen + when 355 then return command_355 # Script + else return true # Other + end + end + + def command_dummy + return true + end + #----------------------------------------------------------------------------- + # * End Event + #----------------------------------------------------------------------------- + def command_end + @list = nil + # If main map event and event ID are valid, unlock event + if @main and @event_id > 0 && $game_map.events[@event_id] + $game_map.events[@event_id].unlock + end + end + #----------------------------------------------------------------------------- + # * Command Skip + #----------------------------------------------------------------------------- + def command_skip + indent = @list[@index].indent + loop do + return true if @list[@index + 1].indent == indent + @index += 1 + end + end + #----------------------------------------------------------------------------- + # * Command If + #----------------------------------------------------------------------------- + def command_if(value) + if @branch[@list[@index].indent] == value + @branch.delete(@list[@index].indent) + return true + end + return command_skip + end + #----------------------------------------------------------------------------- + # * Show Text + #----------------------------------------------------------------------------- + def command_101 + return false if $game_temp.message_window_showing + message = @list[@index].parameters[0] + message_end = "" + commands = nil + number_input_variable = nil + number_input_max_digits = nil + # Check the next command(s) for things to add on to this text + loop do + next_index = pbNextIndex(@index) + case @list[next_index].code + when 401 # Continuation of 101 Show Text + text = @list[next_index].parameters[0] + message += " " if text != "" && message[message.length - 1, 1] != " " + message += text + @index = next_index + next + when 101 # Show Text + message_end = "\1" + when 102 # Show Choices + commands = @list[next_index].parameters + @index = next_index + when 103 # Input Number + number_input_variable = @list[next_index].parameters[0] + number_input_max_digits = @list[next_index].parameters[1] + @index = next_index + end + break + end + # Translate the text + message = _MAPINTL($game_map.map_id, message) + # Display the text, with commands/number choosing if appropriate + @message_waiting = true # Lets parallel process events work while a message is displayed + if commands + cmd_texts = [] + for cmd in commands[0] + cmd_texts.push(_MAPINTL($game_map.map_id, cmd)) + end + command = pbMessage(message + message_end, cmd_texts, commands[1]) + @branch[@list[@index].indent] = command + elsif number_input_variable + params = ChooseNumberParams.new + params.setMaxDigits(number_input_max_digits) + params.setDefaultValue($game_variables[number_input_variable]) + $game_variables[number_input_variable] = pbMessageChooseNumber(message + message_end, params) + $game_map.need_refresh = true if $game_map + else + pbMessage(message + message_end) + end + @message_waiting = false + return true + end + #----------------------------------------------------------------------------- + # * Show Choices + #----------------------------------------------------------------------------- + def command_102 + @message_waiting = true + command = pbShowCommands(nil, @list[@index].parameters[0], @list[@index].parameters[1]) + @message_waiting = false + @branch[@list[@index].indent] = command + Input.update # Must call Input.update again to avoid extra triggers + return true + end + #----------------------------------------------------------------------------- + # * When [**] + #----------------------------------------------------------------------------- + def command_402 + if @branch[@list[@index].indent] == @parameters[0] + @branch.delete(@list[@index].indent) + return true + end + return command_skip + end + #----------------------------------------------------------------------------- + # * When Cancel + #----------------------------------------------------------------------------- + def command_403 + if @branch[@list[@index].indent] == 4 + @branch.delete(@list[@index].indent) + return true + end + return command_skip + end + #----------------------------------------------------------------------------- + # * Input Number + #----------------------------------------------------------------------------- + def command_103 + @message_waiting = true + variable_number = @list[@index].parameters[0] + params = ChooseNumberParams.new + params.setMaxDigits(@list[@index].parameters[1]) + params.setDefaultValue($game_variables[variable_number]) + $game_variables[variable_number] = pbChooseNumber(nil, params) + $game_map.need_refresh = true if $game_map + @message_waiting = false + return true + end + #----------------------------------------------------------------------------- + # * Change Text Options + #----------------------------------------------------------------------------- + def command_104 + return false if $game_temp.message_window_showing + $game_system.message_position = @parameters[0] + $game_system.message_frame = @parameters[1] + return true + end + #----------------------------------------------------------------------------- + # * Button Input Processing + #----------------------------------------------------------------------------- + def pbButtonInputProcessing(variable_number = 0, timeout_frames = 0) + ret = 0 + timer = timeout_frames * Graphics.frame_rate / 20 + loop do + Graphics.update + Input.update + pbUpdateSceneMap + # Check for input and break if there is one + for i in 1..18 + ret = i if Input.trigger?(i) + end + break if ret != 0 + # Count down the timer and break if it runs out + if timeout_frames > 0 + timer -= 1 + break if timer <= 0 + end + end + Input.update + if variable_number && variable_number > 0 + $game_variables[variable_number] = ret + $game_map.need_refresh = true if $game_map + end + return ret + end + + def command_105 + return false if @buttonInput + @buttonInput = true + pbButtonInputProcessing(@list[@index].parameters[0]) + @buttonInput = false + @index += 1 + return true + end + #----------------------------------------------------------------------------- + # * Wait + #----------------------------------------------------------------------------- + def command_106 + @wait_count = @parameters[0] * Graphics.frame_rate / 20 + return true + end + #----------------------------------------------------------------------------- + # * Conditional Branch + #----------------------------------------------------------------------------- + def command_111 + result = false + case @parameters[0] + when 0 # switch + switch_name = $data_system.switches[@parameters[1]] + if switch_name && switch_name[/^s\:/] + result = (eval($~.post_match) == (@parameters[2] == 0)) + else + result = ($game_switches[@parameters[1]] == (@parameters[2] == 0)) + end + when 1 # variable + value1 = $game_variables[@parameters[1]] + value2 = (@parameters[2] == 0) ? @parameters[3] : $game_variables[@parameters[3]] + case @parameters[4] + when 0 then result = (value1 == value2) + when 1 then result = (value1 >= value2) + when 2 then result = (value1 <= value2) + when 3 then result = (value1 > value2) + when 4 then result = (value1 < value2) + when 5 then result = (value1 != value2) + end + when 2 # self switch + if @event_id > 0 + key = [$game_map.map_id, @event_id, @parameters[1]] + result = ($game_self_switches[key] == (@parameters[2] == 0)) + end + when 3 # timer + if $game_system.timer_working + sec = $game_system.timer / Graphics.frame_rate + result = (@parameters[2] == 0) ? (sec >= @parameters[1]) : (sec <= @parameters[1]) + end +# when 4, 5 # actor, enemy + when 6 # character + character = get_character(@parameters[1]) + result = (character.direction == @parameters[2]) if character + when 7 # gold + gold = $Trainer.money + result = (@parameters[2] == 0) ? (gold >= @parameters[1]) : (gold <= @parameters[1]) +# when 8, 9, 10 # item, weapon, armor + when 11 # button + result = Input.press?(@parameters[1]) + when 12 # script + result = execute_script(@parameters[1]) + end + # Store result in hash + @branch[@list[@index].indent] = result + if @branch[@list[@index].indent] + @branch.delete(@list[@index].indent) + return true + end + return command_skip + end + #----------------------------------------------------------------------------- + # * Else + #----------------------------------------------------------------------------- + def command_411 + if !@branch[@list[@index].indent] + @branch.delete(@list[@index].indent) + return true + end + return command_skip + end + #----------------------------------------------------------------------------- + # * Loop + #----------------------------------------------------------------------------- + def command_112 + return true + end + #----------------------------------------------------------------------------- + # * Repeat Above + #----------------------------------------------------------------------------- + def command_413 + indent = @list[@index].indent + loop do + @index -= 1 + return true if @list[@index].indent == indent + end + end + #----------------------------------------------------------------------------- + # * Break Loop + #----------------------------------------------------------------------------- + def command_113 + indent = @list[@index].indent + temp_index = @index + loop do + temp_index += 1 + return true if temp_index >= @list.size - 1 # Reached end of commands + # Skip ahead to after the [Repeat Above] end of the current loop + if @list[temp_index].code == 413 and @list[temp_index].indent < indent + @index = temp_index + return true + end + end + end + #----------------------------------------------------------------------------- + # * Exit Event Processing + #----------------------------------------------------------------------------- + def command_115 + command_end + return true + end + #----------------------------------------------------------------------------- + # * Erase Event + #----------------------------------------------------------------------------- + def command_116 + if @event_id > 0 + $game_map.events[@event_id].erase if $game_map.events[@event_id] + $PokemonMap.addErasedEvent(@event_id) if $PokemonMap + end + @index += 1 + return false + end + #----------------------------------------------------------------------------- + # * Call Common Event + #----------------------------------------------------------------------------- + def command_117 + common_event = $data_common_events[@parameters[0]] + if common_event + @child_interpreter = Interpreter.new(@depth + 1) + @child_interpreter.setup(common_event.list, @event_id) + end + return true + end + #----------------------------------------------------------------------------- + # * Label + #----------------------------------------------------------------------------- + def command_118 + return true + end + #----------------------------------------------------------------------------- + # * Jump to Label + #----------------------------------------------------------------------------- + def command_119 + label_name = @parameters[0] + temp_index = 0 + loop do + return true if temp_index >= @list.size - 1 # Reached end of commands + # Check whether this command is a label with the desired name + if @list[temp_index].code == 118 && + @list[temp_index].parameters[0] == label_name + @index = temp_index + return true + end + # Command isn't the desired label, increment temp_index and keep looking + temp_index += 1 + end + end + #----------------------------------------------------------------------------- + # * Control Switches + #----------------------------------------------------------------------------- + def command_121 + should_refresh = false + for i in @parameters[0]..@parameters[1] + next if $game_switches[i] == (@parameters[2] == 0) + $game_switches[i] = (@parameters[2] == 0) + should_refresh = true + end + # Refresh map + $game_map.need_refresh = true if should_refresh + return true + end + #----------------------------------------------------------------------------- + # * Control Variables + #----------------------------------------------------------------------------- + def command_122 + value = 0 + case @parameters[3] + when 0 # invariable (fixed value) + value = @parameters[4] + when 1 # variable + value = $game_variables[@parameters[4]] + when 2 # random number + value = @parameters[4] + rand(@parameters[5] - @parameters[4] + 1) +# when 3, 4, 5 # item, actor, enemy + when 6 # character + character = get_character(@parameters[4]) + if character + case @parameters[5] + when 0 then value = character.x # x-coordinate + when 1 then value = character.y # y-coordinate + when 2 then value = character.direction # direction + when 3 then value = character.screen_x # screen x-coordinate + when 4 then value = character.screen_y # screen y-coordinate + when 5 then value = character.terrain_tag # terrain tag + end + end + when 7 # other + case @parameters[4] + when 0 then value = $game_map.map_id # map ID + when 1 then value = $Trainer.pokemonParty.length # party members + when 2 then value = $Trainer.money # gold +# when 3 # steps + when 4 then value = Graphics.frame_count / Graphics.frame_rate # play time + when 5 then value = $game_system.timer / Graphics.frame_rate # timer + when 6 then value = $game_system.save_count # save count + end + end + # Apply value and operation to all specified game variables + for i in @parameters[0]..@parameters[1] + case @parameters[2] + when 0 # set + next if $game_variables[i] == value + $game_variables[i] = value + when 1 # add + next if $game_variables[i] >= 99999999 + $game_variables[i] += value + when 2 # subtract + next if $game_variables[i] <= -99999999 + $game_variables[i] -= value + when 3 # multiply + next if value == 1 + $game_variables[i] *= value + when 4 # divide + next if value == 1 || value == 0 + $game_variables[i] /= value + when 5 # remainder + next if value == 1 || value == 0 + $game_variables[i] %= value + end + $game_variables[i] = 99999999 if $game_variables[i] > 99999999 + $game_variables[i] = -99999999 if $game_variables[i] < -99999999 + $game_map.need_refresh = true + end + return true + end + #----------------------------------------------------------------------------- + # * Control Self Switch + #----------------------------------------------------------------------------- + def command_123 + if @event_id > 0 + new_value = (@parameters[1] == 0) + key = [$game_map.map_id, @event_id, @parameters[0]] + if $game_self_switches[key] != new_value + $game_self_switches[key] = new_value + $game_map.need_refresh = true + end + end + return true + end + #----------------------------------------------------------------------------- + # * Control Timer + #----------------------------------------------------------------------------- + def command_124 + $game_system.timer_working = (@parameters[0] == 0) + $game_system.timer = @parameters[1] * Graphics.frame_rate if @parameters[0] == 0 + return true + end + #----------------------------------------------------------------------------- + # * Change Gold + #----------------------------------------------------------------------------- + def command_125 + value = (@parameters[1] == 0) ? @parameters[2] : $game_variables[@parameters[2]] + value = -value if @parameters[0] == 1 # Decrease + $Trainer.money += value + return true + end + + def command_126; command_dummy; end # Change Items + def command_127; command_dummy; end # Change Weapons + def command_128; command_dummy; end # Change Armor + def command_129; command_dummy; end # Change Party Member + #----------------------------------------------------------------------------- + # * Change Windowskin + #----------------------------------------------------------------------------- + def command_131 + for i in 0...$SpeechFrames.length + next if $SpeechFrames[i] != @parameters[0] + $PokemonSystem.textskin = i + MessageConfig.pbSetSpeechFrame("Graphics/Windowskins/" + $SpeechFrames[i]) + return true + end + return true + end + #----------------------------------------------------------------------------- + # * Change Battle BGM + #----------------------------------------------------------------------------- + def command_132 + ($PokemonGlobal.nextBattleBGM = @parameters[0]) ? @parameters[0].clone : nil + return true + end + #----------------------------------------------------------------------------- + # * Change Battle End ME + #----------------------------------------------------------------------------- + def command_133 + ($PokemonGlobal.nextBattleME = @parameters[0]) ? @parameters[0].clone : nil + return true + end + #----------------------------------------------------------------------------- + # * Change Save Access + #----------------------------------------------------------------------------- + def command_134 + $game_system.save_disabled = (@parameters[0] == 0) + return true + end + #----------------------------------------------------------------------------- + # * Change Menu Access + #----------------------------------------------------------------------------- + def command_135 + $game_system.menu_disabled = (@parameters[0] == 0) + return true + end + #----------------------------------------------------------------------------- + # * Change Encounter + #----------------------------------------------------------------------------- + def command_136 + $game_system.encounter_disabled = (@parameters[0] == 0) + $game_player.make_encounter_count + return true + end + #----------------------------------------------------------------------------- + # * Transfer Player + #----------------------------------------------------------------------------- + def command_201 + return true if $game_temp.in_battle + return false if $game_temp.player_transferring || + $game_temp.message_window_showing || + $game_temp.transition_processing + # Set up the transfer and the player's new coordinates + $game_temp.player_transferring = true + if @parameters[0] == 0 # Direct appointment + $game_temp.player_new_map_id = @parameters[1] + $game_temp.player_new_x = @parameters[2] + $game_temp.player_new_y = @parameters[3] + $game_temp.player_new_direction = @parameters[4] + else # Appoint with variables + $game_temp.player_new_map_id = $game_variables[@parameters[1]] + $game_temp.player_new_x = $game_variables[@parameters[2]] + $game_temp.player_new_y = $game_variables[@parameters[3]] + $game_temp.player_new_direction = @parameters[4] + end + @index += 1 + # If transition happens with a fade, do the fade + if @parameters[5] == 0 + Graphics.freeze + $game_temp.transition_processing = true + $game_temp.transition_name = "" + end + return false + end + #----------------------------------------------------------------------------- + # * Set Event Location + #----------------------------------------------------------------------------- + def command_202 + return true if $game_temp.in_battle + character = get_character(@parameters[0]) + return true if character.nil? + # Move the character + if @parameters[1] == 0 # Direct appointment + character.moveto(@parameters[2], @parameters[3]) + elsif @parameters[1] == 1 # Appoint with variables + character.moveto($game_variables[@parameters[2]], $game_variables[@parameters[3]]) + else # Exchange with another event + character2 = get_character(@parameters[2]) + if character2 + old_x = character.x + old_y = character.y + character.moveto(character2.x, character2.y) + character2.moveto(old_x, old_y) + end + end + # Set character's direction + case @parameters[4] + when 2 then character.turn_down + when 4 then character.turn_left + when 6 then character.turn_right + when 8 then character.turn_up + end + return true + end + #----------------------------------------------------------------------------- + # * Scroll Map + #----------------------------------------------------------------------------- + def command_203 + return true if $game_temp.in_battle + return false if $game_map.scrolling? + $game_map.start_scroll(@parameters[0], @parameters[1], @parameters[2]) + return true + end + #----------------------------------------------------------------------------- + # * Change Map Settings + #----------------------------------------------------------------------------- + def command_204 + case @parameters[0] + when 0 # panorama + $game_map.panorama_name = @parameters[1] + $game_map.panorama_hue = @parameters[2] + when 1 # fog + $game_map.fog_name = @parameters[1] + $game_map.fog_hue = @parameters[2] + $game_map.fog_opacity = @parameters[3] + $game_map.fog_blend_type = @parameters[4] + $game_map.fog_zoom = @parameters[5] + $game_map.fog_sx = @parameters[6] + $game_map.fog_sy = @parameters[7] + when 2 # battleback + $game_map.battleback_name = @parameters[1] + $game_temp.battleback_name = @parameters[1] + end + return true + end + #----------------------------------------------------------------------------- + # * Change Fog Color Tone + #----------------------------------------------------------------------------- + def command_205 + $game_map.start_fog_tone_change(@parameters[0], @parameters[1] * Graphics.frame_rate / 20) + return true + end + #----------------------------------------------------------------------------- + # * Change Fog Opacity + #----------------------------------------------------------------------------- + def command_206 + $game_map.start_fog_opacity_change(@parameters[0], @parameters[1] * Graphics.frame_rate / 20) + return true + end + #----------------------------------------------------------------------------- + # * Show Animation + #----------------------------------------------------------------------------- + def command_207 + character = get_character(@parameters[0]) + return true if character.nil? + character.animation_id = @parameters[1] + return true + end + #----------------------------------------------------------------------------- + # * Change Transparent Flag + #----------------------------------------------------------------------------- + def command_208 + $game_player.transparent = (@parameters[0] == 0) + return true + end + #----------------------------------------------------------------------------- + # * Set Move Route + #----------------------------------------------------------------------------- + def command_209 + character = get_character(@parameters[0]) + return true if character.nil? + character.force_move_route(@parameters[1]) + return true + end + #----------------------------------------------------------------------------- + # * Wait for Move's Completion + #----------------------------------------------------------------------------- + def command_210 + @move_route_waiting = true if !$game_temp.in_battle + return true + end + #----------------------------------------------------------------------------- + # * Prepare for Transition + #----------------------------------------------------------------------------- + def command_221 + return false if $game_temp.message_window_showing + Graphics.freeze + return true + end + #----------------------------------------------------------------------------- + # * Execute Transition + #----------------------------------------------------------------------------- + def command_222 + return false if $game_temp.transition_processing + $game_temp.transition_processing = true + $game_temp.transition_name = @parameters[0] + @index += 1 + return false + end + #----------------------------------------------------------------------------- + # * Change Screen Color Tone + #----------------------------------------------------------------------------- + def command_223 + $game_screen.start_tone_change(@parameters[0], @parameters[1] * Graphics.frame_rate / 20) + return true + end + #----------------------------------------------------------------------------- + # * Screen Flash + #----------------------------------------------------------------------------- + def command_224 + $game_screen.start_flash(@parameters[0], @parameters[1] * Graphics.frame_rate / 20) + return true + end + #----------------------------------------------------------------------------- + # * Screen Shake + #----------------------------------------------------------------------------- + def command_225 + $game_screen.start_shake(@parameters[0], @parameters[1], @parameters[2] * Graphics.frame_rate / 20) + return true + end + #----------------------------------------------------------------------------- + # * Show Picture + #----------------------------------------------------------------------------- + def command_231 + number = @parameters[0] + ($game_temp.in_battle ? 50 : 0) + if @parameters[3] == 0 # Direct appointment + x = @parameters[4] + y = @parameters[5] + else # Appoint with variables + x = $game_variables[@parameters[4]] + y = $game_variables[@parameters[5]] + end + $game_screen.pictures[number].show(@parameters[1], @parameters[2], + x, y, @parameters[6], @parameters[7], @parameters[8], @parameters[9]) + return true + end + #----------------------------------------------------------------------------- + # * Move Picture + #----------------------------------------------------------------------------- + def command_232 + number = @parameters[0] + ($game_temp.in_battle ? 50 : 0) + if @parameters[3] == 0 # Direct appointment + x = @parameters[4] + y = @parameters[5] + else # Appoint with variables + x = $game_variables[@parameters[4]] + y = $game_variables[@parameters[5]] + end + $game_screen.pictures[number].move(@parameters[1] * Graphics.frame_rate / 20, + @parameters[2], x, y, @parameters[6], @parameters[7], @parameters[8], @parameters[9]) + return true + end + #----------------------------------------------------------------------------- + # * Rotate Picture + #----------------------------------------------------------------------------- + def command_233 + number = @parameters[0] + ($game_temp.in_battle ? 50 : 0) + $game_screen.pictures[number].rotate(@parameters[1]) + return true + end + #----------------------------------------------------------------------------- + # * Change Picture Color Tone + #----------------------------------------------------------------------------- + def command_234 + number = @parameters[0] + ($game_temp.in_battle ? 50 : 0) + $game_screen.pictures[number].start_tone_change(@parameters[1], + @parameters[2] * Graphics.frame_rate / 20) + return true + end + #----------------------------------------------------------------------------- + # * Erase Picture + #----------------------------------------------------------------------------- + def command_235 + number = @parameters[0] + ($game_temp.in_battle ? 50 : 0) + $game_screen.pictures[number].erase + return true + end + #----------------------------------------------------------------------------- + # * Set Weather Effects + #----------------------------------------------------------------------------- + def command_236 + $game_screen.weather(@parameters[0], @parameters[1], @parameters[2]) + return true + end + #----------------------------------------------------------------------------- + # * Play BGM + #----------------------------------------------------------------------------- + def command_241 + pbBGMPlay(@parameters[0]) + return true + end + #----------------------------------------------------------------------------- + # * Fade Out BGM + #----------------------------------------------------------------------------- + def command_242 + pbBGMFade(@parameters[0]) + return true + end + #----------------------------------------------------------------------------- + # * Play BGS + #----------------------------------------------------------------------------- + def command_245 + pbBGSPlay(@parameters[0]) + return true + end + #----------------------------------------------------------------------------- + # * Fade Out BGS + #----------------------------------------------------------------------------- + def command_246 + pbBGSFade(@parameters[0]) + return true + end + #----------------------------------------------------------------------------- + # * Memorize BGM/BGS + #----------------------------------------------------------------------------- + def command_247 + $game_system.bgm_memorize + $game_system.bgs_memorize + return true + end + #----------------------------------------------------------------------------- + # * Restore BGM/BGS + #----------------------------------------------------------------------------- + def command_248 + $game_system.bgm_restore + $game_system.bgs_restore + return true + end + #----------------------------------------------------------------------------- + # * Play ME + #----------------------------------------------------------------------------- + def command_249 + pbMEPlay(@parameters[0]) + return true + end + #----------------------------------------------------------------------------- + # * Play SE + #----------------------------------------------------------------------------- + def command_250 + pbSEPlay(@parameters[0]) + return true + end + #----------------------------------------------------------------------------- + # * Stop SE + #----------------------------------------------------------------------------- + def command_251 + pbSEStop + return true + end + + def command_301; command_dummy; end # Battle Processing + def command_601; command_if(0); end # If Win + def command_602; command_if(1); end # If Escape + def command_603; command_if(2); end # If Lose + def command_302; command_dummy; end # Shop Processing + #----------------------------------------------------------------------------- + # * Name Input Processing + #----------------------------------------------------------------------------- + def command_303 + if $Trainer + $Trainer.name = pbEnterPlayerName(_INTL("Your name?"), 1, @parameters[1], $Trainer.name) + return true + end + if $game_actors && $data_actors && $data_actors[@parameters[0]] != nil + $game_temp.battle_abort = true + pbFadeOutIn { + sscene = PokemonEntryScene.new + sscreen = PokemonEntry.new(sscene) + $game_actors[@parameters[0]].name = sscreen.pbStartScreen( + _INTL("Enter {1}'s name.", $game_actors[@parameters[0]].name), + 1, @parameters[1], $game_actors[@parameters[0]].name) + } + end + return true + end + + def command_311; command_dummy; end # Change HP + def command_312; command_dummy; end # Change SP + def command_313; command_dummy; end # Change State + #----------------------------------------------------------------------------- + # * Recover All + #----------------------------------------------------------------------------- + def command_314 + pbHealAll if @parameters[0] == 0 + return true + end + + def command_315; command_dummy; end # Change EXP + def command_316; command_dummy; end # Change Level + def command_317; command_dummy; end # Change Parameters + def command_318; command_dummy; end # Change Skills + def command_319; command_dummy; end # Change Equipment + def command_320; command_dummy; end # Change Actor Name + def command_321; command_dummy; end # Change Actor Class + def command_322; command_dummy; end # Change Actor Graphic + def command_331; command_dummy; end # Change Enemy HP + def command_332; command_dummy; end # Change Enemy SP + def command_333; command_dummy; end # Change Enemy State + def command_334; command_dummy; end # Enemy Recover All + def command_335; command_dummy; end # Enemy Appearance + def command_336; command_dummy; end # Enemy Transform + def command_337; command_dummy; end # Show Battle Animation + def command_338; command_dummy; end # Deal Damage + def command_339; command_dummy; end # Force Action + def command_340; command_dummy; end # Abort Battle + #----------------------------------------------------------------------------- + # * Call Menu Screen + #----------------------------------------------------------------------------- + def command_351 + $game_temp.menu_calling = true + @index += 1 + return false + end + #----------------------------------------------------------------------------- + # * Call Save Screen + #----------------------------------------------------------------------------- + def command_352 + scene = PokemonSave_Scene.new + screen = PokemonSaveScreen.new(scene) + screen.pbSaveScreen + return true + end + #----------------------------------------------------------------------------- + # * Game Over + #----------------------------------------------------------------------------- + def command_353 + pbBGMFade(1.0) + pbBGSFade(1.0) + pbFadeOutIn { pbStartOver(true) } + end + #----------------------------------------------------------------------------- + # * Return to Title Screen + #----------------------------------------------------------------------------- + def command_354 + $game_temp.to_title = true + return false + end + #----------------------------------------------------------------------------- + # * Script + #----------------------------------------------------------------------------- + def command_355 + script = @list[@index].parameters[0] + "\n" + # Look for more script commands or a continuation of one, and add them to script + loop do + break if ![355, 655].include?(@list[@index + 1].code) + script += @list[@index+1].parameters[0] + "\n" + @index += 1 + end + # Run the script + execute_script(script) + return true + end +end diff --git a/Data/Scripts/006_Game processing/002_Scene_Map.rb b/Data/Scripts/006_Game processing/002_Scene_Map.rb index a5738d88d..4e802d355 100644 --- a/Data/Scripts/006_Game processing/002_Scene_Map.rb +++ b/Data/Scripts/006_Game processing/002_Scene_Map.rb @@ -91,12 +91,6 @@ class Scene_Map Input.update end - def call_name - $game_temp.name_calling = false - $game_player.straighten - $game_map.update - end - def call_menu $game_temp.menu_calling = false $game_temp.in_menu = true @@ -202,12 +196,8 @@ class Scene_Map end end unless $game_player.moving? - if $game_temp.name_calling; call_name - elsif $game_temp.menu_calling; call_menu + if $game_temp.menu_calling; call_menu elsif $game_temp.debug_calling; call_debug -# elsif $game_temp.battle_calling; call_battle -# elsif $game_temp.shop_calling; call_shop -# elsif $game_temp.save_calling; call_save elsif $PokemonTemp.keyItemCalling $PokemonTemp.keyItemCalling = false $game_player.straighten diff --git a/Data/Scripts/009_Objects and windows/002_MessageConfig.rb b/Data/Scripts/009_Objects and windows/002_MessageConfig.rb index 58ef37d5d..ae7376160 100644 --- a/Data/Scripts/009_Objects and windows/002_MessageConfig.rb +++ b/Data/Scripts/009_Objects and windows/002_MessageConfig.rb @@ -513,21 +513,9 @@ def pbDisposed?(x) return false end - - #=============================================================================== # Fades and window activations for sprite hashes #=============================================================================== -class Game_Temp - attr_writer :fadestate - - def fadestate - return @fadestate || 0 - end -end - - - def pbPushFade $game_temp.fadestate = [$game_temp.fadestate+1,0].max if $game_temp end diff --git a/Data/Scripts/009_Objects and windows/011_Messages.rb b/Data/Scripts/009_Objects and windows/011_Messages.rb index fd58d3ded..20c34ebd9 100644 --- a/Data/Scripts/009_Objects and windows/011_Messages.rb +++ b/Data/Scripts/009_Objects and windows/011_Messages.rb @@ -1,30 +1,9 @@ #=============================================================================== # Message variables #=============================================================================== -class Game_Temp - attr_accessor :background - attr_writer :message_window_showing - attr_writer :player_transferring - attr_writer :transition_processing - - def message_window_showing - return @message_window_showing || false - end - - def player_transferring - return @player_transferring || false - end - - def transition_processing - return @transition_processing || false - end -end - - - class Game_Message - attr_writer :background attr_writer :visible + attr_writer :background def visible return @visible || false @@ -37,16 +16,6 @@ end -class Game_System - attr_writer :message_position - - def message_position - return @message_position || 2 - end -end - - - #=============================================================================== # #=============================================================================== @@ -155,8 +124,6 @@ def pbUpdateSceneMap end end - - #=============================================================================== # #=============================================================================== @@ -189,330 +156,6 @@ def pbCurrentEventCommentInput(elements,trigger) return pbEventCommentInput(event,elements,trigger) end -def pbButtonInputProcessing(variableNumber=0,timeoutFrames=0) - ret=0 - timeoutFrames = timeoutFrames*Graphics.frame_rate/20 - loop do - Graphics.update - Input.update - pbUpdateSceneMap - for i in 1..18 - ret=i if Input.trigger?(i) - end - break if ret!=0 - if timeoutFrames>0 - i+=1 - break if i>=timeoutFrames - end - end - Input.update - if variableNumber && variableNumber>0 - $game_variables[variableNumber]=ret - $game_map.need_refresh = true if $game_map - end - return ret -end - - - -#=============================================================================== -# Interpreter functions for displaying messages -#=============================================================================== -module InterpreterMixin - # Freezes all events on the map (for use at the beginning of common events) - def pbGlobalLock - for event in $game_map.events.values - event.minilock - end - end - - # Unfreezes all events on the map (for use at the end of common events) - def pbGlobalUnlock - for event in $game_map.events.values - event.unlock - end - end - - def pbRepeatAbove(index) - index=@list[index].indent - loop do - index-=1 - return index+1 if @list[index].indent==indent - end - end - - def pbBreakLoop(index) - indent = @list[index].indent - temp_index=index - # Copy index to temporary variables - loop do - # Advance index - temp_index += 1 - # If a fitting loop was not found - return index+1 if temp_index >= @list.size-1 - return temp_index+1 if @list[temp_index].code == 413 and - @list[temp_index].indent < indent - end - end - - def pbJumpToLabel(index,label_name) - temp_index = 0 - loop do - return index+1 if temp_index >= @list.size-1 - return temp_index+1 if @list[temp_index].code == 118 and - @list[temp_index].parameters[0] == label_name - temp_index += 1 - end - end - - # Gets the next index in the interpreter, ignoring - # certain events between messages - def pbNextIndex(index) - return -1 if !@list || @list.length==0 - i=index+1 - loop do - return i if i>=@list.length-1 - case @list[i].code - when 118, 108, 408 # Label, Comment - i+=1 - when 413 # Repeat Above - i=pbRepeatAbove(i) - when 113 # Break Loop - i=pbBreakLoop(i) - when 119 # Jump to Label - newI=pbJumpToLabel(i,@list[i].parameters[0]) - i = (newI>i) ? newI : i+1 - else - return i - end - end - end - - # Helper function that shows a picture in a script. To be used in - # a script event command. - def pbShowPicture(number,name,origin,x,y,zoomX=100,zoomY=100,opacity=255,blendType=0) - number = number + ($game_temp.in_battle ? 50 : 0) - $game_screen.pictures[number].show(name,origin, - x, y, zoomX,zoomY,opacity,blendType) - end - - # Erases an event and adds it to the list of erased events so that - # it can stay erased when the game is saved then loaded again. To be used in - # a script event command. - def pbEraseThisEvent - if $game_map.events[@event_id] - $game_map.events[@event_id].erase - $PokemonMap.addErasedEvent(@event_id) if $PokemonMap - end - @index+=1 - return true - end - - # Runs a common event. To be used in a script event command. - def pbCommonEvent(id) - common_event = $data_common_events[id] - if $game_temp.in_battle - if common_event != nil - interp = Interpreter.new - interp.setup(common_event.list,0) - loop do - Graphics.update - Input.update - interp.update - pbUpdateSceneMap - break if !interp.running? - end - end - else - $game_system.battle_interpreter.setup(common_event.list, 0) - end - end - - # Sets another event's self switch (eg. pbSetSelfSwitch(20,"A",true) ). - # To be used in a script event command. - def pbSetSelfSwitch(event,swtch,value,mapid=-1) - mapid = @map_id if mapid<0 - oldValue = $game_self_switches[[mapid,event,swtch]] - $game_self_switches[[mapid,event,swtch]] = value - if value!=oldValue && $MapFactory.hasMap?(mapid) - $MapFactory.getMap(mapid,false).need_refresh = true - end - end - - # Must use this approach to share the methods because the methods already - # defined in a class override those defined in an included module - CustomEventCommands=<<_END_ - - def command_242 - pbBGMFade(pbParams[0]) - return true - end - - def command_246 - pbBGSFade(pbParams[0]) - return true - end - - def command_251 - pbSEStop - return true - end - - def command_241 - pbBGMPlay(pbParams[0]) - return true - end - - def command_245 - pbBGSPlay(pbParams[0]) - return true - end - - def command_249 - pbMEPlay(pbParams[0]) - return true - end - - def command_250 - pbSEPlay(pbParams[0]) - return true - end -_END_ -end - - - -class Interpreter # Used by RMXP - include InterpreterMixin - eval(InterpreterMixin::CustomEventCommands) - @@immediateDisplayAfterWait=false - @buttonInput=false - - def pbParams - return @parameters - end - - def command_105 - return false if @buttonInput - @buttonInput=true - pbButtonInputProcessing(@list[@index].parameters[0]) - @buttonInput=false - @index+=1 - return true - end - - def command_101 - if $game_temp.message_window_showing - return false - end - message="" - commands=nil - numInputVar=nil - numInputDigitsMax=nil - text="" - firstText=nil - if @list[@index].parameters.length==1 - text+=@list[@index].parameters[0] - firstText=@list[@index].parameters[0] - text+=" " if text[text.length-1,1]!=" " - message+=text - else - facename=@list[@index].parameters[0] - faceindex=@list[@index].parameters[1] - if facename && facename!="" - text+="\\ff[#{facename},#{faceindex}]" - message+=text - end - end - messageend="" - loop do - nextIndex=pbNextIndex(@index) - code=@list[nextIndex].code - if code == 401 - text=@list[nextIndex].parameters[0] - text+=" " if text[text.length-1,1]!=" " - message+=text - @index=nextIndex - else - if code == 102 - commands=@list[nextIndex].parameters - @index=nextIndex - elsif code == 106 && @@immediateDisplayAfterWait - params=@list[nextIndex].parameters - if params[0]<=10 - nextcode=@list[nextIndex+1].code - if nextcode==101 || nextcode==102 || nextcode==103 - @index=nextIndex - else - break - end - else - break - end - elsif code == 103 - numInputVar=@list[nextIndex].parameters[0] - numInputDigitsMax=@list[nextIndex].parameters[1] - @index=nextIndex - elsif code == 101 - if @list[@index].parameters.length==1 - text=@list[@index].parameters[0] - if text[/\A\\ignr/] && text==firstText - text+=" " if text[text.length-1,1]!=" " - message+=text - @index=nextIndex - continue - end - end - messageend="\1" - end - break - end - end - @message_waiting=true # needed to allow parallel process events to work while - # a message is displayed - message=_MAPINTL($game_map.map_id,message) - if commands - cmdlist=[] - for cmd in commands[0] - cmdlist.push(_MAPINTL($game_map.map_id,cmd)) - end - command=pbMessage(message+messageend,cmdlist,commands[1]) - @branch[@list[@index].indent] = command - elsif numInputVar - params=ChooseNumberParams.new - params.setMaxDigits(numInputDigitsMax) - params.setDefaultValue($game_variables[numInputVar]) - $game_variables[numInputVar]=pbMessageChooseNumber(message+messageend,params) - $game_map.need_refresh = true if $game_map - else - pbMessage(message+messageend,nil) - end - @message_waiting=false - return true - end - - def command_102 - @message_waiting=true - command=pbShowCommands(nil,@list[@index].parameters[0],@list[@index].parameters[1]) - @message_waiting=false - @branch[@list[@index].indent] = command - Input.update # Must call Input.update again to avoid extra triggers - return true - end - - def command_103 - varnumber=@list[@index].parameters[0] - @message_waiting=true - params=ChooseNumberParams.new - params.setMaxDigits(@list[@index].parameters[1]) - params.setDefaultValue($game_variables[varnumber]) - $game_variables[varnumber]=pbChooseNumber(nil,params) - $game_map.need_refresh = true if $game_map - @message_waiting=false - return true - end -end - #=============================================================================== diff --git a/Data/Scripts/009_Objects and windows/012_TextEntry.rb b/Data/Scripts/009_Objects and windows/012_TextEntry.rb index 417224182..d2e71933e 100644 --- a/Data/Scripts/009_Objects and windows/012_TextEntry.rb +++ b/Data/Scripts/009_Objects and windows/012_TextEntry.rb @@ -1507,32 +1507,6 @@ end -#=============================================================================== -# Interpreter functions for naming the player -#=============================================================================== -class Interpreter - def command_303 - if $Trainer - $Trainer.name=pbEnterPlayerName(_INTL("Your name?"),1,@parameters[1],$Trainer.name) - return true - end - if $game_actors && $data_actors && $data_actors[@parameters[0]] != nil - # Set battle abort flag - $game_temp.battle_abort = true - pbFadeOutIn { - sscene=PokemonEntryScene.new - sscreen=PokemonEntry.new(sscene) - $game_actors[@parameters[0]].name=sscreen.pbStartScreen( - _INTL("Enter {1}'s name.",$game_actors[@parameters[0]].name), - 1,@parameters[1],$game_actors[@parameters[0]].name) - } - end - return true - end -end - - - #=============================================================================== # #=============================================================================== diff --git a/Data/Scripts/011_Data/001_Game data/005_Metadata.rb b/Data/Scripts/011_Data/001_Game data/005_Metadata.rb index 185e09e9a..bf51c3bbc 100644 --- a/Data/Scripts/011_Data/001_Game data/005_Metadata.rb +++ b/Data/Scripts/011_Data/001_Game data/005_Metadata.rb @@ -137,92 +137,8 @@ end def pbGetMetadata(map_id, metadata_type) if map_id == 0 # Global metadata Deprecation.warn_method('pbGetMetadata', 'v20', 'GameData::Metadata.get.something') - ret = GameData::Metadata.get - case metadata_type - when Metadata::HOME then return ret.home - when Metadata::WILD_BATTLE_BGM then return ret.wild_battle_BGM - when Metadata::TRAINER_BATTLE_BGM then return ret.trainer_battle_BGM - when Metadata::WILD_VICTORY_ME then return ret.wild_victory_ME - when Metadata::TRAINER_VICTORY_ME then return ret.trainer_victory_ME - when Metadata::WILD_CAPTURE_ME then return ret.wild_capture_ME - when Metadata::SURF_BGM then return ret.surf_BGM - when Metadata::BICYCLE_BGM then return ret.bicycle_BGM - when Metadata::PLAYER_A then return ret.player_A - when Metadata::PLAYER_B then return ret.player_B - when Metadata::PLAYER_C then return ret.player_C - when Metadata::PLAYER_D then return ret.player_D - when Metadata::PLAYER_E then return ret.player_E - when Metadata::PLAYER_F then return ret.player_F - when Metadata::PLAYER_G then return ret.player_G - when Metadata::PLAYER_H then return ret.player_H - end else # Map metadata Deprecation.warn_method('pbGetMetadata', 'v20', 'GameData::MapMetadata.get(map_id).something') - ret = GameData::MapMetadata.get(map_id) - case metadata_type - when MapMetadata::OUTDOOR then return ret.outdoor_map - when MapMetadata::SHOW_AREA then return ret.announce_location - when MapMetadata::BICYCLE then return ret.can_bicycle - when MapMetadata::BICYCLE_ALWAYS then return ret.always_bicycle - when MapMetadata::HEALING_SPOT then return ret.teleport_destination - when MapMetadata::WEATHER then return ret.weather - when MapMetadata::MAP_POSITION then return ret.town_map_position - when MapMetadata::DIVE_MAP then return ret.dive_map_id - when MapMetadata::DARK_MAP then return ret.dark_map - when MapMetadata::SAFARI_MAP then return ret.safari_map - when MapMetadata::SNAP_EDGES then return ret.snap_edges - when MapMetadata::DUNGEON then return ret.random_dungeon - when MapMetadata::BATTLE_BACK then return ret.battle_background - when MapMetadata::WILD_BATTLE_BGM then return ret.wild_battle_BGM - when MapMetadata::TRAINER_BATTLE_BGM then return ret.trainer_battle_BGM - when MapMetadata::WILD_VICTORY_ME then return ret.wild_victory_ME - when MapMetadata::TRAINER_VICTORY_ME then return ret.trainer_victory_ME - when MapMetadata::WILD_CAPTURE_ME then return ret.wild_capture_ME - when MapMetadata::MAP_SIZE then return ret.town_map_size - when MapMetadata::ENVIRONMENT then return ret.battle_environment - end end return nil end - -module Metadata - HOME = 1 - WILD_BATTLE_BGM = 2 - TRAINER_BATTLE_BGM = 3 - WILD_VICTORY_ME = 4 - TRAINER_VICTORY_ME = 5 - WILD_CAPTURE_ME = 6 - SURF_BGM = 7 - BICYCLE_BGM = 8 - PLAYER_A = 9 - PLAYER_B = 10 - PLAYER_C = 11 - PLAYER_D = 12 - PLAYER_E = 13 - PLAYER_F = 14 - PLAYER_G = 15 - PLAYER_H = 16 -end - -module MapMetadata - OUTDOOR = 1 - SHOW_AREA = 2 - BICYCLE = 3 - BICYCLE_ALWAYS = 4 - HEALING_SPOT = 5 - WEATHER = 6 - MAP_POSITION = 7 - DIVE_MAP = 8 - DARK_MAP = 9 - SAFARI_MAP = 10 - SNAP_EDGES = 11 - DUNGEON = 12 - BATTLE_BACK = 13 - WILD_BATTLE_BGM = 14 - TRAINER_BATTLE_BGM = 15 - WILD_VICTORY_ME = 16 - TRAINER_VICTORY_ME = 17 - WILD_CAPTURE_ME = 18 - MAP_SIZE = 19 - ENVIRONMENT = 20 -end diff --git a/Data/Scripts/011_Data/001_Game data/007_Move.rb b/Data/Scripts/011_Data/001_Game data/007_Move.rb index 32f8f42f2..c752dda4d 100644 --- a/Data/Scripts/011_Data/001_Game data/007_Move.rb +++ b/Data/Scripts/011_Data/001_Game data/007_Move.rb @@ -72,23 +72,6 @@ end #=============================================================================== # Deprecated methods #=============================================================================== -module MoveData - ID = 0 - INTERNAL_NAME = 1 - NAME = 2 - FUNCTION_CODE = 3 - BASE_DAMAGE = 4 - TYPE = 5 - CATEGORY = 6 - ACCURACY = 7 - TOTAL_PP = 8 - EFFECT_CHANCE = 9 - TARGET = 10 - PRIORITY = 11 - FLAGS = 12 - DESCRIPTION = 13 -end - def pbGetMoveData(move_id, move_data_type = -1) Deprecation.warn_method('pbGetMoveData', 'v20', 'GameData::Move.get(move_id)') return GameData::Move.get(move_id) diff --git a/Data/Scripts/011_Data/001_Game data/009_Type.rb b/Data/Scripts/011_Data/001_Game data/009_Type.rb index ae78a79ae..66dab9c2b 100644 --- a/Data/Scripts/011_Data/001_Game data/009_Type.rb +++ b/Data/Scripts/011_Data/001_Game data/009_Type.rb @@ -56,7 +56,3 @@ module GameData end end end - -#=============================================================================== -# Deprecated methods -#=============================================================================== diff --git a/Data/Scripts/011_Data/001_Game data/010_Species.rb b/Data/Scripts/011_Data/001_Game data/010_Species.rb index 8adb1d526..064c057cb 100644 --- a/Data/Scripts/011_Data/001_Game data/010_Species.rb +++ b/Data/Scripts/011_Data/001_Game data/010_Species.rb @@ -72,7 +72,6 @@ module GameData return (DATA.has_key?(species_form)) ? DATA[species_form] : nil end - # TODO: Needs tidying up. def self.schema(compiling_forms = false) ret = { "FormName" => [0, "q"], @@ -224,92 +223,11 @@ end #=============================================================================== # Deprecated methods #=============================================================================== -module SpeciesData - TYPE1 = 0 - TYPE2 = 1 - BASE_STATS = 2 - GENDER_RATE = 3 - GROWTH_RATE = 4 - BASE_EXP = 5 - EFFORT_POINTS = 6 - RARENESS = 7 - HAPPINESS = 8 - ABILITIES = 9 - HIDDEN_ABILITY = 10 - COMPATIBILITY = 11 - STEPS_TO_HATCH = 12 - HEIGHT = 13 - WEIGHT = 14 - COLOR = 15 - SHAPE = 16 - HABITAT = 17 - WILD_ITEM_COMMON = 18 - WILD_ITEM_UNCOMMON = 19 - WILD_ITEM_RARE = 20 - INCENSE = 21 - POKEDEX_FORM = 22 # For alternate forms - MEGA_STONE = 23 # For alternate forms - MEGA_MOVE = 24 # For alternate forms - UNMEGA_FORM = 25 # For alternate forms - MEGA_MESSAGE = 26 # For alternate forms - METRIC_PLAYER_X = 27 - METRIC_PLAYER_Y = 28 - METRIC_ENEMY_X = 29 - METRIC_ENEMY_Y = 30 - METRIC_ALTITUDE = 31 - METRIC_SHADOW_X = 32 - METRIC_SHADOW_SIZE = 33 -end - -#=============================================================================== -# Methods to get Pokémon species data. -#=============================================================================== def pbGetSpeciesData(species, form = 0, species_data_type = -1) Deprecation.warn_method('pbGetSpeciesData', 'v20', 'GameData::Species.get_species_form(species, form).something') - ret = GameData::Species.get_species_form(species, form) - return ret if species_data_type == -1 - case species_data_type - when SpeciesData::TYPE1 then return ret.type1 - when SpeciesData::TYPE2 then return ret.type2 - when SpeciesData::BASE_STATS then return ret.base_stats - when SpeciesData::GENDER_RATE then return ret.gender_rate - when SpeciesData::GROWTH_RATE then return ret.growth_rate - when SpeciesData::BASE_EXP then return ret.base_exp - when SpeciesData::EFFORT_POINTS then return ret.evs - when SpeciesData::RARENESS then return ret.catch_rate - when SpeciesData::HAPPINESS then return ret.happiness - when SpeciesData::ABILITIES then return ret.abilities - when SpeciesData::HIDDEN_ABILITY then return ret.hidden_abilities - when SpeciesData::COMPATIBILITY then return ret.egg_groups - when SpeciesData::STEPS_TO_HATCH then return ret.hatch_steps - when SpeciesData::HEIGHT then return ret.height - when SpeciesData::WEIGHT then return ret.weight - when SpeciesData::COLOR then return ret.color - when SpeciesData::SHAPE then return ret.shape - when SpeciesData::HABITAT then return ret.habitat - when SpeciesData::WILD_ITEM_COMMON then return ret.wild_item_common - when SpeciesData::WILD_ITEM_UNCOMMON then return ret.wild_item_uncommon - when SpeciesData::WILD_ITEM_RARE then return ret.wild_item_rare - when SpeciesData::INCENSE then return ret.incense - when SpeciesData::POKEDEX_FORM then return ret.pokedex_form - when SpeciesData::MEGA_STONE then return ret.mega_stone - when SpeciesData::MEGA_MOVE then return ret.mega_move - when SpeciesData::UNMEGA_FORM then return ret.unmega_form - when SpeciesData::MEGA_MESSAGE then return ret.mega_message - when SpeciesData::METRIC_PLAYER_X then return ret.back_sprite_x - when SpeciesData::METRIC_PLAYER_Y then return ret.back_sprite_y - when SpeciesData::METRIC_ENEMY_X then return ret.front_sprite_x - when SpeciesData::METRIC_ENEMY_Y then return ret.front_sprite_y - when SpeciesData::METRIC_ALTITUDE then return ret.front_sprite_altitude - when SpeciesData::METRIC_SHADOW_X then return ret.shadow_x - when SpeciesData::METRIC_SHADOW_SIZE then return ret.shadow_size - end - return 0 + return GameData::Species.get_species_form(species, form) end -#=============================================================================== -# Methods to get Pokémon moves data. -#=============================================================================== def pbGetSpeciesEggMoves(species, form = 0) Deprecation.warn_method('pbGetSpeciesEggMoves', 'v20', 'GameData::Species.get_species_form(species, form).egg_moves') return GameData::Species.get_species_form(species, form).egg_moves @@ -325,9 +243,6 @@ def pbGetEvolutionData(species) return GameData::Species.get(species).evolutions end -#=============================================================================== -# Method to get Pokémon species metrics (sprite positioning) data. -#=============================================================================== def pbApplyBattlerMetricsToSprite(sprite, index, species_data, shadow = false, metrics = nil) Deprecation.warn_method('pbApplyBattlerMetricsToSprite', 'v20', 'GameData::Species.get(species).apply_metrics_to_sprite') GameData::Species.get(species).apply_metrics_to_sprite(sprite, index, shadow) diff --git a/Data/Scripts/011_Data/001_Game data/011_Species files.rb b/Data/Scripts/011_Data/001_Game data/011_Species files.rb index 2a78c37ef..b3557fe4d 100644 --- a/Data/Scripts/011_Data/001_Game data/011_Species files.rb +++ b/Data/Scripts/011_Data/001_Game data/011_Species files.rb @@ -268,7 +268,7 @@ module GameData end #=============================================================================== -# Deprecated +# Deprecated methods #=============================================================================== def pbLoadSpeciesBitmap(species, gender = 0, form = 0, shiny = false, shadow = false, back = false , egg = false) Deprecation.warn_method('pbLoadSpeciesBitmap', 'v20', 'GameData::Species.sprite_bitmap(species, form, gender, shiny, shadow, back, egg)') diff --git a/Data/Scripts/013_Overworld/002_PField_Field.rb b/Data/Scripts/013_Overworld/002_PField_Field.rb index b77dff19d..695428586 100644 --- a/Data/Scripts/013_Overworld/002_PField_Field.rb +++ b/Data/Scripts/013_Overworld/002_PField_Field.rb @@ -634,195 +634,6 @@ end -#=============================================================================== -# Events -#=============================================================================== -class Game_Event - def cooledDown?(seconds) - return true if expired?(seconds) && tsOff?("A") - self.need_refresh = true - return false - end - - def cooledDownDays?(days) - return true if expiredDays?(days) && tsOff?("A") - self.need_refresh = true - return false - end -end - - - -module InterpreterFieldMixin - # Used in boulder events. Allows an event to be pushed. To be used in - # a script event command. - def pbPushThisEvent - event = get_character(0) - oldx = event.x - oldy = event.y - # Apply strict version of passable, which makes impassable - # tiles that are passable only from certain directions - return if !event.passableStrict?(event.x,event.y,$game_player.direction) - case $game_player.direction - when 2 then event.move_down - when 4 then event.move_left - when 6 then event.move_right - when 8 then event.move_up - end - $PokemonMap.addMovedEvent(@event_id) if $PokemonMap - if oldx!=event.x || oldy!=event.y - $game_player.lock - loop do - Graphics.update - Input.update - pbUpdateSceneMap - break if !event.moving? - end - $game_player.unlock - end - end - - def pbPushThisBoulder - pbPushThisEvent if $PokemonMap.strengthUsed - return true - end - - def pbSmashThisEvent - event = get_character(0) - pbSmashEvent(event) if event - @index += 1 - return true - end - - def pbTrainerIntro(symbol) - return true if $DEBUG && !GameData::TrainerType.exists?(symbol) - tr_type = GameData::TrainerType.get(symbol).id - pbGlobalLock - pbPlayTrainerIntroME(tr_type) - return true - end - - def pbTrainerEnd - pbGlobalUnlock - e = get_character(0) - e.erase_route if e - end - - def pbParams - (@parameters) ? @parameters : @params - end - - def pbGetPokemon(id) - return $Trainer.party[pbGet(id)] - end - - def pbSetEventTime(*arg) - $PokemonGlobal.eventvars = {} if !$PokemonGlobal.eventvars - time = pbGetTimeNow - time = time.to_i - pbSetSelfSwitch(@event_id,"A",true) - $PokemonGlobal.eventvars[[@map_id,@event_id]]=time - for otherevt in arg - pbSetSelfSwitch(otherevt,"A",true) - $PokemonGlobal.eventvars[[@map_id,otherevt]]=time - end - end - - def getVariable(*arg) - if arg.length==0 - return nil if !$PokemonGlobal.eventvars - return $PokemonGlobal.eventvars[[@map_id,@event_id]] - else - return $game_variables[arg[0]] - end - end - - def setVariable(*arg) - if arg.length==1 - $PokemonGlobal.eventvars = {} if !$PokemonGlobal.eventvars - $PokemonGlobal.eventvars[[@map_id,@event_id]]=arg[0] - else - $game_variables[arg[0]] = arg[1] - $game_map.need_refresh = true - end - end - - def tsOff?(c) - get_character(0).tsOff?(c) - end - - def tsOn?(c) - get_character(0).tsOn?(c) - end - - alias isTempSwitchOn? tsOn? - alias isTempSwitchOff? tsOff? - - def setTempSwitchOn(c) - get_character(0).setTempSwitchOn(c) - end - - def setTempSwitchOff(c) - get_character(0).setTempSwitchOff(c) - end - - # Must use this approach to share the methods because the methods already - # defined in a class override those defined in an included module - CustomEventCommands=<<_END_ - - def command_352 - scene = PokemonSave_Scene.new - screen = PokemonSaveScreen.new(scene) - screen.pbSaveScreen - return true - end - - def command_125 - value = operate_value(pbParams[0], pbParams[1], pbParams[2]) - $Trainer.money += value - return true - end - - def command_132 - ($PokemonGlobal.nextBattleBGM = pbParams[0]) ? pbParams[0].clone : nil - return true - end - - def command_133 - ($PokemonGlobal.nextBattleME = pbParams[0]) ? pbParams[0].clone : nil - return true - end - - def command_353 - pbBGMFade(1.0) - pbBGSFade(1.0) - pbFadeOutIn { pbStartOver(true) } - end - - def command_314 - pbHealAll if pbParams[0]==0 - return true - end - -_END_ -end - - - -class Interpreter - include InterpreterFieldMixin - eval(InterpreterFieldMixin::CustomEventCommands) -end - - - -class Game_Interpreter - include InterpreterFieldMixin - eval(InterpreterFieldMixin::CustomEventCommands) -end - - - #=============================================================================== # Audio playing #=============================================================================== diff --git a/Data/Scripts/013_Overworld/003_PField_Visuals.rb b/Data/Scripts/013_Overworld/003_PField_Visuals.rb index 4c21da853..316d575c5 100644 --- a/Data/Scripts/013_Overworld/003_PField_Visuals.rb +++ b/Data/Scripts/013_Overworld/003_PField_Visuals.rb @@ -1,12 +1,6 @@ #=============================================================================== # Battle start animation #=============================================================================== -class Game_Temp - attr_accessor :background_bitmap -end - - - def pbSceneStandby $scene.disposeSpritesets if $scene && $scene.is_a?(Scene_Map) GC.start diff --git a/Data/Scripts/017_UI/001_PScreen_PauseMenu.rb b/Data/Scripts/017_UI/001_PScreen_PauseMenu.rb index 079ef172c..eec49fbfe 100644 --- a/Data/Scripts/017_UI/001_PScreen_PauseMenu.rb +++ b/Data/Scripts/017_UI/001_PScreen_PauseMenu.rb @@ -1,3 +1,6 @@ +#=============================================================================== +# +#=============================================================================== class PokemonPauseMenu_Scene def pbStartScene @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) @@ -78,8 +81,9 @@ class PokemonPauseMenu_Scene def pbRefresh; end end - - +#=============================================================================== +# +#=============================================================================== class PokemonPauseMenu def initialize(scene) @scene = scene diff --git a/Data/Scripts/017_UI/002_PScreen_PokedexMenu.rb b/Data/Scripts/017_UI/002_PScreen_PokedexMenu.rb index 32c1d444b..b9fc88e28 100644 --- a/Data/Scripts/017_UI/002_PScreen_PokedexMenu.rb +++ b/Data/Scripts/017_UI/002_PScreen_PokedexMenu.rb @@ -31,8 +31,9 @@ class Window_DexesList < Window_CommandPokemon end end - - +#=============================================================================== +# +#=============================================================================== class PokemonPokedexMenu_Scene def pbUpdate pbUpdateSpriteHash(@sprites) @@ -81,8 +82,9 @@ class PokemonPokedexMenu_Scene end end - - +#=============================================================================== +# +#=============================================================================== class PokemonPokedexMenuScreen def initialize(scene) @scene = scene diff --git a/Data/Scripts/017_UI/003_PScreen_PokedexMain.rb b/Data/Scripts/017_UI/003_PScreen_PokedexMain.rb index 8c71026ae..826a76c2c 100644 --- a/Data/Scripts/017_UI/003_PScreen_PokedexMain.rb +++ b/Data/Scripts/017_UI/003_PScreen_PokedexMain.rb @@ -1,3 +1,6 @@ +#=============================================================================== +# +#=============================================================================== class Window_Pokedex < Window_DrawableCommand def initialize(x,y,width,height,viewport) @commands = [] @@ -69,8 +72,9 @@ class Window_Pokedex < Window_DrawableCommand end end - - +#=============================================================================== +# +#=============================================================================== class PokedexSearchSelectionSprite < SpriteWrapper attr_reader :index attr_accessor :cmds @@ -207,8 +211,6 @@ class PokedexSearchSelectionSprite < SpriteWrapper end end - - #=============================================================================== # Pokédex main screen #=============================================================================== @@ -236,8 +238,8 @@ class PokemonPokedex_Scene @viewport.z = 99999 addBackgroundPlane(@sprites,"background","Pokedex/bg_list",@viewport) =begin -# Suggestion for changing the background depending on region. You can change -# the line above with the following: + # Suggestion for changing the background depending on region. You can change + # the line above with the following: if pbGetPokedexRegion==-1 # Using national Pokédex addBackgroundPlane(@sprites,"background","Pokedex/bg_national",@viewport) elsif pbGetPokedexRegion==0 # Using first regional Pokédex @@ -1174,8 +1176,9 @@ class PokemonPokedex_Scene end end - - +#=============================================================================== +# +#=============================================================================== class PokemonPokedexScreen def initialize(scene) @scene = scene diff --git a/Data/Scripts/017_UI/004_PScreen_PokedexEntry.rb b/Data/Scripts/017_UI/004_PScreen_PokedexEntry.rb index 836dba23b..f47566aab 100644 --- a/Data/Scripts/017_UI/004_PScreen_PokedexEntry.rb +++ b/Data/Scripts/017_UI/004_PScreen_PokedexEntry.rb @@ -1,16 +1,6 @@ -def pbFindEncounter(encounter,species) - return false if !encounter - for i in 0...encounter.length - next if !encounter[i] - for j in 0...encounter[i].length - return true if encounter[i][j][0]==species - end - end - return false -end - - - +#=============================================================================== +# +#=============================================================================== class PokemonPokedexInfo_Scene def pbStartScene(dexlist,index,region) @viewport = Viewport.new(0,0,Graphics.width,Graphics.height) @@ -286,6 +276,17 @@ class PokemonPokedexInfo_Scene pbDrawImagePositions(overlay, imagepos) end + def pbFindEncounter(encounter,species) + return false if !encounter + for i in 0...encounter.length + next if !encounter[i] + for j in 0...encounter[i].length + return true if encounter[i][j][0]==species + end + end + return false + end + def drawPageArea @sprites["background"].setBitmap(_INTL("Graphics/Pictures/Pokedex/bg_area")) overlay = @sprites["overlay"].bitmap @@ -539,8 +540,9 @@ class PokemonPokedexInfo_Scene end end - - +#=============================================================================== +# +#=============================================================================== class PokemonPokedexInfoScreen def initialize(scene) @scene = scene diff --git a/Data/Scripts/017_UI/005_PScreen_Party.rb b/Data/Scripts/017_UI/005_PScreen_Party.rb index 4c4ecbf13..c11d9c3d3 100644 --- a/Data/Scripts/017_UI/005_PScreen_Party.rb +++ b/Data/Scripts/017_UI/005_PScreen_Party.rb @@ -75,32 +75,36 @@ class PokemonPartyConfirmCancelSprite < SpriteWrapper end end - - +#=============================================================================== +# +#=============================================================================== class PokemonPartyCancelSprite < PokemonPartyConfirmCancelSprite def initialize(viewport=nil) super(_INTL("CANCEL"),398,328,false,viewport) end end - - +#=============================================================================== +# +#=============================================================================== class PokemonPartyConfirmSprite < PokemonPartyConfirmCancelSprite def initialize(viewport=nil) super(_INTL("CONFIRM"),398,308,true,viewport) end end - - +#=============================================================================== +# +#=============================================================================== class PokemonPartyCancelSprite2 < PokemonPartyConfirmCancelSprite def initialize(viewport=nil) super(_INTL("CANCEL"),398,346,true,viewport) end end - - +#=============================================================================== +# +#=============================================================================== class Window_CommandPokemonColor < Window_CommandPokemon def initialize(commands,width=nil) @colorKey = [] @@ -127,10 +131,8 @@ class Window_CommandPokemonColor < Window_CommandPokemon end end - - #=============================================================================== -# Pokémon party panels +# Blank party panel #=============================================================================== class PokemonPartyBlankPanel < SpriteWrapper attr_accessor :text @@ -158,8 +160,9 @@ class PokemonPartyBlankPanel < SpriteWrapper def refresh; end end - - +#=============================================================================== +# Pokémon party panel +#=============================================================================== class PokemonPartyPanel < SpriteWrapper attr_reader :pokemon attr_reader :active @@ -423,8 +426,6 @@ class PokemonPartyPanel < SpriteWrapper end end - - #=============================================================================== # Pokémon party visuals #=============================================================================== @@ -820,8 +821,6 @@ class PokemonParty_Scene end end - - #=============================================================================== # Pokémon party mechanics #=============================================================================== @@ -941,7 +940,7 @@ class PokemonPartyScreen def pbChooseMove(pokemon,helptext,index=0) movenames = [] for i in pokemon.moves - break if i.id==0 + next if !i || !i.id if i.total_pp<=0 movenames.push(_INTL("{1} (PP: ---)",i.name)) else @@ -1324,8 +1323,6 @@ class PokemonPartyScreen end end - - #=============================================================================== # Open the party screen #=============================================================================== diff --git a/Data/Scripts/017_UI/006_PScreen_Summary.rb b/Data/Scripts/017_UI/006_PScreen_Summary.rb index ed70b37b5..4c8fa2575 100644 --- a/Data/Scripts/017_UI/006_PScreen_Summary.rb +++ b/Data/Scripts/017_UI/006_PScreen_Summary.rb @@ -1,3 +1,6 @@ +#=============================================================================== +# +#=============================================================================== class MoveSelectionSprite < SpriteWrapper attr_reader :preselected attr_reader :index @@ -52,8 +55,9 @@ class MoveSelectionSprite < SpriteWrapper end end - - +#=============================================================================== +# +#=============================================================================== class RibbonSelectionSprite < MoveSelectionSprite def initialize(viewport=nil) super(viewport) @@ -94,8 +98,9 @@ class RibbonSelectionSprite < MoveSelectionSprite end end - - +#=============================================================================== +# +#=============================================================================== class PokemonSummary_Scene def pbUpdate pbUpdateSpriteHash(@sprites) @@ -1305,8 +1310,9 @@ class PokemonSummary_Scene end end - - +#=============================================================================== +# +#=============================================================================== class PokemonSummaryScreen def initialize(scene,inbattle=false) @scene = scene @@ -1347,8 +1353,6 @@ class PokemonSummaryScreen end end - - #=============================================================================== # #=============================================================================== diff --git a/Data/Scripts/017_UI/007_PScreen_Bag.rb b/Data/Scripts/017_UI/007_PScreen_Bag.rb index ac3ee41f3..fd09bed5b 100644 --- a/Data/Scripts/017_UI/007_PScreen_Bag.rb +++ b/Data/Scripts/017_UI/007_PScreen_Bag.rb @@ -1,3 +1,6 @@ +#=============================================================================== +# +#=============================================================================== class Window_PokemonBag < Window_DrawableCommand attr_reader :pocket attr_accessor :sorting @@ -117,8 +120,6 @@ class Window_PokemonBag < Window_DrawableCommand end end - - #=============================================================================== # Bag visuals #=============================================================================== @@ -319,7 +320,6 @@ class PokemonBag_Scene # Set the selected item's description @sprites["itemtext"].text = (itemlist.item) ? GameData::Item.get(itemlist.item).description : _INTL("Close bag.") - end def pbRefreshFilter @@ -443,8 +443,6 @@ class PokemonBag_Scene end end - - #=============================================================================== # Bag mechanics #=============================================================================== diff --git a/Data/Scripts/017_UI/008_PScreen_Pokegear.rb b/Data/Scripts/017_UI/008_PScreen_Pokegear.rb index f7f188104..e24a155be 100644 --- a/Data/Scripts/017_UI/008_PScreen_Pokegear.rb +++ b/Data/Scripts/017_UI/008_PScreen_Pokegear.rb @@ -1,3 +1,6 @@ +#=============================================================================== +# +#=============================================================================== class PokegearButton < SpriteWrapper attr_reader :index attr_reader :name @@ -49,8 +52,9 @@ class PokegearButton < SpriteWrapper end end - - +#=============================================================================== +# +#=============================================================================== class PokemonPokegear_Scene def pbUpdate for i in 0...@commands.length @@ -111,8 +115,9 @@ class PokemonPokegear_Scene end end - - +#=============================================================================== +# +#=============================================================================== class PokemonPokegearScreen def initialize(scene) @scene = scene diff --git a/Data/Scripts/017_UI/009_PScreen_RegionMap.rb b/Data/Scripts/017_UI/009_PScreen_RegionMap.rb index 27f9d558c..b41d499c0 100644 --- a/Data/Scripts/017_UI/009_PScreen_RegionMap.rb +++ b/Data/Scripts/017_UI/009_PScreen_RegionMap.rb @@ -1,3 +1,6 @@ +#=============================================================================== +# +#=============================================================================== class MapBottomSprite < SpriteWrapper attr_reader :mapname attr_reader :maplocation @@ -52,8 +55,9 @@ class MapBottomSprite < SpriteWrapper end end - - +#=============================================================================== +# +#=============================================================================== class PokemonRegionMap_Scene LEFT = 0 TOP = 0 @@ -339,8 +343,9 @@ class PokemonRegionMap_Scene end end - - +#=============================================================================== +# +#=============================================================================== class PokemonRegionMapScreen def initialize(scene) @scene = scene @@ -360,8 +365,9 @@ class PokemonRegionMapScreen end end - - +#=============================================================================== +# +#=============================================================================== def pbShowMap(region=-1,wallmap=true) pbFadeOutIn { scene = PokemonRegionMap_Scene.new(region,wallmap) diff --git a/Data/Scripts/017_UI/010_PScreen_Phone.rb b/Data/Scripts/017_UI/010_PScreen_Phone.rb index 51ab4af75..3d0571b67 100644 --- a/Data/Scripts/017_UI/010_PScreen_Phone.rb +++ b/Data/Scripts/017_UI/010_PScreen_Phone.rb @@ -17,8 +17,9 @@ class Window_PhoneList < Window_CommandPokemon end end - - +#=============================================================================== +# +#=============================================================================== class PokemonPhoneScene def start commands = [] diff --git a/Data/Scripts/017_UI/011_PScreen_Jukebox.rb b/Data/Scripts/017_UI/011_PScreen_Jukebox.rb index 3310995e0..02b3b835c 100644 --- a/Data/Scripts/017_UI/011_PScreen_Jukebox.rb +++ b/Data/Scripts/017_UI/011_PScreen_Jukebox.rb @@ -1,3 +1,6 @@ +#=============================================================================== +# +#=============================================================================== class PokemonJukebox_Scene def pbUpdate pbUpdateSpriteHash(@sprites) @@ -49,8 +52,9 @@ class PokemonJukebox_Scene end end - - +#=============================================================================== +# +#=============================================================================== class PokemonJukeboxScreen def initialize(scene) @scene = scene diff --git a/Data/Scripts/017_UI/012_PScreen_TrainerCard.rb b/Data/Scripts/017_UI/012_PScreen_TrainerCard.rb index c97a42b7e..6c3c25a1f 100644 --- a/Data/Scripts/017_UI/012_PScreen_TrainerCard.rb +++ b/Data/Scripts/017_UI/012_PScreen_TrainerCard.rb @@ -1,3 +1,6 @@ +#=============================================================================== +# +#=============================================================================== class PokemonTrainerCard_Scene def pbUpdate pbUpdateSpriteHash(@sprites) @@ -95,8 +98,9 @@ class PokemonTrainerCard_Scene end end - - +#=============================================================================== +# +#=============================================================================== class PokemonTrainerCardScreen def initialize(scene) @scene = scene diff --git a/Data/Scripts/017_UI/013_PScreen_Load.rb b/Data/Scripts/017_UI/013_PScreen_Load.rb index 8a724ea52..f15c461d6 100644 --- a/Data/Scripts/017_UI/013_PScreen_Load.rb +++ b/Data/Scripts/017_UI/013_PScreen_Load.rb @@ -1,3 +1,6 @@ +#=============================================================================== +# +#=============================================================================== class PokemonLoadPanel < SpriteWrapper attr_reader :selected @@ -91,8 +94,9 @@ class PokemonLoadPanel < SpriteWrapper end end - - +#=============================================================================== +# +#=============================================================================== class PokemonLoad_Scene def pbStartScene(commands,showContinue,trainer,framecount,mapid) @commands = commands @@ -202,8 +206,9 @@ class PokemonLoad_Scene end end - - +#=============================================================================== +# +#=============================================================================== class PokemonLoadScreen def initialize(scene) @scene = scene diff --git a/Data/Scripts/017_UI/014_PScreen_Save.rb b/Data/Scripts/017_UI/014_PScreen_Save.rb index bc5997f52..6a11e4bcd 100644 --- a/Data/Scripts/017_UI/014_PScreen_Save.rb +++ b/Data/Scripts/017_UI/014_PScreen_Save.rb @@ -1,3 +1,6 @@ +#=============================================================================== +# +#=============================================================================== def pbSave(safesave=false) $Trainer.metaID=$PokemonGlobal.playerID begin @@ -55,8 +58,9 @@ def pbEmergencySave $scene=oldscene end - - +#=============================================================================== +# +#=============================================================================== class PokemonSave_Scene def pbStartScreen @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) @@ -93,8 +97,9 @@ class PokemonSave_Scene end end - - +#=============================================================================== +# +#=============================================================================== class PokemonSaveScreen def initialize(scene) @scene=scene @@ -146,8 +151,9 @@ class PokemonSaveScreen end end - - +#=============================================================================== +# +#=============================================================================== def pbSaveScreen scene = PokemonSave_Scene.new screen = PokemonSaveScreen.new(scene) diff --git a/Data/Scripts/017_UI/015_PScreen_Options.rb b/Data/Scripts/017_UI/015_PScreen_Options.rb index 21aa1ff1a..46fcfb8f7 100644 --- a/Data/Scripts/017_UI/015_PScreen_Options.rb +++ b/Data/Scripts/017_UI/015_PScreen_Options.rb @@ -1,3 +1,6 @@ +#=============================================================================== +# +#=============================================================================== class PokemonSystem attr_accessor :textspeed attr_accessor :battlescene @@ -36,8 +39,6 @@ class PokemonSystem def tilemap; return MAP_VIEW_MODE; end end - - #=============================================================================== # Stores game options # Default options are at the top of script section SpriteWindow. @@ -113,8 +114,9 @@ def pbSettingToTextSpeed(speed) return MessageConfig::TextSpeed || 1 end - - +#=============================================================================== +# +#=============================================================================== module MessageConfig def self.pbDefaultSystemFrame begin @@ -153,8 +155,6 @@ module MessageConfig end end - - #=============================================================================== # #=============================================================================== @@ -168,8 +168,9 @@ module PropertyMixin end end - - +#=============================================================================== +# +#=============================================================================== class EnumOption include PropertyMixin attr_reader :values @@ -195,8 +196,9 @@ class EnumOption end end - - +#=============================================================================== +# +#=============================================================================== class EnumOption2 include PropertyMixin attr_reader :values @@ -222,8 +224,9 @@ class EnumOption2 end end - - +#=============================================================================== +# +#=============================================================================== class NumberOption include PropertyMixin attr_reader :name @@ -253,8 +256,9 @@ class NumberOption end end - - +#=============================================================================== +# +#=============================================================================== class SliderOption include PropertyMixin attr_reader :name @@ -285,8 +289,6 @@ class SliderOption end end - - #=============================================================================== # Main options list #=============================================================================== @@ -403,8 +405,6 @@ class Window_PokemonOption < Window_DrawableCommand end end - - #=============================================================================== # Options main screen #=============================================================================== @@ -587,8 +587,6 @@ class PokemonOption_Scene end end - - #=============================================================================== # #=============================================================================== diff --git a/Data/Scripts/017_UI/016_PScreen_ReadyMenu.rb b/Data/Scripts/017_UI/016_PScreen_ReadyMenu.rb index b16095f58..cd891b44b 100644 --- a/Data/Scripts/017_UI/016_PScreen_ReadyMenu.rb +++ b/Data/Scripts/017_UI/016_PScreen_ReadyMenu.rb @@ -1,3 +1,6 @@ +#=============================================================================== +# +#=============================================================================== class ReadyMenuButton < SpriteWrapper attr_reader :index # ID of button attr_reader :selected @@ -91,8 +94,9 @@ class ReadyMenuButton < SpriteWrapper end end - - +#=============================================================================== +# +#=============================================================================== class PokemonReadyMenu_Scene attr_reader :sprites @@ -217,8 +221,9 @@ class PokemonReadyMenu_Scene end end - - +#=============================================================================== +# +#=============================================================================== class PokemonReadyMenu def initialize(scene) @scene = scene @@ -290,8 +295,6 @@ class PokemonReadyMenu end end - - #=============================================================================== # Using a registered item #=============================================================================== diff --git a/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb b/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb index f68ef7d6d..2f8d55b7c 100644 --- a/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb +++ b/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb @@ -41,8 +41,6 @@ class PokemonBoxIcon < IconSprite end end - - #=============================================================================== # Pokémon sprite #=============================================================================== @@ -106,8 +104,9 @@ class MosaicPokemonSprite < PokemonSprite end end - - +#=============================================================================== +# +#=============================================================================== class AutoMosaicPokemonSprite < MosaicPokemonSprite def update super @@ -115,8 +114,6 @@ class AutoMosaicPokemonSprite < MosaicPokemonSprite end end - - #=============================================================================== # Cursor #=============================================================================== @@ -288,8 +285,6 @@ class PokemonBoxArrow < SpriteWrapper end end - - #=============================================================================== # Box #=============================================================================== @@ -444,8 +439,6 @@ class PokemonBoxSprite < SpriteWrapper end end - - #=============================================================================== # Party pop-up panel #=============================================================================== @@ -565,8 +558,6 @@ class PokemonBoxPartySprite < SpriteWrapper end end - - #=============================================================================== # Pokémon storage visuals #=============================================================================== @@ -1452,8 +1443,6 @@ class PokemonStorageScene end end - - #=============================================================================== # Pokémon storage mechanics #=============================================================================== @@ -1469,8 +1458,7 @@ class PokemonStorageScreen def pbStartScreen(command) @heldpkmn = nil - if command==0 -### ORGANISE ################################################################### + if command==0 # Organise @scene.pbStartBox(self,command) loop do selected = @scene.pbSelectBox(@storage.party) @@ -1551,8 +1539,7 @@ class PokemonStorageScreen end end @scene.pbCloseBox - elsif command==1 -### WITHDRAW ################################################################### + elsif command==1 # Withdraw @scene.pbStartBox(self,command) loop do selected = @scene.pbSelectBox(@storage.party) @@ -1592,8 +1579,7 @@ class PokemonStorageScreen end end @scene.pbCloseBox - elsif command==2 -### DEPOSIT #################################################################### + elsif command==2 # Deposit @scene.pbStartBox(self,command) loop do selected = @scene.pbSelectParty(@storage.party) diff --git a/Data/Scripts/017_UI/018_PScreen_ItemStorage.rb b/Data/Scripts/017_UI/018_PScreen_ItemStorage.rb index ac53c3506..073d3fcee 100644 --- a/Data/Scripts/017_UI/018_PScreen_ItemStorage.rb +++ b/Data/Scripts/017_UI/018_PScreen_ItemStorage.rb @@ -1,3 +1,6 @@ +#=============================================================================== +# +#=============================================================================== class Window_PokemonItemStorage < Window_DrawableCommand attr_reader :bag attr_reader :pocket @@ -47,8 +50,9 @@ class Window_PokemonItemStorage < Window_DrawableCommand end end - - +#=============================================================================== +# +#=============================================================================== class ItemStorage_Scene ITEMLISTBASECOLOR = Color.new(88,88,80) ITEMLISTSHADOWCOLOR = Color.new(168,184,184) @@ -169,24 +173,24 @@ class ItemStorage_Scene end end - - +#=============================================================================== +# +#=============================================================================== class WithdrawItemScene < ItemStorage_Scene def initialize super(_INTL("Withdraw\nItem")) end end - - +#=============================================================================== +# +#=============================================================================== class TossItemScene < ItemStorage_Scene def initialize super(_INTL("Toss\nItem")) end end - - #=============================================================================== # Common UI functions used in both the Bag and item storage screens. # Displays messages and allows the user to choose a number/command. diff --git a/Data/Scripts/017_UI/019_PScreen_PC.rb b/Data/Scripts/017_UI/019_PScreen_PC.rb index d4b442fce..ab06fc218 100644 --- a/Data/Scripts/017_UI/019_PScreen_PC.rb +++ b/Data/Scripts/017_UI/019_PScreen_PC.rb @@ -1,3 +1,113 @@ +#=============================================================================== +# +#=============================================================================== +class TrainerPC + def shouldShow? + return true + end + + def name + return _INTL("{1}'s PC",$Trainer.name) + end + + def access + pbMessage(_INTL("\\se[PC access]Accessed {1}'s PC.",$Trainer.name)) + pbTrainerPCMenu + end +end + +#=============================================================================== +# +#=============================================================================== +class StorageSystemPC + def shouldShow? + return true + end + + def name + if $PokemonGlobal.seenStorageCreator + return _INTL("{1}'s PC",pbGetStorageCreator) + else + return _INTL("Someone's PC") + end + end + + def access + pbMessage(_INTL("\\se[PC access]The Pokémon Storage System was opened.")) + command = 0 + loop do + command = pbShowCommandsWithHelp(nil, + [_INTL("Organize Boxes"), + _INTL("Withdraw Pokémon"), + _INTL("Deposit Pokémon"), + _INTL("See ya!")], + [_INTL("Organize the Pokémon in Boxes and in your party."), + _INTL("Move Pokémon stored in Boxes to your party."), + _INTL("Store Pokémon in your party in Boxes."), + _INTL("Return to the previous menu.")],-1,command + ) + if command>=0 && command<3 + if command==1 # Withdraw + if $PokemonStorage.party.length>=6 + pbMessage(_INTL("Your party is full!")) + next + end + elsif command==2 # Deposit + count=0 + for p in $PokemonStorage.party + count += 1 if p && !p.egg? && p.hp>0 + end + if count<=1 + pbMessage(_INTL("Can't deposit the last Pokémon!")) + next + end + end + pbFadeOutIn { + scene = PokemonStorageScene.new + screen = PokemonStorageScreen.new(scene,$PokemonStorage) + screen.pbStartScreen(command) + } + else + break + end + end + end +end + +#=============================================================================== +# +#=============================================================================== +module PokemonPCList + @@pclist = [] + + def self.registerPC(pc) + @@pclist.push(pc) + end + + def self.getCommandList + commands = [] + for pc in @@pclist + commands.push(pc.name) if pc.shouldShow? + end + commands.push(_INTL("Log Off")) + return commands + end + + def self.callCommand(cmd) + return false if cmd<0 || cmd>=@@pclist.length + i = 0 + for pc in @@pclist + next if !pc.shouldShow? + if i==cmd + pc.access + return true + end + i += 1 + end + return false + end +end + #=============================================================================== # PC menus #=============================================================================== @@ -118,90 +228,6 @@ def pbTrainerPCMenu end end - - -class TrainerPC - def shouldShow? - return true - end - - def name - return _INTL("{1}'s PC",$Trainer.name) - end - - def access - pbMessage(_INTL("\\se[PC access]Accessed {1}'s PC.",$Trainer.name)) - pbTrainerPCMenu - end -end - - - -def pbGetStorageCreator - creator = pbStorageCreator - creator = _INTL("Bill") if !creator || creator=="" - return creator -end - - - -class StorageSystemPC - def shouldShow? - return true - end - - def name - if $PokemonGlobal.seenStorageCreator - return _INTL("{1}'s PC",pbGetStorageCreator) - else - return _INTL("Someone's PC") - end - end - - def access - pbMessage(_INTL("\\se[PC access]The Pokémon Storage System was opened.")) - command = 0 - loop do - command = pbShowCommandsWithHelp(nil, - [_INTL("Organize Boxes"), - _INTL("Withdraw Pokémon"), - _INTL("Deposit Pokémon"), - _INTL("See ya!")], - [_INTL("Organize the Pokémon in Boxes and in your party."), - _INTL("Move Pokémon stored in Boxes to your party."), - _INTL("Store Pokémon in your party in Boxes."), - _INTL("Return to the previous menu.")],-1,command - ) - if command>=0 && command<3 - if command==1 # Withdraw - if $PokemonStorage.party.length>=6 - pbMessage(_INTL("Your party is full!")) - next - end - elsif command==2 # Deposit - count=0 - for p in $PokemonStorage.party - count += 1 if p && !p.egg? && p.hp>0 - end - if count<=1 - pbMessage(_INTL("Can't deposit the last Pokémon!")) - next - end - end - pbFadeOutIn { - scene = PokemonStorageScene.new - screen = PokemonStorageScreen.new(scene,$PokemonStorage) - screen.pbStartScreen(command) - } - else - break - end - end - end -end - - - def pbTrainerPC pbMessage(_INTL("\\se[PC open]{1} booted up the PC.",$Trainer.name)) pbTrainerPCMenu @@ -220,40 +246,14 @@ def pbPokeCenterPC pbSEPlay("PC close") end - - -module PokemonPCList - @@pclist = [] - - def self.registerPC(pc) - @@pclist.push(pc) - end - - def self.getCommandList - commands = [] - for pc in @@pclist - commands.push(pc.name) if pc.shouldShow? - end - commands.push(_INTL("Log Off")) - return commands - end - - def self.callCommand(cmd) - return false if cmd<0 || cmd>=@@pclist.length - i = 0 - for pc in @@pclist - next if !pc.shouldShow? - if i==cmd - pc.access - return true - end - i += 1 - end - return false - end +def pbGetStorageCreator + creator = pbStorageCreator + creator = _INTL("Bill") if !creator || creator=="" + return creator end - - +#=============================================================================== +# +#=============================================================================== PokemonPCList.registerPC(StorageSystemPC.new) PokemonPCList.registerPC(TrainerPC.new) diff --git a/Data/Scripts/017_UI/020_PScreen_EggHatching.rb b/Data/Scripts/017_UI/020_PScreen_EggHatching.rb index 7aeaf3660..49f4d6fe6 100644 --- a/Data/Scripts/017_UI/020_PScreen_EggHatching.rb +++ b/Data/Scripts/017_UI/020_PScreen_EggHatching.rb @@ -162,8 +162,9 @@ class PokemonEggHatch_Scene end end - - +#=============================================================================== +# +#=============================================================================== class PokemonEggHatchScreen def initialize(scene) @scene=scene @@ -176,8 +177,9 @@ class PokemonEggHatchScreen end end - - +#=============================================================================== +# +#=============================================================================== def pbHatchAnimation(pokemon) pbMessage(_INTL("Huh?\1")) pbFadeOutInWithMusic { diff --git a/Data/Scripts/017_UI/021_PScreen_Evolution.rb b/Data/Scripts/017_UI/021_PScreen_Evolution.rb index 5aaeb21ba..7f981bc1d 100644 --- a/Data/Scripts/017_UI/021_PScreen_Evolution.rb +++ b/Data/Scripts/017_UI/021_PScreen_Evolution.rb @@ -226,8 +226,9 @@ class SpriteMetafile end end - - +#=============================================================================== +# +#=============================================================================== class SpriteMetafilePlayer def initialize(metafile,sprite=nil) @metafile=metafile @@ -283,8 +284,9 @@ class SpriteMetafilePlayer end end - - +#=============================================================================== +# +#=============================================================================== def pbSaveSpriteState(sprite) state=[] return state if !sprite || sprite.disposed? @@ -342,8 +344,6 @@ def pbRestoreSpriteStateAndBitmap(sprite,state) return state end - - #=============================================================================== # Evolution screen #=============================================================================== diff --git a/Data/Scripts/017_UI/022_PScreen_Trading.rb b/Data/Scripts/017_UI/022_PScreen_Trading.rb index a0b1d9f74..68673ffed 100644 --- a/Data/Scripts/017_UI/022_PScreen_Trading.rb +++ b/Data/Scripts/017_UI/022_PScreen_Trading.rb @@ -1,3 +1,6 @@ +#=============================================================================== +# +#=============================================================================== class PokemonTrade_Scene def pbUpdate pbUpdateSpriteHash(@sprites) @@ -187,8 +190,9 @@ class PokemonTrade_Scene end end - - +#=============================================================================== +# +#=============================================================================== def pbStartTrade(pokemonIndex,newpoke,nickname,trainerName,trainerGender=0) myPokemon = $Trainer.party[pokemonIndex] opponent = PokeBattle_Trainer.new(trainerName,trainerGender) @@ -220,9 +224,6 @@ def pbStartTrade(pokemonIndex,newpoke,nickname,trainerName,trainerGender=0) $Trainer.party[pokemonIndex] = yourPokemon end -#=============================================================================== -# Evolution methods -#=============================================================================== def pbTradeCheckEvolution(pkmn, other_pkmn) return pbCheckEvolutionEx(pkmn) { |pkmn, method, parameter, new_species| success = PBEvolution.call("tradeCheck", method, pkmn, parameter, other_pkmn) diff --git a/Data/Scripts/017_UI/023_PScreen_MoveRelearner.rb b/Data/Scripts/017_UI/023_PScreen_MoveRelearner.rb index f00faf336..70d31d1d2 100644 --- a/Data/Scripts/017_UI/023_PScreen_MoveRelearner.rb +++ b/Data/Scripts/017_UI/023_PScreen_MoveRelearner.rb @@ -1,30 +1,6 @@ -# Unused -def pbHasRelearnableMove?(pokemon) - return pbGetRelearnableMoves(pokemon).length>0 -end - -def pbGetRelearnableMoves(pokemon) - return [] if !pokemon || pokemon.egg? || pokemon.shadowPokemon? - moves=[] - pokemon.getMoveList.each do |m| - next if m[0] > pokemon.level || pokemon.hasMove?(m[1]) - moves.push(m[1]) if !moves.include?(m[1]) - end - tmoves=[] - if pokemon.firstmoves - for i in pokemon.firstmoves - tmoves.push(i) if !pokemon.hasMove?(i) && !moves.include?(i) - end - end - moves=tmoves+moves - return moves|[] # remove duplicates -end - - - -################################################################################ +#=============================================================================== # Scene class for handling appearance of the screen -################################################################################ +#=============================================================================== class MoveRelearner_Scene VISIBLEMOVES = 4 @@ -168,27 +144,44 @@ class MoveRelearner_Scene end end - - +#=============================================================================== # Screen class for handling game logic +#=============================================================================== class MoveRelearnerScreen def initialize(scene) @scene = scene end - def pbStartScreen(pokemon) - moves=pbGetRelearnableMoves(pokemon) - @scene.pbStartScene(pokemon,moves) + def pbGetRelearnableMoves(pkmn) + return [] if !pkmn || pkmn.egg? || pkmn.shadowPokemon? + moves = [] + pkmn.getMoveList.each do |m| + next if m[0] > pkmn.level || pkmn.hasMove?(m[1]) + moves.push(m[1]) if !moves.include?(m[1]) + end + tmoves = [] + if pkmn.firstmoves + for i in pkmn.firstmoves + tmoves.push(i) if !pkmn.hasMove?(i) && !moves.include?(i) + end + end + moves = tmoves + moves + return moves | [] # remove duplicates + end + + def pbStartScreen(pkmn) + moves = pbGetRelearnableMoves(pkmn) + @scene.pbStartScene(pkmn, moves) loop do - move=@scene.pbChooseMove + move = @scene.pbChooseMove if move - if @scene.pbConfirm(_INTL("Teach {1}?",GameData::Move.get(move).name)) - if pbLearnMove(pokemon,move) + if @scene.pbConfirm(_INTL("Teach {1}?", GameData::Move.get(move).name)) + if pbLearnMove(pkmn, move) @scene.pbEndScene return true end end - elsif @scene.pbConfirm(_INTL("Give up trying to teach a new move to {1}?",pokemon.name)) + elsif @scene.pbConfirm(_INTL("Give up trying to teach a new move to {1}?", pkmn.name)) @scene.pbEndScene return false end @@ -196,14 +189,15 @@ class MoveRelearnerScreen end end - - -def pbRelearnMoveScreen(pokemon) +#=============================================================================== +# +#=============================================================================== +def pbRelearnMoveScreen(pkmn) retval = true pbFadeOutIn { scene = MoveRelearner_Scene.new screen = MoveRelearnerScreen.new(scene) - retval = screen.pbStartScreen(pokemon) + retval = screen.pbStartScreen(pkmn) } return retval end diff --git a/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb b/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb index 87637413e..3f1cc15c2 100644 --- a/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb +++ b/Data/Scripts/017_UI/024_PScreen_PurifyChamber.rb @@ -1,3 +1,42 @@ +#=============================================================================== +# +#=============================================================================== +class PokemonGlobalMetadata + attr_writer :purifyChamber + attr_accessor :seenPurifyChamber + + def purifyChamber + @purifyChamber = PurifyChamber.new() if !@purifyChamber + return @purifyChamber + end +end + +#=============================================================================== +# General purpose utilities +#=============================================================================== +def pbDrawGauge(bitmap,rect,color,value,maxValue) + return if !bitmap + bitmap.fill_rect(rect.x,rect.y,rect.width,rect.height,Color.new(0,0,0)) + width=(maxValue<=0) ? 0 : (rect.width-4)*value/maxValue + if rect.width>=4 && rect.height>=4 + bitmap.fill_rect(rect.x+2,rect.y+2,rect.width-4,rect.height-4,Color.new(248,248,248)) + bitmap.fill_rect(rect.x+2,rect.y+2,width,rect.height-4,color) + end +end + +def calcPoint(x,y,distance,angle) # angle in degrees + angle -=(angle/360.0).floor*360 # normalize + angle = (angle/360.0)*(2*Math::PI) # convert to radians + angle = -angle % (2*Math::PI) # normalize radians + point = [(Math.cos(angle) * distance), (Math.sin(angle) * distance)] + point[0] += x + point[1] += y + return point +end + +#=============================================================================== +# +#=============================================================================== class PurifyChamberSet attr_reader :facing attr_reader :shadow @@ -27,11 +66,9 @@ class PurifyChamberSet end end -=begin -Main component is tempo -Boosted if center has advantage over facing Pokemon -Boosted based on number of best circles -=end + # Main component is tempo + # Boosted if center has advantage over facing Pokemon + # Boosted based on number of best circles def flow ret=0 return 0 if !@shadow @@ -54,8 +91,8 @@ Boosted based on number of best circles return (PurifyChamberSet.isSuperEffective(@list[i],@list[(i+1)%@list.length])) ? 2 : 1 end -# Tempo refers to the type advantages of each Pokemon in a certain set in a -# clockwise direction. Tempo also depends on the number of Pokemon in the set + # Tempo refers to the type advantages of each Pokemon in a certain set in a + # clockwise direction. Tempo also depends on the number of Pokemon in the set def tempo ret=0 for i in 0...@list.length @@ -103,9 +140,10 @@ Boosted based on number of best circles end end - - -class PurifyChamber # German: der Kryptorbis +#=============================================================================== +# +#=============================================================================== +class PurifyChamber NUMSETS=9 SETSIZE=4 attr_reader :currentSet # German: das Forum @@ -231,68 +269,9 @@ class PurifyChamber # German: der Kryptorbis end end - - -class PokemonGlobalMetadata - attr_writer :purifyChamber - attr_accessor :seenPurifyChamber - - def purifyChamber - @purifyChamber = PurifyChamber.new() if !@purifyChamber - return @purifyChamber - end -end - - - -class PurifyChamberPC - def shouldShow? - return $PokemonGlobal.seenPurifyChamber - end - - def name - return _INTL("Purify Chamber") - end - - def access - pbMessage(_INTL("\\se[PC access]Accessed the Purify Chamber.")) - pbPurifyChamber() - end -end - - - -PokemonPCList.registerPC(PurifyChamberPC.new) - -##################### +#=============================================================================== # -# General purpose utilities -# - -def pbDrawGauge(bitmap,rect,color,value,maxValue) - return if !bitmap - bitmap.fill_rect(rect.x,rect.y,rect.width,rect.height,Color.new(0,0,0)) - width=(maxValue<=0) ? 0 : (rect.width-4)*value/maxValue - if rect.width>=4 && rect.height>=4 - bitmap.fill_rect(rect.x+2,rect.y+2,rect.width-4,rect.height-4,Color.new(248,248,248)) - bitmap.fill_rect(rect.x+2,rect.y+2,width,rect.height-4,color) - end -end - -def calcPoint(x,y,distance,angle) # angle in degrees - angle -=(angle/360.0).floor*360 # normalize - angle = (angle/360.0)*(2*Math::PI) # convert to radians - angle = -angle % (2*Math::PI) # normalize radians - point = [(Math.cos(angle) * distance), (Math.sin(angle) * distance)] - point[0] += x - point[1] += y - return point -end - - -##################### - - +#=============================================================================== module PurifyChamberHelper def self.pbGetPokemon2(chamber,set,position) if position==0 @@ -349,19 +328,20 @@ module PurifyChamberHelper end end - - +#=============================================================================== +# +#=============================================================================== class PurifyChamberScreen def initialize(scene) @scene=scene @chamber=$PokemonGlobal.purifyChamber -# for j in 0...PurifyChamber::NUMSETS -# @chamber.debugAddShadow(j,rand(100)+1) -# @chamber[j].shadow.heartgauge=0 -# for i in 0...PurifyChamber::SETSIZE -# @chamber.debugAddNormal(j,rand(100)+1) -# end -# end +# for j in 0...PurifyChamber::NUMSETS +# @chamber.debugAddShadow(j,rand(100)+1) +# @chamber[j].shadow.heartgauge=0 +# for i in 0...PurifyChamber::SETSIZE +# @chamber.debugAddNormal(j,rand(100)+1) +# end +# end end def pbPlace(pkmn,position) @@ -637,10 +617,9 @@ class PurifyChamberScreen end end - -################################################ - - +#=============================================================================== +# +#=============================================================================== class Window_PurifyChamberSets < Window_DrawableCommand attr_reader :switching @@ -682,8 +661,9 @@ class Window_PurifyChamberSets < Window_DrawableCommand end end - - +#=============================================================================== +# +#=============================================================================== class DirectFlowDiagram def initialize(viewport=nil) @points=[] @@ -756,8 +736,9 @@ class DirectFlowDiagram end end - - +#=============================================================================== +# +#=============================================================================== class FlowDiagram def initialize(viewport=nil) @points=[] @@ -844,8 +825,9 @@ class FlowDiagram end end - - +#=============================================================================== +# +#=============================================================================== class PurifyChamberSetView < SpriteWrapper attr_reader :set attr_reader :cursor @@ -1085,8 +1067,9 @@ class PurifyChamberSetView < SpriteWrapper end end - - +#=============================================================================== +# +#=============================================================================== class PurifyChamberScene def pbUpdate() pbUpdateSpriteHash(@sprites) @@ -1297,8 +1280,9 @@ class PurifyChamberScene end end - - +#=============================================================================== +# +#=============================================================================== def pbPurifyChamber $PokemonGlobal.seenPurifyChamber = true pbFadeOutIn { @@ -1307,3 +1291,26 @@ def pbPurifyChamber screen.pbStartPurify } end + +#=============================================================================== +# +#=============================================================================== +class PurifyChamberPC + def shouldShow? + return $PokemonGlobal.seenPurifyChamber + end + + def name + return _INTL("Purify Chamber") + end + + def access + pbMessage(_INTL("\\se[PC access]Accessed the Purify Chamber.")) + pbPurifyChamber() + end +end + +#=============================================================================== +# +#=============================================================================== +PokemonPCList.registerPC(PurifyChamberPC.new) diff --git a/Data/Scripts/017_UI/025_PScreen_Mart.rb b/Data/Scripts/017_UI/025_PScreen_Mart.rb index 29da610f0..c28270498 100644 --- a/Data/Scripts/017_UI/025_PScreen_Mart.rb +++ b/Data/Scripts/017_UI/025_PScreen_Mart.rb @@ -81,8 +81,6 @@ class PokemonMartAdapter end end - - #=============================================================================== # Abstraction layer for RPG Maker XP # Won't be used if $PokemonBag exists @@ -216,7 +214,6 @@ class RpgxpMartAdapter end end - #=============================================================================== # Buy and Sell adapters #=============================================================================== @@ -238,8 +235,9 @@ class BuyAdapter end end - - +#=============================================================================== +# +#=============================================================================== class SellAdapter def initialize(adapter) @adapter = adapter @@ -262,8 +260,6 @@ class SellAdapter end end - - #=============================================================================== # Pokémon Mart #=============================================================================== @@ -305,8 +301,9 @@ class Window_PokemonMart < Window_DrawableCommand end end - - +#=============================================================================== +# +#=============================================================================== class PokemonMart_Scene def update pbUpdateSpriteHash(@sprites) @@ -657,10 +654,9 @@ class PokemonMart_Scene end end - -####################################################### - - +#=============================================================================== +# +#=============================================================================== class PokemonMartScreen def initialize(scene,stock) @scene=scene @@ -786,8 +782,9 @@ class PokemonMartScreen end end - - +#=============================================================================== +# +#=============================================================================== def pbPokemonMart(stock,speech=nil,cantsell=false) for i in 0...stock.length stock[i] = GameData::Item.get(stock[i]).id @@ -822,64 +819,3 @@ def pbPokemonMart(stock,speech=nil,cantsell=false) end $game_temp.clear_mart_prices end - - - -class Game_Temp - attr_writer :mart_prices - - def mart_prices - @mart_prices = [] if !@mart_prices - return @mart_prices - end - - def clear_mart_prices - @mart_prices = [] - end -end - - - -class Interpreter - def getItem(p) - if p[0]==0; return $data_items[p[1]] - elsif p[0]==1; return $data_weapons[p[1]] - elsif p[0]==2; return $data_armors[p[1]] - end - return nil - end - - def command_302 - $game_temp.battle_abort = true - shop_goods = [getItem(@parameters)] - # Loop - loop do - # Advance index - @index += 1 - # If next event command has shop on second line or after - if @list[@index].code == 605 - # Add goods list to new item - shop_goods.push(getItem(@list[@index].parameters)) - else - # End - pbPokemonMart(shop_goods.compact) - return true - end - end - end - - def setPrice(item,buyprice=-1,sellprice=-1) - item = GameData::Item.get(item).id - $game_temp.mart_prices[item] = [-1,-1] if !$game_temp.mart_prices[item] - $game_temp.mart_prices[item][0] = buyprice if buyprice>0 - if sellprice>=0 # 0=can't sell - $game_temp.mart_prices[item][1] = sellprice*2 - else - $game_temp.mart_prices[item][1] = buyprice if buyprice>0 - end - end - - def setSellPrice(item,sellprice) - setPrice(item,-1,sellprice) - end -end diff --git a/Data/Scripts/017_UI/026_PScreen_MysteryGift.rb b/Data/Scripts/017_UI/026_PScreen_MysteryGift.rb index cb34ff338..033577370 100644 --- a/Data/Scripts/017_UI/026_PScreen_MysteryGift.rb +++ b/Data/Scripts/017_UI/026_PScreen_MysteryGift.rb @@ -9,8 +9,9 @@ MYSTERY_GIFT_URL = "http://images1.wikia.nocookie.net/pokemonessentials/images/e/e7/MysteryGift.txt" # MYSTERY_GIFT_URL = "http://pastebin.com/raw/w6BqqUsm" - - +#=============================================================================== +# +#=============================================================================== class PokeBattle_Trainer attr_writer :mysterygiftaccess # Whether MG can be used from load screen attr_writer :mysterygift # Variable that stores downloaded MG data @@ -24,8 +25,6 @@ class PokeBattle_Trainer end end - - #=============================================================================== # Creating a new Mystery Gift for the Master file, and editing an existing one. #=============================================================================== diff --git a/Data/Scripts/017_UI/027_PScreen_HallOfFame.rb b/Data/Scripts/017_UI/027_PScreen_HallOfFame.rb index 821ac2453..57efb9ff1 100644 --- a/Data/Scripts/017_UI/027_PScreen_HallOfFame.rb +++ b/Data/Scripts/017_UI/027_PScreen_HallOfFame.rb @@ -437,8 +437,9 @@ class HallOfFame_Scene end end - - +#=============================================================================== +# +#=============================================================================== class HallOfFameScreen def initialize(scene) @scene = scene @@ -457,8 +458,9 @@ class HallOfFameScreen end end - - +#=============================================================================== +# +#=============================================================================== class HallOfFamePC def shouldShow? return $PokemonGlobal.hallOfFameLastNumber>0 @@ -474,12 +476,14 @@ class HallOfFamePC end end - - +#=============================================================================== +# +#=============================================================================== PokemonPCList.registerPC(HallOfFamePC.new) - - +#=============================================================================== +# +#=============================================================================== class PokemonGlobalMetadata attr_writer :hallOfFame # Number necessary if hallOfFame array reach in its size limit @@ -495,8 +499,9 @@ class PokemonGlobalMetadata end end - - +#=============================================================================== +# +#=============================================================================== def pbHallOfFameEntry scene=HallOfFame_Scene.new screen=HallOfFameScreen.new(scene)