查看: 2481|回复: 3

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

[复制链接]
梦石
0
星屑
50
在线时间
51 小时
注册时间
2013-1-18
回帖
6
发表于 2015-6-6 09:48:58 | 显示全部楼层 |阅读模式

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

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

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

脚本如下:

[pre lang="Ruby"]#--------------------------------------------------------------------------
  # ● 设置物品或特技对像方的战斗者
  #     scope : 特技或者是物品的范围
  #--------------------------------------------------------------------------
  def set_target_battlers(scope)
    # 行动方的战斗者是敌人的情况下
    if @active_battler.is_a?(Game_Enemy)
      # 效果范围分支
      case scope
      when 1  # 敌单体
         
         index = @active_battler.current_action.target_index
         @target_battlers.push($game_party.smooth_target_actor(index))
  
      when 2  # 敌全体
        for actor in 0...[$game_party.actors.size,4].min
          if $game_party.actors[actor].exist?
            @target_battlers.push($game_party.actors[actor])
          end
        end
      when 3  # 我方单体
        index = @active_battler.current_action.target_index
        @target_battlers.push($game_troop.smooth_target_enemy(index))
      when 4  # 我方全体
        for enemy in $game_troop.enemies
          if enemy.exist?
            @target_battlers.push(enemy)
          end
        end
      when 5  # 我方单体 (HP 0)
        index = @active_battler.current_action.target_index
        enemy = $game_troop.enemies[index]
        if enemy != nil and enemy.hp0?
          @target_battlers.push(enemy)
        end
      when 6  # 我方全体 (HP 0)
        for enemy in $game_troop.enemies
          if enemy != nil and enemy.hp0?
            @target_battlers.push(enemy)
          end
        end
      when 7  # 使用者
        @target_battlers.push(@active_battler)
      end
    end
    # 行动方的战斗者是角色的情况下
    if @active_battler.is_a?(Game_Actor)
      # 效果范围分支
      case scope
      when 1  # 敌单体
        index = @active_battler.current_action.target_index
        @target_battlers.push($game_troop.smooth_target_enemy(index))
      when 2  # 敌全体
        for enemy in $game_troop.enemies
          if enemy.exist?
            @target_battlers.push(enemy)
          end
        end
      when 3  # 我方单体
        index = @active_battler.current_action.target_index
        @target_battlers.push($game_party.smooth_target_actor(index))
      when 4  # 我方全体
        for actor in 0...[$game_party.actors.size,4].min
          if $game_party.actors[actor].exist?
            @target_battlers.push($game_party.actors[actor])
          end
        end
      when 5  # 我方单体 (HP 0)
        index = @active_battler.current_action.target_index
        actor = $game_party.actors[index]
        if actor != nil and actor.hp0?
          @target_battlers.push(actor)
        end
      when 6  # 我方全体 (HP 0)
        for actor in 0...[$game_party.actors.size,4].min
          if $game_party.actors[actor] != nil and $game_party.actors[actor].hp0?
            @target_battlers.push($game_party.actors[actor])
          end
        end
      when 7  # 使用者
        @target_battlers.push(@active_battler)
      end
    end
  end  
  #--------------------------------------------------------------------------
  # ● 生成行动循序
  #--------------------------------------------------------------------------
  def make_action_orders
    # 初始化序列 @action_battlers
    @action_battlers = []
    # 添加敌人到 @action_battlers 序列
    for enemy in $game_troop.enemies
      @action_battlers.push(enemy)
    end
    # 添加角色到 @action_battlers 序列
    for actor in 0...[$game_party.actors.size,4].min
      @action_battlers.push($game_party.actors[actor])
    end
    # 确定全体的行动速度
    for battler in @action_battlers
      battler.make_action_speed
    end
    # 按照行动速度从大到小排列
    @action_battlers.sort! {|a,b|
      b.current_action.speed - a.current_action.speed }
  end
  #--------------------------------------------------------------------------
  # ● 开始结束战斗回合
  #--------------------------------------------------------------------------
  def start_phase5
    # 转移到回合 5
    @phase = 5
    # 演奏战斗结束 ME
    $game_system.me_play($game_system.battle_end_me)
    # 还原为战斗开始前的 BGM
    $game_system.bgm_play($game_temp.map_bgm)
    # 初始化 EXP、金钱、宝物
    exp = 0
    gold = 0
    treasures = []
    # 循环
    for enemy in $game_troop.enemies
      # 敌人不是隐藏状态的情况下
      unless enemy.hidden
        # 获得 EXP、增加金钱
        exp += enemy.exp
        gold += enemy.gold
        # 出现宝物判定
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end
      end
    end
    # 限制宝物数为 6 个
    treasures = treasures[0..5]
    # 获得 EXP
    for i in 0...[$game_party.actors.size,4].min
      actor = $game_party.actors
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp
        if actor.level > last_level
          actor.hp = actor.maxhp; actor.sp = actor.maxsp #角色HP SP 等于最大值
          @status_window.level_up(i)
        end
      end
    end
    # 获得金钱
    $game_party.gain_gold(gold)
    # 获得宝物
    for item in treasures
      case item
      when RPG::Item
        $game_party.gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.gain_armor(item.id, 1)
      end
    end
    # 生成战斗结果窗口
    @result_window = Window_BattleResult.new(exp, gold, treasures)
    # 设置等待计数
    @phase5_wait_count = 100
  end[/pre]


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

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

我知道应该改

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

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

所有新增脚本

所有新增脚本

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

敌人技能(单体)出现问题
3.PNG
梦石
0
星屑
9557
在线时间
5074 小时
注册时间
2013-6-21
回帖
3459

开拓者贵宾剧作品鉴家

发表于 2015-6-6 10:06:49 | 显示全部楼层
初步判断应该是队伍脚本的这里出了问题,Game_Party#random_target_actor没有修正为只攻击活动队员,或者是因为多个脚本对其的重定义。
可以把它改成这样:
[pre lang="Ruby"]class Game_Party
  def random_target_actor(hp0 = false)
    # 初始化轮流
    roulette = []
    # 循环
    for actor in @actors
      # 符合条件的场合
      #↓增加判断条件
      if (actor.index < 4) && (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
        # 获取角色职业的位置 [位置]
        position = $data_classes[actor.class_id].position
        # 前卫的话 n = 4、中卫的话 n = 3、后卫的话 n = 2
        n = 4 - position
        # 添加角色的轮流 n 回
        n.times do
          roulette.push(actor)
        end
      end
    end
    # 轮流大小为 0 的情况
    if roulette.size == 0
      return nil
    end
    # 转轮盘赌,决定角色
    return roulette[rand(roulette.size)]
  end
end[/pre]

点评

已解决  发表于 2015-6-6 10:48
回复

使用道具 举报

梦石
0
星屑
34462
在线时间
5096 小时
注册时间
2012-11-19
回帖
4715

开拓者

发表于 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 各类型脚本/插件定制
回复

使用道具 举报

梦石
0
星屑
50
在线时间
51 小时
注册时间
2013-1-18
回帖
6
 楼主| 发表于 2015-6-6 10:33:13 | 显示全部楼层
芯☆淡茹水 发表于 2015-6-6 10:11

谢谢,我去试试
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部