236 lines
8.7 KiB
Ruby
236 lines
8.7 KiB
Ruby
module FAKEREAL
|
||
|
||
HIT_AND_EVA = true # trueで命中回避を独自判定
|
||
HIT_RATE_BASE = 0.5
|
||
EVA_RATE_BASE = 0.4
|
||
|
||
end
|
||
|
||
class RPG::Enemy < RPG::BaseItem
|
||
def hit_rate
|
||
@hit_rate ||= hit_rate_set
|
||
end
|
||
def hit_rate_set
|
||
self.note =~ /\<命中プラス:(\d*?\.?\d+?)\>/ ? $1.to_f : 0.1
|
||
end
|
||
def eva_rate
|
||
@eva_rate ||= eva_rate_set
|
||
end
|
||
def eva_rate_set
|
||
self.note =~ /\<回避プラス:(\d*?\.?\d+?)\>/ ? $1.to_f : 0.1
|
||
end
|
||
def cri_rate
|
||
@cri_rate ||= cri_rate_set
|
||
end
|
||
def cri_rate_set
|
||
self.note =~ /\<会心プラス:(\d*?\.?\d+?)\>/ ? $1.to_f : 0.005
|
||
end
|
||
end
|
||
|
||
|
||
#==============================================================================
|
||
# ■ Game_BattlerBase
|
||
#------------------------------------------------------------------------------
|
||
# バトラーを扱う基本のクラスです。主に能力値計算のメソッドを含んでいます。こ
|
||
# のクラスは Game_Battler クラスのスーパークラスとして使用されます。
|
||
#==============================================================================
|
||
|
||
class Game_BattlerBase
|
||
#--------------------------------------------------------------------------
|
||
# ● 命中率敏捷性反映 ※エイリアス
|
||
#--------------------------------------------------------------------------
|
||
alias ori_hit hit
|
||
def hit
|
||
ori_hit + hit_plus
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● クリティカル変更 ※エイリアス
|
||
#--------------------------------------------------------------------------
|
||
alias ori_cri cri
|
||
def cri
|
||
ori_cri + cri_plus
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 回避変更 ※エイリアス
|
||
#--------------------------------------------------------------------------
|
||
alias ori_eva eva
|
||
def eva
|
||
ori_eva + eva_plus
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def hit_plus
|
||
return hit_rate * (agi * FAKEREAL::HIT_RATE_BASE) * 0.01 if FAKEREAL::HIT_AND_EVA
|
||
0
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def eva_plus
|
||
return eva_rate * (agi * FAKEREAL::EVA_RATE_BASE) * 0.01 if FAKEREAL::HIT_AND_EVA
|
||
0
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def cri_plus
|
||
return cri_rate * 0.01 if FAKEREAL::HIT_AND_EVA
|
||
0
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def hit_rate
|
||
0
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def eva_rate
|
||
0
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def cri_rate
|
||
0
|
||
end
|
||
end
|
||
|
||
#==============================================================================
|
||
# ■ Game_Actor
|
||
#------------------------------------------------------------------------------
|
||
# アクターを扱うクラスです。このクラスは Game_Actors クラス($game_actors)
|
||
# の内部で使用され、Game_Party クラス($game_party)からも参照されます。
|
||
#==============================================================================
|
||
|
||
class Game_Actor < Game_Battler
|
||
#--------------------------------------------------------------------------
|
||
# ○ 会心回避率 ※オーバーライド
|
||
#--------------------------------------------------------------------------
|
||
def cev
|
||
super + (eva + cri)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def hit_rate
|
||
actor.note =~ /\<命中プラス:(\d*?\.?\d+?)\>/ ? $1.to_f : 0.1
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def eva_rate
|
||
actor.note =~ /\<回避プラス:(\d*?\.?\d+?)\>/ ? $1.to_f : 0.1
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def cri_rate
|
||
(@level + 1) * (actor.note =~ /\<会心プラス:(\d*?\.?\d+?)\>/ ? $1.to_f : 0.01)
|
||
end
|
||
end
|
||
|
||
#==============================================================================
|
||
# ■ Game_Enemy
|
||
#------------------------------------------------------------------------------
|
||
# 敵キャラを扱うクラスです。このクラスは Game_Troop クラス($game_troop)の
|
||
# 内部で使用されます。
|
||
#==============================================================================
|
||
|
||
class Game_Enemy < Game_Battler
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def hit_rate
|
||
enemy.hit_rate#note =~ /\<命中プラス:(\d*?\.?\d+?)\>/ ? $1.to_f : 0.1
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def eva_rate
|
||
enemy.eva_rate#note =~ /\<回避プラス:(\d*?\.?\d+?)\>/ ? $1.to_f : 0.1
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def cri_rate
|
||
agi * enemy.cri_rate
|
||
end
|
||
end
|
||
|
||
#==============================================================================
|
||
# ■ Game_Battler
|
||
#------------------------------------------------------------------------------
|
||
# スプライトや行動に関するメソッドを追加したバトラーのクラスです。このクラス
|
||
# は Game_Actor クラスと Game_Enemy クラスのスーパークラスとして使用されます。
|
||
#==============================================================================
|
||
|
||
class Game_Battler < Game_BattlerBase
|
||
#--------------------------------------------------------------------------
|
||
# ● スキル/アイテムの会心率計算
|
||
#--------------------------------------------------------------------------
|
||
def item_cri(user, item)
|
||
item.damage.critical ? (user.cri + item.cri_rate) * (1 - cev) : 0
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● スキル/アイテムの命中&回避計算
|
||
#--------------------------------------------------------------------------
|
||
def hit_and_eva(user, item)
|
||
#p "#{user.name}→#{self.name}"
|
||
if item.success_rate < 100
|
||
rate = item.success_rate * 0.01 # 成功率を取得
|
||
rate *= (user.hit + item.hit_rate) if item.physical? # 物理攻撃:命中率を乗算
|
||
rate -= item_eva(user, item)
|
||
#p "99以下 #{rate}"
|
||
@result.missed = (@result.used && rand >= rate)
|
||
else
|
||
rate = item.success_rate * 0.01 # 成功率を取得
|
||
rate *= (user.hit + item.hit_rate) if item.physical? # 物理攻撃:命中率を乗算
|
||
rate -= item_eva(user, item)
|
||
#p "100 #{rate}"
|
||
@result.evaded = (@result.used && rand >= rate)
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● スキル/アイテムの効果適用
|
||
#--------------------------------------------------------------------------
|
||
alias hae_item_apply item_apply
|
||
def item_apply(user, item)
|
||
if FAKEREAL::HIT_AND_EVA
|
||
@result.clear
|
||
@result.used = item_test(user, item)
|
||
hit_and_eva(user, item)
|
||
if @result.hit?
|
||
unless item.damage.none?
|
||
@result.critical = (rand < item_cri(user, item))
|
||
make_damage_value(user, item)
|
||
execute_damage(user)
|
||
end
|
||
item.effects.each {|effect| item_effect_apply(user, item, effect) }
|
||
item_user_effect(user, item)
|
||
end
|
||
else
|
||
hae_item_apply(user, item)
|
||
end
|
||
end
|
||
end
|
||
|
||
class RPG::UsableItem < RPG::BaseItem
|
||
def hit_rate
|
||
@hit_rate ||= set_hit_rate
|
||
end
|
||
def set_hit_rate
|
||
return $1.to_i * 0.01 if self.note =~ /\<命中プラス\:(\-?\d+)\>/
|
||
return 0
|
||
end
|
||
def cri_rate
|
||
@cri_rate ||= set_cri_rate
|
||
end
|
||
def set_cri_rate
|
||
return $1.to_i * 0.01 if self.note =~ /\<会心プラス\:(\-?\d+)\>/
|
||
return 0
|
||
end
|
||
end
|
||
|