818 lines
41 KiB
Ruby
818 lines
41 KiB
Ruby
|
||
|
||
=begin
|
||
#==============================================================================
|
||
[名前] 使用効果の機能拡張
|
||
[作者] 焼きノリ
|
||
[配布元] まったりツクール雑貨 http://mata-tuku.ldblog.jp/
|
||
#------------------------------------------------------------------------------
|
||
[更新履歴]
|
||
・2014/04/06 公開
|
||
・2014/07/15 反撃or反射されて死亡した時にエラーで落ちるバグの修正
|
||
・2014/07/19 「使用効果リストの拡張補助」の更新に対応
|
||
・2014/11/27 TPの回復時の割合と固定値が逆になっていましたが、
|
||
同日修正の「使用効果リストの拡張補助」で対応しました。
|
||
・2014/11/27 TP増加が機能していなかったので修正
|
||
・2014/12/06 デフォルトで搭載されている効果が発動しないバグの修正
|
||
#==============================================================================
|
||
|
||
#------------------------------------------------------------------------------
|
||
[対応]
|
||
・RGSS3のみ可能
|
||
#------------------------------------------------------------------------------
|
||
|
||
#------------------------------------------------------------------------------
|
||
[機能]
|
||
・一部のデフォルトの使用効果の機能の拡張と、新規の使用効果の設定
|
||
使用効果の適用範囲を拡張できるようになります。
|
||
|
||
・以下のデフォルトの使用効果を拡張しました。
|
||
(そのため、メモ帳への記述の仕方が変わります。詳細は後述の [使用方法] にて)
|
||
|
||
[ TP増加, 能力強化, 能力弱体, 成長, スキル習得 ]
|
||
|
||
・「TP増加」の機能を拡張。
|
||
既存の"TP増加"は、指定した値分しか増えませんでしたが、
|
||
割合でも増えるようにしました。さらに、増加だけでなく減少も可能にしました。
|
||
この効果による増加量は、回復効果率、薬の知識 の影響を受けません。
|
||
|
||
・「能力強化/弱体」の「付加/解除」に発動確率を指定可能。
|
||
弱体の付加に限り、100%以上の指定で対象の有効度よりも高い確率で付加できます。
|
||
また、弱体有効度と運の要素も絡むので、
|
||
必ずしも指定した確率で付加するとは限らないので注意。
|
||
|
||
・「スキル習得」にも発動確率を指定可能。
|
||
低確率で派生スキルを覚えるときとかに使えるかも…?
|
||
|
||
・「成長」にも発動確率を指定可能。
|
||
低確率で急成長するアイテムとかに使えるかも…?
|
||
|
||
・「成長」の増加値に負の数も指定できるようになります。
|
||
これにより、使うたびに自身の最大HPが1ずつ減るスキルが作れるかも。
|
||
ダークチップヲツカイナサイ
|
||
|
||
|
||
・以下の新規の使用効果を追加します。
|
||
|
||
[ TP回復, スキルの忘却, ステートのターン数変更, 能力変化のターン数変更 ]
|
||
|
||
・TP回復の機能を追加。
|
||
この効果による回復量は、回復効果率、薬の知識 の影響を受けます。
|
||
ちなみに、TP増加ではこれらの影響は受けません。
|
||
|
||
・スキルの忘却の機能を追加。
|
||
習得があるなら忘却もないと…と思って作ったもの。
|
||
1度しか使用できないスキルとか色々できそうです。対象がアクターのみ有効です。
|
||
|
||
・ステート、能力変化の残りターン数を変更できるようになります。
|
||
加算、減算、直接指定が使用可能です。
|
||
|
||
|
||
・使用効果の適用対象の範囲を "対象" 以外にも以下の設定が可能。
|
||
|
||
[ 使用者, 味方全体, 味方全体(使用者以外), 味方全体(戦闘不能) ]
|
||
[ 敵全体, 敵味方全体, 敵味方全体(使用者以外) ]
|
||
|
||
・使用者以外を対象にしたスキル/アイテムでも、
|
||
使用者に使用効果を与えることができるようになったり、
|
||
敵全体や味方全体、敵味方全体など、幅広い攻撃範囲に
|
||
使用効果を与えることができるようになります。
|
||
(敵に攻撃しながら自分の攻撃力を上昇させたりできます。)
|
||
|
||
※スキル/アイテムの効果適用後、使用者が生存していれば
|
||
使用者→味方→敵 の順に効果を適用します。
|
||
|
||
|
||
#------------------------------------------------------------------------------
|
||
|
||
#------------------------------------------------------------------------------
|
||
[使用方法]
|
||
・拙作のスクリプト「使用効果リストの拡張補助」が必須です。
|
||
上記のスクリプトより下に導入してください。
|
||
|
||
・このスクリプトのカスタマイズ項目から、メニュー画面でアイテムを使用した時の
|
||
一部の使用効果の挙動を変えることができます(デフォルトは false )。
|
||
|
||
|
||
・一部のデフォルトの使用効果の記述方法が以下に変更:
|
||
|
||
<対象効果: TP増加: -50%: 0p> # TPを 50% 減らします
|
||
<対象効果: 付加: Buff[0]: 5ターン: 30%> # 30% で 最大HP を 5ターン 強化
|
||
<対象効果: 付加: Debuff[0]: 5ターン: 100%> # 100% で 最大HP を 5ターン 弱体
|
||
<対象効果: 解除: Buff[0]: 50%> # 50% で 最大HP の強化を解除
|
||
<対象効果: 解除: Debuff[0]: 100%> # 100% で 最大HP の弱体を解除
|
||
<対象効果: 成長: Param[0]: -100p: 50%> # 50% で 最大HP を -100p 退化させる
|
||
<対象効果: スキル習得: Skill[51]: 25%> # 25% で スキルID:51 のスキルを習得
|
||
|
||
|
||
・新規の使用効果の記述例:
|
||
|
||
<対象効果: TP回復: 0%: 20p> # TPを 20p 回復します
|
||
<対象効果: スキル忘却: Skill[51]: 100%> # 100% で スキルID:51 のスキルを忘却
|
||
<対象効果: ターン数変更: State[6]: +2> # ステート6 のターン数を 2加算 する
|
||
<対象効果: ターン数変更: State[6]: -1> # ステート6 のターン数を 1減算 する
|
||
<対象効果: ターン数変更: State[6]: =5> # ステート6 のターン数を 5 にする
|
||
<対象効果: ターン数変更: Buff[1]: +3> # 最大MP強化 のターン数を 3 加算 する
|
||
<対象効果: ターン数変更: Buff[1]: -2> # 最大MP強化 のターン数を 2 減算 する
|
||
<対象効果: ターン数変更: Buff[1]: =3> # 最大MP強化 のターン数を 3 にする
|
||
<対象効果: ターン数変更: Debuff[2]: +1> # 攻撃力弱体 のターン数を 1 加算 する
|
||
<対象効果: ターン数変更: Debuff[2]: -4> # 攻撃力弱体 のターン数を 4 減算 する
|
||
<対象効果: ターン数変更: Debuff[2]: =1> # 攻撃力弱体 のターン数を 1 にする
|
||
|
||
|
||
・使用者に使用効果を与える設定:
|
||
上記の "対象効果" を "使用者効果" と書き換えることで適用可能。
|
||
|
||
・味方全体(使用者含む)に使用効果を与える設定:
|
||
上記の "対象効果" を "味方全体効果" と書き換えることで適用可能。
|
||
|
||
・味方全体(使用者以外)に使用効果を与える設定:
|
||
上記の "対象効果" を "味方効果" と書き換えることで適用可能。
|
||
|
||
・戦闘不能の味方全体に使用効果を与える設定:
|
||
上記の "対象効果" を "味方(戦闘不能)効果" と書き換えることで適用可能。
|
||
|
||
・敵全体に使用効果を与える設定:
|
||
上記の "対象効果" を "敵全体効果" と書き換えることで適用可能。
|
||
|
||
・敵味方全体(使用者含む)に使用効果を与える設定:
|
||
上記の "対象効果" を "全体効果" と書き換えることで適用可能。
|
||
|
||
・敵味方全体(使用者以外)に使用効果を与える設定:
|
||
上記の "対象効果" を "使用者以外効果" と書き換えることで適用可能。
|
||
|
||
#------------------------------------------------------------------------------
|
||
|
||
[再定義箇所]
|
||
・ExEffects の StrRexGainTP, StrRexAddBuff, StrRexAddDebuff, StrRexRemoveBuff,
|
||
StrRexRemoveDebuff, StrRexGrow, StrRexLearnSkill,
|
||
struct_gain, struct_params, struct_remove_params, struct_skill
|
||
#------------------------------------------------------------------------------
|
||
[○ : 新規定義, ◎ : エイリアス定義, ● : 再定義]
|
||
#------------------------------------------------------------------------------
|
||
=end
|
||
$YkNr_Scripts ||= {}
|
||
$YkNr_Scripts[:PliableEffects] = true
|
||
#※このスクリプトを使用しない場合は、↑を false にすること
|
||
|
||
if $YkNr_Scripts[:PliableEffects] && $YkNr_Scripts[:ExEffects]
|
||
#==============================================================================
|
||
# ■ PliableEffects
|
||
#------------------------------------------------------------------------------
|
||
# スキルやアイテムの使用効果の拡張を設定するモジュールです。
|
||
#==============================================================================
|
||
module YakiNori::BaseExModules::PliableEffects
|
||
#==============================================================================
|
||
# ■ 定数モジュール
|
||
#==============================================================================
|
||
module Const
|
||
#==============================================================================
|
||
# ▼ カスタマイズ
|
||
#==============================================================================
|
||
# メニューのアイテム画面からアイテムを使用した際に
|
||
# アイテム使用者にも 使用者効果 を適用できるようにする。
|
||
# また、この機能が false の場合、アイテム画面からアイテムを使用した場合は
|
||
# "使用者以外" を含んだ効果範囲は全て "味方全体" として処理します。
|
||
EnabledApplyEffectForUser = false
|
||
|
||
#==============================================================================
|
||
# ▲ カスタマイズここまで
|
||
#==============================================================================
|
||
end
|
||
YakiNori.freeze_all_constants(self) # 定数をフリーズ
|
||
end
|
||
|
||
#==============================================================================
|
||
# ■ ExEffects
|
||
#==============================================================================
|
||
class << ExEffects
|
||
#--------------------------------------------------------------------------
|
||
# ● 定数(使用効果の正規表現の文字列)
|
||
#--------------------------------------------------------------------------
|
||
StrRexGainTP = "<pattern: TP増加: (-?\\d+)%: (-?\\d+)p>"
|
||
StrRexAddBuff = "<pattern: 付加: Buff\\[(\\d+)\\]: (\\d+)ターン: (\\d+)%>"
|
||
StrRexAddDebuff = "<pattern: 付加: Debuff\\[(\\d+)\\]: (\\d+)ターン: (\\d+)%>"
|
||
StrRexRemoveBuff = "<pattern: 解除: Buff\\[(\\d+)\\]: (\\d+)%>"
|
||
StrRexRemoveDebuff = "<pattern: 解除: Debuff\\[(\\d+)\\]: (\\d+)%>"
|
||
StrRexGrow = "<pattern: 成長: Param\\[(\\d+)\\]: (-?\\d+)p: (\\d+)%>"
|
||
StrRexLearnSkill = "<pattern: スキル習得: Skill\\[(\\d+)\\]: (\\d+)%>"
|
||
#--------------------------------------------------------------------------
|
||
# ○ 定数(使用効果の正規表現の文字列)
|
||
#--------------------------------------------------------------------------
|
||
StrRexRecoverTP = "<pattern: TP回復: (-?\\d+)%: (-?\\d+)p>"
|
||
StrRexForgetSkill = "<pattern: スキル忘却: Skill\\[(\\d+)\\]: (\\d+)%>"
|
||
StrRexTurnsState = "<pattern: ターン数変更: State\\[(\\d+)\\]: (\\+|-|=)(\\d+)>"
|
||
StrRexTurnsBuff = "<pattern: ターン数変更: Buff\\[(\\d+)\\]: (\\+|-|=)(\\d+)>"
|
||
StrRexTurnsDebuff = "<pattern: ターン数変更: Debuff\\[(\\d+)\\]: (\\+|-|=)(\\d+)>"
|
||
#--------------------------------------------------------------------------
|
||
# ◎ 特徴コードリスト
|
||
#--------------------------------------------------------------------------
|
||
alias yknr_PliableEffectsExEffects_code :code
|
||
def code
|
||
b = Game_Battler
|
||
_code = yknr_PliableEffectsExEffects_code
|
||
_code[:RECOVER_TP ] = b::EFFECT_RECOVER_TP # TP 回復
|
||
_code[:FORGET_SKILL] = b::EFFECT_FORGET_SKILL # スキルの忘却
|
||
_code[:TURNS_STATE ] = b::EFFECT_SET_TURNS_STATE # ステートのターン数変動
|
||
_code[:TURNS_BUFF ] = b::EFFECT_SET_TURNS_BUFF # 能力強化のターン数変動
|
||
_code[:TURNS_DEBUFF] = b::EFFECT_SET_TURNS_DEBUFF # 能力弱体のターン数変動
|
||
_code
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ◎ 拡張使用効果リストテーブル
|
||
#--------------------------------------------------------------------------
|
||
alias yknr_PliableEffectsExEffects_table :table
|
||
def table(code, data_id, pattern)
|
||
[
|
||
struct_recover(pattern, StrRexRecoverTP, code[:RECOVER_TP]),
|
||
struct_skill(pattern, StrRexForgetSkill, code[:EFFECT_FORGET_SKILL]),
|
||
struct_turns(pattern, StrRexTurnsState, code[:TURNS_STATE]),
|
||
struct_turns(pattern, StrRexTurnsBuff, code[:TURNS_BUFF]),
|
||
struct_turns(pattern, StrRexTurnsDebuff, code[:TURNS_DEBUFF]),
|
||
] + yknr_PliableEffectsExEffects_table(code, data_id, pattern)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● TP増加の要素を構成
|
||
#--------------------------------------------------------------------------
|
||
def struct_gain(pattern, str_rex, code)
|
||
struct(pattern, str_rex, code, 0, "a[2].to_i", "a[1].to_i * 0.01")
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 能力値の要素を構成
|
||
#--------------------------------------------------------------------------
|
||
def struct_params(pattern, str_rex, code)
|
||
data_id = "a[1].to_i"
|
||
v1 = "a[2].to_i"
|
||
v2 = "a[3].nil? ? 0 : a[3].to_i * 0.01"
|
||
struct(pattern, str_rex, code, data_id, v1, v2)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 能力値解除の要素を構成
|
||
#--------------------------------------------------------------------------
|
||
def struct_remove_params(pattern, str_rex, code)
|
||
struct(pattern, str_rex, code, "a[1].to_i", "a[2].to_i * 0.01", 0)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● スキルの要素を構成
|
||
#--------------------------------------------------------------------------
|
||
def struct_skill(pattern, str_rex, code)
|
||
struct(pattern, str_rex, code, "a[1].to_i", "a[2].to_i * 0.01", 0)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ ターン数変更の要素を追加
|
||
#--------------------------------------------------------------------------
|
||
def struct_turns(pattern, str_rex, code)
|
||
data_id = "a[1].to_i"
|
||
v1 = "(a[2] == '=') ? 0 : (a[2] == '+') ? 1 : -1"
|
||
v2 = "a[3].to_i"
|
||
struct(pattern, str_rex, code, data_id, v1, v2)
|
||
end
|
||
end
|
||
|
||
#==============================================================================
|
||
# ■ Game_Battler
|
||
#==============================================================================
|
||
class Game_Battler
|
||
#--------------------------------------------------------------------------
|
||
# ○ 定数(使用効果)
|
||
#--------------------------------------------------------------------------
|
||
EFFECT_RECOVER_TP = 110 # TP 回復
|
||
EFFECT_FORGET_SKILL = 111 # スキルの忘却
|
||
EFFECT_SET_TURNS_STATE = 112 # ステートのターン数変動
|
||
EFFECT_SET_TURNS_BUFF = 113 # 能力強化のターン数変動
|
||
EFFECT_SET_TURNS_DEBUFF = 114 # 能力弱体のターン数変動
|
||
#--------------------------------------------------------------------------
|
||
# ◎ スキル/アイテムに有効な使用効果が一つでもあるかを判定
|
||
#--------------------------------------------------------------------------
|
||
alias yknr_PliableEffectsGame_Battler_i_h_a_v_e? :item_has_any_valid_effects?
|
||
def item_has_any_valid_effects?(user, item)
|
||
return true if yknr_PliableEffectsGame_Battler_i_h_a_v_e?(user, item)
|
||
return true if any_valid_effects_for_user?(user, item)
|
||
return true if any_valid_effects_for_friends?(user, item, false)
|
||
return true if any_valid_effects_for_friends?(user, item, true)
|
||
return false if !$game_party.in_battle
|
||
return true if any_valid_effects_for_opponents?(user, item)
|
||
return false
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ スキル/アイテムに使用者への有効な使用効果が一つでもあるかを判定
|
||
#--------------------------------------------------------------------------
|
||
def any_valid_effects_for_user?(user, item)
|
||
effects = item.alive_user_effects
|
||
effects += item.alive_friends_effects
|
||
effects += item.all_alive_unit_effects
|
||
return effects.any? {|effect| user.item_effect_test(user, item, effect) }
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ スキル/アイテムに味方への有効な使用効果が一つでもあるかを判定
|
||
#--------------------------------------------------------------------------
|
||
def any_valid_effects_for_friends?(user, item, for_dead)
|
||
members = user.friends_unit.alive_members if !for_dead
|
||
members = user.friends_unit.dead_members if for_dead
|
||
members.any? do |friend|
|
||
if friend != user
|
||
effects = item.alive_friends_effects + item.all_alive_unit_effects
|
||
effects += item.alive_friends_except_user_effects
|
||
effects += item.all_alive_unit_except_user_effects
|
||
effects = item.dead_friends_effects if for_dead
|
||
effects.any? {|effect| friend.item_effect_test(user, item, effect) }
|
||
else
|
||
false
|
||
end
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ スキル/アイテムに敵全体への有効な使用効果が一つでもあるかを判定
|
||
#--------------------------------------------------------------------------
|
||
def any_valid_effects_for_opponents?(user, item)
|
||
members = user.opponents_unit.alive_members
|
||
effects = item.alive_friends_effects + item.all_alive_unit_effects
|
||
effects += item.all_alive_unit_except_user_effects
|
||
members.any? do |opponent|
|
||
effects.any? {|effect| opponent.item_effect_test(user, item, effect) }
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ スキル/アイテムの拡張使用効果の適用
|
||
#--------------------------------------------------------------------------
|
||
def ex_effects_apply(user, item, effects, for_dead)
|
||
@result.clear
|
||
effects.each do |effect|
|
||
if ex_effect_test(user, item, effect, for_dead)
|
||
item_effect_apply(user, item, effect)
|
||
end
|
||
end
|
||
@result.used = @result.success
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ 拡張使用効果の適用テスト
|
||
#--------------------------------------------------------------------------
|
||
def ex_effect_test(user, item, effect, for_dead)
|
||
return false if for_dead != dead?
|
||
return true if $game_party.in_battle
|
||
return true if item_effect_test(user, item, effect)
|
||
return false
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ◎ 使用効果のテスト
|
||
#--------------------------------------------------------------------------
|
||
alias yknr_PliableEffectsGame_Battler_item_effect_test :item_effect_test
|
||
def item_effect_test(user, item, effect)
|
||
case effect.code
|
||
when EFFECT_RECOVER_TP
|
||
tp < max_tp || effect.value1 < 0 || effect.value2 < 0
|
||
when EFFECT_FORGET_SKILL
|
||
actor? && skills.include?($data_skills[effect.data_id])
|
||
when EFFECT_SET_TURNS_STATE
|
||
state?(effect.data_id) && @state_turns[effect.data_id] > 0
|
||
when EFFECT_SET_TURNS_BUFF
|
||
buff?(effect.data_id) && @buff_turns[effect.data_id] > 0
|
||
when EFFECT_SET_TURNS_DEBUFF
|
||
debuff?(effect.data_id) && @buff_turns[effect.data_id] > 0
|
||
else
|
||
yknr_PliableEffectsGame_Battler_item_effect_test(user, item, effect)
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ◎ 使用効果の適用
|
||
#--------------------------------------------------------------------------
|
||
alias yknr_PliableEffectsGame_Battler_item_effect_apply :item_effect_apply
|
||
def item_effect_apply(user, item, effect)
|
||
ex_method_table = {
|
||
EFFECT_RECOVER_TP => :item_effect_recover_tp,
|
||
EFFECT_FORGET_SKILL => :item_effect_forget_skill,
|
||
EFFECT_SET_TURNS_STATE => :item_effect_set_turns_state,
|
||
EFFECT_SET_TURNS_BUFF => :item_effect_set_turns_buff,
|
||
EFFECT_SET_TURNS_DEBUFF => :item_effect_set_turns_debuff,
|
||
}
|
||
method_name = ex_method_table[effect.code]
|
||
if method_name
|
||
send(method_name, user, item, effect)
|
||
else
|
||
yknr_PliableEffectsGame_Battler_item_effect_apply(user, item, effect)
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ◎ 使用効果[TP 増加]
|
||
#--------------------------------------------------------------------------
|
||
alias yknr_PliableEffectsGame_Battler_item_effect_gain_tp :item_effect_gain_tp
|
||
def item_effect_gain_tp(user, item, effect)
|
||
yknr_PliableEffectsGame_Battler_item_effect_gain_tp(user, item, effect)
|
||
value = (max_tp * effect.value2).to_i
|
||
@result.tp_damage -= value
|
||
@result.success = true if value != 0
|
||
self.tp += value
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ◎ 使用効果[能力強化]
|
||
#--------------------------------------------------------------------------
|
||
alias yknr_PliableEffectsGame_Battler_item_effect_add_buff :item_effect_add_buff
|
||
def item_effect_add_buff(user, item, effect)
|
||
chance = effect.value2
|
||
if chance.zero? || rand < chance
|
||
yknr_PliableEffectsGame_Battler_item_effect_add_buff(user, item, effect)
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ◎ 使用効果[能力弱体]
|
||
#--------------------------------------------------------------------------
|
||
alias yknr_PliableEffectsGame_Battler_item_effect_add_debuff :item_effect_add_debuff
|
||
def item_effect_add_debuff(user, item, effect)
|
||
chance = effect.value2
|
||
if chance.zero? || rand < chance
|
||
yknr_PliableEffectsGame_Battler_item_effect_add_debuff(user, item, effect)
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ◎ 使用効果[能力強化の解除]
|
||
#--------------------------------------------------------------------------
|
||
alias yknr_PliableEffectsGame_Battler_item_effect_remove_buff :item_effect_remove_buff
|
||
def item_effect_remove_buff(user, item, effect)
|
||
chance = effect.value1
|
||
if chance.zero? || rand < chance
|
||
yknr_PliableEffectsGame_Battler_item_effect_remove_buff(user, item, effect)
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ◎ 使用効果[能力弱体の解除]
|
||
#--------------------------------------------------------------------------
|
||
alias yknr_PliableEffectsGame_Battler_item_effect_remove_debuff :item_effect_remove_debuff
|
||
def item_effect_remove_debuff(user, item, effect)
|
||
chance = effect.value1
|
||
if chance.zero? || rand < chance
|
||
yknr_PliableEffectsGame_Battler_item_effect_remove_debuff(user, item, effect)
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ◎ 使用効果[スキル習得]
|
||
#--------------------------------------------------------------------------
|
||
alias yknr_PliableEffectsGame_Battler_item_effect_learn_skill :item_effect_learn_skill
|
||
def item_effect_learn_skill(user, item, effect)
|
||
chance = effect.value1
|
||
if chance.zero? || rand < chance
|
||
yknr_PliableEffectsGame_Battler_item_effect_learn_skill(user, item, effect)
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ 使用効果[TP 回復]
|
||
#--------------------------------------------------------------------------
|
||
def item_effect_recover_tp(user, item, effect)
|
||
value = (max_tp * effect.value1 + effect.value2) * rec
|
||
value *= user.pha if item.is_a?(RPG::Item)
|
||
value = value.to_i
|
||
@result.tp_damage -= value
|
||
@result.success = true if value != 0
|
||
self.tp += value
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ 使用効果[スキルの忘却]
|
||
#--------------------------------------------------------------------------
|
||
def item_effect_forget_skill(user, item, effect)
|
||
chance = effect.value1
|
||
if rand < chance
|
||
forget_skill(effect.data_id) if actor?
|
||
@result.success = true
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ 使用効果[ステートのターン数変動]
|
||
#--------------------------------------------------------------------------
|
||
def item_effect_set_turns_state(user, item, effect)
|
||
state_id = effect.data_id
|
||
type = effect.value1
|
||
turns = effect.value2
|
||
if state?(state_id) && @state_turns[state_id] > 0
|
||
lt = @state_turns[state_id]
|
||
@state_turns[state_id] = type.zero? ? turns : [lt + turns * type, 0].max
|
||
remove_state(state_id) if @state_turns[state_id].zero?
|
||
@result.success = true
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ 使用効果[能力強化のターン数変動]
|
||
#--------------------------------------------------------------------------
|
||
def item_effect_set_turns_buff(user, item, effect)
|
||
param_id = effect.data_id
|
||
type = effect.value1
|
||
turns = effect.value2
|
||
if buff?(param_id) && @buff_turns[param_id] > 0
|
||
lt = @buff_turns[param_id]
|
||
@buff_turns[param_id] = type.zero? ? turns : [lt + turns * type, 0].max
|
||
remove_buff(param_id) if @buff_turns[param_id].zero?
|
||
@result.success = true
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ 使用効果[能力弱体のターン数変動]
|
||
#--------------------------------------------------------------------------
|
||
def item_effect_set_turns_debuff(user, item, effect)
|
||
param_id = effect.data_id
|
||
type = effect.value1
|
||
turns = effect.value2
|
||
if debuff?(param_id) && @buff_turns[param_id] > 0
|
||
lt = @buff_turns[param_id]
|
||
@buff_turns[param_id] = type.zero? ? turns : [lt + turns * type, 0].max
|
||
remove_buff(param_id) if @buff_turns[param_id] <= 0
|
||
@result.success = true
|
||
end
|
||
end
|
||
end
|
||
|
||
#==============================================================================
|
||
# ■ Scene_ItemBase
|
||
#==============================================================================
|
||
class Scene_ItemBase < Scene_MenuBase
|
||
#--------------------------------------------------------------------------
|
||
# ○ インクルード
|
||
#--------------------------------------------------------------------------
|
||
include YakiNori::BaseExModules::PliableEffects::Const
|
||
#--------------------------------------------------------------------------
|
||
# ◎ アイテムをアクターに対して使用
|
||
#--------------------------------------------------------------------------
|
||
alias yknr_PliableEffectsScene_ItemBase_use_item_to_actors :use_item_to_actors
|
||
def use_item_to_actors
|
||
yknr_PliableEffectsScene_ItemBase_use_item_to_actors
|
||
invoke_ex_effects
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ アイテムの拡張使用効果の発動
|
||
#--------------------------------------------------------------------------
|
||
def invoke_ex_effects
|
||
if enabled_apply_for_user? # 使用者
|
||
effects = item.alive_user_effects
|
||
effects += item.alive_friends_effects
|
||
effects += item.all_alive_unit_effects
|
||
item.repeats.times { user.ex_effects_apply(user, item, effects, false) }
|
||
end
|
||
user.friends_unit.alive_members.each do |actor| # 味方
|
||
if enabled_apply_for_user? ? actor != user : true
|
||
effects = item.alive_friends_effects + item.all_alive_unit_effects
|
||
effects += item.alive_friends_except_user_effects
|
||
effects += item.all_alive_unit_except_user_effects
|
||
item.repeats.times { actor.ex_effects_apply(user, item, effects, false) }
|
||
end
|
||
end
|
||
user.friends_unit.dead_members.each do |actor| # 味方(戦闘不能)
|
||
effects = item.dead_friends_effects
|
||
item.repeats.times { actor.ex_effects_apply(user, item, effects, true) }
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ アイテムの使用者効果の適用が有効か判定
|
||
#--------------------------------------------------------------------------
|
||
def enabled_apply_for_user?
|
||
self.is_a?(Scene_Item) ? EnabledApplyEffectForUser : true
|
||
end
|
||
end
|
||
|
||
#==============================================================================
|
||
# ■ Game_ActionResult
|
||
#==============================================================================
|
||
class Game_ActionResult
|
||
#--------------------------------------------------------------------------
|
||
# ○ HP ダメージの文章を取得(拡張使用効果)
|
||
#--------------------------------------------------------------------------
|
||
def hp_damage_text_from_effect(user)
|
||
use_actor_fmt = user.actor? ? @battler.actor? : true
|
||
if @hp_drain > 0
|
||
fmt = use_actor_fmt ? Vocab::ActorDrain : Vocab::EnemyDrain
|
||
sprintf(fmt, @battler.name, Vocab::hp, @hp_drain)
|
||
elsif @hp_damage > 0
|
||
fmt = use_actor_fmt ? Vocab::ActorDamage : Vocab::EnemyDamage
|
||
sprintf(fmt, @battler.name, @hp_damage)
|
||
elsif @hp_damage < 0
|
||
fmt = use_actor_fmt ? Vocab::ActorRecovery : Vocab::EnemyRecovery
|
||
sprintf(fmt, @battler.name, Vocab::hp, -hp_damage)
|
||
else
|
||
fmt = use_actor_fmt ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
|
||
sprintf(fmt, @battler.name)
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ MP ダメージの文章を取得(拡張使用効果)
|
||
#--------------------------------------------------------------------------
|
||
def mp_damage_text_from_effect(user)
|
||
use_actor_fmt = user.actor? ? @battler.actor? : true
|
||
if @mp_drain > 0
|
||
fmt = use_actor_fmt ? Vocab::ActorDrain : Vocab::EnemyDrain
|
||
sprintf(fmt, @battler.name, Vocab::mp, @mp_drain)
|
||
elsif @mp_damage > 0
|
||
fmt = use_actor_fmt ? Vocab::ActorLoss : Vocab::EnemyLoss
|
||
sprintf(fmt, @battler.name, Vocab::mp, @mp_damage)
|
||
elsif @mp_damage < 0
|
||
fmt = use_actor_fmt ? Vocab::ActorRecovery : Vocab::EnemyRecovery
|
||
sprintf(fmt, @battler.name, Vocab::mp, -@mp_damage)
|
||
else
|
||
""
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ TP ダメージの文章を取得(拡張使用効果)
|
||
#--------------------------------------------------------------------------
|
||
def tp_damage_text_from_effect(user)
|
||
use_actor_fmt = user.actor? ? @battler.actor? : true
|
||
if @tp_damage > 0
|
||
fmt = use_actor_fmt ? Vocab::ActorLoss : Vocab::EnemyLoss
|
||
sprintf(fmt, @battler.name, Vocab::tp, @tp_damage)
|
||
elsif @tp_damage < 0
|
||
fmt = use_actor_fmt ? Vocab::ActorGain : Vocab::EnemyGain
|
||
sprintf(fmt, @battler.name, Vocab::tp, -@tp_damage)
|
||
else
|
||
""
|
||
end
|
||
end
|
||
end
|
||
|
||
#==============================================================================
|
||
# ■ Window_BattleLog
|
||
#==============================================================================
|
||
class Window_BattleLog < Window_Selectable
|
||
#--------------------------------------------------------------------------
|
||
# ○ 行動結果の表示(拡張使用効果)
|
||
#--------------------------------------------------------------------------
|
||
def display_apply_effect_results(target, user, item)
|
||
if target.result.used
|
||
last_line_number = line_number
|
||
display_hp_damage_from_effect(target, user, item)
|
||
display_mp_damage_from_effect(target, user, item)
|
||
display_tp_damage_from_effect(target, user, item)
|
||
display_affected_status_from_effect(target, user, item)
|
||
wait if line_number > last_line_number
|
||
back_to(last_line_number)
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ HP ダメージ表示(拡張使用効果)
|
||
#--------------------------------------------------------------------------
|
||
def display_hp_damage_from_effect(target, user, item)
|
||
return if target.result.hp_damage.zero?
|
||
if target.result.hp_damage > 0 && target.result.hp_drain.zero?
|
||
target.perform_damage_effect
|
||
end
|
||
Sound.play_recovery if target.result.hp_damage < 0
|
||
add_text(target.result.hp_damage_text_from_effect(user))
|
||
wait
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ MP ダメージ表示(拡張使用効果)
|
||
#--------------------------------------------------------------------------
|
||
def display_mp_damage_from_effect(target, user, item)
|
||
return if target.dead? || target.result.mp_damage.zero?
|
||
Sound.play_recovery if target.result.mp_damage < 0
|
||
add_text(target.result.mp_damage_text_from_effect(user))
|
||
wait
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ TP ダメージ表示(拡張使用効果)
|
||
#--------------------------------------------------------------------------
|
||
def display_tp_damage_from_effect(target, user, item)
|
||
return if target.dead? || target.result.tp_damage.zero?
|
||
Sound.play_recovery if target.result.tp_damage < 0
|
||
add_text(target.result.tp_damage_text_from_effect(user))
|
||
wait
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ 影響を受けたステータスの表示(拡張使用効果)
|
||
#--------------------------------------------------------------------------
|
||
def display_affected_status_from_effect(target, user, item)
|
||
if target.result.status_affected?
|
||
add_text("") if line_number < max_line_number
|
||
display_added_states_from_effect(target, user)
|
||
display_removed_states(target)
|
||
display_changed_buffs(target)
|
||
back_one if last_text.empty?
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ ステート付加の表示(拡張使用効果)
|
||
#--------------------------------------------------------------------------
|
||
def display_added_states_from_effect(target, user)
|
||
target.result.added_state_objects.each do |state|
|
||
use_msg1 = user.actor? ? target.actor? : true
|
||
state_msg = use_msg1 ? state.message1 : state.message2
|
||
target.perform_collapse_effect if state.id == target.death_state_id
|
||
next if state_msg.empty?
|
||
replace_text(target.name + state_msg)
|
||
wait
|
||
wait_for_effect
|
||
end
|
||
end
|
||
end
|
||
|
||
#==============================================================================
|
||
# ■ Scene_Battle
|
||
#==============================================================================
|
||
class Scene_Battle < Scene_Base
|
||
#--------------------------------------------------------------------------
|
||
# ◎ スキル/アイテムの使用
|
||
#--------------------------------------------------------------------------
|
||
alias yknr_PliableEffectsScene_Battle_use_item :use_item
|
||
def use_item
|
||
item = @subject.current_action.item
|
||
yknr_PliableEffectsScene_Battle_use_item
|
||
invoke_ex_effects(item) if @subject.alive?
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ スキル/アイテムの拡張使用効果の発動
|
||
#--------------------------------------------------------------------------
|
||
def invoke_ex_effects(item)
|
||
apply_ex_effects_for_user(item) # 使用者
|
||
apply_ex_effects_for_friends(item) # 味方
|
||
apply_ex_effects_for_opponents(item) # 敵全体
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ スキル/アイテムの拡張使用効果を使用者へ適用
|
||
#--------------------------------------------------------------------------
|
||
def apply_ex_effects_for_user(item)
|
||
effects = item.alive_user_effects
|
||
effects += item.alive_friends_effects
|
||
effects += item.all_alive_unit_effects
|
||
item.repeats.times { apply_ex_effects(@subject, item, effects, false) }
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ スキル/アイテムの拡張使用効果を味方へ適用
|
||
#--------------------------------------------------------------------------
|
||
def apply_ex_effects_for_friends(item)
|
||
@subject.friends_unit.alive_members.each do |friend|
|
||
if friend != @subject
|
||
effects = item.alive_friends_effects + item.all_alive_unit_effects
|
||
effects += item.alive_friends_except_user_effects
|
||
effects += item.all_alive_unit_except_user_effects
|
||
item.repeats.times { apply_ex_effects(friend, item, effects, false) }
|
||
end
|
||
end
|
||
@subject.friends_unit.dead_members.each do |friend|
|
||
effects = item.dead_friends_effects
|
||
item.repeats.times { apply_ex_effects(friend, item, effects, true) }
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ スキル/アイテムの拡張使用効果を敵全体へ適用
|
||
#--------------------------------------------------------------------------
|
||
def apply_ex_effects_for_opponents(item)
|
||
@subject.opponents_unit.alive_members.each do |opponent|
|
||
effects = item.alive_opponents_effects + item.all_alive_unit_effects
|
||
effects += item.all_alive_unit_except_user_effects if opponent != @subject
|
||
item.repeats.times { apply_ex_effects(opponent, item, effects, false) }
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ スキル/アイテムの拡張使用効果の適用
|
||
#--------------------------------------------------------------------------
|
||
def apply_ex_effects(target, item, effects, for_dead)
|
||
target.ex_effects_apply(@subject, item, effects, for_dead)
|
||
refresh_status
|
||
@log_window.display_apply_effect_results(target, @subject, item)
|
||
end
|
||
end
|
||
|
||
#==============================================================================
|
||
# ■ RPG::UsableItem
|
||
#==============================================================================
|
||
class RPG::UsableItem
|
||
#--------------------------------------------------------------------------
|
||
# ○ 使用者に付加する使用効果
|
||
#--------------------------------------------------------------------------
|
||
def alive_user_effects
|
||
@alive_user_effects ||= ExEffects.get(self, "使用者効果")
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ 味方全体(使用者含む)に付加する使用効果
|
||
#--------------------------------------------------------------------------
|
||
def alive_friends_effects
|
||
@alive_friends_effects ||= ExEffects.get(self, "味方全体効果")
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ 味方全体(使用者以外)に付加する使用効果
|
||
#--------------------------------------------------------------------------
|
||
def alive_friends_except_user_effects
|
||
@alive_friends_except_user_effects ||= ExEffects.get(self, "味方効果")
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ 戦闘不能の味方全体に付加する使用効果
|
||
#--------------------------------------------------------------------------
|
||
def dead_friends_effects
|
||
@dead_friends_effects ||= ExEffects.get(self, "味方(戦闘不能)効果")
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ 敵全体に付加する使用効果
|
||
#--------------------------------------------------------------------------
|
||
def alive_opponents_effects
|
||
@alive_opponents_effects ||= ExEffects.get(self, "敵全体効果")
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ 敵味方全体(使用者含む)に付加する使用効果
|
||
#--------------------------------------------------------------------------
|
||
def all_alive_unit_effects
|
||
@all_alive_unit_effects ||= ExEffects.get(self, "全体効果")
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ 敵味方全体(使用者以外)に付加する使用効果
|
||
#--------------------------------------------------------------------------
|
||
def all_alive_unit_except_user_effects
|
||
@all_alive_unit_except_user_effects ||= ExEffects.get(self, "使用者以外効果")
|
||
end
|
||
end
|
||
|
||
end # $YkNr_Scripts
|
||
|