#============================================================================== # ■ XP-RGSS-11-opt 武器属性スキル制限 [Ver.1.0.0] by Claimh #------------------------------------------------------------------------------ # ・武器属性にない属性のスキルを使用できないようにします #============================================================================== module SysUpdate # 武器属性によってスキル使用可否を制限する属性 RESTRICATION_ELE = [SWORD, LANCE, AX, BOW, GUN, WAND] #-------------------------------------------------------------------------- # ● スキルの属性制限判定 # actor : アクター(Game_Actor) # skill : スキル(RPG::Skill) #-------------------------------------------------------------------------- def self.restrication?(actor, skill) return false if skill.nil? restrication_elements = [] for ele in RESTRICATION_ELE if skill.element_set.include?(ele) restrication_elements.push(ele) # 制限対象の属性 end end restrication = false if !restrication_elements.empty? # 制限あり for ele in restrication_elements unless actor.element_set.include?(ele) restrication = true # 制限対象の属性がない break end end end return restrication end end class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● スキルの使用可能判定 # skill_id : スキル ID #-------------------------------------------------------------------------- alias restrication_skill_can_use? skill_can_use? def skill_can_use?(skill_id) return false if SysUpdate.restrication?(self, $data_skills[skill_id]) # 制限あり return restrication_skill_can_use?(skill_id) end end #============================================================================== # ■ Window_Skill #============================================================================== class Window_Skill < Window_Selectable #-------------------------------------------------------------------------- # ● リフレッシュ <再定義> #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] restrication_skills = [] for i in 0...@actor.skills.size skill = $data_skills[@actor.skills[i]] next if skill == nil if SysUpdate.restrication?(@actor, skill) # 制限あり restrication_skills.push(skill) else @data.push(skill) # 制限なし end end @data += restrication_skills # 制限されたスキルは最後尾に # 項目数が 0 でなければビットマップを作成し、全項目を描画 @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i) end end end end