Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Extra Stats Window Script
- # Version : 1.3
- # Demo Version : N/A
- # Author : Companion Wulf
- # Platform : RMVXA
- # Last Updated : 16 February 2012
- # Release Date : 30 January 2012
- # Demo Date : Unreleased
- #==============================================================================
- #==============================================================================
- # ? Version History
- #==============================================================================
- # Version 1.3
- # o 16-Feb-2012
- # - Added gold gained from shop sales to gold total
- # Version 1.2
- # o 13-Feb-2012
- # - Added Encounter Rate
- # - Added Members In Party
- # Version 1.1
- # o 30-Jan-2012
- # - Completed the script
- # Version 1.0
- # o 28-Jan-2012
- # - Began working on the script
- #
- # Planned for future versions (maybe):
- # o Number of items gained/lost/used
- # o Number of skills gained/lost/used
- #==============================================================================
- # ? Introduction
- #==============================================================================
- # This script displays a new window containing extra game statistics (see
- # below for a complete list), accessible from the Status Menu. I've left it
- # open for expansion at a later date.
- #
- # The script is provided "as is" and no doubt could do with a major tidy-up,
- # but this is actually my first major script for RMVXA, so it's bound to
- # contain errors and/or incompatibility problems. I only really made this to
- # see if I could do it. There are also versions for RMXP and RMVX.
- #
- #==============================================================================
- # ? Instructions
- #==============================================================================
- # This is a "plug 'n' play" script. Just place it between Materials and Main.
- # To increase/decrease some of the stats, use the following formulae, either
- # in a script or event using the "Script" command:
- #
- # o Number of Rests -- $game_system.inn_count += 1
- # Use each time the party uses an inn. (It may be possible to automate
- # this through scripts, but I've not tried it for this version.)
- #
- # o Number of Chests Opened -- $game_system.chest_count += 1
- # Use each time a chest is opened.
- #
- # o Number of Towns Visited -- $game_system.town_count += 1
- # Use when visiting a town for the first time, then activate a switch
- # so the counter doesn't increase each time you enter the same town.
- #
- # o Number of Keys Found -- $game_system.key_count += 1
- # Use each time a key to unlock a door or chest is found.
- #
- # o Number of Secrets Found -- $game_system.secrets_count += 1
- # This might be well-suited to when the party discovers a hidden area
- # or treasure chest, or perhaps a secret society, or even a side-quest.
- #
- # o Game Progress -- $game_system.game_progress += n
- # n is the number (percentage) to increase. To make things easier, I'd
- # recommend that the number is only increased after completing certain
- # "chapters". If the game is broken down into 4 chapters, then you'd
- # simply add 20 each time to make it 100%, i.e. game complete, with the
- # last 20% being the end of the game.
- #
- #==============================================================================
- # ? Licensing Info
- #==============================================================================
- # This script can be used in non-commercial projects only, providing that credit
- # is given somewhere in the game, such as the beginning or end credits.
- #
- # This script cannot be distributed without my express written permission. It is
- # only allowed for distribution (at present) on the following websites:
- #
- # * http://rpgmakertimes.blogspot.com
- # * http://rpgmakertimes.tk
- #
- # Not understanding the above conditions or not understanding English will not
- # exempt you in any way, shape or form.
- #
- # For permission to distribute, translate or re-use this script, please use
- # the contact email above.
- #
- # Please do NOT use that email address for anything other than asking permission
- # or, of course, letting me know about your project. ~Wulf
- #
- #==============================================================================
- # ? Methods Affected
- #==============================================================================
- # Aliased Methods
- # initialize (Game_System), perform_collapse_effect (Game_Enemy)
- # do_sell (Scene_Shop), create_command_window (Scene_Menu)
- # add_main_command (Window_MenuCommand)
- # Overwritten Methods
- # BattleManager: process_escape, battle_end, display_exp, gain_gold
- #==============================================================================
- $imported = {} if $imported == nil
- $imported["CW-ExtraStats-VXA"] = true
- #==============================================================================
- # ¦ System Vocab
- #------------------------------------------------------------------------------
- # At the moment this is the only editable portion of the script. In time I'll
- # probably add more editable options.
- #==============================================================================
- module CW_SYSTEM
- module Terms
- # This appears in the Menu Status, but it can be changed to suit the game.
- Stats = "Extra Stats"
- end
- end
- #==============================================================================
- # Do not edit anything below unless you're a scripter, as this can have some
- # deleterious effects on the game.
- #==============================================================================
- #==============================================================================
- # ¦ Window_Stats
- #==============================================================================
- class Window_Stats < Window_Selectable
- #--------------------------------------------------------------------------
- # ? Initialize
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, Graphics.width, Graphics.height)
- define_variables
- refresh
- activate
- end
- #--------------------------------------------------------------------------
- # ? Define Variables
- #--------------------------------------------------------------------------
- def define_variables
- @dy = y + line_height
- @saves = $game_system.save_count
- @rests = $game_system.inn_count
- @steps = $game_party.steps
- @chests = $game_system.chest_count
- @battles = $game_system.battle_count
- @victories = $game_system.victory_count
- @escapes = $game_system.escape_count
- @kills = $game_system.kill_count
- @total_exp = $game_system.total_exp_count
- @total_gold = $game_system.total_gold_count
- @keys = $game_system.key_count
- @secrets = $game_system.secrets_count
- @towns = $game_system.town_count
- @game_progress = $game_system.game_progress
- @encounters = $game_map.encounter_step
- @party = $game_party.members.size
- end
- #--------------------------------------------------------------------------
- # ? Refresh
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_block1; draw_block2; draw_block3
- draw_block4; draw_block5; draw_block6
- end
- #--------------------------------------------------------------------------
- # ? Draw Block: System Stats
- #--------------------------------------------------------------------------
- def draw_block1
- x = 0
- draw_title(x, @dy * 0, "System Stats", 260)
- make_font_smaller
- draw_text(x, @dy * 1, 260, line_height, "Number of Saves:", 0)
- draw_text(x, @dy * 2, 260, line_height, "Number of Rests:", 0)
- draw_text(x, @dy * 3, 260, line_height, "Number of Steps:", 0)
- draw_text(x, @dy * 4, 260, line_height, "Members In Party:", 0)
- x = 4; self.contents.font.color = text_color(4)
- draw_text(x, @dy * 1, 220, line_height, @saves.to_s, 2)
- draw_text(x, @dy * 2, 220, line_height, @rests.to_s, 2)
- draw_text(x, @dy * 3, 220, line_height, @steps.to_s, 2)
- draw_text(x, @dy * 4, 220, line_height, @party, 2)
- end
- #--------------------------------------------------------------------------
- # ? Draw Block: Battle Stats
- #--------------------------------------------------------------------------
- def draw_block2
- x = 278
- draw_title(x, @dy * 0, "Battle Stats", 260)
- make_font_smaller
- draw_text(x, @dy * 1, 260, line_height, "Battles Won:", 0)
- draw_text(x, @dy * 2, 260, line_height, "Battles Escaped:", 0)
- draw_text(x, @dy * 3, 260, line_height, "Total Battles:", 0)
- draw_text(x, @dy * 4, 260, line_height, "Kill Count:", 0)
- x += 4; self.contents.font.color = text_color(4)
- draw_text(x, @dy * 1, 220, line_height, @victories.to_s, 2)
- draw_text(x, @dy * 2, 220, line_height, @escapes.to_s, 2)
- draw_text(x, @dy * 3, 220, line_height, @battles.to_s, 2)
- draw_text(x, @dy * 4, 220, line_height, @kills.to_s, 2)
- end
- #--------------------------------------------------------------------------
- # ? Draw Block: Parameter Stats
- #--------------------------------------------------------------------------
- def draw_block3
- x = 0
- draw_title(x, @dy * 6, "Parameter Stats", 260)
- make_font_smaller
- draw_text(x, @dy * 7, 260, line_height, "Total Exp:", 0)
- draw_text(x, @dy * 8, 260, line_height, "Total Gold:", 0)
- x += 4; self.contents.font.color = text_color(4)
- draw_text(x, @dy * 7, 220, line_height, @total_exp.to_s, 2)
- draw_text(x, @dy * 8, 220, line_height, @total_gold.to_s, 2)
- end
- #--------------------------------------------------------------------------
- # ? Draw Block: Game Stats
- #--------------------------------------------------------------------------
- def draw_block4
- x = 278
- draw_title(x, @dy * 6, "Game Stats", 260)
- make_font_smaller
- draw_text(x, @dy * 7, 260, line_height, "Chests Opened:", 0)
- draw_text(x, @dy * 8, 260, line_height, "Keys Found:", 0)
- draw_text(x, @dy * 9, 260, line_height, "Secrets Found:", 0)
- draw_text(x, @dy * 10, 260, line_height, "Game Progress:", 0)
- x += 4; self.contents.font.color = text_color(4)
- draw_text(x, @dy * 7, 220, line_height, @chests.to_s, 2)
- draw_text(x, @dy * 8, 220, line_height, @keys.to_s, 2)
- draw_text(x, @dy * 9, 220, line_height, @secrets.to_s, 2)
- draw_text(x, @dy * 10, 220, line_height, @game_progress.to_s+"%", 2)
- end
- #--------------------------------------------------------------------------
- # ? Draw Block: Time/Date Stats
- #--------------------------------------------------------------------------
- def draw_block5
- x = 0
- draw_title(x, @dy * 12, "Time/Date Stats", 260)
- make_font_smaller
- draw_text(x, @dy * 13, 260, line_height, "Time Played:", 0)
- draw_text(x, @dy * 14, 260, line_height, "Current Date:", 0)
- draw_text(x, @dy * 15, 260, line_height, "Current Time:", 0)
- x += 4; self.contents.font.color = text_color(4)
- get_time_date
- draw_text(x, @dy * 13, 220, line_height, @timeplayed.to_s, 2)
- draw_text(x, @dy * 14, 220, line_height, @cdate, 2)
- draw_text(x, @dy * 15, 220, line_height, @ctime, 2)
- end
- #--------------------------------------------------------------------------
- # ? Draw Block: Map Stats
- #--------------------------------------------------------------------------
- def draw_block6
- x = 278
- draw_title(x, @dy * 12, "Map Stats", 260)
- make_font_smaller
- draw_text(x, @dy * 13, 220, line_height, "Map Location:", 0)
- draw_text(x, @dy * 14, 220, line_height, "Towns Visited:", 0)
- draw_text(x, @dy * 15, 260, line_height, "Encounter Rate:", 0)
- x += 4; self.contents.font.color = text_color(4)
- mapname = load_data("Data/MapInfos.rvdata2")[$game_map.map_id]
- draw_text(x, @dy * 13, 220, line_height, mapname.name, 2)
- draw_text(x, @dy * 14, 220, line_height, @towns.to_s, 2)
- draw_text(x, @dy * 15, 220, line_height, @encounters, 2)
- end
- #--------------------------------------------------------------------------
- # ? Draw Title Text
- #--------------------------------------------------------------------------
- def draw_title(x, y, text, width = 260, height = line_height, align = 1)
- self.contents.font.color = text_color(6)
- self.contents.font.size = 20
- self.contents.font.bold = true
- draw_text(x, y, width, height, text, align)
- draw_horz_line(x, y + line_height * 0)
- reset_font_settings
- end
- #--------------------------------------------------------------------------
- # ? Draw Horizontal Line
- #--------------------------------------------------------------------------
- def draw_horz_line(x, y, contents_width = 240, line_color = text_color(4))
- line_y = y + line_height / 2 + 10
- contents.fill_rect(x, line_y, contents_width, 1, line_color)
- end
- #--------------------------------------------------------------------------
- # ? Get System Time and Date
- #--------------------------------------------------------------------------
- def get_time_date
- t = Time.new
- @total_sec = Graphics.frame_count / Graphics.frame_rate
- hour = @total_sec / 60 / 60
- min = @total_sec / 60 % 60
- sec = @total_sec % 60
- @timeplayed = sprintf("%02d:%02d:%02d", hour, min, sec)
- @cdate = t.strftime("%a, %d %b, %Y")
- @ctime = t.strftime("%I:%M:%S %p")
- end
- #--------------------------------------------------------------------------
- # ? Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- refresh if Graphics.frame_count / Graphics.frame_rate != @total_sec
- end
- #--------------------------------------------------------------------------
- # ? Open Window
- #--------------------------------------------------------------------------
- def open
- refresh
- super
- end
- end
- #==============================================================================
- # ¦ BattleManager
- #------------------------------------------------------------------------------
- # Methods Overwritten: process_escape, battle_end, display_exp, gain_gold
- #==============================================================================
- module BattleManager
- #--------------------------------------------------------------------------
- # ? Process Escape |-OVERWRITE-|
- #--------------------------------------------------------------------------
- def self.process_escape
- $game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
- success = @preemptive ? true : (rand < @escape_ratio)
- Sound.play_escape
- if success
- #--CW Add--
- $game_system.escape_count += 1
- #----------
- process_abort
- else
- @escape_ratio += 0.1
- $game_message.add('\.' + Vocab::EscapeFailure)
- $game_party.clear_actions
- end
- wait_for_message
- return success
- end
- #--------------------------------------------------------------------------
- # ? Battle Result |-OVERWRITE-|
- #--------------------------------------------------------------------------
- def self.battle_end(result)
- #--CW Add--
- case result
- when 0; $game_system.victory_count += 1
- end
- #----------
- @phase = nil
- @event_proc.call(result) if @event_proc
- $game_party.on_battle_end
- $game_troop.on_battle_end
- SceneManager.exit if $BTEST
- end
- #--------------------------------------------------------------------------
- # ? Display Experience |-OVERWRITE-|
- #--------------------------------------------------------------------------
- def self.display_exp
- if $game_troop.exp_total > 0
- text = sprintf(Vocab::ObtainExp, $game_troop.exp_total)
- $game_message.add('\.' + text)
- $game_system.total_exp_count += $game_troop.exp_total #--CW Add--
- end
- end
- #--------------------------------------------------------------------------
- # ? Gain Gold |-OVERWRITE-|
- #--------------------------------------------------------------------------
- def self.gain_gold
- if $game_troop.gold_total > 0
- text = sprintf(Vocab::ObtainGold, $game_troop.gold_total)
- $game_message.add('\.' + text)
- $game_party.gain_gold($game_troop.gold_total)
- $game_system.total_gold_count += $game_troop.gold_total #--CW Add--
- end
- wait_for_message
- end
- end
- #==============================================================================
- # ¦ Game_System
- #------------------------------------------------------------------------------
- # Aliased Method : initialize
- #==============================================================================
- class Game_System
- #--------------------------------------------------------------------------
- # ? Public Instance Variables |-ALIASED-|
- #--------------------------------------------------------------------------
- attr_accessor :inn_count # Number of rests
- attr_accessor :chest_count # Number of chests opened
- attr_accessor :victory_count # Number of battles won
- attr_accessor :escape_count # Number of battles escaped
- attr_accessor :kill_count # Number of monsters killed
- attr_accessor :total_exp_count # Total experience awarded
- attr_accessor :total_gold_count # Total gold awarded
- attr_accessor :key_count # Number of keys found
- attr_accessor :secrets_count # Number of secrets unlocked
- attr_accessor :game_progress # Game progress percentage
- attr_accessor :town_count # Number of towns visited
- #--------------------------------------------------------------------------
- # ? Initialize
- #--------------------------------------------------------------------------
- alias cwtgp_gmsys_init initialize
- def initialize
- cwtgp_gmsys_init
- @inn_count = 0
- @chest_count = 0
- @victory_count = 0
- @escape_count = 0
- @kill_count = 0
- @total_exp_count = 0
- @total_gold_count = 0
- @key_count = 0
- @secrets_count = 0
- @game_progress = 0
- @town_count = 0
- end
- end
- #==============================================================================
- # ¦ Game_Enemy
- #------------------------------------------------------------------------------
- # Aliased Method : perform_collapse_effect
- #==============================================================================
- class Game_Enemy < Game_Battler
- #--------------------------------------------------------------------------
- # ? Perform Collapse |-ALIASED-|
- #--------------------------------------------------------------------------
- alias cwtgp_gmenmy_collapse_effect perform_collapse_effect
- def perform_collapse_effect
- cwtgp_gmenmy_collapse_effect
- #--CW Add--
- $game_system.kill_count += 1
- #----------
- end
- end
- #==============================================================================
- # ¦ Scene_Shop
- #------------------------------------------------------------------------------
- # Aliased Method : do_sell
- #==============================================================================
- class Scene_Shop < Scene_MenuBase
- #--------------------------------------------------------------------------
- # ? Execution of Sale
- #--------------------------------------------------------------------------
- alias cwtgp_scnshp_do_sell do_sell
- def do_sell(number)
- cwtgp_scnshp_do_sell(number)
- $game_system.total_gold_count += (number * selling_price)
- end
- end
- #==============================================================================
- # ¦ Scene_Menu
- #------------------------------------------------------------------------------
- # Aliased Methods : create_command_window
- # New Method : command_stats
- #==============================================================================
- class Scene_Menu < Scene_MenuBase
- #--------------------------------------------------------------------------
- # ? Create Command Window |-ALIASED-|
- #--------------------------------------------------------------------------
- alias cwtgp_scnmnu_create_command_window create_command_window
- def create_command_window
- cwtgp_scnmnu_create_command_window
- @command_window.set_handler(:stats, method(:command_stats))
- end
- #--------------------------------------------------------------------------
- # ? Command Stats |-NEW-|
- #--------------------------------------------------------------------------
- def command_stats
- SceneManager.call(Scene_Stats)
- end
- end
- #==============================================================================
- # ¦ Window_MenuCommand
- #------------------------------------------------------------------------------
- # Aliased Method : add_main_command
- #==============================================================================
- class Window_MenuCommand < Window_Command
- #--------------------------------------------------------------------------
- # ? Create Command Window |-ALIASED-|
- #--------------------------------------------------------------------------
- alias cwtgp_winmnucmd_add_main_commands add_main_commands
- def add_main_commands
- cwtgp_winmnucmd_add_main_commands
- add_command(CW_SYSTEM::Terms::Stats, :stats, main_commands_enabled)
- end
- end
- #==============================================================================
- # ¦ Scene_Stats
- #------------------------------------------------------------------------------
- # New Method : start
- #==============================================================================
- class Scene_Stats < Scene_MenuBase
- #--------------------------------------------------------------------------
- # ? Start |-NEW-|
- #--------------------------------------------------------------------------
- def start
- super
- @status_window = Window_Stats.new
- @status_window.set_handler(:cancel, method(:return_scene))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement