查看: 1033|回复: 3

[有事请教] 敌方sp不足仍旧可以使用技能

[复制链接]
梦石
0
星屑
579
在线时间
83 小时
注册时间
2021-3-17
回帖
40
发表于 2025-6-19 16:54:06 | 显示全部楼层 |阅读模式

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

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

×
如题,使用技能会消耗sp值,当sp不足(技能消耗的sp大于剩余sp)时,技能将无法使用,如何对敌人也有效,我在 Game_Battler 3设置了,对我方有效,敌人sp不足时还能使用,如何解决

素材区好人

梦石
5
星屑
12559
在线时间
4345 小时
注册时间
2011-7-21
回帖
2264

超评测参与极短28参与极短27参与极短26参与极短25参与极短24参与极短23参与极短22参与极短21参与

发表于 2025-6-20 08:24:34 | 显示全部楼层
当敌人MP不足以发动某项技能时,便不会执行发动该技能的操作(哪怕把该技能的优先级拉满)
[pre lang="ruby"]class Game_Enemy
  def make_action
    # 清除当前行动
    self.current_action.clear
    # 无法行动的情况
    unless self.movable?
      # 过程结束
      return
    end
    # 抽取现在有效的行动
    available_actions = []
    rating_max = 0
    for action in self.actions
      # 确认回合条件
      n = $game_temp.battle_turn
      a = action.condition_turn_a
      b = action.condition_turn_b
      if (b == 0 and n != a) or
         (b > 0 and (n < 1 or n < a or n % b != a % b))
        next
      end
#=====
      if action.kind == 1
        if self.sp < $data_skills[action.skill_id].sp_cost
          next
        end
      end
#=====
      # 确认 HP 条件
      if self.hp * 100.0 / self.maxhp > action.condition_hp
        next
      end
      # 确认等级条件
      if $game_party.max_level < action.condition_level
        next
      end
      # 确认开关条件
      switch_id = action.condition_switch_id
      if switch_id > 0 and $game_switches[switch_id] == false
        next
      end
      # 符合条件 : 添加本行动
      available_actions.push(action)
      if action.rating > rating_max
        rating_max = action.rating
      end
    end
    # 最大概率值作为 3 合计计算(0 除外)
    ratings_total = 0
    for action in available_actions
      if action.rating > rating_max - 3
        ratings_total += action.rating - (rating_max - 3)
      end
    end
    # 概率合计不为 0 的情况下
    if ratings_total > 0
      # 生成随机数
      value = rand(ratings_total)
      # 设置对应生成随机数的当前行动
      for action in available_actions
        if action.rating > rating_max - 3
          if value < action.rating - (rating_max - 3)
            self.current_action.kind = action.kind
            self.current_action.basic = action.basic
            self.current_action.skill_id = action.skill_id
            self.current_action.decide_random_target_for_enemy
            return
          else
            value -= action.rating - (rating_max - 3)
          end
        end
      end
    end
  end
end[/pre]
回复

使用道具 举报

梦石
0
星屑
39236
在线时间
11155 小时
注册时间
2009-3-15
回帖
4768
发表于 2025-6-20 18:27:58 | 显示全部楼层
本帖最后由 soulsaga 于 2025-6-22 05:24 编辑

原来敌人SP不足也会抽到技能但是会变成不能行动
回复

使用道具 举报

梦石
0
星屑
579
在线时间
83 小时
注册时间
2021-3-17
回帖
40
 楼主| 发表于 2025-6-21 14:53:57 | 显示全部楼层
搞定了。大佬威武
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部