赞 | 3 |
VIP | 0 |
好人卡 | 0 |
积分 | 16 |
经验 | 0 |
最后登录 | 2024-11-24 |
在线时间 | 195 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 1561
- 在线时间
- 195 小时
- 注册时间
- 2019-10-4
- 帖子
- 286
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
#========================================================================
# □ 自定义设定
#========================================================================
class Game_Battler
# 反击的状态名
STATE_COUNTER_NAME = '反击'
end
#========================================================================
# ◇ 说明文档
#=======================================================================
#****Warning! 重新定义了 Game_Actor#skill_can_use? ****
#使用方法
#对于身中“反击”状态的角色,当收到单独的攻击的时候会自动反击
#反击的模式可以在下面设定
#-cr (counter react)下面设定可以反击的挨打设定:
# 比如设定一个状态名为“反击 -crm”,则受到魔法攻击的时候会自动反击
#-cra50(attack) =>遭到物理攻击(普攻)的时候50%概率反击。
#-crp (physical) =>遭到物理伤害(物攻+物理技能)的时候反击。
#-crm (magic) =>遭到法术伤害(法术技能)的时候反击。
#-crs (skill) =>遭到技能伤害(物理技能+法术技能)的时候反击。
#-cre7 (element) =>遭到属性ID为7的攻击的时候反击。
#-ca (counter act)下面设定反击行为:
#比如设置一个状态名叫做“反击 -cas19”,那么受到攻击的时候就会用19号特技反击。
#-caa (attack) =>使用物理攻击反击。
#-cas1 (skill) =>使用ID为1的技能反击。
#-cac (copy) =>复制敌人攻击方式(普攻+技能)进行反击。
#-cai1 (item) =>使用ID为1的物品。
#-cae (escape) =>逃跑,敌人使用。
#注意和即时战斗的共同使用问题……
#举例:设置一个状态,使得遭遇物理攻击的时候使用物品4,“反击 -crp -cai4”
#========================================================================
# ■ Game_Battler (分割定义 1)
#========================================================================
class Game_Battler
#-----------------------------------------------------------------------
# ● 状态初始化
#-----------------------------------------------------------------------
def states=(states)
@states = states
end
#-----------------------------------------------------------------------
# ● 对象初始化
#-----------------------------------------------------------------------
alias original_initialize_before_counter_action initialize
def initialize
original_initialize_before_counter_action()
@counter_action = Game_BattleAction.new
end
#-----------------------------------------------------------------------
# ● 获取当前的动作
#-----------------------------------------------------------------------
alias original_current_action_before_counter_action current_action
def current_action
if @counter_action.cleared?
return original_current_action_before_counter_action()
else
return @counter_action
end
end
#-----------------------------------------------------------------------
# ● 获取当前的动作
#-----------------------------------------------------------------------
def counter_action
return @counter_action
end
#-----------------------------------------------------------------------
# ● 是否待机
#-----------------------------------------------------------------------
def counter_acting?
if !@counter_action.cleared?
return true
else
return false
end
end
#-----------------------------------------------------------------------
# ● 战斗不能判定
#-----------------------------------------------------------------------
#alias original_dead_before_counter_action dead?
#def dead?
# if self.counter_acting?
# return false
# else
# return original_dead_before_counter_action()
# end
#end
#----------------------------------------------------------------------
# ●
#----------------------------------------------------------------------
def counter_action_for(attacker, skill = nil)
# 行动存在时
if attacker.counter_acting?
return
end
# 无法行动和不存在的情况
#if !self.movable? || !self.exist?
# return
#end
if attacker.is_a?(Game_Actor)
if self.is_a?(Game_Actor) # 攻击目标是伙伴的情况下
return
end
ind = $game_party.get_index_by(attacker)
s_ind = $game_troop.get_index_by(self)
elsif attacker.is_a?(Game_Enemy)
if self.is_a?(Game_Enemy) # 攻击目标是伙伴的情况下
return
end
ind = $game_troop.get_index_by(attacker)
s_ind = $game_party.get_index_by(self)
end
if ind.nil? || s_ind.nil?
return
end
# 初始化反击类型为普攻
act_kind = 'a'
act_id = 0
# 检测状态
for id in @states
# 如果状态名包含“反击”
if $data_states[id].name =~ /^#{STATE_COUNTER_NAME}/
# 初始化反击行动
react_cond = false
react_succ = false
# 检测
for opt in $data_states[id].options
# 检测伤害类型
if opt =~ /^cr([apmsend])([0-9]*)/
kind = $1
id = $2.to_i
react_cond = true
# 判断伤害类型
case kind
when 'a' # 物理攻击(普攻)
if skill.nil? && (rand(100) < id)
react_succ = true
end
when 'p' # 物理伤害(物理技能 + 普攻)
if skill.nil? || skill.atk_f != 0
react_succ = true
end
when 'm' # 法术伤害(法术技能)
if !skill.nil? && skill.power > 0
react_succ = true
end
when 's' # 技能伤害(法术技能+物理技能)
if !skill.nil? && (skill.power > 0 || skill.atk_f != 0)
react_succ = true
end
when 'e' # 属性攻击
if id.nil? || id.zero?
next
elsif skill.nil? # 武器攻击属性
if attacker.is_a?(Game_Actor) && !$data_weapons[@weapon_id].nil?
if $data_weapons[@weapon_id].element_set.include?(id)
react_succ = true
end
end
elsif skill.element_set.include?(id)# 敌人攻击属性
react_succ = true
end
when 'n' # 令目标攻击无效
no_attack = true
#when 'ss' # 目标闪避攻击时反击
# miss_attack = true
when 'd' # 目标死亡时反击
if self.dead? && self.movable?
react_succ = true
end
end
# 检测反击类型
elsif opt =~ /^ca([ascie])([0-9]*)/
act_kind = $1
act_id = $2.to_i
#react_cond = true
end
end
# 反击条件成立的情况下
if (!react_cond || react_succ)
counter = true
break
else
next
end
end
end
# 不反击的情况下直接返回
if !counter
return
end
# 目标攻击无效的话恢复损失气血
if no_attack == true
if self.damage != "Miss"
self.hp += self.damage
self.damage = "Miss"
self.critical = false
@state_changed = false
self.states = @old_states
end
end
# 目标没有闪避伤害时直接返回
#if miss_attack == true and self.damage != "Miss"
# return
#end
# 如果是复制攻击方行动效果
if act_kind == 'c'
if skill.nil?
act_kind = 'a'
else
act_kind = 's'
act_id = skill.id
end
end
# 判断反击类型
case act_kind
when 'a' # 攻击 kind:0 basic:0
self.counter_action.kind = 0
self.counter_action.target_index = ind
self.counter_action.basic = 0
when 's' # 技能 kind:1 basic:0
s = $data_skills[act_id]
# 判断技能是否不存在,是否战斗可用,是否角色可用
if s.nil? || ![0,1].include?(s.occasion) || !self.skill_can_use?(act_id)
return
end
self.counter_action.skill_id = act_id
self.counter_action.kind = 1
# 1敌单体,2敌全体
if [1,2].include?(s.scope)
self.counter_action.target_index = ind
else
self.counter_action.target_index = s_ind
end
when 'i' # 物品 kind:2 basic:0
i = $data_items[act_id]
# 判断是否是角色,物品是否不存在,是否战斗可用,是否角色可用
if !self.is_a?(Game_Actor) || i.nil? || ![0,1].include?(i.occasion) || !$game_party.item_can_use?(act_id)
return
end
self.counter_action.item_id = act_id
self.counter_action.kind = 2
# 1敌单体,2敌全体
if [1,2].include?(i.scope)
self.counter_action.target_index = ind
else
self.counter_action.target_index = s_ind
end
when 'e' # 逃跑 kind:0 basic:2
# 判断是否是敌人
if !self.is_a?(Game_Enemy)
return
end
self.counter_action.kind = 0
self.counter_action.target_index = ind
self.counter_action.basic = 2
end
return
end
#----------------------------------------------------------------------
# ● 普通攻击效果
# attacker : 攻击者
#----------------------------------------------------------------------
alias original_attack_effect_before_counter_action attack_effect
def attack_effect(attacker)
@old_states = self.states.clone
val = original_attack_effect_before_counter_action(attacker)
# 检测反击
self.counter_action_for(attacker)
return val
end
#----------------------------------------------------------------------
# ● 技能攻击效果
# user : 技能使用者
# skill : 技能ID
#----------------------------------------------------------------------
alias original_skill_effect_before_counter_action skill_effect
def skill_effect(attacker, skill)
@old_states = self.states.clone
val = original_skill_effect_before_counter_action(attacker, skill)
# 检测反击
self.counter_action_for(attacker, skill)
return val
end
end
#===============================================================================
# ■ Game_Actor
#-------------------------------------------------------------------------------
=begin
class Game_Actor < Game_Battler
#----------------------------------------------------------------------
# ● 技能使用判定
# skill_id : 技能 ID
#----------------------------------------------------------------------
def skill_can_use?(skill_id)
#if not skill_learn?(skill_id)
# return false
#end
return super
end
end
=end
#===============================================================================
# ■ Game_BattleAction
#-------------------------------------------------------------------------------
class Game_BattleAction
#-----------------------------------------------------------------------
# ● 初始化
#-----------------------------------------------------------------------
alias :xp_original_initialize :initialize
def initialize
xp_original_initialize()
@turn_move_times = 0
end
#-----------------------------------------------------------------------
# ● 清除判定
#-----------------------------------------------------------------------
def cleared?
if @speed == 0 && @kind == 0 && @basic == 3 && @skill_id == 0 && @item_id == 0 && @target_index == -1 && @forcing == false
return true
else
return false
end
end
end
#===============================================================================
# ■ Game_Party
#-------------------------------------------------------------------------------
class Game_Party
#----------------------------------------------------------------------
# ● 获得角色目标
#----------------------------------------------------------------------
def get_index_by(actor)
for i in [email protected]()
if @actors.equal?(actor)
return i
end
end
return nil
end
end
#==========================================================================
# ■ Game_Troop
#--------------------------------------------------------------------------
class Game_Troop
#----------------------------------------------------------------------
# ● 获得敌人目标
#----------------------------------------------------------------------
def get_index_by(enemy)
for i in [email protected]()
if @enemies.equal?(enemy)
return i
end
end
return nil
end
end |
|