本帖最后由 guoxiaomi 于 2017-4-3 22:44 编辑  
 
继续说一点,Sailcat 前辈的脚本为了解决回血的问题——即在显示伤害数字(@phase4_step = 5)的时候目标的血量实际上已经扣除——将 phase4 的几个 step 位置移动了。我的这个脚本里没有这么做,所以对于减伤的技能效果,实现起来要困难一些。但是其他的效果也算是比较容易实现了。 
下面会举一些例子,其实大部分实现方法跟 Sailcat 前辈差不多,所以我这里着重讲几个区别比较大的地方。 
 
1. 连击(单回合多次行动) 
连击的话,思路很清楚,在第 2 处公共事件里,或者在物品、技能的公共事件里,设置 $scene.phase4_step = 2。这样在 step = 5(或6) 结束后,会回到 step = 2,此时@active_battler没有改变,就会重复执行之前的行动。 
所以要把 phase4_step 给拿出来,同时为了方便添加说明文字,把 help_window 也拿出来。 
class Scene_Battle   attr_reader   :help_window     attr_accessor :phase4_step end 
 
 class Scene_Battle  
  attr_reader   :help_window    
  attr_accessor :phase4_step  
end  
 
  
比如说,在技能 1 释放后会追加 1 次攻击。事件脚本: 
@battler = $scene.active_battler a = @battler.current_action if a.kind == 1 && a.skill_id == 1   a.kind, a.basic = 0, 0   $scene.phase4_step = 2   $scene.help_window.set_text("追加攻击", 1)   $scene.help_window.visible = true end 
 
 @battler = $scene.active_battler  
a = @battler.current_action  
if a.kind == 1 && a.skill_id == 1  
  a.kind, a.basic = 0, 0  
  $scene.phase4_step = 2  
  $scene.help_window.set_text("追加攻击", 1)  
  $scene.help_window.visible = true  
end  
 
  
 
2. 技能暴击(添加暴击字符串) 
技能暴击,关键是要添加一个暴击字符串,然后修正对象HP。在第 2 处公共事件判断技能ID、概率决定后面的处理。添加以下的事件脚本,这里分成 2 个,其实写成 1 个也没问题。 
@battler = $scene.active_battler @targets =  $scene.target_battlers 
 
 @battler = $scene.active_battler  
@targets =  $scene.target_battlers  
 
  
a = @battler.current_action  if a.kind == 1 && a.skill_id == 57  @targets.each do |t|   if t.damage.is_a?(Numeric) && rand < 0.25    t.hp = [t.hp-t.damage,0].max    t.damage = t.damage * 2       t.critical = true   end  end end 
 
 a = @battler.current_action   
if a.kind == 1 && a.skill_id == 57  
 @targets.each do |t|  
  if t.damage.is_a?(Numeric) && rand < 0.25  
   t.hp = [t.hp-t.damage,0].max  
   t.damage = t.damage * 2     
   t.critical = true  
  end  
 end  
end  
 
  
则 57 号技能有 25% 的概率造成 2 倍伤害,并显示 Critical 字样。 
 
3. 魔法盾(减伤+伤害SP) 
减伤比较麻烦的地方在于,damage 里记录的是造成的伤害值,而不是 hp 的损失值。比如 damage > 现有 hp,直接致死,但是在第 2 处公共事件触发时 hp = 0,所以如果回血直接 hp += damage 就不对了。 
有 2 种解决方案: 
1. 在扣血前记录对象方 HP。 
2. 附加状态防御以减伤。 
第 1 种方法就不细说了,只要在第 1 处公共事件里记录下所有敌人、队友的HP值即可。 
第 2 种方法的思路还是比较巧妙的: 
要实现 60% 的伤害被 SP 吸收,首先保证实际造成的伤害不能高于 40%,否则对象方 hp < 0 再回血就BUG了。首先要做以下准备工作: 
  1. 设置技能附带属性和状态,假设是属性:[魔法攻击]和状态:[受到魔法伤害] 
  2. 设置 2 个状态,分别是[魔法盾],[减伤1],都能防御属性:[魔法攻击],持续 3 回合 
  3. 设置[魔法盾]状态,附加[减伤1] 这个状态 
这样由于 2 重属性防御使得最终受到的伤害为 25% < 40%,从而确保此技能不会有伤害溢出。流程如下: 
1. 发动攻击,属性[魔法攻击],对象方附加上状态[受到魔法伤害] 
2. 由于对象方带有状态[魔法盾],[减伤1],所以对属性[魔法攻击] 2 次减伤,无 Miss 的情况下承受 25% 的伤害 
3. 进入行动后公共事件,由于对象方带有状态[魔法盾],[受到魔法伤害],且伤害不为 Miss,魔法盾效果发动 
4. 对象方再次承受 15% 的伤害,并且根据 SP 的量承受额外的伤害,以及损失 SP 
5. 显示最终的伤害值,移除[受到魔法伤害]的状态 
这里,状态 20 是[受到魔法伤害] 状态 21 是[魔法盾] 状态 22 是[减伤1] 
@battler = $scene.active_battler @targets =  $scene.target_battlers 
 
 @battler = $scene.active_battler  
@targets =  $scene.target_battlers  
 
  
@targets.each do |t|  next if not t.state?(21)  if t.damage.is_a?(Numeric) && t.state?(20)   t.damage = t.damage * 4   a = t.damage * 60/100 - t.sp   t.hp = t.hp - t.damage * 15/100   t.damage -= (a>0)? t.sp : t.damage*60/100     t.sp = (a>0)? 0 : -a   t.hp = (a>0)? t.hp - a : t.hp  end end 
 
 @targets.each do |t|  
 next if not t.state?(21)  
 if t.damage.is_a?(Numeric) && t.state?(20)  
  t.damage = t.damage * 4  
  a = t.damage * 60/100 - t.sp  
  t.hp = t.hp - t.damage * 15/100  
  t.damage -= (a>0)? t.sp : t.damage*60/100    
  t.sp = (a>0)? 0 : -a  
  t.hp = (a>0)? t.hp - a : t.hp  
 end  
end  
 
  
@targets.each do |t|  t.remove_state(20) end 
 
 @targets.each do |t|  
 t.remove_state(20)  
end  
 
  
 
4. 多合一范例 
范例里十字斩可以200%暴击、追加随机攻击;魔法盾减少60%十字斩的伤害,不减少攻击伤害;敌人会自带魔法盾,和 5 回合的薄葬效果,并且每回合回复 100 HP。 
公共事件里按照触发顺序依次是,关闭伤害显示 -> 判断暴击(施加伤害) -> 判断魔法盾(承受伤害) -> 显示伤害、移除标记 -> 判断薄葬 -> 判断连击 
 
公共事件战斗.zip
(202.72 KB, 下载次数: 289)
 
 
5. 理想的设置 
理想的设置是这样的: 
1. 武器、技能会附带[物理伤害]、[魔法伤害]、[纯粹伤害]中的一种属性,并且给对象方施加[承受物理伤害]、[承受魔法伤害]、[承受纯粹伤害]的状态。 
2. 魔法盾等伤害减免的效果,响应哪种类型的技能,就对此技能进行减伤,然后根据对象方身上承受伤害类型的状态来决定后续的处理。 
3. 最后显示伤害数字,并且移除对象方[承受物理伤害]、[承受魔法伤害]、[承受纯粹伤害]的状态。 
4. 目标受到的伤害数字 t.damage 会收到不同的技能效果而发生变化并传递给下一个技能效果,最终得到一个伤害数字,然后显示。 |