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

Project1

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

[已经过期] 梦幻多体攻击冲突,不使用就不出现问题

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1237
在线时间
163 小时
注册时间
2019-10-4
帖子
217
跳转到指定楼层
1
发表于 2023-1-8 16:45:50 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
RUBY 代码复制
  1. class Scene_Battle
  2.   def set_target_battlers(item, type)
  3.  
  4.     @多秒_特技 = {} # 初始化多秒功能哈希
  5.     @多秒_物品 = {} # 初始化多秒功能哈希
  6.  
  7.     # ---------------------------
  8.     # 特技多秒 设置
  9.     # ---------------------------
  10.  
  11.     @多秒_特技[57] = 3 # 57号技能 秒3 默认十字斩秒三
  12.     @多秒_特技[29] = 4
  13.     @多秒_特技[95] = 2
  14.     @多秒_特技[106] = 2
  15.     # ---------------------------
  16.     # 物品多秒 设置
  17.     # ---------------------------
  18.  
  19.     @多秒_物品[40] = 5 # 40号物品 秒5 设置 : 敌单体即可 HP 回复量 为负值
  20.  
  21.     # ------------------------------------------------------
  22.     # PS 如果设置了多秒 数据库 中效果范围怎么设置都可以
  23.     # 但必须明确是对敌使用还是对同伴使用,并且明确 是否
  24.     # HP 0 时使用!
  25.     # ------------------------------------------------------
  26.  
  27.     if @active_battler.is_a?(Game_Enemy)
  28.       case item.scope
  29.       when 1  # 敌单体
  30.         index = @active_battler.current_action.target_index
  31.         @target_battlers.push($game_party.smooth_target_actor(index))
  32.         敌方秒(0, item, 0, type, $game_party.smooth_target_actor(index))
  33.       when 2  # 敌全体
  34.         index = @active_battler.current_action.target_index
  35.         for actor in $game_party.actors
  36.           if actor.exist?
  37.             @target_battlers.push(actor)
  38.           end
  39.         end
  40.         敌方秒(0, item, 0, type, $game_party.smooth_target_actor(index))
  41.       when 3  # 我方单体
  42.         index = @active_battler.current_action.target_index
  43.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  44.         敌方秒(0, item, 1, type, $game_troop.smooth_target_enemy(index))
  45.       when 4  # 我方全体
  46.         index = @active_battler.current_action.target_index
  47.         for enemy in $game_troop.enemies
  48.           if enemy.exist?
  49.             @target_battlers.push(enemy)
  50.           end
  51.         end
  52.         敌方秒(0, item, 1, type, $game_troop.smooth_target_enemy(index))
  53.       when 5  # 我方单体 (HP 0)
  54.         index = @active_battler.current_action.target_index
  55.         enemy = $game_troop.enemies[index]
  56.         if enemy != nil and enemy.hp0?
  57.           @target_battlers.push(enemy)
  58.         end
  59.         敌方秒(1, item, 1, type, $game_troop.smooth_target_enemy(index))
  60.       when 6  # 我方全体 (HP 0)
  61.         index = @active_battler.current_action.target_index
  62.         for enemy in $game_troop.enemies
  63.           if enemy != nil and enemy.hp0?
  64.             @target_battlers.push(enemy)
  65.           end
  66.         end
  67.         敌方秒(1, item, 1, type, $game_troop.smooth_target_enemy(index))
  68.       when 7  # 使用者
  69.         @target_battlers.push(@active_battler)
  70.       end
  71.     end
  72.     if @active_battler.is_a?(Game_Actor)
  73.       # 效果范围分支
  74.       case item.scope
  75.       when 1  # 敌单体
  76.         index = @active_battler.current_action.target_index
  77.         @target_battlers.push($game_troop.smooth_target_enemy(index))
  78.         我方秒(0, item, 0, type, $game_troop.smooth_target_enemy(index))
  79.       when 2  # 敌全体
  80.         index = @active_battler.current_action.target_index
  81.         for enemy in $game_troop.enemies
  82.           if enemy.exist?
  83.             @target_battlers.push(enemy)
  84.           end
  85.         end
  86.         我方秒(0, item, 0, type, $game_troop.smooth_target_enemy(index))
  87.       when 3  # 我方单体
  88.         index = @active_battler.current_action.target_index
  89.         @target_battlers.push($game_party.smooth_target_actor(index))
  90.         我方秒(0, item, 1, type, $game_party.smooth_target_actor(index))
  91.       when 4  # 我方全体
  92.         index = @active_battler.current_action.target_index
  93.         for actor in $game_party.actors
  94.           if actor.exist?
  95.             @target_battlers.push(actor)
  96.           end
  97.         end
  98.         我方秒(0, item, 1, type, $game_party.smooth_target_actor(index))
  99.       when 5  # 我方单体 (HP 0)
  100.         index = @active_battler.current_action.target_index
  101.         actor = $game_party.actors[index]
  102.         if actor != nil and actor.hp0?
  103.           @target_battlers.push(actor)
  104.         end
  105.         我方秒(1, item, 1, type, $game_party.smooth_target_actor(index))
  106.       when 6  # 我方全体 (HP 0)
  107.         index = @active_battler.current_action.target_index
  108.         for actor in $game_party.actors
  109.           if actor != nil and actor.hp0?
  110.             @target_battlers.push(actor)
  111.           end
  112.         end
  113.         我方秒(1, item, 1, type, $game_party.smooth_target_actor(index))
  114.       when 7  # 使用者
  115.         @target_battlers.push(@active_battler)
  116.       end
  117.     end
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # ● 生成特技行动结果
  121.   #--------------------------------------------------------------------------
  122.   def make_skill_action_result
  123.     # 获取特技
  124.     @skill = $data_skills[@active_battler.current_action.skill_id]
  125.     # 如果不是强制行动
  126.     unless @active_battler.current_action.forcing
  127.       # 因为 SP 耗尽而无法使用的情况下
  128.       unless @active_battler.skill_can_use?(@skill.id)
  129.         # 清除强制行动对像的战斗者
  130.         $game_temp.forcing_battler = nil
  131.         # 移至步骤 1
  132.         @phase4_step = 1
  133.         return
  134.       end
  135.     end
  136.     # 消耗 SP
  137.     @active_battler.sp -= @skill.sp_cost
  138.     # 刷新状态窗口
  139.     @status_window.refresh
  140.     # 在帮助窗口显示特技名
  141.     @help_window.set_text(@skill.name, 1)
  142.     # 设置动画 ID
  143.     @animation1_id = @skill.animation1_id
  144.     @animation2_id = @skill.animation2_id
  145.     # 设置公共事件 ID
  146.     @common_event_id = @skill.common_event_id
  147.     # 设置对像侧战斗者
  148.  
  149.     # ---------------------------------------
  150.     set_target_battlers(@skill, 0)
  151.     # ---------------------------------------
  152.  
  153.     # 应用特技效果
  154.     for target in @target_battlers
  155.       target.skill_effect(@active_battler, @skill)
  156.     end
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # ● 生成物品行动结果
  160.   #--------------------------------------------------------------------------
  161.   def make_item_action_result
  162.     # 获取物品
  163.     @item = $data_items[@active_battler.current_action.item_id]
  164.     # 因为物品耗尽而无法使用的情况下
  165.     unless $game_party.item_can_use?(@item.id)
  166.       # 移至步骤 1
  167.       @phase4_step = 1
  168.       return
  169.     end
  170.     # 消耗品的情况下
  171.     if @item.consumable
  172.       # 使用的物品减 1
  173.       $game_party.lose_item(@item.id, 1)
  174.     end
  175.     # 在帮助窗口显示物品名
  176.     @help_window.set_text(@item.name, 1)
  177.     # 设置动画 ID
  178.     @animation1_id = @item.animation1_id
  179.     @animation2_id = @item.animation2_id
  180.     # 设置公共事件 ID
  181.     @common_event_id = @item.common_event_id
  182.     # 确定对像
  183.     index = @active_battler.current_action.target_index
  184.     target = $game_party.smooth_target_actor(index)
  185.     # 设置对像侧战斗者
  186.  
  187.     # ---------------------------------------
  188.     set_target_battlers(@item, 1)
  189.     # ---------------------------------------
  190.  
  191.     # 应用物品效果
  192.     for target in @target_battlers
  193.       target.item_effect(@item)
  194.     end
  195.   end
  196.  
  197.   def 敌方秒(n, item, t, type, 目标)
  198.     # ----------------------------------------
  199.     return if @多秒_特技[item.id].nil? and @多秒_物品[item.id].nil?
  200.     @target_battlers = []
  201.     case t
  202.     when 0
  203.       for actor in $game_party.actors
  204.         @target_battlers.push(actor) if actor.exist?
  205.       end
  206.     when 1
  207.       for enemy in $game_troop.enemies
  208.         @target_battlers.push(enemy) if enemy.exist?
  209.       end
  210.     end
  211.     return if @多秒_特技[item.id] > @target_battlers.size#>=把等号去掉了
  212.     while @target_battlers.size > @多秒_特技[item.id]
  213.       a = rand(@target_battlers.size)
  214.       unless a == @target_battlers.size - 1 or
  215.         # 如果用了我发布的嘲讽状态脚本 请把后边的注释去掉!
  216.         @target_battlers[a] == 目标 #or @target_battlers[a].state? Wall
  217.         @target_battlers.delete_at(a)
  218.       end
  219.     end
  220.     # -------------------------------------------
  221.   end
  222.   #   参数   是否hp0 项目 对敌还是对友 特技还是物品 目标
  223.   def 我方秒(n, item, t, type, 目标)
  224.     # ----------------------------------------
  225.     return if @多秒_特技[item.id].nil? and @多秒_物品[item.id].nil?
  226.     @target_battlers = []
  227.     case type
  228.     when 0 # 特技
  229.       case t
  230.       when 0
  231.         for enemy in $game_troop.enemies
  232.           case n
  233.           when 0
  234.             @target_battlers.push(enemy) if enemy.exist?
  235.           when 1
  236.             @target_battlers.push(enemy) unless enemy.exist?
  237.           end
  238.         end
  239.       when 1
  240.         for actor in $game_party.actors
  241.           case n
  242.           when 0
  243.             @target_battlers.push(actor) if actor.exist?
  244.           when 1
  245.             @target_battlers.push(actor) unless actor.exist?
  246.           end
  247.         end
  248.       end
  249.       return if @多秒_特技[item.id] >= @target_battlers.size
  250.       while @target_battlers.size > @多秒_特技[item.id]
  251.         a = rand(@target_battlers.size)
  252.         unless a == @target_battlers.size - 1 or
  253.           @target_battlers[a] == 目标
  254.           @target_battlers.delete_at(a)
  255.         end
  256.       end
  257.     when 1 # 物品
  258.       case t
  259.       when 0
  260.         for enemy in $game_troop.enemies
  261.           case n
  262.           when 0
  263.             @target_battlers.push(enemy) if enemy.exist?
  264.           when 1
  265.             @target_battlers.push(enemy) unless enemy.exist?
  266.           end
  267.         end
  268.       when 1
  269.         for actor in $game_party.actors[attach]395710[/attach]
  270.           case n
  271.           when 0
  272.             @target_battlers.push(actor) if actor.exist?
  273.           when 1
  274.             @target_battlers.push(actor) unless actor.exist?
  275.           end
  276.         end
  277.       end
  278.       return if @多秒_物品[item.id] >= @target_battlers.size
  279.       while @target_battlers.size > @多秒_物品[item.id]
  280.         a = rand(@target_battlers.size)
  281.         unless a == @target_battlers.size - 1 or
  282.           @target_battlers[a] == 目标
  283.           @target_battlers.delete_at(a)
  284.         end
  285.       end
  286.     end
  287.     # ----------------------------------------
  288.   end
  289.  
  290. end
用了多秒,偶尔会出现问题,能拯救一下也好,或者跳过这个BUG

Lv3.寻梦者

梦石
0
星屑
3841
在线时间
1966 小时
注册时间
2013-1-3
帖子
9536
2
发表于 2023-1-12 15:20:46 | 只看该作者
我半天才整明白这是个什么意思……
以后提问描述清楚点 这论坛本来就人少而且高手不多
你上来贴个脚本 不解释没多少人看的……
和 >= 没关系,>=是判断目标人数和设定攻击人数的
提示是“没有方法定义”,是不是有的技能没加入哈希表里?导致读取出的数值为nil
我这里测试没什么问题 以上为猜测
《宿愿·寻剑篇》正式版已经发布!快去看看!点击进入论坛发布贴
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-28 14:02

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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