设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
Project1 查看内容

23种战斗特效的公共事件版(实践)

2005-10-14 00:00| 发布者: 柳柳| 查看: 13508| 评论: 0|原作者: 66RPG

摘要:    作者   SailCat(中国大陆)  版本与更新 本实践的理论部分点此进入  相关网址    范例工程 不提供  教程内容 作者: SailCat     时间: 2005-9
 

 作者

  SailCat(中国大陆)

 版本与更新

本实践的理论部分点此进入

 相关网址

 

 范例工程

不提供



 教程内容

作者: SailCat     时间: 2005-9-17 02:50 PM    标题: 23种战斗特效的公共事件版(Perfect!)

更新于9.18夜
更新说明:
1.视觉效果99%完美化(除了“消耗HP发动”仍然有一个先刷新消耗过SP的窗口再改消耗HP外,所有视觉效果均与一般内置技能无异)
2.加了三个脚本,魔封那个纯粹是偷了FF6的创意和设定
3.经过严格的测试,现在技能如果不命中不会再出错了,加了一堆关于系统返回伤害值是否为一个整数的判断(凡是打击后效果的那些事件)
4.如果你想要其他效果请和我联系,只要不是太复杂的算法,我可以现场写一段给你,包括反击在内都已经实现了,但是因为公共事件毕竟还是有局限性,从动画上不太好体现出来(当然精心设置还是可以的,因为我把公共事件插在这里已经完全能够重新定义攻击者和被攻击者)……
5.怎么说呢,和上一个版本相比兼容性是一模一样的。但是和其他脚本的冲突不能说没有,毕竟最大的系统修改是挪动了公共事件的执行顺序,我没有在RTAB里测试这个东西。可能用了这个以后公共事件在战斗中就不能拿来干其他事情了……不过我想知道会有人需要拿技能附加的公共事件做除了这个事以外的其他事么。。。?


步骤1:将以下脚本插入到Main之前。

class Game_Battler
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_reader   :last_hp                  # 受效前的HP
end
class Scene_Battle
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_accessor :target_battlers
  attr_accessor :active_battler
  attr_reader :skill
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    # 执行战斗事件中的情况下
    if $game_system.battle_interpreter.running?
      # 刷新解释器
      $game_system.battle_interpreter.update
      # 强制行动的战斗者不存在的情况下
      if $game_temp.forcing_battler == nil
        # 执行战斗事件结束的情况下
        unless $game_system.battle_interpreter.running?
          # 继续战斗的情况下、再执行战斗事件的设置
          unless @common_event_id != 0
            unless judge
              setup_battle_event
            end
          end
        end
        # 如果不是结束战斗回合的情况下
        if @phase != 5 and @common_event_id == 0
          # 刷新状态窗口
          @status_window.refresh
        end
      end
    end
    # 系统 (计时器)、刷新画面
    $game_system.update
    $game_screen.update
    # 计时器为 0 的情况下
    if $game_system.timer_working and $game_system.timer == 0
      # 中断战斗
      $game_temp.battle_abort = true
    end
    # 刷新窗口
    @help_window.update
    @party_command_window.update
    @actor_command_window.update
    @status_window.update
    @message_window.update
    # 刷新活动块
    @spriteset.update
    # 处理过渡中的情况下
    if $game_temp.transition_processing
      # 清除处理过渡中标志
      $game_temp.transition_processing = false
      # 执行过渡
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    # 显示信息窗口中的情况下
    if $game_temp.message_window_showing
      return
    end
    # 显示效果中的情况下
    if @spriteset.effect?
      return
    end
    # 游戏结束的情况下
    if $game_temp.gameover
      # 切换到游戏结束画面
      $scene = Scene_Gameover.new
      return
    end
    # 返回标题画面的情况下
    if $game_temp.to_title
      # 切换到标题画面
      $scene = Scene_Title.new
      return
    end
    # 中断战斗的情况下
    if $game_temp.battle_abort
      # 还原为战斗前的 BGM
      $game_system.bgm_play($game_temp.map_bgm)
      # 战斗结束
      battle_end(1)
      return
    end
    # 等待中的情况下
    if @wait_count > 0
      # 减少等待计数
      @wait_count -= 1
      return
    end
    # 强制行动的角色存在、
    # 并且战斗事件正在执行的情况下
    if $game_temp.forcing_battler == nil and
       $game_system.battle_interpreter.running?
      return
    end
    # 回合分支
    case @phase
    when 1  # 自由战斗回合
      update_phase1
    when 2  # 同伴命令回合
      update_phase2
    when 3  # 角色命令回合
      update_phase3
    when 4  # 主回合
      update_phase4
    when 5  # 战斗结束回合
      update_phase5
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (主回合步骤 3 : 行动方动画)
  #--------------------------------------------------------------------------
  def update_phase4_step3
    # 行动方动画 (ID 为 0 的情况下是白色闪烁)
    if @animation1_id == 0
      @active_battler.white_flash = true
    else
      @active_battler.animation_id = @animation1_id
      @active_battler.animation_hit = true
    end
    # 公共事件 ID 有效的情况下
    if @common_event_id > 0
      # 设置事件
      common_event = $data_common_events[@common_event_id]
      $game_system.battle_interpreter.setup(common_event.list, 0)
    end
    # 移至步骤 4
    @phase4_step = 4
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (主回合步骤 5 : 显示伤害)
  #--------------------------------------------------------------------------
  def update_phase4_step5
    # 隐藏帮助窗口
    @help_window.visible = false
    # 刷新状态窗口
    @status_window.refresh
    # 显示伤害
    for target in @target_battlers
      if target.damage != nil
        target.damage_pop = true
      end
    end
    if @active_battler.damage != nil
      @active_battler.damage_pop = true
    end
    # 移至步骤 6
    @phase4_step = 6
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (主回合步骤 6 : 刷新)
  #--------------------------------------------------------------------------
  def update_phase4_step6
    # 清除强制行动对像的战斗者
    $game_temp.forcing_battler = nil
    # 移至步骤 1
    @phase4_step = 1
  end
end

步骤2:以下两种做法任选一种,推荐第一种:
  做法一:定位到系统脚本的Game_Battler 2部分,第106行,该行内容是:
        unless movable?
        如果不是,可以用Ctrl+F搜索该行。将内容改为:
        unless movable? or hp0?
  做法二:在数据库中,更改“战斗不能”的行动限制为“无限制”


步骤3:这些公共事件的用法
  想要哪个效果,就复制哪个效果的脚本。
  将你要用到的效果脚本全部粘贴到同一个公共事件中
  把要实现效果的技能的公共事件设为该事件
  用条件分歧(以技能名称为条件)来实现不同的效果
  这样做有两点好处:
  1. 允许一个技能多重效果(当然,要注意一下排放的先后顺序问题),优先级如下:
     有修改攻击范围的最优先,其次是修改伤害计算法则的,最后是只含有附加效果的
  2. 节省公共事件,也就是节省内存


一、全体化(效果:攻击范围=被攻击方全体):
脚本段落1(还原):
for t in $scene.target_battlers
  t.hp = t.last_hp
end
脚本段落2(全体化对象):
@a=$scene.active_battler
n=[]
if @a.is_a?(Game_Enemy)
  for actor in $game_party.actors
    n.push(actor) if actor.exist?
  end
else
  for enemy in $game_troop.enemies
    n.push(enemy) if enemy.exist?
  end
end
$scene.target_battlers=n
脚本段落3(应用效果):
s=$scene.skill
for t in $scene.target_battlers
  t.skill_effect(@a,s)
end
备注:这个不如直接在技能效果范围里设定了……

二、全域化(效果:攻击范围=被攻击方全体+攻击方全体):
脚本段落1(还原&全域化对象):
for t in $scene.target_battlers
  t.hp = t.last_hp
end
n=[]
for actor in $game_party.actors
  n.push(actor) if actor.exist?
end
for enemy in $game_troop.enemies
  n.push(enemy) if enemy.exist?
end
$scene.target_battlers=n
脚本段落2(应用效果):
a=$scene.active_battler
s=$scene.skill
for t in $scene.target_battlers
  t.skill_effect(a,s)
end

三、敌方随机(效果:攻击范围=被攻击方随机选定单体):
脚本段落1(还原&随机化):
for t in $scene.target_battlers
  t.hp = t.last_hp
end
@a=$scene.active_battler
if @a.is_a?(Game_Enemy)
  t=$game_party.random_target_actor
else
  t=$game_troop.random_target_enemy
end
$scene.target_battlers=[t]
脚本段落2(应用效果):
s=$scene.skill
for t in $scene.target_battlers
  t.skill_effect(@a,s)
end

四、我方随机(效果:攻击范围=攻击方随机选定单体):
脚本段落1(还原&随机化):
for t in $scene.target_battlers
  t.hp = t.last_hp
end
@a=$scene.active_battler
if @a.is_a?(Game_Actor)
  t=$game_party.random_target_actor
else
  t=$game_troop.random_target_enemy
end
$scene.target_battlers=[t]
脚本段落2(应用效果):
s=$scene.skill
for t in $scene.target_battlers
  t.skill_effect(@a,s)
end

五、对象随机(效果:攻击范围=攻击方+被攻击方随机选定单体):
脚本段落1(还原&随机化):
for t in $scene.target_battlers
  t.hp = t.last_hp
end
n=[]
for actor in $game_party.actors
  n.push(actor) if actor.exist?
end
for enemy in $game_troop.enemies
  n.push(enemy) if enemy.exist?
end
$scene.target_battlers=[n[rand(n.size)]]
脚本段落2(应用效果):
a=$scene.active_battler
s=$scene.skill
for t in $scene.target_battlers
  t.skill_effect(a,s)
end

六、HP吸收(效果:攻击者增加等同于伤害值的HP,对不死系(属性9)反效果):
a = $scene.active_battler
for t in $scene.target_battlers
  f=t.damage
  f=0 unless t.damage.is_a?(Integer)
  if t.element_rate(9)>=150
    t.hp=t.last_hp+f;a.hp-=f
    a.damage=t.damage;t.damage=-f if f!=0
  else
    a.hp+=f; a.damage=-f if f!=0
  end
end
$scene.active_battler = a

七、SP伤害(效果:本来伤害到对方HP上的改成伤害到SP上):
for t in $scene.target_battlers
  t.hp=t.last_hp
  t.sp-=t.damage if t.damage.is_a?(Integer)
end

八、SP同等伤害(效果:对方损失多少HP,就等量损失多少SP):
for t in $scene.target_battlers
  t.sp-=t.damage if t.damage.is_a?(Integer)
end


九、SP吸收(效果:本来伤害到对方HP上的改到伤害到SP上,攻击者增加等同于伤害值的SP,对不死系(属性9)反效果):
脚本段落1(还原&SP伤害):
for t in $scene.target_battlers
  t.hp=t.last_hp
  if t.damage.is_a?(Integer)
    if t.element_rate(9)>=150
      t.sp+=t.damage
      t.damage=-t.damage
    else
      t.sp-=t.damage
    end
  end
end
脚本段落2(SP吸收):
a = $scene.active_battler
for t in $scene.target_battlers
  f=t.damage; f=0 unless f.is_a?(Integer)
  if t.element_rate(9)>=150
    a.damage=f
    a.sp-=a.damage
  else
    a.damage=-f
    a.sp-=a.damage
  end
end
$scene.active_battler = a

九、消耗HP发动(效果:本来是消耗SP发动的技能改为消耗HP来发动):
a = $scene.active_battler
s = $scene.skill
a.sp+=s.sp_cost
a.hp-=s.sp_cost
$scene.active_battler = a

十、比例伤害(效果:按对方现有HP定比例伤害,比例值为技能在数据库中的威力值,属性&防御有效):
s = $scene.skill
for t in $scene.target_battlers
  t.hp=t.last_hp
  e=t.elements_correct(s.element_set)
  t.damage=t.hp*s.power*e/10000
  t.damage/=2 if t.guarding?
  t.hp-=t.damage
end

十一、最大HP比例(效果:按对方最大HP定比例伤害,比例值为技能在数据库中的威力值,属性有效,防御无效):
s = $scene.skill
for t in $scene.target_battlers
  t.hp=t.last_hp
  e=t.elements_correct(s.element_set)
  t.damage=t.maxhp*s.power*e/10000
  t.hp-=t.damage
end

十二、HP差分比例(效果:按(对方最大HP-现有HP)的差值定比例伤害,比例值为技能在数据库中的威力值,属性&防御无效):
s = $scene.skill
for t in $scene.target_battlers
  t.hp=t.last_hp
  t.damage=(t.maxhp-t.hp)*s.power/100
  t.hp-=t.damage
end

十三、自身HP比例(效果:按攻击者现有HP定比例伤害,比例值为技能在数据库中的威力值,属性&防御有效):
s = $scene.skill
a = $scene.active_battler
for t in $scene.target_battlers
  t.hp=t.last_hp
  e=t.elements_correct(s.element_set)
  t.damage=a.hp*s.power*e/10000
  t.damage/=2 if t.guarding?
  t.hp-=t.damage
end

十四、自身最大HP比例(效果:按攻击者最大HP定比例伤害,比例值为技能在数据库中的威力值,属性&防御无效):
s = $scene.skill
a = $scene.active_battler
for t in $scene.target_battlers
  t.hp=t.last_hp
  t.damage=a.maxhp*s.power/100
  t.hp-=t.damage
end

十五、自身HP差分比例(效果:按(攻击者最大HP-现有HP)的差值定比例伤害,比例值为技能在数据库中的威力值,属性有效,防御无效):
s = $scene.skill
a = $scene.active_battler
for t in $scene.target_battlers
  t.hp=t.last_hp
  e=t.elements_correct(s.element_set)
  t.damage=(a.maxhp-a.hp)*s.power*e/10000
  t.hp-=t.damage
end

十六、舍命一击(效果:攻击者攻击后死亡):
$scene.active_battler.hp=0

十七、二次攻击(效果:同一种技能连续攻击两次):
s = $scene.skill
a = $scene.active_battler
for t in $scene.target_battlers
  d = t.last_hp
  t.skill_effect(a,s)
  t.damage = d - t.hp
  t.damage = "Miss" if d==t.hp
end

十八、必定会心一击(效果:永远造成会心一击):
for t in $scene.target_battlers
  if t.damage.is_a?(Integer)
    t.critical=true
    t.hp-=t.damage
    t.damage*=2
  end
end

十九、反射(效果:若被攻击者带反射状态,则将技能效果返还给对方随机一名队员,反射状态请先在数据库中设定,这里预设值为15号状态):
脚本段落1(还原&对象重确认):
c=$scene.target_battlers
for t in $scene.target_battlers
  t.hp=t.last_hp
  if t.state?(14)
    c.delete(t)
    a=(t.is_a?(Game_Enemy))?true:false
    b= !a
c.push($game_party.random_target_actor) if a
c.push($game_troop.random_target_enemy) if b
  end
end
$scene.target_battlers=c
脚本段落2(重新应用技能效果):
a=$scene.active_battler
s=$scene.skill
for t in $scene.target_battlers
  t.skill_effect(a,s)
end

二十、金钱投掷(效果:攻击方减少等同于伤害值千分比的金钱,这个比例在技能的分散度里设定(0-100对应0-10%),该技能的伤害值预设为150*(技能威力+攻击者等级-敌人防御),公式可以修改):
条件分歧: 脚本: $scene.active_battler.is_a?(Game_Actor)
  脚本段落:
  s=$scene.skill
  a=$scene.active_battler
  for t in $scene.target_battlers
    power=s.power+a.level
    power-=t.pdef*s.pdef_f/100
    power-=t.mdef*s.mdef_f/100
    power=[power,0].max
    t.damage=power*150
    t.hp=t.last_hp-t.damage
    gold_cost=t.damage*s.variance/1000
    $game_party.lose_gold(gold_cost)
  end
除此以外的场合
  脚本段落:
  for t in $scene.target_battlers
    t.hp=t.last_hp
    t.damage="Miss"
  end
分歧结束
备注:外包一个条件是为了如果敌人执行该技能就不会出错(最多是没有效果)。

二十一、魔封(效果:当被攻击方里有人处于魔封状态时,纯魔法攻击无效,魔封者回复该技能所消耗的SP,受属性影响有修正。魔封状态请预先设定,默认为17,这个效果出现后状态即解除(多人有此状态时,只有1人能回复SP,其他人只解除状态)):
脚本段落1(魔封):
s=$scene.skill; runic=nil
for t in $scene.target_battlers
  runic=t if t.state?(17)
end
if runic!=nil
  for t in $scene.target_battlers
    t.hp=t.last_hp; t.damage="Miss"
  end
  e=runic.elements_correct(s.element_set)
  runic.damage=-s.sp_cost*e/100
  runic.sp-=runic.damage
end
脚本段落2(解除状态):
for t in $scene.target_battlers
  t.remove_state(17) if t.state?(17)
end
备注:魔封的条件(纯魔法攻击)我没有写在脚本里,因为没必要,建议在之外的条件分歧中写脚本
$scene.skill.atk_f==0
这个和沈默状态下不能使用的判定准则一模一样
然后把所有你认为能魔封的魔法都设为公共事件就行了。

二十二、回复不死系反效果(效果:回复HP的魔法对不死系伤害HP,复活的魔法对不死系即死)
s=$scene.skill
for t in $scene.target_battlers
  f=t.damage
  f=0 unless t.damage.is_a?(Integer)
  if t.element_rate(9)>=150
    t.hp=t.last_hp+f
    t.hp=0 if s.minus_state_set.include?(1)
    t.damage = -f if f!=0
    t.damage = "" if t.hp==0
  end
end

二十三、死后自动复活(效果:身中自动复活状态的角色,当HP=0时会变成最大HP的1/8,并解除自动复活,该状态先在数据库里设定,这里范例为22号状态):
for t in $scene.target_battlers
  if t.hp==0 and t.state?(22)
    t.hp=t.maxhp/8
    t.remove_state(22)
  end
end
备注:这个解决方法不算很完美,因为你看不到角色复活的明灭过程……个人觉得还是用改脚本来做好一些……


 

教程的通用说明

本站发布的教程,大多经过一些测试,应该都能够实现相应功能。但不保证所有的教程都是最优化的制作方法。

相关问题,点击发布贴进行讨论。谢谢您的鼓励与支持。

1

鲜花

刚表态过的朋友 (1 人)

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-29 13:56

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

返回顶部