Advertisement
mjshi

Goddess's Light

Oct 21st, 2015
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.96 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Goddess's Light v1.0
  3. #-- Show a resurrection option on gameover as well as additional holy gifts
  4. #-- By mjshi
  5. #-- LONG LIVE TEAM GOOD! -oh wait, with this script, we're basically immortal
  6. #-------------------------------------------------------------------------------
  7. # Installation:
  8. # Put above Main, preferably below all other custom scripts.
  9. #
  10. module LIGHT
  11.   #-----------------------------------------------------------------------------
  12.   # **CONFIGURATION**
  13.   #-----------------------------------------------------------------------------
  14.   # What should be the background of the resurrection screen?
  15.   #
  16.   GODDESS = "Graphics/Pictures/goddess.jpg"
  17.   #
  18.   # What should the resurrection window say?
  19.   #
  20.   REVIVE = "Resurrection"
  21.   REWIND = "Rewind Time"
  22.   TO_TITLE = "Ascension"
  23.   #  
  24.   #-----------------------------------------------------------------------------
  25.   # Width and location of the resurrection window
  26.   #
  27.   WIDTH = 180 #default 160
  28.   XPOS = (Graphics.width - WIDTH)/2
  29.   YPOS = (Graphics.height/4) * 3
  30.   #
  31.   #-----------------------------------------------------------------------------
  32.   # The ID of the common event to run after the player is resurrected
  33.   #
  34.   RESURRECTION_EVENTID = 1
  35.   #
  36.   #-----------------------------------------------------------------------------
  37.   # How much HP/MP should resurrection restore?
  38.   #-----------------------------------------------------------------------------
  39.   # SPECIAL CASES:
  40.   # RESTORE_HP = "full heal" restores both HP and MP to max.
  41.   # Set RESTORE_MP = "none" if you have RESTORE_HP set to "full heal".
  42.   #-----------------------------------------------------------------------------
  43.   # OTHERWISE:
  44.   # Set RESTORE_HP to a point value (greater than or equal to 1) to restore
  45.   # that much HP.
  46.   # Set RESTORE_HP to a decimal percentage (less than 1) to restore a percentage
  47.   # of HP. The same rules apply for RESTORE_MP.
  48.   #-----------------------------------------------------------------------------
  49.   #
  50.   RESTORE_HP = "full heal"
  51.   RESTORE_MP = 100
  52.   #
  53.   #-----------------------------------------------------------------------------
  54.   # Should there be additional blessings/gifts when you're resurrected?
  55.   #
  56.   BLESSING = false #set to false if not
  57.  
  58.   # If true, what should the background be?
  59.   BLESSING_BG = "Graphics/Pictures/goddess_blessing.jpg"
  60.  
  61.   # How wide should the window be? Where should it be?
  62.   BWIDTH = 160
  63.   BXPOS = (Graphics.width - BWIDTH)/2
  64.   BYPOS = YPOS
  65.  
  66.   # Okay, and what should the gifts be called?
  67.   STRENGTH = "Strength"
  68.   WISDOM = "Wisdom"
  69.   SPEED = "Swiftness"
  70.  
  71.   # What are the item IDs of the gifts?
  72.   STR_ITEM = 1
  73.   WIS_ITEM = 2
  74.   SPD_ITEM = 3
  75.   #
  76.   #-----------------------------------------------------------------------------
  77.  
  78. end
  79.  
  80. #--------------------------------------------------------------------#
  81. # !!! Beware of crashes and errors if you edit beyond this point !!! #
  82. #--------------------------------------------------------------------#
  83.  
  84. class Window_GoddessLight < Window_Command
  85.   def initialize
  86.     super(0, 0)
  87.   end
  88.  
  89.   def window_width
  90.     return LIGHT::WIDTH
  91.   end
  92.  
  93.   def visible_line_number
  94.     item_max
  95.   end
  96.  
  97.   def make_command_list
  98.     add_command(LIGHT::REVIVE, :resurrect)
  99.     add_command(LIGHT::REWIND, :load)
  100.     add_command(LIGHT::TO_TITLE, :title)
  101.   end
  102. end
  103.  
  104. class Window_GoddessBlessing < Window_Command
  105.   def initialize
  106.     super(0, 0)
  107.   end
  108.  
  109.   def window_width
  110.     return LIGHT::BWIDTH
  111.   end
  112.   def visible_line_number
  113.     item_max
  114.   end
  115.   def make_command_list
  116.     add_command(LIGHT::STRENGTH, :strength)
  117.     add_command(LIGHT::WISDOM, :wisdom)
  118.     add_command(LIGHT::SPEED, :speed)
  119.   end
  120. end
  121.  
  122. class Scene_Gameover < Scene_Base
  123.   def start
  124.     super
  125.     play_gameover_music
  126.     fadeout_frozen_graphics
  127.     create_background
  128.     create_command_window
  129.   end
  130.  
  131.   def terminate
  132.     super
  133.     dispose_background
  134.   end
  135.  
  136.   def create_command_window
  137.     @command_window =  Window_GoddessLight.new
  138.     @command_window.set_handler(:resurrect,   method(:command_resurrect))
  139.     @command_window.set_handler(:load,    method(:command_load))
  140.     @command_window.set_handler(:title,  method(:command_title))
  141.     @command_window.x = (LIGHT::XPOS)
  142.     @command_window.y = (LIGHT::YPOS)
  143.     end
  144.  
  145.   def perform_transition
  146.     Graphics.transition(fadein_speed)
  147.   end
  148.  
  149.   def play_gameover_music
  150.     RPG::BGM.stop
  151.     RPG::BGS.stop
  152.     $data_system.gameover_me.play
  153.   end
  154.  
  155.   def fadeout_frozen_graphics
  156.     Graphics.transition(fadeout_speed)
  157.     Graphics.freeze
  158.   end
  159.  
  160.   def create_background
  161.     @sprite = Sprite.new
  162.     @sprite = Sprite.new
  163.     @sprite.bitmap = Bitmap.new(LIGHT::GODDESS)
  164.   end
  165.  
  166.   def dispose_background
  167.     @sprite.bitmap.dispose
  168.     @sprite.dispose
  169.   end
  170.  
  171.   def fadein_speed
  172.     return 120
  173.   end
  174.  
  175.   def fadeout_speed
  176.     return 60
  177.   end
  178.  
  179.   def command_load
  180.     SceneManager.call(Scene_Load)
  181.   end
  182.  
  183.   def command_title
  184.     SceneManager.call(Scene_Title)
  185.   end
  186.  
  187.   def command_resurrect
  188.     if not LIGHT::BLESSING
  189.       resurrect
  190.     else
  191.       blessing
  192.     end
  193.   end
  194.  
  195.   def blessing
  196.     @sprite.bitmap = Bitmap.new(LIGHT::BLESSING_BG)
  197.     @command_window.hide
  198.     @command_window =  Window_GoddessBlessing.new
  199.     @command_window.set_handler(:strength,    method(:command_str))
  200.     @command_window.set_handler(:wisdom,      method(:command_wis))
  201.     @command_window.set_handler(:speed,  method(:command_spd))
  202.     @command_window.x = (LIGHT::BXPOS)
  203.     @command_window.y = (LIGHT::BYPOS)
  204.     @command_window.set_handler(:cancel, method(:command_return_blessing))
  205.   end
  206.   def command_return_blessing
  207.     @command_window.hide
  208.     @sprite.bitmap = Bitmap.new(LIGHT::GODDESS)
  209.     create_command_window
  210.   end
  211.   def command_str
  212.     $game_party.gain_item($data_items[LIGHT::STR_ITEM], 1)
  213.     resurrect
  214.   end
  215.   def command_wis
  216.     $game_party.gain_item($data_items[LIGHT::WIS_ITEM], 1)
  217.     resurrect
  218.   end
  219.   def command_spd
  220.     $game_party.gain_item($data_items[LIGHT::SPD_ITEM], 1)
  221.     resurrect
  222.   end
  223.   def resurrect
  224.     if LIGHT::RESTORE_HP == "full heal"
  225.       $game_party.members.each { |actor| actor.recover_all }
  226.     elsif LIGHT::RESTORE_HP >= 1
  227.       $game_party.members.each { |actor|
  228.       actor.hp += LIGHT::RESTORE_HP
  229.       }
  230.     elsif LIGHT::RESTORE_HP < 1
  231.       $game_party.members.each { |actor|
  232.       actor.hp += actor.mhp * LIGHT::RESTORE_HP
  233.       }
  234.     end
  235.    
  236.     if LIGHT::RESTORE_MP == "none"
  237.       nil
  238.     elsif LIGHT::RESTORE_MP >= 1
  239.       $game_party.members.each { |actor|
  240.       actor.mp += LIGHT::RESTORE_MP
  241.       }
  242.     elsif LIGHT::RESTORE_MP < 1
  243.       $game_party.members.each { |actor|
  244.       actor.mp += actor.mmp * LIGHT::RESTORE_MP
  245.       }
  246.     end
  247.     revive_end_proc
  248.   end
  249.   def revive_end_proc
  250.     SceneManager.call(Scene_Map)
  251.     $game_temp.reserve_common_event(LIGHT::RESURRECTION_EVENTID)
  252.   end
  253. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement