luistop12Miér Ene 23, 2013 8:47 pm
SUPER MODERADOR
este script hace una ventana que te muestra los estados y su descripcion
screen
este tag va en las notas del estado
\DESC[x] (remplazar x por la descripcion del estado)
Llamar script
$scene = Scene_StateView.new
script
screen
este tag va en las notas del estado
\DESC[x] (remplazar x por la descripcion del estado)
Llamar script
$scene = Scene_StateView.new
script
- Código:
#==============================================================================
# State Viewer
# Version: 1.1
# Author: modern algebra (rmrk.net)
# Date: March 2, 2011
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script allows you to give states descriptions and call up a scene
# whose sole purpose is to describe what each state does. This script has
# built-in customization and 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 any other script which gives states descriptions than this should
# be put below it. If you are using a menu script, this script must be below
# it. Note that this will automatically add itself to the menu if using the
# default menu, YEM Menu, FSCMS, or Phantasia-Esque CMS.
#
# The scene can be called using the code:
# $scene = Scene_StateView.new
#
# To set the descriptions for each state, simply use the following code in
# its notebox:
# \DESC[x]
# where x is the description you want.
#
# EXAMPLE:
# \DESC[This state drains HP every turn]
#
# You can exclude some states from showing up in the list with the code:
# \DESC_HIDE
# It might be useful if you use dummy states for any purpose.
#
# You have the option to make it accessible from the menu, status or both at
# lines 46-56. You can then go on to set whether a label will be shown in the
# scene and its size, font, color etc... at lines 57-69. You can also set an
# option so that descriptions of states are only revealed once they have been
# inflicted at line 70.
#==============================================================================
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# 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 = Input::SHIFT
# 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
# If using YEM Menu, FSCMS, or Phantasia-Esque CMS, you can choose an icon
# for the menu command. It will do nothing if using default menu however
MASV_MENU_ICON = 240
# The Label used to describe the scene in menu and on the screen
MASV_LABEL = "State List"
# Whether to show the label at the top of the screen when viewing states
MASV_SHOW_LABEL = 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
MASV_LABEL_FONTNAME = Font.default_name
# The size of the font if label is shown
MASV_LABEL_FONTSIZE = 32
# The colour of the label if it is shown
MASV_LABEL_COLOR = 16
# The alignment of the label if shown. 0 => Left; 1 => Centre; 2 => Right
MASV_LABEL_ALIGN = 1
# Whether to show all non-hidden states immediately or only show them once an
# actor or enemy has been inflicted with it
MASV_SHOW_ALL_STATES = true
#``````````````````````````````````````````````````````````````````````````````
# END CONFIGURATION
#//////////////////////////////////////////////////////////////////////////////
#==============================================================================
# ** RPG::State
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new method - description
#==============================================================================
class RPG::State
# In case another script already gives states a description
unless self.method_defined? (:description)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Description
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def description
return self.note[/\\DESC\[(.+?)\]/i].nil? ? "" : $1.to_s
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Excluded?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def desc_exclude?
return !self.note[/\\DESC_HIDE/i].nil?
end
end
#==============================================================================
# ** Game_System
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new methods - masv_states_afflicted
#==============================================================================
class Game_System
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_reader :masv_states_afflicted
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias molbr_stvw_inze_4rp8 initialize
def initialize (*args)
@masv_states_afflicted = []
molbr_stvw_inze_4rp8 (*args) # Run Original Method
end
end
#==============================================================================
# ** Game_Battler
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - add_state
#==============================================================================
class Game_Battler
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Add State
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias morala_stvw_adstat_5fc1 add_state
def add_state (state_id, *args)
$game_system.masv_states_afflicted.push (state_id) unless $game_system.masv_states_afflicted.include? (state_id)
morala_stvw_adstat_5fc1 (state_id, *args) # Run Original Method
end
end
#==============================================================================
# ** Window_StateView
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This window displays all states and descriptions of their effects
#==============================================================================
class Window_StateView < Window_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Create Contents
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def create_contents
self.contents.dispose
hght = 0
$data_states.each { |state| hght += 24 if !state.nil? && !state.desc_exclude? && (MASV_SHOW_ALL_STATES || $game_system.masv_states_afflicted.include? (state.id)) }
hght = 32 if hght == 0
self.contents = Bitmap.new(width - 32, hght)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Refresh
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def refresh
contents.clear
# Draw all states
y = 0
for state in $data_states
next if state.nil? || state.desc_exclude? || (!MASV_SHOW_ALL_STATES && !$game_system.masv_states_afflicted.include? (state.id))
draw_item (y, state)
y += 24
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Draw Item
# state : RPG::State object that is being drawn
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def draw_item (y, state)
# Draw Icon
draw_icon(state.icon_index, 0, y)
# Draw Name
self.contents.font.color = system_color
self.contents.draw_text (28, y, 108, 24, state.name)
# Draw Description
self.contents.font.color = normal_color
self.contents.draw_text (142, y, contents.width - 142, 24, state.description)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update
super
if Input.press? (Input::DOWN) && ((self.oy + self.height - 32) < contents.height)
self.oy += 3
elsif Input.press? (Input::UP) && self.oy != 0
self.oy -= 3
end
end
end
#==============================================================================
# ** Window_StateLabel
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This window shows the label if desired
#==============================================================================
class Window_StateLabel < Window_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize (*args)
super (*args)
color = text_color (MASV_LABEL_COLOR)
contents.fill_rect (0, MASV_LABEL_FONTSIZE - 4, contents.width, 2, color)
contents.font = Font.new (MASV_LABEL_FONTNAME, MASV_LABEL_FONTSIZE)
contents.font.color = color
contents.draw_text (12, 0, contents.width - 24, MASV_LABEL_FONTSIZE, MASV_LABEL, MASV_LABEL_ALIGN)
end
end
#==============================================================================
# ** Scene_StateView
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This scene processes the state viewing scene
#==============================================================================
class Scene_StateView < Scene_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize (from_class = $scene.class, from_args = [])
@from_class = from_class
# weird, but necessary for YEM since doesn't permit argument passage
@from_args = from_args.empty? && from_class.is_a? (Scene_Menu) ? [MASV_MENU_INDEX] : from_args
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Start Processing
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def start
super
create_menu_background
if MASV_SHOW_LABEL
@dummy_window = Window_StateLabel.new (0, 0, Graphics.width, Graphics.height)
svh = 32 + (((@dummy_window.contents.height - MASV_LABEL_FONTSIZE) / 24)*24)
@states_window = Window_StateView.new (0, Graphics.height - svh, Graphics.width, svh)
@states_window.opacity = 0
else
@states_window = Window_StateView.new (0, 0, Graphics.width, Graphics.height)
end
@states_window.refresh
@states_window.active = true
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Termination Processing
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def terminate
super
@dummy_window.dispose if MASV_SHOW_LABEL
@states_window.dispose
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Frame Update
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update
super
if @states_window.active
if Input.trigger? (Input::C) || Input.trigger? (Input::B) # Escape or Enter
Sound.play_cancel
return_scene
end
@states_window.update # Update Window
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Return Scene
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def return_scene
$scene = @from_class.new (*@from_args)
end
end
# Status Integration
#==============================================================================
# ** Scene Status (Access from Status)
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - update
#==============================================================================
class Scene_Status
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Frame Update
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mal_sv_update_9ic3 update
def update (*args, &block)
mal_sv_update_9ic3 (*args, &block) # Run Original Method
if MASV_STATUS_ACCESS && Input.trigger? (MASV_STATUS_KEY)
$scene = Scene_StateView.new (Scene_Status, [@actor_index])
end
end
end
# Menu Integration
if MASV_MENU_ACCESS
# If YEM Menu
if $imported && $imported["MainMenuMelody"]
YEM::MENU::MENU_COMMANDS.insert (MASV_MENU_INDEX, :stateview)
YEM::MENU::MENU_ICONS[:stateview] = MASV_MENU_ICON
YEM::MENU::IMPORTED_COMMANDS[:stateview] = [nil, nil, false, MASV_MENU_ICON, MASV_LABEL, "Scene_StateView"]
# If Full Status CMS
elsif Game_System.method_defined? (:fscms_command_list)
ModernAlgebra::FSCMS_CUSTOM_COMMANDS[:stateview] = [MASV_LABEL, MASV_MENU_ICON, -1, false, Scene_StateView, "Scene_Menu, [#{MASV_MENU_INDEX}]"]
ModernAlgebra::FSCMS_COMMANDLIST.insert (MASV_MENU_INDEX, :stateview)
# If Phantasia Esque Menu
elsif Game_System.method_defined? (:tpcms_command_list)
Phantasia_CMS::CUSTOM_COMMANDS[:stateview] = [MASV_LABEL, MASV_MENU_ICON, -1, false, Scene_StateView, "Scene_Menu, [#{MASV_MENU_INDEX}]"]
Phantasia_CMS::COMMANDLIST.insert (MASV_MENU_INDEX, :stateview)
else # Default Menu
#========================================================================
# ** Window_Command (unless already done by Quest Journal or IRP)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of Changes:
# new instance variable - ma_disabled_commands
# aliased method - initialize, draw_item
#========================================================================
unless Window_Command.method_defined? (:ma_disabled_commands)
class Window_Command
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variable
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_reader :ma_disabled_commands
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Initialize
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias ma_stateview_initz_8yg1 initialize
def initialize (*args)
@ma_disabled_commands = [] # Initialize new instance variable
ma_stateview_initz_8yg1 (*args) # Run Original Method
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Draw Item
# index : item number
# enabled : enabled flag. When false, draw semi-transparently
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_sttvw_itmdraw_7in3 draw_item
def draw_item (index, enabled = true, *args)
# Run Original Method
modalg_sttvw_itmdraw_7in3 (index, enabled, *args)
enabled ? @ma_disabled_commands.delete (index) : @ma_disabled_commands.push (index)
end
end
end
#==========================================================================
# ** Scene Menu
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased methods - initialize, create_command_window
#==========================================================================
class Scene_Menu
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malba_stview_iniz_5rx2 initialize
def initialize (menu_index = 0, *args)
malba_stview_iniz_5rx2 (menu_index, *args)
$scene.is_a? (Scene_StateView) ? @menu_index = MASV_MENU_INDEX : (@menu_index += 1 if @menu_index >= MASV_MENU_INDEX)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Create Command Window
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modabra_sv_cmmndwin_create_3tb8 create_command_window
def create_command_window (*args)
modabra_sv_cmmndwin_create_3tb8 (*args) # Run Original Method
c = @command_window.commands
c.insert (MASV_MENU_INDEX, MASV_LABEL)
width = @command_window.width
disabled = @command_window.ma_disabled_commands
@command_window.dispose
@command_window = @command_window.class.new (width, c)
@command_window.index = @menu_index
# Disable all of the old commands as well
disabled.each { |i|
i += 1 if i >= MASV_MENU_INDEX
@command_window.draw_item (i, false)
}
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update Command Selection
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modgra_sttview_updcomnd_3rg8 update_command_selection
def update_command_selection (*args)
# If the State List command selected
if @command_window.index == MASV_MENU_INDEX && Input.trigger? (Input::C)
Sound.play_decision
$scene = Scene_StateView.new (Scene_Menu, [@command_window.index])
return
end
# Reduce command window index if over the states index
change = @command_window.index > MASV_MENU_INDEX
@command_window.index -= 1 if change
modgra_sttview_updcomnd_3rg8 (*args) # Run Original Method
@command_window.index += 1 if change
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update Actor Selection
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mdrnab_viewstate_actupd_5fc9 update_actor_selection
def update_actor_selection (*args)
# Reduce command window index if over the states index
change = @command_window.index > MASV_MENU_INDEX
@command_window.index -= 1 if change
mdrnab_viewstate_actupd_5fc9 (*args) # Run Original Method
@command_window.index += 1 if change
end
end
end
end