#============================================================================== # Crystal Engine - Advancement Screen #------------------------------------------------------------------------------ # Current Version: 1.00 #============================================================================== $imported ||= {} $imported["CE-AdvancementScreen"] = true =begin This script sets up a screen where you can see the progress of your character's advancement. This menu shows how close each stat, weapon type, shield type, and skill are to leveling up (or increasing in the case of stats). =end module CRYSTAL module FF2 module SCREEN #-------------------------------------------------------------------------- # * The Term Used for Looking at Parameters #-------------------------------------------------------------------------- STATS_TERM = "Stats" #-------------------------------------------------------------------------- # * The Icons Used for Your Stats #-------------------------------------------------------------------------- STAT_ICONS = { 0 => 122, 1 => 112, 2 => 147, 3 => 161, 4 => 152, 5 => 13, 6 => 12, 7 => 125, } #-------------------------------------------------------------------------- # * The Colors Used for the Progress Gauges #-------------------------------------------------------------------------- GAUGE_COLORS = [10, 2] end end end #============================================================================== # Editing beyond this point may cause stone, zombie, mist frenzy, and/or toad, # so edit at your own risk. #============================================================================== module CRYSTAL module CHECK #-------------------------------------------------------------------------- # * Checks if you have a certain script installed #-------------------------------------------------------------------------- def self.require(self_name, script, site = "http://crystalnoel42.wordpress.com") unless $imported["CE-BasicModule"] msg = "The script '#{self_name}' requires the latest\n" msg += "version of 'Crystal Engine - Basic Module' to work properly\n" msg += "Go to http://crystalnoel42.wordpress.com/ to download this script." raise SyntaxError.new(msg) end unless $imported[script] msg = "The script '#{self_name}' requires the latest\n" msg += "version of #{scripts_list(script)} to work properly\n" msg += "Go to #{site} to download this script." raise SyntaxError.new(msg) end end require("Crystal Engine - Advancement Screen", "CE-BasicModule") #-------------------------------------------------------------------------- # * Script Name Guide #-------------------------------------------------------------------------- class < contents.height end end #-------------------------------------------------------------------------- # * Draw Item Name # enabled : Enabled flag. When false, draw semi-transparently. #-------------------------------------------------------------------------- def draw_skill_name(skill, actor, x, y, enabled = true, width = 172) return unless skill return unless actor draw_icon(skill.icon_index, x, y, enabled) change_color(normal_color, enabled) fmt = CRYSTAL::FF2::SKILLS::NAME_FORMAT old_fmt = actor.no_advancement? || skill.no_levels? text = old_fmt ? skill.name : sprintf(fmt, skill.name, actor.skill_levels[skill.id]) draw_text(x + 24, y, width, line_height, text) end end end #============================================================================== # ** Window_AdvancementCommand #------------------------------------------------------------------------------ # This window is for selecting commands on the skill screen advancement screen. #============================================================================== class Window_AdvancementCommand < Window_Command #-------------------------------------------------------------------------- # * Initialize Command Selection Position (Class Method) #-------------------------------------------------------------------------- def self.set_command_symbol(symbol = nil) @@last_command_symbol = symbol end #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(x, y) super(x, y) @actor = nil end #-------------------------------------------------------------------------- # * Get Window Width #-------------------------------------------------------------------------- def window_width return 160 end #-------------------------------------------------------------------------- # * Set Actor #-------------------------------------------------------------------------- def actor=(actor) return if @actor == actor @actor = actor refresh select_last end #-------------------------------------------------------------------------- # * Get Number of Lines to Show #-------------------------------------------------------------------------- def visible_line_number return 4 end #-------------------------------------------------------------------------- # * Create Command List #-------------------------------------------------------------------------- def make_command_list return unless @actor add_command(CRYSTAL::FF2::SCREEN::STATS_TERM, :stats) if $imported["CE-UseBasedStatGrowth"] add_command(Vocab.weapon, :weapons) if $imported["CE-WeaponLevels"] add_command(Vocab.skill, :skills) if $imported["CE-SkillLevels"] end #-------------------------------------------------------------------------- # * Update Help Window #-------------------------------------------------------------------------- def update_help @help_window.set_text("View progress of character advancement.") end #-------------------------------------------------------------------------- # * Restore Previous Selection Position #-------------------------------------------------------------------------- def select_last select_symbol(@@last_command_symbol) if @@last_command_symbol select(0) if index == -1 end end #============================================================================== # ** Window_AdvancementSpecs #------------------------------------------------------------------------------ # This window is for displaying the process of advancement. #============================================================================== class Window_AdvancementSpecs < Window_Selectable #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(x, y, width, height) super @actor = nil @data = [] end #-------------------------------------------------------------------------- # * Set Actor #-------------------------------------------------------------------------- def actor=(actor) return if @actor == actor @actor = actor refresh self.oy = 0 end #-------------------------------------------------------------------------- # * Set Skill Type ID #-------------------------------------------------------------------------- def command_window=(command_window) return if @command_window == command_window @command_window = command_window refresh self.oy = 0 end #-------------------------------------------------------------------------- # * Get Digit Count #-------------------------------------------------------------------------- def col_max return 2 end #-------------------------------------------------------------------------- # * Get Number of Items #-------------------------------------------------------------------------- def item_max return 0 unless @command_window return 0 unless @actor case @command_window.current_symbol when :stats extra = $imported["CE-ExtraStats"] ? CRYSTAL::XSTAT::STATS.size : 0 return 8 + extra when :weapons return $data_system.weapon_types.size + CRYSTAL::FF2::WEAPONS::SHIELD_ATYPES.size when :skills skills = @actor.skills.select {|skill| !skill.no_levels? } return skills.size end end #-------------------------------------------------------------------------- # * Draw Item #-------------------------------------------------------------------------- def draw_item(index) return unless @command_window return unless @actor rect = item_rect(index) rect.width -= 4 color1 = text_color(CRYSTAL::FF2::SCREEN::GAUGE_COLORS[0]) color2 = text_color(CRYSTAL::FF2::SCREEN::GAUGE_COLORS[1]) case @command_window.current_symbol when :stats if index <= 7 icon = CRYSTAL::FF2::SCREEN::STAT_ICONS[index] draw_icon(icon, rect.x, rect.y) draw_actor_param(@actor, rect.x + 24, rect.y, index) rate = @actor.stat_exp[index] / CRYSTAL::FF2::STATS::STAT_EXP_NEEDED.to_f draw_gauge(rect.x + 196, rect.y, rect.width - 196, rate, color1, color2) else stat = CRYSTAL::XSTAT::STATS[index - 8] icon = CRYSTAL::FF2::SCREEN::STAT_ICONS[stat] draw_icon(icon, rect.x, rect.y) draw_actor_xstat(@actor, rect.x + 24, rect.y, stat) rate = @actor.stat_exp[stat] / CRYSTAL::FF2::STATS::STAT_EXP_NEEDED.to_f draw_gauge(rect.x + 196, rect.y, rect.width - 196, rate, color1, color2) end when :weapons if index < $data_system.weapon_types.size icon = CRYSTAL::FF2::WEAPONS::WEAPON_ICONS[index] draw_icon(icon, rect.x, rect.y) fmt = CRYSTAL::FF2::WEAPONS::WEAPON_LEVEL_FORMAT term = index == 0 ? CRYSTAL::FF2::WEAPONS::BAREHANDED_TERM : Vocab.wtype(index) text = sprintf(fmt, term, @actor.weapon_levels[:weapons][index]) draw_text(rect.x + 24, rect.y, 156, line_height, text) rate = @actor.weapon_exp[:weapons][index] / CRYSTAL::FF2::WEAPONS::EXP_FOR_RANK.to_f draw_gauge(rect.x + 196, rect.y, rect.width - 196, rate, color1, color2) else atype = CRYSTAL::FF2::WEAPONS::SHIELD_ATYPES[index - $data_system.weapon_types.size] icon = CRYSTAL::FF2::WEAPONS::SHIELD_ICONS[atype] draw_icon(icon, rect.x, rect.y) fmt = CRYSTAL::FF2::WEAPONS::WEAPON_LEVEL_FORMAT text = sprintf(fmt, Vocab.atype(atype), @actor.weapon_levels[:armors][atype]) draw_text(rect.x + 24, rect.y, 156, line_height, text) rate = @actor.weapon_exp[:armors][atype] / CRYSTAL::FF2::WEAPONS::EXP_FOR_RANK.to_f draw_gauge(rect.x + 196, rect.y, rect.width - 196, rate, color1, color2) end when :skills skills = @actor.skills.select {|skill| !skill.no_levels? } draw_skill_name(skills[index], @actor, rect.x, rect.y) rate = @actor.skill_exp[skills[index].id] / CRYSTAL::FF2::SKILLS::EXP_FOR_LEVEL.to_f draw_gauge(rect.x + 196, rect.y, rect.width - 196, rate, color1, color2) end end #-------------------------------------------------------------------------- # * Draw Item Name # enabled : Enabled flag. When false, draw semi-transparently. #-------------------------------------------------------------------------- def draw_skill_name(skill, actor, x, y, enabled = true, width = 172) return unless skill return unless actor draw_icon(skill.icon_index, x, y, enabled) change_color(normal_color, enabled) fmt = CRYSTAL::FF2::SKILLS::NAME_FORMAT old_fmt = actor.no_advancement? || skill.no_levels? text = old_fmt ? skill.name : sprintf(fmt, skill.name, actor.skill_levels[skill.id]) draw_text(x + 24, y, width, line_height, text) end #-------------------------------------------------------------------------- # * Draw Skill Use Cost #-------------------------------------------------------------------------- def draw_skill_cost(rect, skill) if @actor.skill_tp_cost(skill) > 0 change_color(tp_cost_color, enable?(skill)) draw_text(rect, @actor.skill_tp_cost(skill), 2) elsif @actor.skill_mp_cost(skill) > 0 change_color(mp_cost_color, enable?(skill)) draw_text(rect, @actor.skill_mp_cost(skill), 2) end end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh create_contents draw_all_items @current_symbol = @command_window.current_symbol if @command_window end #-------------------------------------------------------------------------- # * Update Help Window #-------------------------------------------------------------------------- def update_help @help_window.set_text("View progress of character advancement.") end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super refresh if @current_symbol != @command_window.current_symbol end end #============================================================================== # ** Scene_Menu #------------------------------------------------------------------------------ # This class performs the menu screen processing. #============================================================================== class Scene_Menu < Scene_MenuBase #-------------------------------------------------------------------------- # * [OK] Personal Command #-------------------------------------------------------------------------- alias on_personal_ok_ce_advancement_screen on_personal_ok def on_personal_ok on_personal_ok_ce_advancement_screen case @command_window.current_symbol when :advance if $game_party.members[@status_window.index].no_advancement? Sound.play_buzzer @status_window.activate else Window_AdvancementCommand::set_command_symbol SceneManager.call(Scene_Advancement) end end end end #============================================================================== # ** Scene_Skill #------------------------------------------------------------------------------ # This class performs skill screen processing. Skills are handled as items for # the sake of process sharing. #============================================================================== class Scene_Skill < Scene_ItemBase #-------------------------------------------------------------------------- # * [Advancement] Command #-------------------------------------------------------------------------- def command_advancement if @actor.no_advancement? Sound.play_buzzer @command_window.activate else Window_AdvancementCommand::set_command_symbol(:skills) SceneManager.call(Scene_Advancement) end end end #============================================================================== # ** Scene_Equip #------------------------------------------------------------------------------ # This class performs the equipment screen processing. #============================================================================== class Scene_Equip < Scene_MenuBase #-------------------------------------------------------------------------- # * [Advancement] Command #-------------------------------------------------------------------------- def command_advancement if @actor.no_advancement? Sound.play_buzzer @command_window.activate else Window_AdvancementCommand::set_command_symbol(:weapons) SceneManager.call(Scene_Advancement) end end end #============================================================================== # ** Scene_Status #------------------------------------------------------------------------------ # This class performs the status screen processing. #============================================================================== class Scene_Status < Scene_MenuBase #-------------------------------------------------------------------------- # * [Advancement] Command #-------------------------------------------------------------------------- def command_advancement if @actor.no_advancement? Sound.play_buzzer @command_window.activate else Window_AdvancementCommand::set_command_symbol(:stats) SceneManager.call(Scene_Advancement) end end end #============================================================================== # ** Scene_Advancement #------------------------------------------------------------------------------ # This class performs the Advancement Scene processing. This Scene shows your # progress towards stat increases and other changes. #============================================================================== class Scene_Advancement < Scene_MenuBase #-------------------------------------------------------------------------- # * Start Processing #-------------------------------------------------------------------------- def start super create_help_window create_command_window create_status_window create_item_window end #-------------------------------------------------------------------------- # * Create Command Window #-------------------------------------------------------------------------- def create_command_window wy = @help_window.height @command_window = Window_AdvancementCommand.new(0, wy) @command_window.viewport = @viewport @command_window.help_window = @help_window @command_window.actor = @actor @command_window.set_handler(:ok, method(:command_advance)) @command_window.set_handler(:cancel, method(:return_scene)) @command_window.set_handler(:pagedown, method(:next_actor)) @command_window.set_handler(:pageup, method(:prev_actor)) end #-------------------------------------------------------------------------- # * Create Status Window #-------------------------------------------------------------------------- def create_status_window y = @help_window.height @status_window = Window_SkillStatus.new(@command_window.width, y) @status_window.viewport = @viewport @status_window.actor = @actor end #-------------------------------------------------------------------------- # * Create Item Window #-------------------------------------------------------------------------- def create_item_window wx = 0 wy = @status_window.y + @status_window.height ww = Graphics.width wh = Graphics.height - wy @item_window = Window_AdvancementSpecs.new(wx, wy, ww, wh) @item_window.actor = @actor @item_window.viewport = @viewport @item_window.help_window = @help_window @item_window.command_window = @command_window @item_window.set_handler(:cancel, method(:on_item_cancel)) end #-------------------------------------------------------------------------- # * Change Actors #-------------------------------------------------------------------------- def on_actor_change @command_window.actor = @actor @status_window.actor = @actor @item_window.actor = @actor @command_window.activate end #-------------------------------------------------------------------------- # * [Advance] Command #-------------------------------------------------------------------------- def command_advance @item_window.activate @item_window.select(0) end #-------------------------------------------------------------------------- # * Item [Cancel] #-------------------------------------------------------------------------- def on_item_cancel @item_window.unselect @command_window.activate end #-------------------------------------------------------------------------- # * Switch to Next Actor #-------------------------------------------------------------------------- def next_actor @actor = $game_party.menu_actor_next @actor = $game_party.menu_actor_next until !@actor.no_advancement? on_actor_change end #-------------------------------------------------------------------------- # * Switch to Previous Actor #-------------------------------------------------------------------------- def prev_actor @actor = $game_party.menu_actor_prev @actor = $game_party.menu_actor_prev until !@actor.no_advancement? on_actor_change end end