#============================================================================== # ■ VXAce-RGSS3-8 熟練度システム [Ver.1.0.1] by Claimh #------------------------------------------------------------------------------ # [再定義] Scene_Battle#apply_item_effects #============================================================================== module SysUpdate #-------------------------------------------------------------------------- # ● 連続攻撃系スクリプトとの併用化処理 # 【仕様】連続攻撃系が動作中はレベルアップさせない。 # 他の連続攻撃系との併用についてもこのメソッドで吸収させる。 #-------------------------------------------------------------------------- def self.use_together_other_system(actor) # 閃きシステム 併用時 if defined?(SysFlash) return false if actor.flash_flg end # 戦闘以外はカウントしない return false unless $game_party.in_battle return true # 有効 end def self.init # p caller return 1 end #-------------------------------------------------------------------------- # ● 汎用データ取得 #-------------------------------------------------------------------------- def self.get_data(data, attr_id, actor_id) return init if !data.is_a?(Array) return init if data[0].nil? and data[actor_id].nil? return init if data[actor_id].nil? and data[0][attr_id].nil? return data[0][attr_id] if data[actor_id].nil? or data[actor_id][attr_id].nil? return data[actor_id][attr_id] end #-------------------------------------------------------------------------- # ● 熟練度初期値 #-------------------------------------------------------------------------- def self.attr_first_lv(attr_id, actor_id) return get_data(INIT_LEVEL, attr_id, actor_id) end #-------------------------------------------------------------------------- # ● 熟練度上限 #-------------------------------------------------------------------------- def self.attr_limit_lv(attr_id, actor_id) return get_data(LV_LIMIT, attr_id, actor_id) end #-------------------------------------------------------------------------- # ● 熟練度上昇:基本値 #-------------------------------------------------------------------------- def self.attr_interval(attr_id, actor_id) return get_data(UP_INTERVAL, attr_id, actor_id) end #-------------------------------------------------------------------------- # ● 熟練度上昇:傾き #-------------------------------------------------------------------------- def self.attr_slope(attr_id, actor_id) return get_data(UP_SLOPE, attr_id, actor_id) end #-------------------------------------------------------------------------- # ● 威力上昇率 #-------------------------------------------------------------------------- def self.attr_rate(attr_id, actor_id) return get_data(ATK_RATE, attr_id, actor_id) / 100.0 end #-------------------------------------------------------------------------- # ● 属性修正 取得 #-------------------------------------------------------------------------- def self.attr_guard_rate(attr_id, actor_id) return get_data(GUARD_RATE, attr_id, actor_id) / 100.0 end #-------------------------------------------------------------------------- # ● 熟練度EXPリスト(詳細版)取得 #-------------------------------------------------------------------------- def self.attr_exp(actor_id, attr_id, lv) return A_EXP[actor_id][attr_id][lv] if !A_EXP[actor_id].nil? and !A_EXP[actor_id][attr_id].nil? and !A_EXP[actor_id][attr_id][lv].nil? return A_EXP[actor_id][0][lv] if !A_EXP[actor_id].nil? and !A_EXP[actor_id][0].nil? and !A_EXP[actor_id][0][lv].nil? return A_EXP[0][attr_id][lv] if !A_EXP[0].nil? and !A_EXP[0][attr_id].nil? and !A_EXP[0][attr_id][lv].nil? return A_EXP[0][0][lv] if !A_EXP[0].nil? and !A_EXP[0][0].nil? and !A_EXP[0][0][lv].nil? return 0 end #-------------------------------------------------------------------------- # ● EXP 計算 #-------------------------------------------------------------------------- def self.make_attr_list(attr_id, actor_id, lv_limit) # 上昇間隔 up_interval = attr_interval(attr_id, actor_id) # 傾き up_slope = attr_slope(attr_id, actor_id) list = [] list[0] = list[1] = 0 # 熟練度EXPリスト作成 for lv in 2..lv_limit case LEVEL_UP_PATTERN when 0; exp = up_interval * (lv-1) when 1; exp = list[lv-1] + up_slope * (lv-1) + up_interval when 2; exp = list[lv-1] + up_slope * (lv-1) * (lv-1) + up_interval when 3; exp = attr_exp(actor_id, attr_id, lv) end list[lv] = exp.truncate end #p actor_id, attr_id, list return list end #-------------------------------------------------------------------------- # ● 属性情報管理クラス #-------------------------------------------------------------------------- class Attr attr_accessor :id # 属性id attr_accessor :level # 属性レベル def initialize @level = 0 @id = 0 end end #-------------------------------------------------------------------------- # ● 熟練度取得(共通処理) #-------------------------------------------------------------------------- def self.best_attr(actor, element_set) attr = Attr.new element_set.each do |w_element| next unless ELEMENTS.include?(w_element) # 管理対象外 next if attr.level >= actor.attr[w_element].level # 最大でないので除外 attr.level = actor.attr[w_element].level attr.id = w_element end return attr end #-------------------------------------------------------------------------- # ● 管理下属性の配列抽出 #-------------------------------------------------------------------------- def self.correct_element(element_set) element_set.select { |element_id| ELEMENTS.include?(element_id) } end #-------------------------------------------------------------------------- # ● 得意/不得意属性 威力計算 #-------------------------------------------------------------------------- def self.calc_taste(taste, base_rate) case taste when ATTR_NORMAL; return base_rate when ATTR_GOOD; return base_rate + (TASTE_RATE/100.0) when ATTR_BAD; return base_rate - (TASTE_RATE/100.0) else; p "unknown taste:{#taste}" end end #-------------------------------------------------------------------------- # ● 得意/不得意属性 属性修正計算 #-------------------------------------------------------------------------- def self.calc_guard_taste(taste, base_rate) case taste when ATTR_NORMAL; return base_rate when ATTR_GOOD; return base_rate + (TASTE_G_RATE/100.0) when ATTR_BAD; return base_rate - (TASTE_G_RATE/100.0) else; p "unknown taste:{#taste}" end end #-------------------------------------------------------------------------- # ● 熟練度取得 #-------------------------------------------------------------------------- def self.attr_attack(actor, elements) attr = best_attr(actor, elements) return 1 if attr.id == 0 or attr.level == 0 rate = attr_rate(attr.id, actor.id) * (attr.level-1) return calc_taste(actor.attr[attr.id].taste, rate) end #-------------------------------------------------------------------------- # ● 属性修正 取得 #-------------------------------------------------------------------------- def self.attr_guard(actor, attr_id) rate = attr_guard_rate(attr_id, actor.id) * (actor.attr[attr_id].level-1) return calc_guard_taste(actor.attr[attr_id].taste, rate) end #-------------------------------------------------------------------------- # ● 属性攻撃使用回数更新 #-------------------------------------------------------------------------- def self.element_use_count(actor, elements) return unless use_together_other_system(actor) # 併用認知 element_set = correct_element(elements) element_set.each do |attr_id| old_level = actor.attr[attr_id].level actor.attr[attr_id].use_cnt += 1 # 使用回数のカウント if old_level < actor.attr[attr_id].level # レベルアップした場合は記憶 actor.attr_level_up.push(attr_id) end end end #-------------------------------------------------------------------------- # ● 属性攻撃使用回数再更新(後戻し) #-------------------------------------------------------------------------- def self.element_use_recount(actor, elements) return unless use_together_other_system(actor) # 併用認知 element_set = correct_element(elements) element_set.each do |attr_id| actor.attr[attr_id].use_cnt -= 1 # 使用回数の再カウント end actor.attr_level_up = [] # レベルアップ情報は削除 end #-------------------------------------------------------------------------- # ● 属性抽出 #-------------------------------------------------------------------------- def self.elements(actor, item) if item.damage.element_id < 0 if item.is_a?(RPG::Skill) and item.id == actor.attack_skill_id return actor.atk_elements + actor.equip_weapon_types(OFST) else return actor.atk_elements end else return [item.damage.element_id] end end #-------------------------------------------------------------------------- # ● 属性名 #-------------------------------------------------------------------------- def self.attr_name(attr_id) if attr_id < OFST return $data_system.elements[attr_id] else return $data_system.weapon_types[attr_id - OFST] end end end #---------------------------------------------------------------------------- # ■ 熟練度クラス #---------------------------------------------------------------------------- class ActorAttr attr_accessor :use_cnt # 属性使用回数 attr_accessor :level # 属性レベル attr_accessor :lv_limit # 限界レベル attr_accessor :exp_list # 属性EXPリスト attr_accessor :taste # 属性好み #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(attr_id, actor_id) @attr_id = attr_id @actor_id = actor_id @level = SysUpdate.attr_first_lv(attr_id, actor_id) @lv_limit = SysUpdate.attr_limit_lv(attr_id, actor_id) @exp_list = SysUpdate.make_attr_list(attr_id, actor_id, @lv_limit) if !SysUpdate::GOOD_E[actor_id].nil? and SysUpdate::GOOD_E[actor_id].include?(attr_id) @taste = SysUpdate::ATTR_GOOD elsif !SysUpdate::BAD_E[actor_id].nil? and SysUpdate::BAD_E[actor_id].include?(attr_id) @taste = SysUpdate::ATTR_BAD else @taste = SysUpdate::ATTR_NORMAL end reset_use end #-------------------------------------------------------------------------- # ● 使用回数のリセット(現在のLV最小値に変更) #-------------------------------------------------------------------------- def reset_use @use_cnt = @exp_list[@level] end #-------------------------------------------------------------------------- # ● 使用回数設定 #-------------------------------------------------------------------------- def use_cnt=(exp) @use_cnt = [[exp, 9999999].min, 0].max # レベルアップ while levelup? and @exp_list[@level+1] > 0 @level += 1 end # レベルダウン while @use_cnt < @exp_list[@level] @level -= 1 end end #-------------------------------------------------------------------------- # ● レベルセット #-------------------------------------------------------------------------- def level=(new_level) return if new_level > @lv_limit return if new_level < 1 @level = new_level reset_use end #-------------------------------------------------------------------------- # ● レベルアップ判定 #-------------------------------------------------------------------------- def levelup? return false if limit_lv? # 最大レベル到達時は無視 return (@use_cnt >= @exp_list[@level+1]) end #-------------------------------------------------------------------------- # ● リミットレベル判定 #-------------------------------------------------------------------------- def limit_lv? return @level >= @lv_limit end #-------------------------------------------------------------------------- # ● 次のレベルアップ経験値 #-------------------------------------------------------------------------- def next_exp return @exp_list[@level+1] end #-------------------------------------------------------------------------- # ● 次のレベルアップまであといくら? #-------------------------------------------------------------------------- def diff_next_exp return @exp_list[@level+1] - @use_cnt end #-------------------------------------------------------------------------- # ● 得意属性? #-------------------------------------------------------------------------- def is_good_taste? return @taste == SysUpdate::ATTR_GOOD end #-------------------------------------------------------------------------- # ● 不得意属性? #-------------------------------------------------------------------------- def is_bad_taste? return @taste == SysUpdate::ATTR_BAD end end #---------------------------------------------------------------------------- # ■ 熟練度クラス #---------------------------------------------------------------------------- class ActorAttrList #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(actor_id) @actor_id = actor_id @attr = {} end #-------------------------------------------------------------------------- # ● 熟練度情報参照 #-------------------------------------------------------------------------- def [](attr_id) if @attr[attr_id].nil? if SysUpdate::ELEMENTS.include?(attr_id) @attr[attr_id] = ActorAttr.new(attr_id, @actor_id) else msgbox_p "Game_Actor.attr[] 不正属性ID #{attr_id}" return nil end end return @attr[attr_id] end end class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # ● スキル/アイテムの効果適用 #-------------------------------------------------------------------------- alias item_apply_sys_update item_apply def item_apply(user, item) SysUpdate.element_use_count(user, SysUpdate.elements(user, item)) if user.actor? item_apply_sys_update(user, item) SysUpdate.element_use_recount(user, SysUpdate.elements(user, item)) if user.actor? and !@result.hit? end #-------------------------------------------------------------------------- # ● スキル/アイテムの属性修正値を取得 #-------------------------------------------------------------------------- alias item_element_rate_sys_update item_element_rate def item_element_rate(user, item) result = item_element_rate_sys_update(user, item) return result unless user.actor? return result + SysUpdate.attr_attack(user, SysUpdate.elements(user, item)) end end class Game_Actor < Game_Battler attr_accessor :attr # 属性情報 attr_accessor :attr_level_up # レベルアップフラグ #-------------------------------------------------------------------------- # ● セットアップ #-------------------------------------------------------------------------- alias setup_sysupdate setup def setup(actor_id) setup_sysupdate(actor_id) @attr = ActorAttrList.new(actor_id) @attr_level_up = [] end #-------------------------------------------------------------------------- # ● 属性有効度の取得 [over ride] #-------------------------------------------------------------------------- def element_rate(element_id) result = super(element_id) # 原型 if SysUpdate::ELEMENTS.include?(element_id) # 熟練度対象の属性だけ result -= SysUpdate.attr_guard(self, element_id) # 熟練度による補正 end return result end #-------------------------------------------------------------------------- # ● 装備中武器のタイプ #-------------------------------------------------------------------------- def equip_weapon_types(offset=0) weapons.select { |w| w.wtype_id > 0 }.collect { |w| w.wtype_id + offset } end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● 戦闘行動の実行 #-------------------------------------------------------------------------- alias execute_action_sys_update execute_action def execute_action @subject.attr_level_up = [] if @subject.actor? execute_action_sys_update # 原物 end #-------------------------------------------------------------------------- # ● スキル/アイテムの効果を適用 [再定義] #-------------------------------------------------------------------------- def apply_item_effects(target, item) target.item_apply(@subject, item) @log_window.display_attr_levelup(@subject) if @subject.actor? #←行追加 refresh_status @log_window.display_action_results(target, item) end end class Window_BattleLog < Window_Selectable #-------------------------------------------------------------------------- # ● 熟練度レベルUP表示 #-------------------------------------------------------------------------- def display_attr_levelup(subject) return if subject.attr_level_up.empty? SysUpdate::SHOW_LV_SE.play unless SysUpdate::SHOW_LV_SE.nil? display_attr_levelup_sub(subject) end #-------------------------------------------------------------------------- # ● レベルアップの表示 [sub] #-------------------------------------------------------------------------- def display_attr_levelup_sub(subject) subject.attr_level_up.each do |attr_id| add_text(SysUpdate.attr_name(attr_id) + "のレベルが上がった!") wait back_one end end end #============================================================================== # ■ Game_Interpreter [イベントスクリプト操作] #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ● 熟練度設定(レベルセット) # actor_id : アクターID # attr_id : 属性ID # level : 設定レベル #-------------------------------------------------------------------------- def set_element_level(actor_id, attr_id, level) $game_actors[actor_id].attr[attr_id].level = level end #-------------------------------------------------------------------------- # ● 熟練度設定(レベルアップ) # actor_id : アクターID # element : 属性ID #-------------------------------------------------------------------------- def element_level_up(actor_id, attr_id) $game_actors[actor_id].attr[attr_id].level += 1 end #-------------------------------------------------------------------------- # ● 熟練度設定(レベルダウン) # actor_id : アクターID # attr_id : 属性ID #-------------------------------------------------------------------------- def element_level_down(actor_id, attr_id) $game_actors[actor_id].attr[attr_id].level -= 1 end #-------------------------------------------------------------------------- # ● 熟練度設定(熟練度上限操作) # actor_id : アクターID # attr_id : 属性ID # limit : 熟練度上限値 #-------------------------------------------------------------------------- def set_element_limit(actor_id, attr_id, limit) actor = $game_actors[actor_id] actor.attr[attr_id].lv_limit = limit if actor.attr[attr_id].level > limit set_element_level(actor_id, attr_id, limit) end end #-------------------------------------------------------------------------- # ● 得意属性/不得意属性の操作 # actor_id :アクターID # attr_id :属性ID # cnt_cmd :操作コマンド # 0:得意属性/不得意属性から解除 # 1:得意属性に設定 # 2:不得意属性に設定 #-------------------------------------------------------------------------- def control_attr(actor_id, attr_id, cnt_cmd) $game_actors[actor_id].attr[attr_id].taste = cnt_cmd end end #============================================================================== # ■ Window_Base #============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # ● レベル限界色の指定(数値を変えると色が変わります) #-------------------------------------------------------------------------- def limit_lv_color return Color.new(255, 255, 64, 255) end #-------------------------------------------------------------------------- # ● レベルの描画 # actor : アクター # attr_id : レベルを表示させる属性 # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_actor_attr_level(actor, attr_id, x, y) change_color(system_color) draw_text(x, y, 32, line_height, "Lv") change_color(actor.attr[attr_id].limit_lv? ? limit_lv_color : normal_color) draw_text(x + 20, y, 24, line_height, actor.attr[attr_id].level.to_s, 2) change_color(normal_color) end #-------------------------------------------------------------------------- # ● アイコンの描画 # attr_id : アイコンを表示する属性 # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_attr_icon(attr_id, x, y) draw_icon(SysUpdate::ELE_ICON[attr_id], x, y) end #-------------------------------------------------------------------------- # ● アイコン(+)の描画 # attr_id : アイコンを表示する属性 # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_attr_icon_p(attr_id, x, y) draw_attr_icon(attr_id, x, y) draw_text(x+12, y-6, 24, 24, "+") end #-------------------------------------------------------------------------- # ● アイコン(-)の描画 # attr_id : アイコンを表示する属性 # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_attr_icon_m(attr_id, x, y) draw_attr_icon(attr_id, x, y) draw_text(x+12, y-6, 24, 24, "-") end #-------------------------------------------------------------------------- # ● アイコン(+/-自動付与式)の描画 # actor : アクター # attr_id : アイコンを表示する属性 # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_attr_icon_pm(actor, attr_id, x, y) case actor.attr[attr_id].taste when SysUpdate::ATTR_NORMAL; draw_attr_icon(attr_id, x, y) when SysUpdate::ATTR_GOOD; draw_attr_icon_p(attr_id, x, y) when SysUpdate::ATTR_BAD; draw_attr_icon_m(attr_id, x, y) end end #-------------------------------------------------------------------------- # ● アイコン + Lvの描画 # actor : アクター # attr_id : アイコンを表示する属性 # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_attr_icon_lv(actor, attr_id, x, y) draw_attr_icon_pm(actor, attr_id, x, y) draw_actor_attr_level(actor, attr_id, x+28, y) end #-------------------------------------------------------------------------- # ● 熟練度Nextの表示(使用回数/NEXT) # actor : アクター # attr_id : 表示する属性 # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_attr_current_next(actor, attr_id, x, y) next_exp = actor.attr[attr_id].limit_lv? ? "−" : actor.attr[attr_id].next_exp.to_s draw_text(x, y, 64, line_height, actor.attr[attr_id].use_cnt, 2) draw_text(x+64, y, 32, line_height, "/") draw_text(x+68, y, 64, line_height, next_exp, 2) end #-------------------------------------------------------------------------- # ● 熟練度Nextの表示(次のLVまでいくら) # actor : アクター # attr_id : 表示する属性 # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_attr_next(actor, attr_id, x, y) change_color(system_color) draw_text(x, y, 60, line_height, "Next") change_color(normal_color) next_exp = actor.attr[attr_id].limit_lv? ? "−" : actor.attr[attr_id].diff_next_exp.to_s draw_text(x+40, y, 64, line_height, next_exp, 2) end #-------------------------------------------------------------------------- # ● 攻撃上昇率の描画 #-------------------------------------------------------------------------- def draw_attr_attack_rate(actor, attr_id, x, y) rate = 100+(SysUpdate.attr_attack(actor, [attr_id])*100).truncate draw_text(x, y, 64, line_height, rate, 2) draw_text(x+70, y, 32, line_height, "%") end #-------------------------------------------------------------------------- # ● 属性有効度の描画 #-------------------------------------------------------------------------- def draw_attr_guard_rate(actor, attr_id, x, y) rate = (actor.element_rate(attr_id)*100).truncate draw_text(x, y, 64, line_height, rate, 2) draw_text(x+70, y, 32, line_height, "%") end #-------------------------------------------------------------------------- # ● 属性 攻撃上昇率/有効度の描画 #-------------------------------------------------------------------------- def draw_attr_rate(actor, attr_id, x, y) draw_attr_attack_rate(actor, attr_id, x, y) draw_text(x+94, y, 32, line_height, "/") draw_attr_guard_rate(actor, attr_id, x+80, y) end end