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

Project1

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

[已经解决] 编队脚本敌人技能目标问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
51 小时
注册时间
2013-1-18
帖子
10
跳转到指定楼层
1
发表于 2015-6-6 09:48:58 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 RyanBern 于 2015-6-6 09:54 编辑

脚本如下:

RUBY 代码复制
  1. #--------------------------------------------------------------------------
  2.   # ● 设置物品或特技对像方的战斗者
  3.   #     scope : 特技或者是物品的范围
  4.   #--------------------------------------------------------------------------
  5.   def set_target_battlers(scope)
  6.     # 行动方的战斗者是敌人的情况下
  7.     if @active_battler.is_a?(Game_Enemy)
  8.       # 效果范围分支
  9.       case scope
  10.       when 1  # 敌单体
  11.  
  12.          index = @active_battler.current_action.target_index
  13.          @target_battlers.push($game_party.smooth_target_actor(index))
  14.  
  15.       when 2  # 敌全体
  16.         for actor in 0...[$game_party.actors.size,4].min
  17.           if $game_party.actors[actor].exist?
  18.             @target_battlers.push($game_party.actors[actor])
  19.           end
  20.         end
  21.       when 3  # 我方单体
  22.         index = @active_battler.current_action.target_index
  23.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  24.       when 4  # 我方全体
  25.         for enemy in $game_troop.enemies
  26.           if enemy.exist?
  27.             @target_battlers.push(enemy)
  28.           end
  29.         end
  30.       when 5  # 我方单体 (HP 0)
  31.         index = @active_battler.current_action.target_index
  32.         enemy = $game_troop.enemies[index]
  33.         if enemy != nil and enemy.hp0?
  34.           @target_battlers.push(enemy)
  35.         end
  36.       when 6  # 我方全体 (HP 0)
  37.         for enemy in $game_troop.enemies
  38.           if enemy != nil and enemy.hp0?
  39.             @target_battlers.push(enemy)
  40.           end
  41.         end
  42.       when 7  # 使用者
  43.         @target_battlers.push(@active_battler)
  44.       end
  45.     end
  46.     # 行动方的战斗者是角色的情况下
  47.     if @active_battler.is_a?(Game_Actor)
  48.       # 效果范围分支
  49.       case scope
  50.       when 1  # 敌单体
  51.         index = @active_battler.current_action.target_index
  52.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  53.       when 2  # 敌全体
  54.         for enemy in $game_troop.enemies
  55.           if enemy.exist?
  56.             @target_battlers.push(enemy)
  57.           end
  58.         end
  59.       when 3  # 我方单体
  60.         index = @active_battler.current_action.target_index
  61.         @target_battlers.push($game_party.smooth_target_actor(index))
  62.       when 4  # 我方全体
  63.         for actor in 0...[$game_party.actors.size,4].min
  64.           if $game_party.actors[actor].exist?
  65.             @target_battlers.push($game_party.actors[actor])
  66.           end
  67.         end
  68.       when 5  # 我方单体 (HP 0)
  69.         index = @active_battler.current_action.target_index
  70.         actor = $game_party.actors[index]
  71.         if actor != nil and actor.hp0?
  72.           @target_battlers.push(actor)
  73.         end
  74.       when 6  # 我方全体 (HP 0)
  75.         for actor in 0...[$game_party.actors.size,4].min
  76.           if $game_party.actors[actor] != nil and $game_party.actors[actor].hp0?
  77.             @target_battlers.push($game_party.actors[actor])
  78.           end
  79.         end
  80.       when 7  # 使用者
  81.         @target_battlers.push(@active_battler)
  82.       end
  83.     end
  84.   end  
  85.   #--------------------------------------------------------------------------
  86.   # ● 生成行动循序
  87.   #--------------------------------------------------------------------------
  88.   def make_action_orders
  89.     # 初始化序列 @action_battlers
  90.     @action_battlers = []
  91.     # 添加敌人到 @action_battlers 序列
  92.     for enemy in $game_troop.enemies
  93.       @action_battlers.push(enemy)
  94.     end
  95.     # 添加角色到 @action_battlers 序列
  96.     for actor in 0...[$game_party.actors.size,4].min
  97.       @action_battlers.push($game_party.actors[actor])
  98.     end
  99.     # 确定全体的行动速度
  100.     for battler in @action_battlers
  101.       battler.make_action_speed
  102.     end
  103.     # 按照行动速度从大到小排列
  104.     @action_battlers.sort! {|a,b|
  105.       b.current_action.speed - a.current_action.speed }
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # ● 开始结束战斗回合
  109.   #--------------------------------------------------------------------------
  110.   def start_phase5
  111.     # 转移到回合 5
  112.     @phase = 5
  113.     # 演奏战斗结束 ME
  114.     $game_system.me_play($game_system.battle_end_me)
  115.     # 还原为战斗开始前的 BGM
  116.     $game_system.bgm_play($game_temp.map_bgm)
  117.     # 初始化 EXP、金钱、宝物
  118.     exp = 0
  119.     gold = 0
  120.     treasures = []
  121.     # 循环
  122.     for enemy in $game_troop.enemies
  123.       # 敌人不是隐藏状态的情况下
  124.       unless enemy.hidden
  125.         # 获得 EXP、增加金钱
  126.         exp += enemy.exp
  127.         gold += enemy.gold
  128.         # 出现宝物判定
  129.         if rand(100) < enemy.treasure_prob
  130.           if enemy.item_id > 0
  131.             treasures.push($data_items[enemy.item_id])
  132.           end
  133.           if enemy.weapon_id > 0
  134.             treasures.push($data_weapons[enemy.weapon_id])
  135.           end
  136.           if enemy.armor_id > 0
  137.             treasures.push($data_armors[enemy.armor_id])
  138.           end
  139.         end
  140.       end
  141.     end
  142.     # 限制宝物数为 6 个
  143.     treasures = treasures[0..5]
  144.     # 获得 EXP
  145.     for i in 0...[$game_party.actors.size,4].min
  146.       actor = $game_party.actors[i]
  147.       if actor.cant_get_exp? == false
  148.         last_level = actor.level
  149.         actor.exp += exp
  150.         if actor.level > last_level
  151.           actor.hp = actor.maxhp; actor.sp = actor.maxsp #角色HP SP 等于最大值
  152.           @status_window.level_up(i)
  153.         end
  154.       end
  155.     end
  156.     # 获得金钱
  157.     $game_party.gain_gold(gold)
  158.     # 获得宝物
  159.     for item in treasures
  160.       case item
  161.       when RPG::Item
  162.         $game_party.gain_item(item.id, 1)
  163.       when RPG::Weapon
  164.         $game_party.gain_weapon(item.id, 1)
  165.       when RPG::Armor
  166.         $game_party.gain_armor(item.id, 1)
  167.       end
  168.     end
  169.     # 生成战斗结果窗口
  170.     @result_window = Window_BattleResult.new(exp, gold, treasures)
  171.     # 设置等待计数
  172.     @phase5_wait_count = 100
  173.   end



所有脚本和出现问题如图:

图2可看出来,敌人使用技能时有一定几率打到替补,也就是4个战斗者以外的队友
而且额外队友越多,几率越大。

我知道应该改

when 1  # 敌单体
         
         index = @active_battler.current_action.target_index
         @target_battlers.push($game_party.smooth_target_actor(index))
  
这一段,但不知道怎么改

求大神们帮我改一下,谢谢

1.PNG (3.07 KB, 下载次数: 7)

所有新增脚本

所有新增脚本

2.PNG (466.19 KB, 下载次数: 8)

敌人技能(单体)出现问题

敌人技能(单体)出现问题

3.PNG (3.64 KB, 下载次数: 7)

3.PNG

Lv4.逐梦者 (版主)

梦石
0
星屑
9532
在线时间
5073 小时
注册时间
2013-6-21
帖子
3580

开拓者贵宾剧作品鉴家

2
发表于 2015-6-6 10:06:49 | 只看该作者
初步判断应该是队伍脚本的这里出了问题,Game_Party#random_target_actor没有修正为只攻击活动队员,或者是因为多个脚本对其的重定义。
可以把它改成这样:
RUBY 代码复制
  1. class Game_Party
  2.   def random_target_actor(hp0 = false)
  3.     # 初始化轮流
  4.     roulette = []
  5.     # 循环
  6.     for actor in @actors
  7.       # 符合条件的场合
  8.       #↓增加判断条件
  9.       if (actor.index < 4) && (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
  10.         # 获取角色职业的位置 [位置]
  11.         position = $data_classes[actor.class_id].position
  12.         # 前卫的话 n = 4、中卫的话 n = 3、后卫的话 n = 2
  13.         n = 4 - position
  14.         # 添加角色的轮流 n 回
  15.         n.times do
  16.           roulette.push(actor)
  17.         end
  18.       end
  19.     end
  20.     # 轮流大小为 0 的情况
  21.     if roulette.size == 0
  22.       return nil
  23.     end
  24.     # 转轮盘赌,决定角色
  25.     return roulette[rand(roulette.size)]
  26.   end
  27. end

点评

已解决  发表于 2015-6-6 10:48
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
33079
在线时间
5104 小时
注册时间
2012-11-19
帖子
4878

开拓者

3
发表于 2015-6-6 10:11:16 | 只看该作者
  1. class Game_Party
  2.   #--------------------------------------------------------------------------
  3.   def smooth_target_actor(actor_index)
  4.     # 取得对像
  5.     actor = @actors[actor_index]
  6.     # 对像存在的情况下
  7.     if actor != nil and actor.exist?
  8.       return actor
  9.     end
  10.     # 循环
  11.     for actor in @actors
  12.       next if actor.index > 3  ####################
  13.       # 对像存在的情况下
  14.       if actor.exist?
  15.         return actor
  16.       end
  17.     end
  18.   end
  19. end
复制代码

评分

参与人数 1星屑 +90 收起 理由
RyanBern + 90 目测这个好像有点问题

查看全部评分

xp vx va mv  va mz 各类型脚本/插件定制
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
51 小时
注册时间
2013-1-18
帖子
10
4
 楼主| 发表于 2015-6-6 10:33:13 | 只看该作者
芯☆淡茹水 发表于 2015-6-6 10:11

谢谢,我去试试
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-23 01:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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