# PowerShield_ver.0.5
#「物理反射&伤害反射&反射伤害倍率」 (作成日……2011/12/ 7)
#______________________________________________________________________________
module PowerShield
MESSAGE="%s反弹了物理攻击!" # %s..反弹时显示的文字
SE ="Audio/SE/Reflection" # 物理攻击or伤害反射时播放的SE
=begin
______________________________________________________________________________
备注栏写法:
物理反射率 <prf:+n%>
物理伤害反射率 <pdrf:+n%>
魔法伤害反射率 <mdrf:+n%>
物理伤害反射倍率 <dr_prf:+n%>
魔法伤害反射倍率 <dr_mrf:+n%>
物理伤害反射伤害倍率<dr_pdrf:+n%>
魔法伤害反射伤害倍率<dr_mdrf:+n%>
0.3 2011/12/11 デフォの反射バグに対応·修正
0.4 2011/12/12 删除要求(RPG::UsableItem)类方法的定义
备注栏判断法(例:<prf:+n%>)增加
0.5 2011/12/25 使用効果「逃げる」適用時に落ちる現象に対応
______________________________________________________________________________
=end
module Methods
def prf
if @__prf == nil
@__prf = 0.0
if /<(?:prf|物理反射率):\+(\d+)\%>/i =~ note
@__prf = $1.to_i / 100.0
end
end
return @__prf
end
#--------------------------------------------------------------------------
def pdrf
if @__pdrf == nil
@__pdrf = 0.0
if /<(?:pdrf|物理伤害反射率):\+(\d+)\%>/i =~ note
@__pdrf = $1.to_i / 100.0
end
end
return @__pdrf
end
#--------------------------------------------------------------------------
def mdrf
if @__mdrf == nil
@__mdrf = 0.0
if /<(?:mdrf|魔法伤害反射率):\+(\d+)\%>/i =~ note
@__mdrf = $1.to_i / 100.0
end
end
return @__mdrf
end
#--------------------------------------------------------------------------
def dr_prf
if @__dr_prf == nil
@__dr_prf = 1.0
if /<(?:dr_prf|物理反射伤害倍率):(\d+)\%>/i =~ note
@__dr_prf = $1.to_i / 100.0
end
end
return @__dr_prf
end
#--------------------------------------------------------------------------
def dr_mrf
if @__dr_mrf == nil
@__dr_mrf = 1.0
if /<(?:dr_mrf|魔法反射伤害倍率):(\d+)\%>/i =~ note
@__dr_mrf = $1.to_i / 100.0
end
end
return @__dr_mrf
end
#--------------------------------------------------------------------------
def dr_pdrf
if @__dr_pdrf == nil
@__dr_pdrf = 1.0
if /<(?:dr_pdrf|物理伤害反射伤害倍率):(\d+)\%>/i =~ note
@__dr_pdrf = $1.to_i / 100.0
end
end
return @__dr_pdrf
end
#--------------------------------------------------------------------------
def dr_mdrf
if @__dr_mdrf == nil
@__dr_mdrf = 1.0
if /<(?:dr_mdrf|魔法伤害反射伤害倍率):(\d+)\%>/i =~ note
@__dr_mdrf = $1.to_i / 100.0
end
end
return @__dr_mdrf
end
end# module PowerShield::Methods
end# module PowerShield
# feature_objects
class RPG::Actor ; include PowerShield::Methods; end
class RPG::Class ; include PowerShield::Methods; end
class RPG::EquipItem; include PowerShield::Methods; end
class RPG::Enemy ; include PowerShield::Methods; end
class RPG::State ; include PowerShield::Methods; end
#______________________________________________________________________________
class Game_Action
attr_accessor :current_target # 現在の攻撃(行動)対象
attr_accessor :be_reflected # 被反射フラグ
alias power_shield__clear clear
def clear
power_shield__clear
@current_target = nil
@be_reflected = false
end
end
class Game_BattlerBase
def prf
return feature_objects.inject(0.0){|r, obj| r += obj.prf }
end
#--------------------------------------------------------------------------
def pdrf
return feature_objects.inject(0.0){|r, obj| r += obj.pdrf }
end
#--------------------------------------------------------------------------
def mdrf
return feature_objects.inject(0.0){|r, obj| r += obj.mdrf }
end
#--------------------------------------------------------------------------
def dr_prf
return feature_objects.inject(1.0){|r, obj| r *= obj.dr_prf }
end
#--------------------------------------------------------------------------
def dr_mrf
return feature_objects.inject(1.0){|r, obj| r *= obj.dr_mrf }
end
#--------------------------------------------------------------------------
def dr_pdrf
return feature_objects.inject(1.0){|r, obj| r *= obj.dr_pdrf }
end
#--------------------------------------------------------------------------
def dr_mdrf
return feature_objects.inject(1.0){|r, obj| r *= obj.dr_mdrf }
end
end
class Game_Battler < Game_BattlerBase
def item_prf(user, item)
return prf if item.physical? # 物理攻撃なら物理反射率を返す
return 0
end
#--------------------------------------------------------------------------
def item_drf(user, item)
return pdrf if item.physical? # 物理攻撃なら物理D反射率を返す
return mdrf if item.magical? # 魔法攻撃なら魔法D反射率を返す
return 0
end
#--------------------------------------------------------------------------
def item_dr_prf(user, item)
return dr_prf if item.physical? # 物理攻撃なら物理反射D倍率を返す
return 1.0
end
#--------------------------------------------------------------------------
def item_dr_mrf(user, item)
return dr_mrf if item.magical? # 魔法攻撃なら魔法反射D倍率を返す
return 1.0
end
#--------------------------------------------------------------------------
def item_dr_pdrf(user, item)
return dr_pdrf if item.physical? # 物理攻撃なら物理D反射D倍率を返す
return 1.0
end
#--------------------------------------------------------------------------
def item_dr_mdrf(user, item)
return dr_mdrf if item.magical? # 魔法攻撃なら魔法D反射D倍率を返す
return 1.0
end
#--------------------------------------------------------------------------
alias power_shield__item_hit item_hit
def item_hit(user, item)
return 1.0 unless $game_party.in_battle
return 1.0 if user.current_action && user.current_action.be_reflected
return power_shield__item_hit(user, item)
end
#--------------------------------------------------------------------------
alias power_shield__item_eva item_eva
def item_eva(user, item)
return 0.0 unless $game_party.in_battle
return 0.0 if user.current_action && user.current_action.be_reflected
return power_shield__item_eva(user, item)
end
#--------------------------------------------------------------------------
# ● 使用効果[ステート付加]:通常 ※ 再定義
#--------------------------------------------------------------------------
def item_effect_add_state_normal(user, item, effect)
chance = effect.value1
if opposite?(user) or
user.current_action && user.current_action.be_reflected
chance *= state_rate(effect.data_id)
chance *= luk_effect_rate(user)
end
if rand < chance
add_state(effect.data_id)
@result.success = true
end
end
#--------------------------------------------------------------------------
alias power_shield___item_element_rate item_element_rate
def item_element_rate(user, item)
r = power_shield___item_element_rate(user, item)
return r * reflected_damage_rate(user, item)
end
#--------------------------------------------------------------------------
def reflected_damage_rate(user, item)
return 1.0 unless $game_party.in_battle
return 1.0 unless user.current_action && user.current_action.be_reflected
target = user.current_action.current_target
return target.item_dr_prf(user, item) * target.item_dr_mrf(user, item)
end
end
class Window_BattleLog < Window_Selectable
def display_attack_reflection(target, item)
Audio.se_play(PowerShield::SE)
add_text(sprintf(PowerShield::MESSAGE, target.name))
wait
back_one
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● スキル/アイテムの発動 ※ 再定義
#--------------------------------------------------------------------------
def invoke_item(target, item)
if @subject.current_action
@subject.current_action.current_target = target
end
if rand < target.item_cnt(@subject, item)
invoke_counter_attack(target, item)
elsif rand < target.item_mrf(@subject, item)
invoke_magic_reflection(target, item)
elsif rand < target.item_prf(@subject, item)
invoke_attack_reflection(target, item)
else
true_target = apply_substitute(target, item)
apply_item_effects(true_target, item)
if true_target.result.hit? && rand < true_target.item_drf(@subject, item)
invoke_damage_reflection(true_target, item)
end
end
@subject.last_target_index = target.index
end
#--------------------------------------------------------------------------
alias power_shield__invoke_magic_reflection invoke_magic_reflection
def invoke_magic_reflection(target, item)
@subject.current_action.be_reflected = true
power_shield__invoke_magic_reflection(target, item)
end
#--------------------------------------------------------------------------
def invoke_attack_reflection(target, item)
@subject.current_action.be_reflected = true
@log_window.display_attack_reflection(target, item)
apply_item_effects(@subject, item)
end
#--------------------------------------------------------------------------
def invoke_damage_reflection(target, item)
@log_window.display_attack_reflection(target, item)
@subject.result.clear
@subject.result.used = true
value = target.result.hp_damage if item.damage.to_hp?
value = target.result.mp_damage if item.damage.to_mp?
value *= target.item_dr_pdrf(@subject, item)
value *= target.item_dr_mdrf(@subject, item)
value = 0 if value < 0 # 吸収された場合を考慮
@subject.result.make_damage(value.to_i, item)
@subject.execute_damage(target)
refresh_status
@log_window.display_action_results(@subject, item)
end
end