State Viewer
Version: 1.0b
Author: modern algebra
Date: February 4, 2012
Version History
- <Version 1.0b> 2012.02.04 - Fixed an oversight where the map would not show up in the background of the scene.
- <Version 1.0a> 2012.01.12 - Fixed an error where the colour of the label text would not change.
- <Version 1.0> 2011.12.30 - Original Release
Description
This script allows you to give states descriptions and calls up a scene which has as its sole purpose to describe what each state (and buff, if desired) does. This sscene can be made accessible from the Menu, the Status Scene, or simply by call script in an event.
Features
- Allows you to show a list of states with descriptions so that the player won't be clueless
- Scrollable contents if you have more than 14 states
- Can exclude some states if you don't want them to show in the list
- Can choose to reveal state descriptions only once they have been inflicted
- Accessible by call script or through the Status or Menu scenes if you prefer
- Compatible with most popular CMSes
- Heavily customizable
Screenshots Instructions
Paste this script into its own slot in the Script Editor, above Main and below Materials. If you are using a Custom Menu Scene, I recommend that this script be placed below it.
Please see the header for detailed instructions on configuration and use.
Script
#==============================================================================
# State Viewer
# Version: 1.0b
# Author: modern algebra (rmrk.net)
# Date: February 4, 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script allows you to give states descriptions and calls up a scene
# which has as its sole purpose to describe what each state (and buff, if
# desired) does. This sscene can be made accessible from the Menu, the Status
# Scene, or simply by call script in an event.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Paste this script into its own slot above Main and below Materials. If you
# are using a menu script and you want this script to add itself to the menu
# automatically, then this script should be below the custom menu.
#
# The scene can be called in an event using the following script call:
# call_stateview
#
# To set the descriptions for each state, simply use the following code in
# its notebox:
# \DESC{x}
# where x is the description you want. You can use the code \LB to go
# to another line. Also, you can use any message codes, so if you want
# to, for instance, change the colour, you could do it with \c[n] - many
# default commands work and, if you use a custom message system, then
# some of those codes might work as well.
#
# EXAMPLE:
# \DESC{This state drains HP every turn}
#
# You can exclude some states from showing up in the list with the code:
# \DESC_HIDE
#
# You have the option to make it accessible from the menu, status or both at
# lines 86-93. You can then go on to set whether a label will be shown in the
# scene and its size, font, color etc... at lines 99-109.
#
# You can set the script to also show descriptions for the buffs at line 123
# and you can setup what is shown for each level of a buff at lines 124-175.
#
# There is an option at line 112 to show all states at all times, but you
# can also turn that feature off and require that the states (and buffs) be
# inflicted before they are shown. There is an option at line 118 to have
# states and buffs be revealed automatically the first time it is inflicted
# on a party member or else you can reveal them manually using the following
# codes in an evented script call:
#
# reveal_state_description(state_id)
# state_id : the ID of the state, as listed in the database.
#
# reveal_buff_description(buff_id)
# reveal_buff_description(buff_id, level)
# buff_id : ID of the buff, where 0 = MaxHP; 1 = MaxMP; 2 = Attack;
# 3 = Defence; 4 = Magic; 5 = Magic Defence; 6 = Agility;
# 7 = Luck
# level : level of the buff, where -1 = Debuff 1; -2 = Debuff 2;
# 1 = Buff 1; 2 = Buff 2. If you exclude level, then all
# levels of the buff will be revealed.
#
# EXAMPLES:
#
# reveal_state_description(2)
# State 2 (Poison) will now be described in the State View scene.
#
# reveal_buff_description(5, 2)
# Level 2 of the Magic Defence Buff will now be described in State View
#
# reveal_buff_description(2)
# All levels of the Attack Buff will be described in State View
#
# I reiterate: the above commands are only relevant if you set the option at
# line 112, MASV_SHOW_ALL_STATES, to false. If you do not and that is true,
# then all states (and buffs, if included) will be shown right off the bat.
#==============================================================================
$imported = {} unless $imported
$imported[:MA_StateView] = true
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# CONFIGURATION
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Whether the scene should be accessible via the Status Scene
MASV_STATUS_ACCESS = false
# If accessible by status screen, what button needs to be pressed?
MASV_STATUS_KEY = :A
# Whether the scene should be accessible via a command in the menu
MASV_MENU_ACCESS = true
# If accessible via the menu, what index is it in the command list
MASV_MENU_INDEX = 4
# The Label used to describe the scene in menu and on the screen
MASV_SCENE_LABEL = "State List"
# The amount of horizontal space, in pixels, to draw the name of the state.
MASV_NAME_FIELD_WIDTH = 124
MASV_LABEL_WINDOW = { # <- Do not touch
# Whether to show the label at the top of the screen when viewing states
show: true,
# The name of the font for the label if shown. Can be a string ("Arial") or
# an array of strings. Font.default_name is the basic font
fontname: Font.default_name,
# The size of the font if label is shown
fontsize: 32,
# The colour of the label if it is shown
colour: 16,
# The alignment of the label if shown. 0 => Left; 1 => Centre; 2 => Right
align: 1
} # <- Do not touch
# Whether to show all non-hidden states immediately
MASV_SHOW_ALL_STATES = true
# If SHOW_ALL_STATES is false, then turning MASV_AUTOREVEAL_STATES to true
# will set it so that the descriptions of states (and buffs) will be shown
# once the party first encounters them. If you set this option to false,
# then you will need to manually reveal states and buffs via call script in
# order for them to show up. See lines 45-62.
MASV_AUTOREVEAL_STATES = true
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# BUFFS
# When this is true, buffs will also be shown in the scene
MASV_INCLUDE_BUFFS = true
# If you are showing buffs, then you will need to set the name and description
# of each level of the buff in the array below.
# They are set in the following way: firstly, there is a hash for each buff,
# and in that hash you can set a different name and description for every
# buff level in the following format:
#
# level => ["name", "description"],
#
# As with states, you can use \\LB to make a new line and message codes in
# the description, but note that you need two backslashes (\\) instead of 1.
# So, it would be \\c[1] to change the colour, not \c[1]
MASV_BUFFS = [ # <- Do not touch
{ # Max HP Maximum HP
-1 => ["MaxHP -1", "MaxHP decreased by 25%"], # Debuff Level 1
-2 => ["MaxHP -2", "MaxHP decreased by 50%"], # Debuff Level 2
1 => ["MaxHP +1", "MaxHP increased by 25%"], # Buff Level 1
2 => ["MaxHP +2", "MaxHP increased by 50%"], # Buff Level 2
},{ # Max MP Maximum MP
-1 => ["MaxMP -1", "MaxMP decreased by 25%"], # Debuff Level 1
-2 => ["MaxMP -2", "MaxMP decreased by 50%"], # Debuff Level 2
1 => ["MaxMP +1", "MaxMP increased by 25%"], # Buff Level 1
2 => ["MaxMP +2", "MaxMP increased by 50%"], # Buff Level 2
},{ # Attack Attack
-1 => ["Attack -1", "Attack decreased by 25%"], # Debuff Level 1
-2 => ["Attack -2", "Attack decreased by 50%"], # Debuff Level 2
1 => ["Attack +1", "Attack increased by 25%"], # Buff Level 1
2 => ["Attack +2", "Attack increased by 50%"], # Buff Level 2
},{ # Defence Defence
-1 => ["Defence -1", "Defence decreased by 25%"], # Debuff Level 1
-2 => ["Defence -2", "Defence decreased by 50%"], # Debuff Level 2
1 => ["Defence +1", "Defence increased by 25%"], # Buff Level 1
2 => ["Defence +2", "Defence increased by 50%"], # Buff Level 2
},{ # Magic Magic
-1 => ["Magic -1", "Magic decreased by 25%"], # Debuff Level 1
-2 => ["Magic -2", "Magic decreased by 50%"], # Debuff Level 2
1 => ["Magic +1", "Magic increased by 25%"], # Buff Level 1
2 => ["Magic +2", "Magic increased by 50%"], # Buff Level 2
},{ # Magic Defence Magic Defence
-1 => ["MDefence -1", "MDefence decreased by 25%"], # Debuff Level 1
-2 => ["MDefence -2", "MDefence decreased by 50%"], # Debuff Level 2
1 => ["MDefence +1", "MDefence increased by 25%"], # Buff Level 1
2 => ["MDefence +2", "MDefence increased by 50%"], # Buff Level 2
},{ # Agility Agility
-1 => ["Agility -1", "Agility decreased by 25%"], # Debuff Level 1
-2 => ["Agility -2", "Agility decreased by 50%"], # Debuff Level 2
1 => ["Agility +1", "Agility increased by 25%"], # Buff Level 1
2 => ["Agility +2", "Agility increased by 50%"], # Buff Level 2
},{ # Luck Luck
-1 => ["Luck -1", "Luck decreased by 25%"], # Debuff Level 1
-2 => ["Luck -2", "Luck decreased by 50%"], # Debuff Level 2
1 => ["Luck +1", "Luck increased by 25%"], # Buff Level 1
2 => ["Luck +2", "Luck increased by 50%"], # Buff Level 2
},
] # <- Do not touch
#``````````````````````````````````````````````````````````````````````````````
# END CONFIGURATION
#//////////////////////////////////////////////////////////////////////////////
MASV_BUFFS.each {|hash| hash.values.each {|ary| ary[1].gsub!(/\\LB/i, "\n") } }
#==============================================================================
# ** RPG::State
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# overwritten super method - description
# new method - desc_hide?
#==============================================================================
class RPG::State
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Description
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def description
if !@masv_description
@masv_description = self.note[/\\DESC\{(.+?)\}/im].nil? ? "" : $1
@masv_description.gsub!(/\n/, "")
@masv_description.gsub!(/\\LB/i, "\n")
end
@masv_description
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Excluded?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def desc_hide?
@desc_hide = !self.note[/\\DESC_HIDE/i].nil? if !@desc_hide
@desc_hide
end
end
#==============================================================================
# *** DataManager
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - extract_save_contents
#==============================================================================
module DataManager
class << self
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Extract Save Contents
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias masv_extrctsvcon_5gh6 extract_save_contents
def extract_save_contents(contents, *args, &block)
masv_extrctsvcon_5gh6(contents, *args, &block)
# Initialize new data if old save file
$game_system.masv_initialize_statebuff_counters if !$game_system.masv_states_afflicted
end
end
end
#==============================================================================
# ** Game_System
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new public instance variables - masv_states_afflicted; masv_buffs_added
# aliased method - initialize
# new methods - reveal_state_description; reveal_buff_description
#==============================================================================
class Game_System
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_reader :masv_states_afflicted
attr_reader :masv_buffs_added
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias molbr_stvw_inze_4rp8 initialize
def initialize(*args, &block)
masv_initialize_statebuff_counters
molbr_stvw_inze_4rp8(*args, &block) # Run Original Method
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Initialize MASV Data
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def masv_initialize_statebuff_counters
@masv_states_afflicted = []
@masv_buffs_added = Array.new(MASV_BUFFS.size, [])
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Reveal State Description
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def reveal_state_description(state_id)
$game_system.masv_states_afflicted.push(state_id) unless $game_system.masv_states_afflicted.include?(state_id)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Reveal Buff Description
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def reveal_buff_description(param_id, lvl = nil)
return if param_id == 0 || lvl == 0
$game_system.masv_buffs_added[param_id] = [] unless $game_system.masv_buffs_added[param_id]
if lvl.nil? # Reveal all levels of a parameter if lvl not specified
$game_system.masv_buffs_added[param_id] |= MASV_BUFFS[param_id].keys
else
$game_system.masv_buffs_added[param_id].push(lvl) unless $game_system.masv_buffs_added[param_id].include?(lvl)
end
end
end
#==============================================================================
# ** Game_Battler
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - add_state; add_buff; add_debuff
#==============================================================================
class Game_Battler
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Add State
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias morala_stvw_adstat_5fc1 add_state
def add_state(state_id, *args, &block)
# Add the state to the added states counter
$game_system.reveal_state_description(state_id) if MASV_AUTOREVEAL_STATES && actor? && state_addable?(state_id)
morala_stvw_adstat_5fc1(state_id, *args, &block) # Run Original Method
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Add Buff
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias masv_adbuff_5tz9 add_buff
def add_buff(param_id, *args, &block)
masv_adbuff_5tz9(param_id, *args, &block) # Run Original Method
# Add the buff level to the added buffs counter
$game_system.reveal_buff_description(param_id, @buffs[param_id]) if MASV_AUTOREVEAL_STATES && actor?
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Add Debuff
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias masv_debuff_3hj7 add_debuff
def add_debuff(param_id, *args, &block)
masv_debuff_3hj7(param_id, *args, &block) # Run Original Method
# Add the buff level to the added buffs counter
$game_system.reveal_buff_description(param_id, @buffs[param_id]) if MASV_AUTOREVEAL_STATES && actor?
end
end
#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new methods - call_stateview; reveal_state_description;
# reveal_buff_description
#==============================================================================
class Game_Interpreter
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Call State View Scene
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def call_stateview
SceneManager.call(Scene_StateView)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Reveal State Description
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[:reveal_state_description, :reveal_buff_description].each { |sys_meth|
define_method(sys_meth) do |*args| $game_system.send(sys_meth, *args) end
}
end
#==============================================================================
# ** Window_StateView
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This window displays all states and descriptions of their effects
#==============================================================================
class Window_StateView < Window_Selectable
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize(*args)
@item_max = 1
super(*args)
refresh
activate
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Item Max
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def item_max
@item_max
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Include State?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def state_include?(state)
return false unless state # False if nil
return false if state.desc_hide?
return true if MASV_SHOW_ALL_STATES
return $game_system.masv_states_afflicted.include?(state.id)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Include Buff?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def buff_include?(param_id, lvl)
return false unless MASV_BUFFS[param_id] && MASV_BUFFS[param_id][lvl].is_a?(Array)
return false unless MASV_BUFFS[param_id][lvl][0].is_a?(String) && MASV_BUFFS[param_id][lvl][1].is_a?(String)
return true
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Make State List
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def make_state_list
@data = $data_states.compact.select { |state| state_include?(state) }
@item_max = @data.inject(0) { |r, state| r += state.description.scan(/\n/).size + 1 }
if MASV_INCLUDE_BUFFS
for i in 0...MASV_BUFFS.size
ary = MASV_SHOW_ALL_STATES ? MASV_BUFFS[i].keys : $game_system.masv_buffs_added[i]
ary.each { |lvl|
if buff_include?(i, lvl)
@data.push([i, lvl])
@item_max += MASV_BUFFS[i][lvl][1].scan(/\n/).size + 1
end
}
end
end
@item_max = 1 if @item_max < 1
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Refresh
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def refresh
make_state_list
create_contents
# Draw all states
y = 0
@dummy_battler = Game_BattlerBase.new
for i in 0...@data.size
y = draw_item(y, i)
end
@dummy_battler = nil
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Draw Item
# state : RPG::State object that is being drawn
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def draw_item(y, index)
reset_font_settings
contents.font.name = Font.default_name
icon_index, icon_hue, name, description = get_data(index)
# Draw Icon
$imported[:MAIcon_Hue] ? draw_icon_with_hue(icon_index, icon_hue, x, y) : draw_icon(icon_index, 0, y)
# Draw Name
change_color(system_color)
draw_text(28, y, MASV_NAME_FIELD_WIDTH, 24, name)
# Draw Description
change_color(normal_color)
draw_text_ex(34 + MASV_NAME_FIELD_WIDTH, y, description)
return y + (description.scan(/\n/).size + 1)*line_height
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Get the data to draw
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def get_data(index)
item = @data[index]
icon_index, icon_hue, name, description = 0, 0, "", ""
if item.is_a?(RPG::State)
icon_index, name, description = item.icon_index, item.name, item.description
icon_hue = $imported[:MAIcon_Hue] ? item.icon_hue : 0
elsif item.is_a?(Array)
icon_index = @dummy_battler.buff_icon_index(item[1], item[0]) if @dummy_battler
name = MASV_BUFFS[item[0]][item[1]][0] rescue ""
description = MASV_BUFFS[item[0]][item[1]][1] rescue ""
end
icon_index = 0 if icon_index.nil?
return icon_index, icon_hue, name, description
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Cursor Down
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def cursor_down(*args)
tr = self.top_row
self.top_row += 1 unless self.bottom_row >= item_max - 1
Sound.play_cursor if tr != self.top_row
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Cursor Down
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def cursor_up(*args)
tr = self.top_row
self.top_row -= 1
Sound.play_cursor if tr != self.top_row
end
end
#==============================================================================
# ** Window_StateLabel
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This window shows the label if desired
#==============================================================================
class Window_StateLabel < Window_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize(*args)
super(*args)
refresh
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Refresh
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def refresh
contents.clear
settings = MASV_LABEL_WINDOW
contents.font.name = settings[:fontname]
contents.font.size = settings[:fontsize]
change_color(text_color(settings[:colour]))
contents.fill_rect(0, settings[:fontsize] - 1, contents_width, 2, contents.font.color)
draw_text(0, 0, contents_width, settings[:fontsize], MASV_SCENE_LABEL, settings[:align])
end
end
#==============================================================================
# ** Scene_StateView
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This scene processes the state viewing scene
#==============================================================================
class Scene_StateView < Scene_MenuBase
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Start Processing
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def start
super
if MASV_LABEL_WINDOW[:show]
@label_window = Window_StateLabel.new(0, 0, Graphics.width, Graphics.height)
swy = ((Graphics.height - MASV_LABEL_WINDOW[:fontsize] - @label_window.padding) / 24)*24
swy += @label_window.padding
@states_window = Window_StateView.new(0, Graphics.height - swy, Graphics.width, swy)
@states_window.opacity = 0
else
@states_window = Window_StateView.new(0, 0, Graphics.width, Graphics.height)
end
@states_window.set_handler(:ok, method(:return_scene))
@states_window.set_handler(:cancel, method(:return_scene))
end
end
# Status Integration
#==============================================================================
# ** Scene Status (Access from Status)
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - update
# new method - update_stateview_call
#==============================================================================
class Scene_Status
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Frame Update
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malsv_updte_2hg1 update
def update(*args, &block)
malsv_updte_2hg1(*args, &block) # Run Original Method
update_stateview_call if MASV_STATUS_ACCESS
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update SceneView Call
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update_stateview_call
SceneManager.call(Scene_StateView) if Input.trigger?(MASV_STATUS_KEY)
end
end
# Menu Integration
if MASV_MENU_ACCESS
unless $imported[:MA_InsertCommand]
# Initialize the Insertion Hash
MA_COMMAND_INSERTS = {}
MA_InsertableMenuCommand = Struct.new(:name, :index, :enable, :scene, :other)
#==============================================================================
# ** Game_System
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new public instance variable - maic_menu_commands
# aliased method - initialize
#==============================================================================
class Game_System
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Inserted Menu Commands
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def maic_inserted_menu_commands
# Lazy Instantiation so that old save files are not corrupted
if !@maic_inserted_menu_commands
@maic_inserted_menu_commands = MA_COMMAND_INSERTS.keys
# Sort by index
@maic_inserted_menu_commands.sort! { |a, b| MA_COMMAND_INSERTS[a].index <=> MA_COMMAND_INSERTS[b].index }
end
@maic_inserted_menu_commands
end
end
#==============================================================================
# ** Window_MenuCommand
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - make_command_list; maic_insert_command
#==============================================================================
class Window_MenuCommand
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Make Command List
#``````````````````````````````````````````````````````````````````````````
# I alias this method instead of add_original_commands because I need to
# have all commands created before I can insert at the correct index
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias maic_mkcmmndl_6yd2 make_command_list
def make_command_list(*args, &block)
maic_mkcmmndl_6yd2(*args, &block) # Run Original Method
# Insert new commands
$game_system.maic_inserted_menu_commands.each { |sym| maic_insert_command(sym) }
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Insert Command
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def maic_insert_command(symbol)
command = MA_COMMAND_INSERTS[symbol]
# Get the command name
name = command.name.is_a?(Symbol) ? eval(command.name.to_s) : command.name
# Check whether enabled
enabled = case command.enable
when Integer then command.enable == 0 ? true : $game_switches[command.enable]
when String then eval(command.enable)
when Symbol then self.send(command.enable)
else
enabled = true
end
# Add the command to the list
add_command(name, symbol, enabled)
added = @list.pop
@list.insert([command.index, @list.size].min, added) # Insert at specific index
end
end
#==============================================================================
# ** Scene_Menu
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - create_command_window; on_personal_ok
# new methods - maic_set_insert_handler; maic_command_insert
#==============================================================================
class Scene_Menu
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Create Command Window
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias maic_createcndwin_3ey7 create_command_window
def create_command_window(*args, &block)
maic_createcndwin_3ey7(*args, &block) # Run Original Method
# Add handlers for all custom commands
$game_system.maic_inserted_menu_commands.each { |symbol| maic_set_insert_handler(symbol) }
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Inserted Handler
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def maic_set_insert_handler(symbol)
other = MA_COMMAND_INSERTS[symbol].other
handler = case other
when Symbol then method(other)
when String then lambda { eval(other) }
when TrueClass then method(:command_personal)
else
handler = method(:maic_command_insert)
end
@command_window.set_handler(symbol, handler)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Custom Command
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def maic_command_insert
SceneManager.call(Kernel.const_get(MA_COMMAND_INSERTS[@command_window.current_symbol].scene))
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Personal OK
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias maic_onpok_3ek9 on_personal_ok
def on_personal_ok(*args, &block)
if $game_system.maic_inserted_menu_commands.include?(@command_window.current_symbol)
maic_command_insert
else
maic_onpok_3ek9(*args, &block) # Run Original Method
end
end
end
$imported[:MA_InsertCommand] = true
end
MA_COMMAND_INSERTS[:stateview] = MA_InsertableMenuCommand.new(MASV_SCENE_LABEL,
MASV_MENU_INDEX, true, :Scene_StateView, false)
end
Credit
Thanks
- Seiryuki, for the request
Support
Please post in this topic at RMRK if you encounter any errors or have any questions regarding this script.