Advertisement
TheSixth

Common Event on Game Over

Aug 30th, 2016
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.38 KB | None | 0 0
  1. =begin
  2.  
  3. - Common Event on Game Over
  4. Made by: Sixth
  5.  
  6. Description:
  7. This script will redirect the game over feature to call a common event instead
  8. of showing the regular game over screen.
  9. NOTE:
  10. This script will NOT work in the engine's default battles, only on the map!
  11. Get Yanfly's Death Common Event script for that!
  12.  
  13. Script Calls:
  14. You can change the death common event during the game with this script call:
  15.  
  16.   $game_system.game_over_data[:cm_event] = cm_event_id
  17.  
  18. Just replace the cm_event_id with the ID of the common event you want to use
  19. after the script call. This change will be permanent, so until you change it
  20. again, it will remain the same common event!
  21.  
  22. Installation:
  23. Put this script between Materials and Main!
  24.  
  25. =end
  26.  
  27. module GmOver
  28.  
  29.   # If this is set to true, the "Game Over" event command will automatically
  30.   # disable this script, so it can proceed to the game over screen like it
  31.   # would normally do.
  32.   # I suppose if you call the game over screen with an event, you want to make
  33.   # sure that the player ends up on that game over screen for real, so I made
  34.   # this setting.
  35.   # If you don't want to use this feature, set this to false.
  36.   # Note that if this is false, whenever you use the "Game Over" event command,
  37.   # your game over common event will run instead of going to the real game over
  38.   # screen, and that means, that you will end up in a loop unless you revive
  39.   # your party members in your event!
  40.   # If you want to call the real game over screen within your event but this
  41.   # fix is NOT enabled, you will first need to turn the disable switch for this
  42.   # script ON and use the "Game Over" event command only AFTER you have done
  43.   # that! If you don't do that, say hi to the loop you get! :P
  44.   EvCmdFix = true
  45.  
  46.   # Set up the common event called on death and the disable switch here.
  47.   # When that disable switch is turned ON, the game over stuffs will happen
  48.   # like it would without this script (so, it will move the player to the real
  49.   # game over screen if the party is dead).
  50.   Settings = {
  51.     :cm_event => 7,  # Common Event ID.
  52.     :d_switch => 170, # Disable Switch ID.
  53.   }
  54.  
  55. end
  56.  
  57. class Game_System
  58.  
  59.   attr_accessor :game_over_data
  60.  
  61.   def game_over_data
  62.     init_game_over_data if @game_over_data.nil?
  63.     return @game_over_data
  64.   end
  65.  
  66.   def init_game_over_data
  67.     @game_over_data = Marshal.load(Marshal.dump(GmOver::Settings))
  68.   end
  69.  
  70. end
  71.  
  72. class << SceneManager
  73.  
  74.   alias redirect_gmover8826 goto
  75.   def goto(scene_class)
  76.     if scene_class == Scene_Gameover && scene_is?(Scene_Map)
  77.       $game_player.reset_action
  78.       if !$game_switches[$game_system.game_over_data[:d_switch]]
  79.         return if $game_map.interpreter.running? || $game_temp.common_event_reserved?
  80.         $game_temp.reserve_common_event($game_system.game_over_data[:cm_event])
  81.       else
  82.         redirect_gmover8826(scene_class)
  83.       end
  84.     else
  85.       redirect_gmover8826(scene_class)
  86.     end
  87.   end
  88.  
  89. end
  90.  
  91. if GmOver::EvCmdFix
  92.  
  93.   class Game_Interpreter
  94.  
  95.     alias fix_gmover_call8872 command_353
  96.     def command_353
  97.       $game_switches[$game_system.game_over_data[:d_switch]] = true
  98.       fix_gmover_call8872
  99.     end
  100.  
  101.   end
  102.  
  103. end
  104. #==============================================================================
  105. # !!END OF SCRIPT - OHH, NOES!!
  106. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement