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

Project1

 找回密码
 注册会员
搜索
查看: 1550|回复: 2
打印 上一主题 下一主题

[已经解决] RTAB魔法反射特效如何实现随机目标?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
381 小时
注册时间
2012-8-13
帖子
113
跳转到指定楼层
1
发表于 2012-11-23 12:21:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 tyq4590 于 2012-11-24 23:19 编辑

脚本用的是RTAB自带的魔法反射脚本,代码如下(我稍微改了一下,把技能必须是魔法的判定取消了,这样只要是技能就可以反射):

RUBY 代码复制
  1. # ▼▲▼ XRXS27. 特殊効果 SuperEX「魔法反射」 ver.1.03 ▼▲▼
  2. # by 桜雅 在土, clum-sea
  3.  
  4. #==============================================================================
  5. # □ カスタマイズポイント
  6. #==============================================================================
  7. class Scene_Battle
  8.   MAGIC_REFREX_STATE_NAME         = "反射"   # 「魔法反射」状态名
  9.   MAGIC_REFREX_ANIMATION_ID       =  263          #  魔法反射的动画ID
  10.   REFREX_PENETRATION_ELEMENT_NAME = "反射贯通"   # 「反射貫通」属性名
  11. end
  12.  
  13. #=============================================================================
  14. # ◇ 「魔法反射」ステート by 桜雅 在土
  15. #=============================================================================
  16. class Scene_Battle
  17.   #--------------------------------------------------------------------------
  18.   # ● スキルまたはアイテムの対象側バトラー設定
  19.   #--------------------------------------------------------------------------
  20.   alias xrxs_magic_refrex_set_target_battlers set_target_battlers
  21.   def set_target_battlers(scope,battler)
  22.     xrxs_magic_refrex_set_target_battlers(scope,battler)
  23.     # スキル使用時
  24.     if battler.current_action.kind == 1
  25.       # 魔法である場合
  26.         element_id = get_refrex_penetration_id
  27.         # スキルに反射貫通が付加されているか。
  28.         skill_state_penetration(@skill, element_id, battler)
  29.         if battler.penetration != true
  30.           # 検索
  31.           for target in battler.target.dup
  32.             # 魔法反射ステートにかかっているか?
  33.             state_id = get_magical_refrex_id
  34.             if state_id != nil and target.state?(state_id)
  35.               # 反射---
  36.               if rand(10) < 5
  37.                 target.refrexed = true
  38.                 battler.target.delete(target)
  39.                 unless battler.target.include?(battler)
  40.                   battler.target.push(battler)
  41.                 end
  42.               end
  43.               # ---反射の設定完了
  44.             end
  45.           end
  46.         end
  47.     end
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # ● スキルに反射貫通属性が付加されているか
  51.   #--------------------------------------------------------------------------
  52.   def skill_state_penetration(skill, element_id, user)
  53.     if skill.element_set.include?(element_id)
  54.       # 反射フラグリセット
  55.       user.refrexed = false
  56.       # 貫通フラグをセット
  57.       user.penetration = true
  58.     end
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # ● フレーム更新 (メインフェーズ ステップ 4 : 対象側アニメーション)
  62.   #--------------------------------------------------------------------------
  63.   alias xrxs_magic_refrex_update_phase4_step4 update_phase4_step4
  64.   def update_phase4_step4(battler)
  65.     # 対象側アニメーション
  66.     xrxs_magic_refrex_update_phase4_step4(battler)
  67.     # 魔法反射(貫通しない場合)
  68.     for target in $game_party.actors + $game_troop.enemies - battler.target
  69.       next if target.refrexed == nil or target.refrexed == false
  70.     #  target.animation_id = MAGIC_REFREX_ANIMATION_ID
  71.     #  target.animation_hit = (target.damage != "Miss")
  72.       target.animation.push([MAGIC_REFREX_ANIMATION_ID,
  73.                                           (target.damage[battler] != "Miss")])
  74.       # 反射フラグリセット
  75.       target.refrexed = false
  76.     end
  77.     for target in battler.target
  78.       # 反射フラグリセット
  79.       target.refrexed = false
  80.     end
  81.     # 貫通フラグリセット
  82.     battler.penetration = false
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ○ 魔法反射ステートのID取得
  86.   #--------------------------------------------------------------------------
  87.   def get_magical_refrex_id
  88.     if @xrxs27_magic_refrex_state_id == nil
  89.       result = nil
  90.       for i in 1 ... $data_states.size
  91.         if $data_states[i].name[/\A#{MAGIC_REFREX_STATE_NAME}\Z/]
  92.           result = $data_states[i].id
  93.           break
  94.         end
  95.       end
  96.       @xrxs27_magic_refrex_state_id = result
  97.     end
  98.     return @xrxs27_magic_refrex_state_id
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ○ 反射貫通属性のID取得
  102.   #--------------------------------------------------------------------------
  103.   def get_refrex_penetration_id
  104.     if @xrxs27_refrex_penetration_element_id == nil
  105.       result = nil
  106.       for i in 1 ... $data_system.elements.size
  107.         if $data_system.elements[i] == REFREX_PENETRATION_ELEMENT_NAME
  108.           result = i
  109.           break
  110.         end
  111.       end
  112.       @xrxs27_refrex_penetration_element_id = result
  113.     end
  114.     return @xrxs27_refrex_penetration_element_id
  115.   end
  116. end
  117. #==============================================================================
  118. # ■ Game_Battler
  119. #==============================================================================
  120. class Game_Battler
  121.   attr_accessor :refrexed
  122.   attr_accessor :penetration
  123. end


这个脚本的功能是受到魔法攻击的时候将攻击对象改为攻击者自身(也就是被谁攻击就反射给谁)。但是我想修改一下,让反射的时候将攻击对象改为在敌方队伍里随机选择目标(也就是说如果敌方队伍里有A、B、C三个敌人,那么主角受到A攻击时可以把攻击对象转移到A、B、C中任意一人身上)。望高手指点!

Lv1.梦旅人

梦石
0
星屑
60
在线时间
568 小时
注册时间
2012-9-7
帖子
611
2
发表于 2012-11-24 13:31:13 | 只看该作者
本帖最后由 wingzeroplus 于 2012-11-24 13:44 编辑
  1. #=============================================================================
  2. # ◇ 「魔法反射」ステート by 桜雅 在土
  3. #=============================================================================
  4. class Scene_Battle
  5.   #--------------------------------------------------------------------------
  6.   # ● スキルまたはアイテムの対象側バトラー設定
  7.   #--------------------------------------------------------------------------
  8.   alias xrxs_magic_refrex_set_target_battlers set_target_battlers
  9.   def set_target_battlers(scope,battler)
  10.     xrxs_magic_refrex_set_target_battlers(scope,battler)
  11.     # スキル使用時
  12.     if battler.current_action.kind == 1
  13.       # 魔法である場合
  14.       if skill_is_a_magic?(@skill)
  15.         element_id = get_refrex_penetration_id
  16.         # スキルに反射貫通が付加されているか。
  17.         skill_state_penetration(@skill, element_id, battler)
  18.         if battler.penetration != true
  19.           # 検索
  20.           for target in battler.target.dup
  21.             # 魔法反射ステートにかかっているか?
  22.             state_id = get_magical_refrex_id
  23.             if state_id != nil and target.state?(state_id)
  24.               # 反射---
  25.               target.refrexed = true
  26.               battler.target.delete(target)
  27. ################################
  28.              if battler.is_a?(Game_Enemy)
  29.                if @skill.scope==1
  30.                for enemy in $game_troop.enemies
  31.                  if enemy.exist?
  32.                   battler.target = [$game_troop.random_target_enemy]
  33.                  battler.target -=[battler] if battler.current_action.self_exclusion
  34.             battler.target = [battler.target[rand(battler.target.size)]]
  35.                 end
  36.                end
  37.                elsif @skill.scope==3 or @skill.scope==5
  38.                for actor in $game_party.actors
  39.                  if actor.exist?
  40.                    battler.target.push(actor)
  41.                    battler.target -=[battler] if battler.current_action.self_exclusion
  42.            battler.target = [battler.target[rand(battler.target.size)]]
  43.                 end
  44.                end
  45.                end
  46.              end
  47.             
  48.             if battler.is_a?(Game_Actor)
  49.               if @skill.scope==3 or @skill.scope==5
  50.                  for enemy in $game_troop.enemies
  51.                  if enemy.exist?
  52.                   battler.target = [$game_troop.random_target_enemy]
  53.                   battler.target -=[battler] if battler.current_action.self_exclusion
  54.         battler.target = [battler.target[rand(battler.target.size)]]
  55.                  end
  56.                 end
  57.               elsif @skill.scope==1
  58.                 for actor in $game_party.actors
  59.                  if actor.exist?
  60.                    battler.target.push(actor)
  61.                    battler.target -=[battler] if battler.current_action.self_exclusion
  62.            battler.target = [battler.target[rand(battler.target.size)]]
  63.                  end
  64.                 end
  65.               end
  66.             end
  67. #####################################           
  68.               # ---反射の設定完了
  69.             end
  70.           end
  71.         end
  72.       end
  73.     end
  74.   end
复制代码
把中间##那段替换相应的位置就可以
不过我把反射的定义改了,单体才能反射,全体魔法不能反射,下面是我自己改的定义
  def skill_is_a_magic?(skill)
    return false unless skill.is_a?(RPG::Skill)
   return (skill.atk_f ==0 and (skill.scope==1 or skill.scope==3 or skill.scope==5))  
end
end
LZ对何种技能才能反射的定义需要如何改的话,自己看着办吧,我只提供随机反射的效果

评分

参与人数 1梦石 +1 收起 理由
hcm + 1 认可答案

查看全部评分

FTM正式版已经发布,点击图片开启传送门
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
381 小时
注册时间
2012-8-13
帖子
113
3
 楼主| 发表于 2012-11-24 19:18:40 | 只看该作者
wingzeroplus 发表于 2012-11-24 17:31
把中间##那段替换相应的位置就可以
不过我把反射的定义改了,单体才能反射,全体魔法不能反射,下面是我自 ...

试了一下,是我要的效果。多谢啦!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-4-27 16:31

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表