Project1

标题: 敌方sp不足仍旧可以使用技能 [打印本页]

作者: 青梅不酸    时间: 3 天前
标题: 敌方sp不足仍旧可以使用技能
如题,使用技能会消耗sp值,当sp不足(技能消耗的sp大于剩余sp)时,技能将无法使用,如何对敌人也有效,我在 Game_Battler 3设置了,对我方有效,敌人sp不足时还能使用,如何解决
作者: 无忧谷主幻    时间: 前天 08:24
当敌人MP不足以发动某项技能时,便不会执行发动该技能的操作(哪怕把该技能的优先级拉满)
RUBY 代码复制
  1. class Game_Enemy
  2.   def make_action
  3.     # 清除当前行动
  4.     self.current_action.clear
  5.     # 无法行动的情况
  6.     unless self.movable?
  7.       # 过程结束
  8.       return
  9.     end
  10.     # 抽取现在有效的行动
  11.     available_actions = []
  12.     rating_max = 0
  13.     for action in self.actions
  14.       # 确认回合条件
  15.       n = $game_temp.battle_turn
  16.       a = action.condition_turn_a
  17.       b = action.condition_turn_b
  18.       if (b == 0 and n != a) or
  19.          (b > 0 and (n < 1 or n < a or n % b != a % b))
  20.         next
  21.       end
  22. #=====
  23.       if action.kind == 1
  24.         if self.sp < $data_skills[action.skill_id].sp_cost
  25.           next
  26.         end
  27.       end
  28. #=====
  29.       # 确认 HP 条件
  30.       if self.hp * 100.0 / self.maxhp > action.condition_hp
  31.         next
  32.       end
  33.       # 确认等级条件
  34.       if $game_party.max_level < action.condition_level
  35.         next
  36.       end
  37.       # 确认开关条件
  38.       switch_id = action.condition_switch_id
  39.       if switch_id > 0 and $game_switches[switch_id] == false
  40.         next
  41.       end
  42.       # 符合条件 : 添加本行动
  43.       available_actions.push(action)
  44.       if action.rating > rating_max
  45.         rating_max = action.rating
  46.       end
  47.     end
  48.     # 最大概率值作为 3 合计计算(0 除外)
  49.     ratings_total = 0
  50.     for action in available_actions
  51.       if action.rating > rating_max - 3
  52.         ratings_total += action.rating - (rating_max - 3)
  53.       end
  54.     end
  55.     # 概率合计不为 0 的情况下
  56.     if ratings_total > 0
  57.       # 生成随机数
  58.       value = rand(ratings_total)
  59.       # 设置对应生成随机数的当前行动
  60.       for action in available_actions
  61.         if action.rating > rating_max - 3
  62.           if value < action.rating - (rating_max - 3)
  63.             self.current_action.kind = action.kind
  64.             self.current_action.basic = action.basic
  65.             self.current_action.skill_id = action.skill_id
  66.             self.current_action.decide_random_target_for_enemy
  67.             return
  68.           else
  69.             value -= action.rating - (rating_max - 3)
  70.           end
  71.         end
  72.       end
  73.     end
  74.   end
  75. end

作者: soulsaga    时间: 前天 18:27
本帖最后由 soulsaga 于 2025-6-20 18:31 编辑

???????原版敌人sp不足是无法使用技能的
作者: 青梅不酸    时间: 昨天 14:53
搞定了。大佬威武




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1