if self.is_a?(Game_Actor) and self.damage > 0 and self.states.include?(***) # 这里的states状态编号就是装备了格挡装备所附加状态的编号。
if rand(10)+1 <= 8 # 80%几率
self.damage = "格挡!" #格挡的名字
self.critical = false
self.animation_id = ** # 格挡触发的动画
end
# ===================================在此项之后,你还可以放更多的if 更多的受击判定和特效
end
end
end
最后,为了避免伤害处理出现字符串而导致错误,
还需要在定义普攻的方法里:
# HP 的伤害计算
self.hp -= self.damage
改成
unless self.damage.is_a?(String)
# HP 的伤害计算
self.hp -= self.damage
end