#============================================================================== # # ¥ Yami Engine Symphony - Skill Equip # -- Last Updated: 2013.01.02 # -- Level: Easy # -- Requires: n/a # #============================================================================== $imported = {} if $imported.nil? $imported["YES-SkillEquip"] = true #============================================================================== # ¥ Updates # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # 2013.01.02 - Fixed: Added Skills. # - Added: Non equip skill, notetag: <non equip skill>. # Non equip skills will always be usable in battle. # 2012.12.17 - Fixed: Big slots list. # 2012.12.12 - Fixed: Reverting slots issue. # 2012.12.08 - Compatible with: YEA - Victory Aftermath. # 2012.12.05 - Finished Script. # 2012.12.03 - Started Script. # #============================================================================== # ¥ Introduction # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # This script requires the player to make decisions as to which skills to bring # into battle for each character. # #============================================================================== # ¥ Instructions # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # To install this script, open up your script editor and copy/paste this script # to an open slot below ¥ Materials/‘fÞ but above ¥ Main. Remember to save. # #============================================================================== # ¥ Compatibility # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that # it will run with RPG Maker VX without adjustments. # #============================================================================== #============================================================================== # ¡ Configuration #============================================================================== module YES module SKILL_EQUIP #=========================================================================== # - Basic Settings - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # The following below will adjust the basic ruleset that the skill equip # system will use. Visual settings will also be adjusted here. #=========================================================================== COMMAND = "Equip Skill" # This is the category title that appears for # the skill equip option. EQUIP_SKILL_SWITCH = 43 # This switch must be enabled in order for the # Equip Skill command to appear in the skill menu. # These are the visual settings used when a skill isn't equipped. EMPTY_SKILL_HELP = "No skill is equipped in this slot.\n Press Enter to assign skill." EMPTY_SKILL_TEXT = "<Empty Slot>" # Text used for no skill equipped. EMPTY_SKILL_ICON = 185 # Icon used for no skill equipped. # This constant adjusts the default maximum amount of equipped skills that # an actor can have without modifications. DEFAULT_MAX_EQUIPS = 6 #=========================================================================== # - Description Settings - #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- # The following below will adjust the description window, which includes # skill's properties and description. # Here's the list of default properties: # ------------------------------------------------------------------------- # :symbol Description # ------------------------------------------------------------------------- # :stype Skill Type. # :cost Skill Cost. # :speed Speed Fix. # :success Success Rate. #=========================================================================== # Default displayed properties of each skill. DEFAULT_PROPERTIES = [ # Start. :stype, # Skill Type :cost, # Mana/TP Cost :speed, # Speed Fix :success, # Success Rate ] # End. # Default displaying texts for properties. PROPERTIES = { # Start. :stype => "分類", :cost => "PP", :speed => "速度修正", :success => "命中率", } # End. end end #============================================================================== # ¥ Editting anything past this point may potentially result in causing # computer damage, incontinence, explosion of user's head, coma, death, and/or # halitosis so edit at your own risk. #============================================================================== #============================================================================== # ¡ Regular Expression #============================================================================== module REGEXP module SKILL_EQUIP MAX_EQUIPS = /<(?:SKILL_SLOTS|skill slots):[ ]*(\d+)>/i CHANGE_EQUIPS = /<(?:CHANGE_SLOTS|change slots):[ ]*([\+\-]?\d+)>/i VALUE_DESCRIPTION = /<(?:SKILL_INFO|skill info)[ ](.*):[ ]*(.*)>/i NON_EQUIP = /<(?:NON_EQUIP_SKILL|non equip skill)>/i end # SKILL_EQUIP end # REGEXP #============================================================================== # ¡ DataManager #============================================================================== module DataManager #-------------------------------------------------------------------------- # alias method: load_database #-------------------------------------------------------------------------- class <<self; alias load_database_skill_equip load_database; end def self.load_database load_database_skill_equip initialize_skill_equip end #-------------------------------------------------------------------------- # alias method: create_game_objects #-------------------------------------------------------------------------- class <<self; alias create_game_objects_skill_equip create_game_objects; end def self.create_game_objects create_game_objects_skill_equip $game_switches[YES::SKILL_EQUIP::EQUIP_SKILL_SWITCH] = true end #-------------------------------------------------------------------------- # new method: initialize_skill_equip #-------------------------------------------------------------------------- def self.initialize_skill_equip groups = [$data_actors, $data_classes, $data_weapons, $data_armors, $data_skills] groups.each { |group| group.each { |obj| next if obj.nil? obj.initialize_skill_equip } } end end # DataManager #============================================================================== # ¡ RPG::BaseItem #============================================================================== class RPG::BaseItem #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :skill_slots attr_accessor :change_slots attr_accessor :slot_properties attr_accessor :non_equip_skill #-------------------------------------------------------------------------- # new method: initialize_skill_equip #-------------------------------------------------------------------------- def initialize_skill_equip @change_slots = 0 @slot_properties = [] self.note.split(/[\r\n]+/).each { |line| case line when REGEXP::SKILL_EQUIP::MAX_EQUIPS @skill_slots = $1.to_i when REGEXP::SKILL_EQUIP::CHANGE_EQUIPS @change_slots = $1.to_i when REGEXP::SKILL_EQUIP::VALUE_DESCRIPTION @slot_properties.push([$1.to_s, $2.to_s]) when REGEXP::SKILL_EQUIP::NON_EQUIP @non_equip_skill = true end } end end # RPG::BaseItem #============================================================================== # ¡ Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :equip_skills #-------------------------------------------------------------------------- # alias method: setup #-------------------------------------------------------------------------- alias yes_skill_equip_setup setup def setup(actor_id) yes_skill_equip_setup(actor_id) correct_equip_skills end #-------------------------------------------------------------------------- # alias method: refresh #-------------------------------------------------------------------------- alias yes_skill_equip_refresh refresh def refresh yes_skill_equip_refresh correct_equip_skills correct_skill_slots end #-------------------------------------------------------------------------- # new method: base_skill_slots #-------------------------------------------------------------------------- def base_skill_slots array = [self.class.skill_slots, self.actor.skill_slots] default = YES::SKILL_EQUIP::DEFAULT_MAX_EQUIPS array.compact.size > 0 ? array.compact[0] : default end #-------------------------------------------------------------------------- # new method: change_slots #-------------------------------------------------------------------------- def change_slots array = self.equips + [self.class, self.actor] array.compact.inject(0) { |r, o| r += o.change_slots } end #-------------------------------------------------------------------------- # new method: skill_slots #-------------------------------------------------------------------------- def skill_slots [base_skill_slots + change_slots, 0].max end #-------------------------------------------------------------------------- # new method: correct_skill_slots #-------------------------------------------------------------------------- def correct_skill_slots if @equip_skills.size < skill_slots @equip_skills = @equip_skills + Array.new(skill_slots - @equip_skills.size, 0) else @equip_skills = @equip_skills[0, skill_slots] end end #-------------------------------------------------------------------------- # new method: correct_equip_skills #-------------------------------------------------------------------------- def correct_equip_skills if @equip_skills.nil? @equip_skills = Array.new(skill_slots, 0) #--- j = 0 all_skills.each_index { |i| break if i == @equip_skills.size while all_skills[j] && $data_skills[all_skills[j]].non_equip_skill j += 1 end @equip_skills[i] = all_skills[j] j += 1 } end #--- @equip_skills.each_index { |i| id = @equip_skills[i] next if id == 0 @equip_skills[i] = 0 unless all_skills.include?(id) } end #-------------------------------------------------------------------------- # new method: all_skills #-------------------------------------------------------------------------- def all_skills (@skills | added_skills).sort end #-------------------------------------------------------------------------- # new method: equip_skill #-------------------------------------------------------------------------- def equip_skill(index, id) return false unless skill_equippable?(id) if @equip_skills.include?(id) && id != 0 @equip_skills[@equip_skills.index(id)] = @equip_skills[index] end @equip_skills[index] = id end #-------------------------------------------------------------------------- # new method: skill_equippable? #-------------------------------------------------------------------------- def skill_equippable?(id) return true end #-------------------------------------------------------------------------- # new method: equipped_skills #-------------------------------------------------------------------------- def equipped_skills @equip_skills.select{|id|id != 0}.collect{|id|$data_skills[id]} end #-------------------------------------------------------------------------- # alias method: skills # Overwrite in Battle #-------------------------------------------------------------------------- alias yes_skill_equip_skills skills def skills if $game_party.in_battle && !$game_troop.all_dead? return equipped_skills + yes_skill_equip_skills.select{|s|s.non_equip_skill} else return yes_skill_equip_skills end end end # Game_Actor #============================================================================== # ¡ Window_SkillSlots #============================================================================== class Window_SkillSlots < Window_Selectable #-------------------------------------------------------------------------- # initialize #-------------------------------------------------------------------------- def initialize(x, y, height) super(x, y, Graphics.width / 2, height) self.index = 0 self.hide end #-------------------------------------------------------------------------- # item_max #-------------------------------------------------------------------------- def item_max @actor.nil? ? 1 : @actor.skill_slots end #-------------------------------------------------------------------------- # current_item_enabled? #-------------------------------------------------------------------------- def current_item_enabled? @actor && @actor.skill_slots > 0 end #-------------------------------------------------------------------------- # actor= #-------------------------------------------------------------------------- def actor=(actor) return if @actor == actor @actor = actor update_padding create_contents refresh self.oy = 0 @index = 0 end #-------------------------------------------------------------------------- # draw_item #-------------------------------------------------------------------------- def draw_item(index) skill_id = @actor.equip_skills[index] #--- return if skill_id.nil? reset_font_settings draw_item_none(index) if skill_id <= 0 draw_item_name(index, skill_id) if skill_id > 0 end #-------------------------------------------------------------------------- # draw_item_none #-------------------------------------------------------------------------- def draw_item_none(index) rect = item_rect(index) #--- change_color(normal_color, false) draw_icon(YES::SKILL_EQUIP::EMPTY_SKILL_ICON, rect.x, rect.y, false) rect.x += 24 draw_text(rect, YES::SKILL_EQUIP::EMPTY_SKILL_TEXT, 0) end #-------------------------------------------------------------------------- # draw_item_name #-------------------------------------------------------------------------- def draw_item_name(index, skill_id, enabled = true) rect = item_rect(index) item = $data_skills[skill_id] #--- change_color(normal_color, enabled) draw_icon(item.icon_index, rect.x, rect.y, enabled) rect.x += 24 draw_text(rect, item.name, 0) end #-------------------------------------------------------------------------- # propertise_window= #-------------------------------------------------------------------------- def properties_window=(properties_window) @properties_window = properties_window id = @actor.equip_skills[index] item = id.nil? ? nil : $data_skills[id] @properties_window.set_item(item) end #-------------------------------------------------------------------------- # update_help #-------------------------------------------------------------------------- def update_help id = @actor.equip_skills[index] item = id.nil? ? nil : $data_skills[id] empty_text = YES::SKILL_EQUIP::EMPTY_SKILL_HELP item.nil? ? @help_window.set_text(empty_text) : @help_window.set_item(item) @properties_window.set_item(item) if @properties_window end end # Window_SkillSlots #============================================================================== # ¡ Window_SkillList_Equip #============================================================================== class Window_SkillList_Equip < Window_SkillList #-------------------------------------------------------------------------- # initialize #-------------------------------------------------------------------------- def initialize(x, y, width, height) super self.hide self.index = 0 end #-------------------------------------------------------------------------- # col_max #-------------------------------------------------------------------------- def col_max return 1 end #-------------------------------------------------------------------------- # enable? #-------------------------------------------------------------------------- def enable?(item) @actor end #-------------------------------------------------------------------------- # include? #-------------------------------------------------------------------------- def include?(item) item end #-------------------------------------------------------------------------- # make_item_list #-------------------------------------------------------------------------- def make_item_list super @data = [0] + @data.select{|s|!s.non_equip_skill} end #-------------------------------------------------------------------------- # draw_item #-------------------------------------------------------------------------- def draw_item(index) skill = @data[index] if skill && skill.is_a?(RPG::Skill) rect = item_rect(index) rect.width -= 4 draw_item_name(skill, rect.x, rect.y, enable?(skill)) else rect = item_rect(index) rect.width -= 4 change_color(normal_color, false) draw_icon(YES::SKILL_EQUIP::EMPTY_SKILL_ICON, rect.x, rect.y, false) rect.x += 24 draw_text(rect, YES::SKILL_EQUIP::EMPTY_SKILL_TEXT, 0) end end #-------------------------------------------------------------------------- # item #-------------------------------------------------------------------------- def item @data && @data[index] == 0 ? @data[index] : super end #-------------------------------------------------------------------------- # properties_window= #-------------------------------------------------------------------------- def properties_window=(properties_window) @properties_window = properties_window end #-------------------------------------------------------------------------- # update_help #-------------------------------------------------------------------------- def update_help empty_text = YES::SKILL_EQUIP::EMPTY_SKILL_HELP item == 0 ? @help_window.set_text(empty_text) : @help_window.set_item(item) @properties_window.set_item(item) if @properties_window end end # Window_SkillList_Equip #============================================================================== # ¡ Window_Properties_Slot #============================================================================== class Window_Properties_Slot < Window_Base #-------------------------------------------------------------------------- # initialize #-------------------------------------------------------------------------- def initialize(x, y, width, height) super(x, y, width, height) @item = nil @actor = nil self.hide refresh end #-------------------------------------------------------------------------- # refresh #-------------------------------------------------------------------------- def refresh contents.clear return unless @actor if @item.nil? || @item == 0 reset_font_settings change_color(normal_color, false) draw_icon(YES::SKILL_EQUIP::EMPTY_SKILL_ICON, 0, 0, false) draw_text(24, 0, contents.width, line_height, YES::SKILL_EQUIP::EMPTY_SKILL_TEXT) end return if @item.nil? || @item == 0 reset_font_settings #--- draw_item_name(@item, 0, 0) #--- i = 0; hash = YES::SKILL_EQUIP::DEFAULT_PROPERTIES contents.font.size -= 2 hash.each { |p| h = (i + 1) * line_height case p when :stype draw_skill_type(h) when :cost draw_skill_cost(h) when :speed draw_skill_speed(h) when :success draw_skill_rate(h) end i += 1 } #--- i = hash.size @item.slot_properties.each { |a| h = (i + 1) * line_height draw_skill_properties(a, h) i += 1 } end #-------------------------------------------------------------------------- # draw_skill_type #-------------------------------------------------------------------------- def draw_skill_type(y) w = contents.width change_color(system_color) draw_text(0, y, w, line_height, YES::SKILL_EQUIP::PROPERTIES[:stype]) change_color(normal_color) draw_text(0, y, w, line_height, $data_system.skill_types[@item.stype_id], 2) end #-------------------------------------------------------------------------- # draw_skill_cost #-------------------------------------------------------------------------- def draw_skill_cost(h) if $imported["YEA-SkillCostManager"] draw_skill_cost_advanced(h) else rect = Rect.new(0,h,contents.width,line_height) #--- change_color(system_color) draw_text(rect, YES::SKILL_EQUIP::PROPERTIES[:cost]) #--- if @actor.skill_tp_cost(@item) > 0 change_color(tp_cost_color) text = @actor.skill_tp_cost(@item).to_s + Vocab.tp_a draw_text(rect, text, 2) rect.width -= text_size(text).width + 4 end #--- if @actor.skill_mp_cost(@item) > 0 change_color(mp_cost_color) text = @actor.skill_mp_cost(@item).to_s + Vocab.mp_a draw_text(rect, text, 2) end end end #-------------------------------------------------------------------------- # draw_skill_cost_advanced #-------------------------------------------------------------------------- def draw_skill_cost_advanced(h) rect = Rect.new(0,h,contents.width,line_height) #--- change_color(system_color) draw_text(rect, YES::SKILL_EQUIP::PROPERTIES[:cost]) #--- draw_tp_skill_cost(rect, @item) unless $imported["YEA-BattleEngine"] draw_mp_skill_cost(rect, @item) draw_tp_skill_cost(rect, @item) if $imported["YEA-BattleEngine"] draw_hp_skill_cost(rect, @item) draw_gold_skill_cost(rect, @item) draw_custom_skill_cost(rect, @item) end #-------------------------------------------------------------------------- # draw_skill_speed #-------------------------------------------------------------------------- def draw_skill_speed(y) w = contents.width change_color(system_color) draw_text(0, y, w, line_height, YES::SKILL_EQUIP::PROPERTIES[:speed]) change_color(normal_color) draw_text(0, y, w, line_height, @item.speed.to_s, 2) end #-------------------------------------------------------------------------- # draw_skill_rate #-------------------------------------------------------------------------- def draw_skill_rate(y) w = contents.width change_color(system_color) draw_text(0, y, w, line_height, YES::SKILL_EQUIP::PROPERTIES[:success]) change_color(normal_color) draw_text(0, y, w, line_height, @item.success_rate.to_s + "%", 2) end #-------------------------------------------------------------------------- # draw_skill_properties #-------------------------------------------------------------------------- def draw_skill_properties(a, y) w = contents.width change_color(system_color) draw_text(0, y, w, line_height, a[0]) change_color(normal_color) draw_text(0, y, w, line_height, a[1], 2) end #-------------------------------------------------------------------------- # set_item #-------------------------------------------------------------------------- def set_item(item) if @item != item @item = item refresh end end #-------------------------------------------------------------------------- # actor= #-------------------------------------------------------------------------- def actor=(actor) @actor = actor end #-------------------------------------------------------------------------- # Yanfly Engine Ace - Skill Cost Manager #-------------------------------------------------------------------------- if $imported["YEA-SkillCostManager"] #-------------------------------------------------------------------------- # new method: draw_mp_skill_cost #-------------------------------------------------------------------------- def draw_mp_skill_cost(rect, skill) return unless @actor.skill_mp_cost(skill) > 0 contents.font.size -= 2 change_color(mp_cost_color) #--- icon = Icon.mp_cost if icon > 0 draw_icon(icon, rect.x + rect.width-24, rect.y) rect.width -= 24 end #--- contents.font.size = YEA::SKILL_COST::MP_COST_SIZE cost = @actor.skill_mp_cost(skill) text = sprintf(YEA::SKILL_COST::MP_COST_SUFFIX, cost.group) draw_text(rect, text, 2) cx = text_size(text).width + 4 rect.width -= cx reset_font_settings end #-------------------------------------------------------------------------- # new method: draw_tp_skill_cost #-------------------------------------------------------------------------- def draw_tp_skill_cost(rect, skill) return unless @actor.skill_tp_cost(skill) > 0 contents.font.size -= 2 change_color(tp_cost_color) #--- icon = Icon.tp_cost if icon > 0 draw_icon(icon, rect.x + rect.width-24, rect.y) rect.width -= 24 end #--- contents.font.size = YEA::SKILL_COST::TP_COST_SIZE cost = @actor.skill_tp_cost(skill) text = sprintf(YEA::SKILL_COST::TP_COST_SUFFIX, cost.group) draw_text(rect, text, 2) cx = text_size(text).width + 4 rect.width -= cx reset_font_settings end #-------------------------------------------------------------------------- # new method: draw_hp_skill_cost #-------------------------------------------------------------------------- def draw_hp_skill_cost(rect, skill) return unless @actor.skill_hp_cost(skill) > 0 contents.font.size -= 2 change_color(hp_cost_color) #--- icon = Icon.hp_cost if icon > 0 draw_icon(icon, rect.x + rect.width-24, rect.y) rect.width -= 24 end #--- contents.font.size = YEA::SKILL_COST::HP_COST_SIZE cost = @actor.skill_hp_cost(skill) text = sprintf(YEA::SKILL_COST::HP_COST_SUFFIX, cost.group) draw_text(rect, text, 2) cx = text_size(text).width + 4 rect.width -= cx reset_font_settings end #-------------------------------------------------------------------------- # new method: draw_gold_skill_cost #-------------------------------------------------------------------------- def draw_gold_skill_cost(rect, skill) return unless @actor.skill_gold_cost(skill) > 0 contents.font.size -= 2 change_color(gold_cost_color) #--- icon = Icon.gold_cost if icon > 0 draw_icon(icon, rect.x + rect.width-24, rect.y) rect.width -= 24 end #--- contents.font.size = YEA::SKILL_COST::GOLD_COST_SIZE cost = @actor.skill_gold_cost(skill) text = sprintf(YEA::SKILL_COST::GOLD_COST_SUFFIX, cost.group) draw_text(rect, text, 2) cx = text_size(text).width + 4 rect.width -= cx reset_font_settings end #-------------------------------------------------------------------------- # new method: draw_custom_skill_cost #-------------------------------------------------------------------------- def draw_custom_skill_cost(rect, skill) return unless skill.use_custom_cost contents.font.size -= 2 change_color(text_color(skill.custom_cost_colour)) icon = skill.custom_cost_icon if icon > 0 draw_icon(icon, rect.x + rect.width-24, rect.y) rect.width -= 24 end contents.font.size = skill.custom_cost_size text = skill.custom_cost_text draw_text(rect, text, 2) cx = text_size(text).width + 4 rect.width -= cx reset_font_settings end end end # Window_Properties_Slot #============================================================================== # ¡ Window_SkillCommand #============================================================================== class Window_SkillCommand < Window_Command #-------------------------------------------------------------------------- # alias method: make_command_list #-------------------------------------------------------------------------- unless $imported["YEA-SkillMenu"] alias yes_skill_equip_make_command_list make_command_list def make_command_list yes_skill_equip_make_command_list add_command(YES::SKILL_EQUIP::COMMAND, :equip_skill, $game_switches[YES::SKILL_EQUIP::EQUIP_SKILL_SWITCH]) end end end # Window_SkillCommand #============================================================================== # ¡ Scene_Skill #============================================================================== class Scene_Skill < Scene_ItemBase #-------------------------------------------------------------------------- # alias method: start #-------------------------------------------------------------------------- alias yes_skill_equip_start start def start yes_skill_equip_start create_slots_window create_skill_equip_window create_properties_window end #-------------------------------------------------------------------------- # alias method: create_command_window #-------------------------------------------------------------------------- alias yes_skill_equip_create_command_window create_command_window def create_command_window yes_skill_equip_create_command_window @command_window.set_handler(:equip_skill, method(:command_equip_skill)) end #-------------------------------------------------------------------------- # new method: create_slots_window #-------------------------------------------------------------------------- def create_slots_window wx = 0 wy = @status_window.y + @status_window.height wh = Graphics.height - wy @slots_window = Window_SkillSlots.new(wx, wy, wh) @slots_window.viewport = @viewport @slots_window.help_window = @help_window @slots_window.actor = @actor @slots_window.set_handler(:ok, method(:on_slot_ok)) @slots_window.set_handler(:cancel, method(:on_slot_cancel)) end #-------------------------------------------------------------------------- # new method: create_skill_equip_window #-------------------------------------------------------------------------- def create_skill_equip_window wx = 0 wy = @status_window.y + @status_window.height ww = Graphics.width / 2 wh = Graphics.height - wy @skill_equip = Window_SkillList_Equip.new(wx, wy, ww, wh) @skill_equip.viewport = @viewport @skill_equip.help_window = @help_window @skill_equip.actor = @actor @skill_equip.set_handler(:ok, method(:on_skill_equip_ok)) @skill_equip.set_handler(:cancel, method(:on_skill_equip_cancel)) end #-------------------------------------------------------------------------- # new method: create_properties_window #-------------------------------------------------------------------------- def create_properties_window wx = @slots_window.width wy = @status_window.y + @status_window.height ww = Graphics.width / 2 wh = Graphics.height - wy @properties_window = Window_Properties_Slot.new(wx, wy, ww, wh) @properties_window.viewport = @viewport @properties_window.actor = @actor @slots_window.properties_window = @properties_window @skill_equip.properties_window = @properties_window end #-------------------------------------------------------------------------- # new method: command_equip_skill #-------------------------------------------------------------------------- def command_equip_skill @slots_window.activate end #-------------------------------------------------------------------------- # new method: on_slot_ok #-------------------------------------------------------------------------- def on_slot_ok @slots_window.deactivate.hide @skill_equip.show.activate end #-------------------------------------------------------------------------- # new method: on_slot_cancel #-------------------------------------------------------------------------- def on_slot_cancel @slots_window.deactivate @command_window.activate end #-------------------------------------------------------------------------- # new method: on_skill_equip_ok #-------------------------------------------------------------------------- def on_skill_equip_ok id = @skill_equip.item == 0 ? 0 : @skill_equip.item.id @actor.equip_skill(@slots_window.index, id) @slots_window.refresh @skill_equip.deactivate.hide @slots_window.show.activate end #-------------------------------------------------------------------------- # new method: on_skill_equip_cancel #-------------------------------------------------------------------------- def on_skill_equip_cancel @skill_equip.deactivate.hide @slots_window.show.activate end #-------------------------------------------------------------------------- # super method: update #-------------------------------------------------------------------------- def update super if @command_window.active if @command_window.current_symbol == :equip_skill @item_window.hide @slots_window.show @properties_window.show else @slots_window.hide @properties_window.hide @item_window.show end end end #-------------------------------------------------------------------------- # alias method: on_actor_change #-------------------------------------------------------------------------- alias yes_skill_equip_on_actor_change on_actor_change def on_actor_change yes_skill_equip_on_actor_change @slots_window.index = 0 @skill_equip.index = 0 @slots_window.actor = @actor @skill_equip.actor = @actor @properties_window.actor = @actor @slots_window.properties_window = @properties_window end end # Scene_Skill #============================================================================== # # ¥ End of File # #==============================================================================
$脸图战斗 = true $imported = {} if $imported.nil? module YEA module BATTLE SKIP_PARTY_COMMAND = true BATTLESTATUS_NAME_FONT_SIZE = 20 BATTLESTATUS_TEXT_FONT_SIZE = 16 BATTLESTATUS_NO_ACTION_ICON = 185 BATTLESTATUS_HPGAUGE_Y_PLUS = 11 BATTLESTATUS_CENTER_FACES = false HELP_TEXT_ALL_FOES = "全体敌人" HELP_TEXT_ONE_RANDOM_FOE = "单个敌人" HELP_TEXT_MANY_RANDOM_FOE = "%d个随机敌人" HELP_TEXT_ALL_ALLIES = "全体队友" HELP_TEXT_ALL_DEAD_ALLIES = "全体死亡队友" HELP_TEXT_ONE_RANDOM_ALLY = "单个随机队友" HELP_TEXT_RANDOM_ALLIES = "%d个随机队友" end end class Game_Battler def can_collapse? return false unless dead? unless actor? return false unless sprite.battler_visible array = [:collapse, :boss_collapse, :instant_collapse] return false if array.include?(sprite.effect_type) end return true end def draw_mp? return true end def draw_tp? return $data_system.opt_display_tp end end module Icon def self.no_action; return YEA::BATTLE::BATTLESTATUS_NO_ACTION_ICON; end end class Game_Temp attr_accessor :battle_aid attr_accessor :evaluating end class Game_Action alias evaluate_item_with_target_abe evaluate_item_with_target def evaluate_item_with_target(target) $game_temp.evaluating = true result = evaluate_item_with_target_abe(target) $game_temp.evaluating = false return result end end class Game_Actor < Game_Battler def draw_mp? return true unless draw_tp? for skill in skills next unless added_skill_types.include?(skill.stype_id) return true if skill.mp_cost > 0 end return false end def draw_tp? return false unless $data_system.opt_display_tp for skill in skills next unless added_skill_types.include?(skill.stype_id) return true if skill.tp_cost > 0 end return false end end class Window_BattleStatus < Window_Selectable def initialize super(0, 0, window_width, window_height) self.openness = 0 @party = $game_party.battle_members.clone end def col_max; return $game_party.max_battle_members; end def battle_members; return $game_party.battle_members; end def actor; return battle_members[@index]; end def update super return if @party == $game_party.battle_members @party = $game_party.battle_members.clone refresh end def draw_item(index) return if index.nil? clear_item(index) actor = battle_members[index] rect = item_rect(index) return if actor.nil? draw_actor_face(actor, rect.x+2, rect.y+2, actor.alive?) draw_actor_name(actor, rect.x, rect.y, rect.width-8) draw_actor_action(actor, rect.x, rect.y) draw_actor_icons(actor, rect.x, line_height*1, rect.width) gx = YEA::BATTLE::BATTLESTATUS_HPGAUGE_Y_PLUS contents.font.size = YEA::BATTLE::BATTLESTATUS_TEXT_FONT_SIZE draw_actor_hp(actor, rect.x+2, line_height*2+gx, rect.width-4) if draw_tp?(actor) && draw_mp?(actor) dw = rect.width/2-2 dw += 1 if $imported["YEA-CoreEngine"] && YEA::CORE::GAUGE_OUTLINE draw_actor_tp(actor, rect.x+2, line_height*3, dw) dw = rect.width - rect.width/2 - 2 draw_actor_mp(actor, rect.x+rect.width/2, line_height*3, dw) elsif draw_tp?(actor) && !draw_mp?(actor) draw_actor_tp(actor, rect.x+2, line_height*3, rect.width-4) else draw_actor_mp(actor, rect.x+2, line_height*3, rect.width-4) end end def item_rect(index) rect = Rect.new rect.width = contents.width / $game_party.max_battle_members rect.height = contents.height rect.x = index * rect.width if YEA::BATTLE::BATTLESTATUS_CENTER_FACES rect.x += (contents.width - $game_party.members.size * rect.width) / 2 end rect.y = 0 return rect end def draw_face(face_name, face_index, dx, dy, enabled = true) bitmap = Cache.face(face_name) fx = [(96 - item_rect(0).width + 1) / 2, 0].max fy = face_index / 4 * 96 + 2 fw = [item_rect(0).width - 4, 92].min rect = Rect.new(fx, fy, fw, 92) rect = Rect.new(face_index % 4 * 96 + fx, fy, fw, 92) contents.blt(dx, dy, bitmap, rect, enabled ? 255 : translucent_alpha) bitmap.dispose end def draw_actor_name(actor, dx, dy, dw = 112) reset_font_settings contents.font.size = YEA::BATTLE::BATTLESTATUS_NAME_FONT_SIZE change_color(hp_color(actor)) draw_text(dx+24, dy, dw-24, line_height, actor.name) end def draw_actor_action(actor, dx, dy) draw_icon(action_icon(actor), dx, dy) end def action_icon(actor) return Icon.no_action if actor.current_action.nil? return Icon.no_action if actor.current_action.item.nil? return actor.current_action.item.icon_index end def draw_tp?(actor) return actor.draw_tp? end def draw_mp?(actor) return actor.draw_mp? end def draw_current_and_max_values(dx, dy, dw, current, max, color1, color2) change_color(color1) draw_text(dx, dy, dw, line_height, current.to_s, 2) end def draw_actor_hp(actor, dx, dy, width = 124) draw_gauge(dx, dy, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2) change_color(system_color) cy = (Font.default_size - contents.font.size) / 2 + 1 draw_text(dx+2, dy+cy, 30, line_height, Vocab::hp_a) draw_current_and_max_values(dx, dy+cy, width, actor.hp, actor.mhp, hp_color(actor), normal_color) end def draw_actor_mp(actor, dx, dy, width = 124) draw_gauge(dx, dy, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2) change_color(system_color) cy = (Font.default_size - contents.font.size) / 2 + 1 draw_text(dx+2, dy+cy, 30, line_height, Vocab::mp_a) draw_current_and_max_values(dx, dy+cy, width, actor.mp, actor.mmp, mp_color(actor), normal_color) end def draw_actor_tp(actor, dx, dy, width = 124) draw_gauge(dx, dy, width, actor.tp_rate, tp_gauge_color1, tp_gauge_color2) change_color(system_color) cy = (Font.default_size - contents.font.size) / 2 + 1 draw_text(dx+2, dy+cy, 30, line_height, Vocab::tp_a) change_color(tp_color(actor)) draw_text(dx + width - 42, dy+cy, 42, line_height, actor.tp.to_i, 2) end end class Window_BattleActor < Window_BattleStatus def show create_flags super end def create_flags set_select_flag(:any) select(0) return if $game_temp.battle_aid.nil? if $game_temp.battle_aid.need_selection? select(0) set_select_flag(:dead) if $game_temp.battle_aid.for_dead_friend? elsif $game_temp.battle_aid.for_user? battler = BattleManager.actor id = battler.nil? ? 0 : $game_party.battle_members.index(battler) select(id) set_select_flag(:user) elsif $game_temp.battle_aid.for_all? select(0) set_select_flag(:all) set_select_flag(:all_dead) if $game_temp.battle_aid.for_dead_friend? elsif $game_temp.battle_aid.for_random? select(0) set_select_flag(:random) if $game_temp.battle_aid.for_random? end end def set_select_flag(flag) @select_flag = flag case @select_flag when :all, :all_dead, :random @cursor_all = true else @cursor_all = false end end def update_cursor if @cursor_all cursor_rect.set(0, 0, contents.width, contents.height) self.top_row = 0 elsif @index < 0 cursor_rect.empty else ensure_cursor_visible cursor_rect.set(item_rect(@index)) end end def cursor_movable? return false if @select_flag == :user return super end def current_item_enabled? return true if $game_temp.battle_aid.nil? if $game_temp.battle_aid.need_selection? member = $game_party.battle_members[@index] return member.dead? if $game_temp.battle_aid.for_dead_friend? elsif $game_temp.battle_aid.for_dead_friend? for member in $game_party.battle_members return true if member.dead? end return false end return true end end class Window_BattleStatusAid < Window_BattleStatus attr_accessor :status_window def initialize super self.visible = false self.openness = 255 end def window_width; return 128; end def show super refresh end def refresh contents.clear return if @status_window.nil? draw_item(@status_window.index) end def item_rect(index) return Rect.new(0, 0, contents.width, contents.height) end end class Window_BattleEnemy < Window_Selectable def initialize(info_viewport) super(0, Graphics.height, window_width, fitting_height(1)) refresh self.visible = false @info_viewport = info_viewport end def col_max; return item_max; end def show create_flags super end def create_flags set_select_flag(:any) select(0) return if $game_temp.battle_aid.nil? if $game_temp.battle_aid.need_selection? select(0) elsif $game_temp.battle_aid.for_all? select(0) set_select_flag(:all) elsif $game_temp.battle_aid.for_random? select(0) set_select_flag(:random) end end def set_select_flag(flag) @select_flag = flag case @select_flag when :all, :random @cursor_all = true else @cursor_all = false end end def select_all? return true if @select_flag == :all return true if @select_flag == :random return false end def update_cursor if @cursor_all cursor_rect.set(0, 0, contents.width, contents.height) self.top_row = 0 elsif @index < 0 cursor_rect.empty else ensure_cursor_visible cursor_rect.set(item_rect(@index)) end end def cursor_movable? return false if @select_flag == :user return super end def current_item_enabled? return true if $game_temp.battle_aid.nil? if $game_temp.battle_aid.need_selection? member = $game_party.battle_members[@index] return member.dead? if $game_temp.battle_aid.for_dead_friend? elsif $game_temp.battle_aid.for_dead_friend? for member in $game_party.battle_members return true if member.dead? end return false end return true end def enemy; @data[index]; end def refresh make_item_list create_contents draw_all_items end def make_item_list @data = $game_troop.alive_members @data.sort! { |a,b| a.screen_x <=> b.screen_x } end def draw_item(index); return; end def update super return unless active enemy.sprite_effect_type = :whiten return unless select_all? for enemy in $game_troop.alive_members enemy.sprite_effect_type = :whiten end end end class Window_BattleHelp < Window_Help attr_accessor :actor_window attr_accessor :enemy_window def update super if !self.visible and @text != "" @text = "" return refresh end update_battler_name end def update_battler_name return unless @actor_window.active || @enemy_window.active if @actor_window.active battler = $game_party.battle_members[@actor_window.index] elsif @enemy_window.active battler = @enemy_window.enemy end if special_display? refresh_special_case(battler) else refresh_battler_name(battler) if battler_name(battler) != @text end end def battler_name(battler) text = battler.name.clone return text end def refresh_battler_name(battler) contents.clear reset_font_settings change_color(normal_color) @text = battler_name(battler) icons = battler.state_icons + battler.buff_icons dy = icons.size <= 0 ? line_height / 2 : 0 draw_text(0, dy, contents.width, line_height, @text, 1) dx = (contents.width - (icons.size * 24)) / 2 draw_actor_icons(battler, dx, line_height, contents.width) end def special_display? return false if $game_temp.battle_aid.nil? return false if $game_temp.battle_aid.for_user? return !$game_temp.battle_aid.need_selection? end def refresh_special_case(battler) if $game_temp.battle_aid.for_opponent? if $game_temp.battle_aid.for_all? text = YEA::BATTLE::HELP_TEXT_ALL_FOES else case $game_temp.battle_aid.number_of_targets when 1 text = YEA::BATTLE::HELP_TEXT_ONE_RANDOM_FOE else number = $game_temp.battle_aid.number_of_targets text = sprintf(YEA::BATTLE::HELP_TEXT_MANY_RANDOM_FOE, number) end end else if $game_temp.battle_aid.for_dead_friend? text = YEA::BATTLE::HELP_TEXT_ALL_DEAD_ALLIES elsif $game_temp.battle_aid.for_random? case $game_temp.battle_aid.number_of_targets when 1 text = YEA::BATTLE::HELP_TEXT_ONE_RANDOM_ALLY else number = $game_temp.battle_aid.number_of_targets text = sprintf(YEA::BATTLE::HELP_TEXT_RANDOM_ALLIES, number) end else text = YEA::BATTLE::HELP_TEXT_ALL_ALLIES end end return if text == @text @text = text contents.clear reset_font_settings draw_text(0, 0, contents.width, line_height*2, @text, 1) end end class Window_SkillList < Window_Selectable def spacing return 8 if $game_party.in_battle return super end end class Window_ItemList < Window_Selectable def spacing return 8 if $game_party.in_battle return super end end class Scene_Battle < Scene_Base attr_accessor :enemy_window attr_accessor :info_viewport attr_accessor :spriteset attr_accessor :status_window attr_accessor :status_aid_window attr_accessor :subject alias scene_battle_create_all_windows_abe create_all_windows def create_all_windows scene_battle_create_all_windows_abe create_battle_status_aid_window set_help_window end alias scene_battle_create_info_viewport_abe create_info_viewport def create_info_viewport scene_battle_create_info_viewport_abe @status_window.refresh end def create_battle_status_aid_window @status_aid_window = Window_BattleStatusAid.new @status_aid_window.status_window = @status_window @status_aid_window.x = Graphics.width - @status_aid_window.width @status_aid_window.y = Graphics.height - @status_aid_window.height end def create_help_window @help_window = Window_BattleHelp.new @help_window.hide end def set_help_window @help_window.actor_window = @actor_window @help_window.enemy_window = @enemy_window end alias scene_battle_create_skill_window_abe create_skill_window def create_skill_window scene_battle_create_skill_window_abe @skill_window.height = @info_viewport.rect.height @skill_window.width = Graphics.width - @actor_command_window.width @skill_window.y = Graphics.height - @skill_window.height end alias scene_battle_create_item_window_abe create_item_window def create_item_window scene_battle_create_item_window_abe @item_window.height = @skill_window.height @item_window.width = @skill_window.width @item_window.y = Graphics.height - @item_window.height end alias scene_battle_next_command_abe next_command def next_command @status_window.show redraw_current_status @actor_command_window.show @status_aid_window.hide scene_battle_next_command_abe end alias scene_battle_prior_command_abe prior_command def prior_command redraw_current_status scene_battle_prior_command_abe end def redraw_current_status return if @status_window.index < 0 @status_window.draw_item(@status_window.index) end alias scene_battle_command_attack_abe command_attack def command_attack $game_temp.battle_aid = $data_skills[BattleManager.actor.attack_skill_id] scene_battle_command_attack_abe end alias scene_battle_command_skill_abe command_skill def command_skill scene_battle_command_skill_abe @status_window.hide @actor_command_window.hide @status_aid_window.show end alias scene_battle_command_item_abe command_item def command_item scene_battle_command_item_abe @status_window.hide @actor_command_window.hide @status_aid_window.show end def on_skill_ok @skill = @skill_window.item $game_temp.battle_aid = @skill BattleManager.actor.input.set_skill(@skill.id) BattleManager.actor.last_skill.object = @skill if @skill.for_opponent? select_enemy_selection elsif @skill.for_friend? select_actor_selection else @skill_window.hide next_command $game_temp.battle_aid = nil end end alias scene_battle_on_skill_cancel_abe on_skill_cancel def on_skill_cancel scene_battle_on_skill_cancel_abe @status_window.show @actor_command_window.show @status_aid_window.hide end def on_item_ok @item = @item_window.item $game_temp.battle_aid = @item BattleManager.actor.input.set_item(@item.id) if @item.for_opponent? select_enemy_selection elsif @item.for_friend? select_actor_selection else @item_window.hide next_command $game_temp.battle_aid = nil end $game_party.last_item.object = @item end alias scene_battle_on_item_cancel_abe on_item_cancel def on_item_cancel scene_battle_on_item_cancel_abe @status_window.show @actor_command_window.show @status_aid_window.hide end alias scene_battle_select_actor_selection_abe select_actor_selection def select_actor_selection @status_aid_window.refresh scene_battle_select_actor_selection_abe @status_window.hide @skill_window.hide @item_window.hide @help_window.show end alias scene_battle_on_actor_ok_abe on_actor_ok def on_actor_ok $game_temp.battle_aid = nil scene_battle_on_actor_ok_abe @status_window.show if $imported["YEA-BattleCommandList"] && !@confirm_command_window.nil? @actor_command_window.visible = !@confirm_command_window.visible else @actor_command_window.show end @status_aid_window.hide end alias scene_battle_on_actor_cancel_abe on_actor_cancel def on_actor_cancel BattleManager.actor.input.clear @status_aid_window.refresh $game_temp.battle_aid = nil scene_battle_on_actor_cancel_abe case @actor_command_window.current_symbol when :skill @skill_window.show when :item @item_window.show end end alias scene_battle_select_enemy_selection_abe select_enemy_selection def select_enemy_selection @status_aid_window.refresh scene_battle_select_enemy_selection_abe @help_window.show end alias scene_battle_on_enemy_ok_abe on_enemy_ok def on_enemy_ok $game_temp.battle_aid = nil scene_battle_on_enemy_ok_abe end alias scene_battle_on_enemy_cancel_abe on_enemy_cancel def on_enemy_cancel BattleManager.actor.input.clear @status_aid_window.refresh $game_temp.battle_aid = nil scene_battle_on_enemy_cancel_abe if @skill_window.visible || @item_window.visible @help_window.show else @help_window.hide end end def end_battle_conditions? return true if $game_party.members.empty? return true if $game_party.all_dead? return true if $game_troop.all_dead? return true if BattleManager.aborting? return false end def refresh_status #如果你是程序员,请顺手帮忙优化下这里,谢谢。 @status_window.refresh for i in $game_party.battle_members @status_window.draw_item($game_party.battle_members.index(i)) end end end
提示.jpg (5.49 KB, 下载次数: 16)
提示
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |