本帖最后由 soulsaga 于 2018-5-17 11:22 编辑
module NODMG GUARD_ONCE_STATE = [ 447, # 状态ID 448, 449, ] GUARD_TIME = [ 1,#免伤次数 2, 3, ] end class Game_Battler alias init0622 initialize def initialize init0622 @guard_times = 0 end alias add_state_0622 add_state def add_state(state_id) for i in 0..NODMG::GUARD_ONCE_STATE.size-1 @guard_times += NODMG::GUARD_TIME[i] if state_id == NODMG::GUARD_ONCE_STATE[i] @state_id = state_id if state_id == NODMG::GUARD_ONCE_STATE[i] end add_state_0622(state_id) end alias remove_state_0622 remove_state def remove_state(state_id) for i in 0..NODMG::GUARD_ONCE_STATE.size-1 @guard_times = 0 if state_id == NODMG::GUARD_ONCE_STATE[i] end remove_state_0622(state_id) end def item_apply(user, item) @result.clear @result.used = item_test(user, item) @result.missed = (@result.used && rand >= item_hit(user, item)) @result.evaded = (!@result.missed && rand < item_eva(user, item)) return unless @result.hit? if @guard_times > 0 if (@guard_times -= 1) <= 0 remove_state(@state_id) return end return if @guard_times > 0 end end end 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 end
module NODMG
GUARD_ONCE_STATE = [
447, # 状态ID
448,
449,
]
GUARD_TIME = [
1,#免伤次数
2,
3,
]
end
class Game_Battler
alias init0622 initialize
def initialize
init0622
@guard_times = 0
end
alias add_state_0622 add_state
def add_state(state_id)
for i in 0..NODMG::GUARD_ONCE_STATE.size-1
@guard_times += NODMG::GUARD_TIME[i] if state_id == NODMG::GUARD_ONCE_STATE[i]
@state_id = state_id if state_id == NODMG::GUARD_ONCE_STATE[i]
end
add_state_0622(state_id)
end
alias remove_state_0622 remove_state
def remove_state(state_id)
for i in 0..NODMG::GUARD_ONCE_STATE.size-1
@guard_times = 0 if state_id == NODMG::GUARD_ONCE_STATE[i]
end
remove_state_0622(state_id)
end
def item_apply(user, item)
@result.clear
@result.used = item_test(user, item)
@result.missed = (@result.used && rand >= item_hit(user, item))
@result.evaded = (!@result.missed && rand < item_eva(user, item))
return unless @result.hit?
if @guard_times > 0
if (@guard_times -= 1) <= 0
remove_state(@state_id)
return
end
return if @guard_times > 0
end
end
end
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
end
未测试..不保证可行..
回合数应该可以在数据库设置.. |