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

Project1

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

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

[复制链接]

Lv2.观梦者

梦石
0
星屑
754
在线时间
61 小时
注册时间
2021-3-17
帖子
39
跳转到指定楼层
1
发表于 前天 16:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

Lv4.逐梦者

素材区好人

梦石
3
星屑
8252
在线时间
3639 小时
注册时间
2011-7-21
帖子
2317

极短25参与极短24参与极短23参与极短22参与极短21参与

2
发表于 昨天 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
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
37240
在线时间
10839 小时
注册时间
2009-3-15
帖子
4862
3
发表于 昨天 18:27 | 只看该作者
本帖最后由 soulsaga 于 2025-6-20 18:31 编辑

???????原版敌人sp不足是无法使用技能的
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-6-21 11:29

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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