Advertisement
kurashi

Ending Stats Scene for RavenBlueIndigo

Apr 12th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.88 KB | None | 0 0
  1. module STAT_VALUES
  2.   ENDING_ITEMS = 5 # Game Variable for collected Items.
  3.   ENDING_ITEMS_MAX = 100 #Maximum number of Ending Items.
  4.   OPTIONAL_SCENES = 6 # Game Variable for Optional Scenes Viewed.
  5.   OPTIONAL_SCENES_MAX = 30 #Maximum number of Optional Scenes Viewed.
  6.   POINTS = 7 # Game Variable for the number of Points recieved.
  7.   DEATHS = 8 # Game Variable for the number of Game Overs. Stored with Theo.
  8.              # Set this to 0 at the begining or you will get wrong values.
  9.   ENDINGS = 9 # Game Variable to indicate the current Ending. Starts at 0.
  10.               # Neutral Ending, Steak Ending, Gold Ending,
  11.               # Cophat Ending, Forthward Ending, Unkown Ending.
  12.   NUMBER_TIMES_ENCOUNTERED = 20 # Starting Game Variable for number of times
  13.                                 # ending is encountered. Note: This follows the
  14.                                 # above list and requires a variable for each.
  15.                                 # They must be in order, and have no gaps.
  16.                                 # Furthermore they must each be stored with
  17.                                 # Theo's Variable Store Script.
  18. end  # STAT_VALUES
  19.  
  20. ################################################################################
  21. ####### DO NOT EDIT BEYOND THIS POINT UNLESS YOU KNOW WHAT YOU ARE DOING #######
  22. ################################################################################
  23.  
  24. class Scene_Gameover < Scene_Base
  25.   def start
  26.     super
  27.     play_gameover_music
  28.     fadeout_frozen_graphics
  29.     create_background
  30.     $game_variables[STAT_VALUES::DEATHS] += 1
  31.     DataManager.save_variables
  32.   end
  33. end  #Scene_Gameover
  34.  
  35.  
  36. class Scene_Statistics < Scene_Base #Waiting until I have the window done.
  37.  
  38.   def start
  39.     super
  40.     create_statistics_window
  41.   end
  42.  
  43.   def create_statistics_window
  44.     @stats_window = Window_EndingStatistics.new
  45.   end
  46.  
  47.   def update
  48.     super
  49.     goto_title if Input.trigger?(:C)
  50.   end
  51.  
  52.   def goto_title
  53.     fadeout_all
  54.     @stats_window.dispose
  55.     SceneManager.goto(Scene_Title)
  56.   end
  57. end
  58.  
  59. class Window_EndingStatistics < Window_Base
  60.   def initialize()
  61.     x = (Graphics.width - 400) / 2
  62.     y = (Graphics.height - 320) / 2
  63.     super(x, y, 400, 320)
  64.     self.windowskin = Cache.system("Window")
  65.     @opening = @closing = false
  66.     fill_text
  67.   end# initialize
  68.   def update
  69.     super
  70.     dispose if Input.trigger?(:C)
  71.   end# update
  72.   def fill_text
  73.     calculate_rank
  74.     @text = ["Deaths: #{$game_variables[STAT_VALUES::DEATHS]}",
  75.     "Saves: #{$game_system.save_count}",
  76.     "Play Time: #{$game_system.playtime_s}",
  77.     "Ending Items Found: #{$game_variables[STAT_VALUES::ENDING_ITEMS]} of #{STAT_VALUES::ENDING_ITEMS_MAX}.",
  78.     "Optional Scenes Found: #{$game_variables[STAT_VALUES::OPTIONAL_SCENES]} of #{STAT_VALUES::OPTIONAL_SCENES_MAX}.",
  79.     "Steps Taken: #{$game_party.steps}",
  80.     "Current Ending: #{self.endings}",
  81.     "Time Ending Recieved: #{@times_recieved}",
  82.     "Total Different Endings: #{self.total_endings}",
  83.     "Total Points: #{$game_variables[STAT_VALUES::POINTS]} of 100.",
  84.     "Rank: #{@rank_score}"
  85.     ] #Do not remove.
  86.     @line = 10
  87.     @text.each do |text|
  88.       draw_text(10, @line, width, line_height, text)
  89.       @line += 24
  90.     end
  91.   end# fill_text
  92.   def calculate_rank
  93.     @rank = self.pointscore - self.deathscore
  94.     if @rank < 0; @rank = 0; end
  95.     case @rank
  96.       when 500
  97.         @rank_score = "S"
  98.       when 400..499
  99.         @rank_score = "A"
  100.       when 300..399
  101.         @rank_score = "B"
  102.       when 200..299
  103.         @rank_score = "C"
  104.       when 100..199
  105.         @rank_score = "D"
  106.       when 0..99
  107.         @rank_score = "F"
  108.     end  
  109.   end# calculate_rank
  110.   def pointscore
  111.     @points_variable = STAT_VALUES::POINTS
  112.     @points = $game_variables[@points_variable]
  113.     @points *= 5
  114.   end# pointscore
  115.   def deathscore
  116.     @deaths_variable = STAT_VALUES::DEATHS
  117.     @deaths = $game_variables[@deaths_variable]
  118.     @deaths *= 5
  119.   end# deathscore
  120.   def endings
  121.     case $game_variables[STAT_VALUES::ENDINGS]
  122.       when 0
  123.         $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED] += 1
  124.         @times_recieved = $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED]
  125.         "Neutral Ending"
  126.       when 1
  127.         $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED+1] += 1
  128.         @times_recieved = $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED+1]
  129.         "Steak Ending"
  130.       when 2
  131.         $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED+2] += 1
  132.         @times_recieved = $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED+2]
  133.         "Gold Ending"
  134.       when 3
  135.         $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED+3] += 1
  136.         @times_recieved = $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED+3]
  137.         "Cophat Ending"
  138.       when 4
  139.         $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED+4] += 1
  140.         @times_recieved = $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED+4]
  141.         "Forthward Ending"
  142.       when 5
  143.         $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED+5] += 1
  144.         @times_recieved = $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED+5]
  145.         "Unkown Ending" #New ending.
  146.     end
  147.   end# endings
  148.   def total_endings
  149.     @total_endings = 0
  150.     if $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED] > 0;@total_endings += 1;end
  151.     if $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED+1] > 0;@total_endings += 1;end
  152.     if $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED+2] > 0;@total_endings += 1;end
  153.     if $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED+3] > 0;@total_endings += 1;end
  154.     if $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED+4] > 0;@total_endings += 1;end
  155.     if $game_variables[STAT_VALUES::NUMBER_TIMES_ENCOUNTERED+5] > 0;@total_endings += 1;end
  156.     return @total_endings
  157.   end# total endings
  158.   def dispose
  159.     super
  160.   end
  161. end# Window_EndingStatistics
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement