#============================================================================== # スキルコスト拡張 ver1.10 #------------------------------------------------------------------------------ #[特徴] # スキルのコストにHPとアイテムを追加します。 # スキルのコストを割合/実数で軽減できる機能を追加。 # #[スキルコスト設定方法] # スキルのメモ欄に記述します。 # #◎HP消費 # <消費HP:数値> # #◎アイテム消費 # <消費アイテム:ID,個数> # #◎割合消費 # <現在HP割合消費> <最大HP割合消費> # <現在MP割合消費> <最大MP割合消費> # 消費MPが 30 のスキルのメモ欄に <最大MP割合消費> と記述すると、 # 最大MPの 30% を消費するスキルになります。 # #[スキルコスト軽減の設定方法] # アクター/職業/武器/防具/敵キャラ/ステートのメモ欄に記述します。 # #◎実数値で軽減 # <消費HP実数軽減:数値> <消費MP実数軽減:数値> <消費TP実数軽減:数値> # <消費MP実数軽減:3> で、消費MPが 3 減ります。 # #◎割合値で軽減 # <消費HP割合軽減:数値> <消費TP割合軽減:数値> # <消費HP割合軽減:80> で、消費HPが 80% になります。 # # # 作成:ぶちょー # ホム:http://nyannyannyan.bake-neko.net/ # 著作:自分で作ったとか言わないで>< # 改造はご自由にどうぞ。 # リードミーとかに私の名前の載せたりするのは任意で。 #============================================================================== #============================================================================== # バージョンアップ情報 # ver1,10 機能、いろいろ追加 # スクリプト名を変更(スキルコスト追加→スキルコスト拡張) # ver1.00 公開 #============================================================================== #============================================================================== # 設定項目はありません #============================================================================== $kzr_imported = {} if $kzr_imported == nil $kzr_imported["AddSkillCost"] = true #============================================================================== # ■ Window_Base #============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # ● 各種文字色の取得 #-------------------------------------------------------------------------- def hp_cost_color; text_color(14); end; # 消費 HP end #============================================================================== # ■ Window_SkillList #============================================================================== class Window_SkillList < Window_Selectable #-------------------------------------------------------------------------- # ● スキルの使用コストを描画 #-------------------------------------------------------------------------- alias kzr_skill_cost_ex_draw_skill_cost draw_skill_cost def draw_skill_cost(rect, skill) if @actor.skill_hp_cost(skill) > 0 change_color(hp_cost_color, enable?(skill)) draw_text(rect, @actor.skill_hp_cost(skill), 2) else kzr_skill_cost_ex_draw_skill_cost(rect, skill) end end end #============================================================================== # ■ Game_BattlerBase #============================================================================== class Game_BattlerBase #-------------------------------------------------------------------------- # ● スキルの消費 HP 計算 #-------------------------------------------------------------------------- def skill_hp_cost(skill) cost = skill.hp_cost case skill.hp_cost_rate when 1 ; cost *= hp / 100.0 when 2 ; cost *= mhp / 100.0 end cost = feature_objects.inject(cost) {|r, obj| r *= obj.reduce_hp_cost_rate } cost = feature_objects.inject(cost) {|r, obj| r -= obj.reduce_hp_cost } [cost.to_i, 0].max end #-------------------------------------------------------------------------- # ● スキルの消費 MP 計算 #-------------------------------------------------------------------------- alias kzr_skill_cost_ex_skill_mp_cost skill_mp_cost def skill_mp_cost(skill) cost = kzr_skill_cost_ex_skill_mp_cost(skill) if skill.mp_cost_rate cost *= mmp / 100.0 elsif skill.mp_cost_rate2 cost *= mp / 100.0 end cost = feature_objects.inject(cost) {|r, obj| r -= obj.reduce_mp_cost } [cost.to_i, 0].max end #-------------------------------------------------------------------------- # ● スキルの消費 TP 計算 #-------------------------------------------------------------------------- alias kzr_skill_cost_ex_skill_tp_cost skill_tp_cost def skill_tp_cost(skill) cost = kzr_skill_cost_ex_skill_tp_cost(skill) cost = feature_objects.inject(cost) {|r, obj| r *= obj.reduce_tp_cost_rate } cost = feature_objects.inject(cost) {|r, obj| r -= obj.reduce_tp_cost } [cost.to_i, 0].max end #-------------------------------------------------------------------------- # ● スキルの消費 アイテム 計算 #-------------------------------------------------------------------------- def skill_item_cost(skill) [] end #-------------------------------------------------------------------------- # ● スキル使用コストの支払い可能判定 #-------------------------------------------------------------------------- alias kzr_skill_cost_ex_skill_cost_payable? skill_cost_payable? def skill_cost_payable?(skill) return false if hp < skill_hp_cost(skill) kzr_skill_cost_ex_skill_cost_payable?(skill) end #-------------------------------------------------------------------------- # ● スキル使用コストの支払い #-------------------------------------------------------------------------- alias kzr_skill_cost_ex_pay_skill_cost pay_skill_cost def pay_skill_cost(skill) kzr_skill_cost_ex_pay_skill_cost(skill) self.hp -= skill_hp_cost(skill) end end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● スキルの消費 アイテム 計算 #-------------------------------------------------------------------------- def skill_item_cost(skill) skill.item_cost end #-------------------------------------------------------------------------- # ● スキル使用コストの支払い可能判定 #-------------------------------------------------------------------------- def skill_cost_payable?(skill) return false unless super(skill) return true if skill.item_cost.empty? cost = skill_item_cost(skill) return $game_party.item_number($data_items[cost[0]]) >= cost[1] end #-------------------------------------------------------------------------- # ● スキル使用コストの支払い #-------------------------------------------------------------------------- def pay_skill_cost(skill) super(skill) unless skill.item_cost.empty? cost = skill_item_cost(skill) $game_party.lose_item($data_items[cost[0]], cost[1]) end end end #============================================================================== # ■ RPG #============================================================================== module RPG class Skill < UsableItem def hp_cost return @hp_cost if @hp_cost != nil @hp_cost = 0 note.each_line { |line| case line when /<消費HP:(\d+)>/ ; @hp_cost = $1.to_i end } @hp_cost end def hp_cost_rate return @hp_cost_rate if @hp_cost_rate != nil @hp_cost_rate = 0 note.each_line { |line| case line when /<現在HP割合消費>/ ; @hp_cost_rate = 1 when /<最大HP割合消費>/ ; @hp_cost_rate = 2 end } @hp_cost_rate end def mp_cost_rate return @mp_cost_rate if @mp_cost_rate != nil @mp_cost_rate = false note.each_line { |line| case line when /<最大MP割合消費>/ ; @mp_cost_rate = true end } @mp_cost_rate end def mp_cost_rate2 return @mp_cost_rate2 if @mp_cost_rate2 != nil @mp_cost_rate2 = false note.each_line { |line| case line when /<現在MP割合消費>/ ; @mp_cost_rate2 = true end } @mp_cost_rate2 end def item_cost return @item_cost if @item_cost != nil @item_cost = [] note.each_line {|line| case line when /<消費アイテム:(\d+),(\d+)>/i ; @item_cost = [$1.to_i, $2.to_i] end } @item_cost end end class BaseItem def reduce_hp_cost_rate return @reduce_hp_cost_rate if @reduce_hp_cost_rate != nil @reduce_hp_cost_rate = 1.0 note.each_line { |line| case line when /<消費HP割合軽減:(\d+)>/ ; @reduce_hp_cost_rate = $1.to_i * 0.01 end } @reduce_hp_cost_rate end def reduce_hp_cost return @reduce_hp_cost if @reduce_hp_cost != nil @reduce_hp_cost = 0 note.each_line { |line| case line when /<消費HP実数軽減:(\d+)>/ ; @reduce_hp_cost = $1.to_i end } @reduce_hp_cost end def reduce_mp_cost return @reduce_mp_cost if @reduce_mp_cost != nil @reduce_mp_cost = 0 note.each_line { |line| case line when /<消費MP実数軽減:(\d+)>/ ; @reduce_mp_cost = $1.to_i end } @reduce_mp_cost end def reduce_tp_cost_rate return @reduce_tp_cost_rate if @reduce_tp_cost_rate != nil @reduce_tp_cost_rate = 1.0 note.each_line { |line| case line when /<消費TP割合軽減:(\d+)>/ ; @reduce_tp_cost_rate = $1.to_i * 0.01 end } @reduce_tp_cost_rate end def reduce_tp_cost return @reduce_tp_cost if @reduce_tp_cost != nil @reduce_tp_cost = 0 note.each_line { |line| case line when /<消費TP実数軽減:(\d+)>/ ; @reduce_tp_cost = $1.to_i end } @reduce_tp_cost end end end