Advertisement
CompanionWulf

Extra Stats -RGSS3/RMVXA

Jul 18th, 2015
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 22.38 KB | None | 0 0
  1. #==============================================================================
  2. # Extra Stats Window Script
  3. #   Version       : 1.3
  4. #   Demo Version  : N/A
  5. #   Author        : Companion Wulf
  6. #   Platform      : RMVXA
  7. #   Last Updated  : 16 February 2012
  8. #   Release Date  : 30 January 2012
  9. #   Demo Date     : Unreleased
  10. #==============================================================================
  11.  
  12. #==============================================================================
  13. # ? Version History
  14. #==============================================================================
  15. # Version 1.3
  16. #   o 16-Feb-2012
  17. #     - Added gold gained from shop sales to gold total
  18. # Version 1.2
  19. #   o 13-Feb-2012
  20. #     - Added Encounter Rate
  21. #     - Added Members In Party
  22. # Version 1.1
  23. #   o 30-Jan-2012
  24. #     - Completed the script
  25. # Version 1.0
  26. #   o 28-Jan-2012
  27. #     - Began working on the script
  28. #
  29. # Planned for future versions (maybe):
  30. #   o Number of items gained/lost/used
  31. #   o Number of skills gained/lost/used
  32. #==============================================================================
  33. # ? Introduction
  34. #==============================================================================
  35. #   This script displays a new window containing extra game statistics (see
  36. #   below for a complete list), accessible from the Status Menu. I've left it
  37. #   open for expansion at a later date.
  38. #
  39. #   The script is provided "as is" and no doubt could do with a major tidy-up,
  40. #   but this is actually my first major script for RMVXA, so it's bound to
  41. #   contain errors and/or incompatibility problems. I only really made this to
  42. #   see if I could do it. There are also versions for RMXP and RMVX.
  43. #
  44. #==============================================================================
  45. # ? Instructions
  46. #==============================================================================
  47. #   This is a "plug 'n' play" script. Just place it between Materials and Main.
  48. #   To increase/decrease some of the stats, use the following formulae, either
  49. #   in a script or event using the "Script" command:
  50. #
  51. #     o Number of Rests           --    $game_system.inn_count += 1
  52. #         Use each time the party uses an inn. (It may be possible to automate
  53. #         this through scripts, but I've not tried it for this version.)
  54. #
  55. #     o Number of Chests Opened   --    $game_system.chest_count += 1
  56. #         Use each time a chest is opened.
  57. #
  58. #     o Number of Towns Visited   --    $game_system.town_count += 1
  59. #         Use when visiting a town for the first time, then activate a switch
  60. #         so the counter doesn't increase each time you enter the same town.
  61. #
  62. #     o Number of Keys Found      --    $game_system.key_count += 1
  63. #         Use each time a key to unlock a door or chest is found.
  64. #
  65. #     o Number of Secrets Found   --    $game_system.secrets_count += 1
  66. #         This might be well-suited to when the party discovers a hidden area
  67. #         or treasure chest, or perhaps a secret society, or even a side-quest.
  68. #
  69. #     o Game Progress             --    $game_system.game_progress += n
  70. #         n is the number (percentage) to increase. To make things easier, I'd
  71. #         recommend that the number is only increased after completing certain
  72. #         "chapters". If the game is broken down into 4 chapters, then you'd
  73. #         simply add 20 each time to make it 100%, i.e. game complete, with the
  74. #         last 20% being the end of the game.
  75. #
  76. #==============================================================================
  77. # ? Licensing Info
  78. #==============================================================================
  79. # This script can be used in non-commercial projects only, providing that credit
  80. # is given somewhere in the game, such as the beginning or end credits.
  81. #
  82. # This script cannot be distributed without my express written permission. It is
  83. # only allowed for distribution (at present) on the following websites:
  84. #
  85. #   * http://rpgmakertimes.blogspot.com
  86. #   * http://rpgmakertimes.tk
  87. #
  88. # Not understanding the above conditions or not understanding English will not
  89. # exempt you in any way, shape or form.
  90. #
  91. # For permission to distribute, translate or re-use this script, please use
  92. # the contact email above.
  93. #
  94. # Please do NOT use that email address for anything other than asking permission
  95. # or, of course, letting me know about your project. ~Wulf
  96. #
  97. #==============================================================================
  98. # ? Methods Affected
  99. #==============================================================================
  100. # Aliased Methods
  101. #   initialize (Game_System), perform_collapse_effect (Game_Enemy)
  102. #   do_sell (Scene_Shop), create_command_window (Scene_Menu)
  103. #   add_main_command (Window_MenuCommand)
  104. # Overwritten Methods
  105. #   BattleManager: process_escape, battle_end, display_exp, gain_gold
  106. #==============================================================================
  107.  
  108. $imported = {} if $imported == nil
  109. $imported["CW-ExtraStats-VXA"] = true
  110.  
  111. #==============================================================================
  112. # ¦ System Vocab
  113. #------------------------------------------------------------------------------
  114. #   At the moment this is the only editable portion of the script. In time I'll
  115. #   probably add more editable options.
  116. #==============================================================================
  117. module CW_SYSTEM
  118.   module Terms
  119.     # This appears in the Menu Status, but it can be changed to suit the game.
  120.     Stats = "Extra Stats"
  121.   end
  122. end
  123. #==============================================================================
  124. # Do not edit anything below unless you're a scripter, as this can have some
  125. # deleterious effects on the game.
  126. #==============================================================================
  127.  
  128. #==============================================================================
  129. # ¦ Window_Stats
  130. #==============================================================================
  131. class Window_Stats < Window_Selectable
  132.   #--------------------------------------------------------------------------
  133.   # ? Initialize
  134.   #--------------------------------------------------------------------------
  135.   def initialize
  136.     super(0, 0, Graphics.width, Graphics.height)
  137.     define_variables
  138.     refresh
  139.     activate
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # ? Define Variables
  143.   #--------------------------------------------------------------------------
  144.   def define_variables
  145.     @dy = y + line_height
  146.     @saves = $game_system.save_count
  147.     @rests = $game_system.inn_count
  148.     @steps = $game_party.steps
  149.     @chests = $game_system.chest_count
  150.     @battles = $game_system.battle_count
  151.     @victories = $game_system.victory_count
  152.     @escapes = $game_system.escape_count
  153.     @kills = $game_system.kill_count
  154.     @total_exp = $game_system.total_exp_count
  155.     @total_gold = $game_system.total_gold_count
  156.     @keys = $game_system.key_count
  157.     @secrets = $game_system.secrets_count
  158.     @towns = $game_system.town_count
  159.     @game_progress = $game_system.game_progress
  160.     @encounters = $game_map.encounter_step
  161.     @party = $game_party.members.size
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # ? Refresh
  165.   #--------------------------------------------------------------------------
  166.   def refresh
  167.     contents.clear
  168.     draw_block1; draw_block2; draw_block3
  169.     draw_block4; draw_block5; draw_block6
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ? Draw Block: System Stats
  173.   #--------------------------------------------------------------------------
  174.   def draw_block1
  175.     x = 0
  176.     draw_title(x, @dy * 0, "System Stats", 260)
  177.     make_font_smaller
  178.     draw_text(x, @dy * 1, 260, line_height, "Number of Saves:", 0)
  179.     draw_text(x, @dy * 2, 260, line_height, "Number of Rests:", 0)
  180.     draw_text(x, @dy * 3, 260, line_height, "Number of Steps:", 0)
  181.     draw_text(x, @dy * 4, 260, line_height, "Members In Party:", 0)
  182.     x = 4; self.contents.font.color = text_color(4)
  183.     draw_text(x, @dy * 1, 220, line_height, @saves.to_s, 2)
  184.     draw_text(x, @dy * 2, 220, line_height, @rests.to_s, 2)
  185.     draw_text(x, @dy * 3, 220, line_height, @steps.to_s, 2)
  186.     draw_text(x, @dy * 4, 220, line_height, @party, 2)
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ? Draw Block: Battle Stats
  190.   #--------------------------------------------------------------------------
  191.   def draw_block2
  192.     x = 278
  193.     draw_title(x, @dy * 0, "Battle Stats", 260)
  194.     make_font_smaller
  195.     draw_text(x, @dy * 1, 260, line_height, "Battles Won:", 0)
  196.     draw_text(x, @dy * 2, 260, line_height, "Battles Escaped:", 0)
  197.     draw_text(x, @dy * 3, 260, line_height, "Total Battles:", 0)
  198.     draw_text(x, @dy * 4, 260, line_height, "Kill Count:", 0)
  199.     x += 4; self.contents.font.color = text_color(4)
  200.     draw_text(x, @dy * 1, 220, line_height, @victories.to_s, 2)
  201.     draw_text(x, @dy * 2, 220, line_height, @escapes.to_s, 2)
  202.     draw_text(x, @dy * 3, 220, line_height, @battles.to_s, 2)
  203.     draw_text(x, @dy * 4, 220, line_height, @kills.to_s, 2)
  204.   end
  205.   #--------------------------------------------------------------------------
  206.   # ? Draw Block: Parameter Stats
  207.   #--------------------------------------------------------------------------
  208.   def draw_block3
  209.     x = 0
  210.     draw_title(x, @dy * 6, "Parameter Stats", 260)
  211.     make_font_smaller
  212.     draw_text(x, @dy * 7, 260, line_height, "Total Exp:", 0)
  213.     draw_text(x, @dy * 8, 260, line_height, "Total Gold:", 0)
  214.     x += 4; self.contents.font.color = text_color(4)
  215.     draw_text(x, @dy * 7, 220, line_height, @total_exp.to_s, 2)
  216.     draw_text(x, @dy * 8, 220, line_height, @total_gold.to_s, 2)
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ? Draw Block: Game Stats
  220.   #--------------------------------------------------------------------------
  221.   def draw_block4
  222.     x = 278
  223.     draw_title(x, @dy * 6, "Game Stats", 260)
  224.     make_font_smaller
  225.     draw_text(x, @dy * 7, 260, line_height, "Chests Opened:", 0)
  226.     draw_text(x, @dy * 8, 260, line_height, "Keys Found:", 0)
  227.     draw_text(x, @dy * 9, 260, line_height, "Secrets Found:", 0)
  228.     draw_text(x, @dy * 10, 260, line_height, "Game Progress:", 0)
  229.     x += 4; self.contents.font.color = text_color(4)
  230.     draw_text(x, @dy * 7, 220, line_height, @chests.to_s, 2)
  231.     draw_text(x, @dy * 8, 220, line_height, @keys.to_s, 2)
  232.     draw_text(x, @dy * 9, 220, line_height, @secrets.to_s, 2)
  233.     draw_text(x, @dy * 10, 220, line_height, @game_progress.to_s+"%", 2)
  234.   end
  235.   #--------------------------------------------------------------------------
  236.   # ? Draw Block: Time/Date Stats
  237.   #--------------------------------------------------------------------------
  238.   def draw_block5
  239.     x = 0
  240.     draw_title(x, @dy * 12, "Time/Date Stats", 260)
  241.     make_font_smaller
  242.     draw_text(x, @dy * 13, 260, line_height, "Time Played:", 0)
  243.     draw_text(x, @dy * 14, 260, line_height, "Current Date:", 0)
  244.     draw_text(x, @dy * 15, 260, line_height, "Current Time:", 0)
  245.     x += 4; self.contents.font.color = text_color(4)
  246.     get_time_date
  247.     draw_text(x, @dy * 13, 220, line_height, @timeplayed.to_s, 2)
  248.     draw_text(x, @dy * 14, 220, line_height, @cdate, 2)
  249.     draw_text(x, @dy * 15, 220, line_height, @ctime, 2)
  250.   end
  251.   #--------------------------------------------------------------------------
  252.   # ? Draw Block: Map Stats
  253.   #--------------------------------------------------------------------------
  254.   def draw_block6
  255.     x = 278
  256.     draw_title(x, @dy * 12, "Map Stats", 260)
  257.     make_font_smaller
  258.     draw_text(x, @dy * 13, 220, line_height, "Map Location:", 0)
  259.     draw_text(x, @dy * 14, 220, line_height, "Towns Visited:", 0)
  260.     draw_text(x, @dy * 15, 260, line_height, "Encounter Rate:", 0)
  261.     x += 4; self.contents.font.color = text_color(4)
  262.     mapname = load_data("Data/MapInfos.rvdata2")[$game_map.map_id]
  263.     draw_text(x, @dy * 13, 220, line_height, mapname.name, 2)
  264.     draw_text(x, @dy * 14, 220, line_height, @towns.to_s, 2)
  265.     draw_text(x, @dy * 15, 220, line_height, @encounters, 2)
  266.   end
  267.   #--------------------------------------------------------------------------
  268.   # ? Draw Title Text
  269.   #--------------------------------------------------------------------------
  270.   def draw_title(x, y, text, width = 260, height = line_height, align = 1)
  271.     self.contents.font.color = text_color(6)
  272.     self.contents.font.size = 20
  273.     self.contents.font.bold = true
  274.     draw_text(x, y, width, height, text, align)
  275.     draw_horz_line(x, y + line_height * 0)
  276.     reset_font_settings
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # ? Draw Horizontal Line
  280.   #--------------------------------------------------------------------------
  281.   def draw_horz_line(x, y, contents_width = 240, line_color = text_color(4))
  282.     line_y = y + line_height / 2 + 10
  283.     contents.fill_rect(x, line_y, contents_width, 1, line_color)
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # ? Get System Time and Date
  287.   #--------------------------------------------------------------------------
  288.   def get_time_date
  289.     t = Time.new
  290.     @total_sec = Graphics.frame_count / Graphics.frame_rate
  291.     hour = @total_sec / 60 / 60
  292.     min = @total_sec / 60 % 60
  293.     sec = @total_sec % 60
  294.     @timeplayed = sprintf("%02d:%02d:%02d", hour, min, sec)
  295.     @cdate = t.strftime("%a, %d %b, %Y")
  296.     @ctime = t.strftime("%I:%M:%S %p")
  297.   end
  298.   #--------------------------------------------------------------------------
  299.   # ? Frame Update
  300.   #--------------------------------------------------------------------------
  301.   def update
  302.     super
  303.     refresh if Graphics.frame_count / Graphics.frame_rate != @total_sec
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # ? Open Window
  307.   #--------------------------------------------------------------------------
  308.   def open
  309.     refresh
  310.     super
  311.   end
  312. end
  313.  
  314.  
  315. #==============================================================================
  316. # ¦ BattleManager
  317. #------------------------------------------------------------------------------
  318. # Methods Overwritten: process_escape, battle_end, display_exp, gain_gold
  319. #==============================================================================
  320. module BattleManager
  321.   #--------------------------------------------------------------------------
  322.   # ? Process Escape                                            |-OVERWRITE-|
  323.   #--------------------------------------------------------------------------
  324.   def self.process_escape
  325.     $game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
  326.     success = @preemptive ? true : (rand < @escape_ratio)
  327.     Sound.play_escape
  328.     if success
  329.       #--CW Add--
  330.       $game_system.escape_count += 1
  331.       #----------
  332.       process_abort
  333.     else
  334.       @escape_ratio += 0.1
  335.       $game_message.add('\.' + Vocab::EscapeFailure)
  336.       $game_party.clear_actions
  337.     end
  338.     wait_for_message
  339.     return success
  340.   end
  341.   #--------------------------------------------------------------------------
  342.   # ? Battle Result                                             |-OVERWRITE-|
  343.   #--------------------------------------------------------------------------
  344.   def self.battle_end(result)
  345.     #--CW Add--
  346.     case result
  347.     when 0; $game_system.victory_count += 1
  348.     end
  349.     #----------
  350.     @phase = nil
  351.     @event_proc.call(result) if @event_proc
  352.     $game_party.on_battle_end
  353.     $game_troop.on_battle_end
  354.     SceneManager.exit if $BTEST
  355.   end
  356.   #--------------------------------------------------------------------------
  357.   # ? Display Experience                                        |-OVERWRITE-|
  358.   #--------------------------------------------------------------------------
  359.   def self.display_exp
  360.     if $game_troop.exp_total > 0
  361.       text = sprintf(Vocab::ObtainExp, $game_troop.exp_total)
  362.       $game_message.add('\.' + text)
  363.       $game_system.total_exp_count += $game_troop.exp_total #--CW Add--
  364.     end
  365.   end
  366.   #--------------------------------------------------------------------------
  367.   # ? Gain Gold                                                 |-OVERWRITE-|
  368.   #--------------------------------------------------------------------------
  369.   def self.gain_gold
  370.     if $game_troop.gold_total > 0
  371.       text = sprintf(Vocab::ObtainGold, $game_troop.gold_total)
  372.       $game_message.add('\.' + text)
  373.       $game_party.gain_gold($game_troop.gold_total)
  374.       $game_system.total_gold_count += $game_troop.gold_total #--CW Add--
  375.     end
  376.     wait_for_message
  377.   end
  378. end
  379.  
  380.  
  381. #==============================================================================
  382. # ¦ Game_System
  383. #------------------------------------------------------------------------------
  384. # Aliased Method : initialize
  385. #==============================================================================
  386. class Game_System
  387.   #--------------------------------------------------------------------------
  388.   # ? Public Instance Variables                                   |-ALIASED-|
  389.   #--------------------------------------------------------------------------
  390.   attr_accessor :inn_count                # Number of rests
  391.   attr_accessor :chest_count              # Number of chests opened
  392.   attr_accessor :victory_count            # Number of battles won
  393.   attr_accessor :escape_count             # Number of battles escaped
  394.   attr_accessor :kill_count               # Number of monsters killed
  395.   attr_accessor :total_exp_count          # Total experience awarded
  396.   attr_accessor :total_gold_count         # Total gold awarded
  397.   attr_accessor :key_count                # Number of keys found
  398.   attr_accessor :secrets_count            # Number of secrets unlocked
  399.   attr_accessor :game_progress            # Game progress percentage
  400.   attr_accessor :town_count               # Number of towns visited
  401.   #--------------------------------------------------------------------------
  402.   # ? Initialize
  403.   #--------------------------------------------------------------------------
  404.   alias cwtgp_gmsys_init initialize
  405.   def initialize
  406.     cwtgp_gmsys_init
  407.     @inn_count = 0
  408.     @chest_count = 0
  409.     @victory_count = 0
  410.     @escape_count = 0
  411.     @kill_count = 0
  412.     @total_exp_count = 0
  413.     @total_gold_count = 0
  414.     @key_count = 0
  415.     @secrets_count = 0
  416.     @game_progress = 0
  417.     @town_count = 0
  418.   end
  419. end
  420.  
  421.  
  422. #==============================================================================
  423. # ¦ Game_Enemy
  424. #------------------------------------------------------------------------------
  425. # Aliased Method : perform_collapse_effect
  426. #==============================================================================
  427. class Game_Enemy < Game_Battler
  428.   #--------------------------------------------------------------------------
  429.   # ? Perform Collapse                                            |-ALIASED-|
  430.   #--------------------------------------------------------------------------
  431.   alias cwtgp_gmenmy_collapse_effect perform_collapse_effect
  432.   def perform_collapse_effect
  433.     cwtgp_gmenmy_collapse_effect
  434.     #--CW Add--
  435.     $game_system.kill_count += 1
  436.     #----------
  437.   end
  438. end
  439.  
  440.  
  441. #==============================================================================
  442. # ¦ Scene_Shop
  443. #------------------------------------------------------------------------------
  444. # Aliased Method : do_sell
  445. #==============================================================================
  446. class Scene_Shop < Scene_MenuBase
  447.   #--------------------------------------------------------------------------
  448.   # ? Execution of Sale
  449.   #--------------------------------------------------------------------------
  450.   alias cwtgp_scnshp_do_sell do_sell
  451.   def do_sell(number)
  452.     cwtgp_scnshp_do_sell(number)
  453.     $game_system.total_gold_count += (number * selling_price)
  454.   end
  455. end
  456.  
  457.  
  458. #==============================================================================
  459. # ¦ Scene_Menu
  460. #------------------------------------------------------------------------------
  461. # Aliased Methods : create_command_window
  462. # New Method      : command_stats
  463. #==============================================================================
  464. class Scene_Menu < Scene_MenuBase
  465.   #--------------------------------------------------------------------------
  466.   # ? Create Command Window                                       |-ALIASED-|
  467.   #--------------------------------------------------------------------------
  468.   alias cwtgp_scnmnu_create_command_window create_command_window
  469.   def create_command_window
  470.     cwtgp_scnmnu_create_command_window
  471.     @command_window.set_handler(:stats,     method(:command_stats))
  472.   end
  473.   #--------------------------------------------------------------------------
  474.   # ? Command Stats                                                   |-NEW-|
  475.   #--------------------------------------------------------------------------
  476.   def command_stats
  477.     SceneManager.call(Scene_Stats)
  478.   end
  479. end
  480.  
  481.  
  482. #==============================================================================
  483. # ¦ Window_MenuCommand
  484. #------------------------------------------------------------------------------
  485. # Aliased Method : add_main_command
  486. #==============================================================================
  487. class Window_MenuCommand < Window_Command
  488.   #--------------------------------------------------------------------------
  489.   # ? Create Command Window                                       |-ALIASED-|
  490.   #--------------------------------------------------------------------------
  491.   alias cwtgp_winmnucmd_add_main_commands add_main_commands
  492.   def add_main_commands
  493.     cwtgp_winmnucmd_add_main_commands    
  494.     add_command(CW_SYSTEM::Terms::Stats, :stats, main_commands_enabled)
  495.   end
  496. end
  497.  
  498.  
  499. #==============================================================================
  500. # ¦ Scene_Stats
  501. #------------------------------------------------------------------------------
  502. # New Method : start
  503. #==============================================================================
  504. class Scene_Stats < Scene_MenuBase
  505.   #--------------------------------------------------------------------------
  506.   # ? Start                                                           |-NEW-|
  507.   #--------------------------------------------------------------------------
  508.   def start
  509.     super
  510.     @status_window = Window_Stats.new
  511.     @status_window.set_handler(:cancel,   method(:return_scene))
  512.   end
  513. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement