Advertisement
kurashi

[RGSS3] GameOver with Continue?

Jul 25th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.29 KB | None | 0 0
  1. module Editable_Region
  2.    
  3.   # If this value is 1 or less it will act as a percentage.
  4.   # If it is more than 1 it will be a flat amount.
  5.   GoldLoss = 0.5
  6.  
  7.   # Set these to the variable ID's that you will store the MapID, X, and Y
  8.   # of where you want the player to respwan at.
  9.   MapID = 1
  10.   XPos  = 0
  11.   YPos  = 0
  12.    
  13. end  # STAT_VALUES
  14.  
  15. ################################################################################
  16. ####### DO NOT EDIT BEYOND THIS POINT UNLESS YOU KNOW WHAT YOU ARE DOING #######
  17. ################################################################################
  18. module BattleManager
  19.   def self.process_defeat
  20.     $game_message.add(sprintf(Vocab::Defeat, $game_party.name))
  21.     wait_for_message
  22.     if @can_lose
  23.       revive_battle_members
  24.       replay_bgm_and_bgs
  25.       SceneManager.return
  26.     else
  27.       SceneManager.goto(Scene_GameOver)
  28.     end
  29.     battle_end(2)
  30.     return true
  31.   end
  32. end
  33.  
  34. class Game_interpreter
  35.   def command_311
  36.     value = operate_value(@params[2], @params[3], @params[4])
  37.     iterate_actor_var(@params[0], @params[1]) do |actor|
  38.       next if actor.dead?
  39.       actor.change_hp(value, @params[5])
  40.       actor.perform_collapse_effect if actor.dead?
  41.     end
  42.     SceneManager.goto(Scene_GameOver) if $game_party.all_dead?
  43.   end
  44. end
  45.  
  46. class Scene_Base
  47.   def check_gameover
  48.     SceneManager.goto(Scene_GameOver) if $game_party.all_dead?
  49.   end
  50. end
  51.  
  52.  
  53. class Scene_GameOver < Scene_MenuBase
  54.   #--------------------------------------------------------------------------
  55.   # * Start Processing
  56.   #--------------------------------------------------------------------------
  57.   def start
  58.     super
  59.     create_command_window
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # * Create Background
  63.   #--------------------------------------------------------------------------
  64.   def create_background
  65.     @background_sprite = Sprite.new
  66.     @background_sprite.bitmap = Cache.system("GameOver")
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # * Create Command Window
  70.   #--------------------------------------------------------------------------
  71.   def create_command_window
  72.     @command_window = Window_GameOver.new
  73.     @command_window.set_handler(:Continue?, method(:continue_and_close_command_window))
  74.     @command_window.set_handler(:to_title, method(:command_to_title))
  75.     @command_window.set_handler(:shutdown,   method(:command_shutdown))
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # * Close Command Window
  79.   #--------------------------------------------------------------------------
  80.   def continue_and_close_command_window
  81.     @command_window.close
  82.     @background_sprite.dispose
  83.     update until @command_window.close?
  84.     heal_all_actors
  85.     $game_player.reserve_transfer($game_variables[Editable_Region::MapID], $game_variables[Editable_Region::XPos], $game_variables[Editable_Region::YPos], 2)
  86.     SceneManager.goto(Scene_Map)
  87.     if Editable_Region::GoldLoss > 1
  88.       $game_party.gold -= Editable_Region::GoldLoss
  89.     elsif Editable_Region::GoldLoss == 0
  90.     else
  91.       @gold = $game_party.gold
  92.       @multiplier = Editable_Region::GoldLoss
  93.       @value = @gold*@multiplier
  94.       p "#{@value}"
  95.       $game_party.lose_gold(@value.ceil)
  96.     end
  97.   end
  98.  
  99.   def heal_all_actors
  100.     $game_party.members.each { |actor|
  101.     actor.recover_all
  102.     actor.hp = 1
  103.     actor.mp = 1
  104.     }
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # * [Go to Title] Command
  108.   #--------------------------------------------------------------------------
  109.   def command_to_title
  110.     @command_window.close
  111.     @background_sprite.dispose
  112.     fadeout_all
  113.     SceneManager.goto(Scene_Title)
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # * [Shut Down] Command
  117.   #--------------------------------------------------------------------------
  118.   def command_shutdown
  119.     @command_window.close
  120.     @background_sprite.dispose
  121.     fadeout_all
  122.     SceneManager.exit
  123.   end
  124. end
  125.  
  126.  
  127. class Window_GameOver < Window_Command
  128.   #--------------------------------------------------------------------------
  129.   # * Object Initialization
  130.   #--------------------------------------------------------------------------
  131.   def initialize
  132.     super(0, 0)
  133.     update_placement
  134.     self.openness = 0
  135.     open
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # * Get Window Width
  139.   #--------------------------------------------------------------------------
  140.   def window_width
  141.     return 160
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # * Update Window Position
  145.   #--------------------------------------------------------------------------
  146.   def update_placement
  147.     self.x = (Graphics.width - width) / 2
  148.     self.y = ((Graphics.height - height) / 2) + 75
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # * Create Command List
  152.   #--------------------------------------------------------------------------
  153.   def make_command_list
  154.     add_command("Continue?", :Continue?)
  155.     add_command(Vocab::to_title, :to_title)
  156.     add_command(Vocab::shutdown, :shutdown)
  157.   end
  158. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement