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

Project1

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

[已经解决] 请教设置当敌人有第15号状态时50%几率发动第8号技能的方法

[复制链接]

Lv4.逐梦者

梦石
0
星屑
9128
在线时间
463 小时
注册时间
2015-5-8
帖子
865
跳转到指定楼层
1
发表于 2022-3-1 10:19:06 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 taeckle 于 2022-3-3 06:40 编辑

数据里没有根据敌人自身状态设置行为的选项,

所以我想自己做个根据敌人自身状态设置发动某个技能,比如我想让1到40号敌人在有第15号状态的情况下50%几率发动第8号技能

还请大家指点一二,多谢了!

敌人行为设置_数据库.png (42.25 KB, 下载次数: 5)

敌人行为设置_数据库.png

Lv5.捕梦者

梦石
0
星屑
37819
在线时间
5410 小时
注册时间
2006-11-10
帖子
6547
2
发表于 2022-3-1 10:50:55 | 只看该作者
本帖最后由 灯笼菜刀王 于 2022-3-1 11:11 编辑

首先, 把猫大的这个脚本塞进去 https://rpg.blue/thread-488418-1-1.html

然后, 把这个脚本塞到main前
  1. def emy_use?
  2.   return false if !$game_temp.in_battle
  3.   return false if (a = $scene.instance_variable_get(:@active_battler)).nil?
  4.   return false if !a.is_a?(Game_Enemy)
  5.   return false if !(1..40).include?(a.id)
  6.   return false if !a.stete?(2)
  7.   return false if rand(100) < 50
  8.   return true
  9. end
  10. class Scene_Battle
  11.   alias oxox_update_phase4_step1 update_phase4_step1
  12.   def update_phase4_step1
  13.     oxox_update_phase4_step1
  14.     @active_battler.make_action if @active_battler.is_a?(Game_Enemy)
  15.   end
  16. end
复制代码


然后找个开关 把名字改成  =emy_use?

然后, 把你要释放的技能, 出现条件里调用这个开关, 搞定收工

点评

这位不会举一反三,也不会自己思考解法, 所以, 我直接给答案, 而这个用法也是猫大的那个脚本最精彩的地方, 不用改原本结构就可以实现复杂条件  发表于 2022-3-1 14:58
然后你不会发现他三年前就问过差不多的问题https://rpg.blue/thread-477797-1-1.html  发表于 2022-3-1 12:39

评分

参与人数 2星屑 +50 +2 收起 理由
RyanBern + 50 + 1 认可答案
taeckle + 1 多谢大神指点!

查看全部评分

回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9128
在线时间
463 小时
注册时间
2015-5-8
帖子
865
3
 楼主| 发表于 2022-3-3 06:52:45 | 只看该作者
本帖最后由 taeckle 于 2022-3-3 11:08 编辑
灯笼菜刀王 发表于 2022-3-1 10:50
首先, 把猫大的这个脚本塞进去 https://rpg.blue/thread-488418-1-1.html

然后, 把这个脚本塞到main前


大神我自己用了一个比较笨的方法也能达到相同的目的,还请大神过目:
在默认脚本中找到Game_Enemy类下的def make_action, 然后用下面的代码替换掉整个默认def make_action:

  1.   def make_action
  2.     # 清除当前行动
  3.     self.current_action.clear
  4.     # 无法行动的情况
  5.     unless self.movable?
  6.       # 过程结束
  7.       return
  8.     end
  9.     # 抽取现在有效的行动
  10.     available_actions = []
  11.     rating_max = 0
  12.     for action in self.actions
  13.       # 确认回合条件
  14.       n = $game_temp.battle_turn
  15.       a = action.condition_turn_a
  16.       b = action.condition_turn_b
  17.       if (b == 0 and n != a) or
  18.          (b > 0 and (n < 1 or n < a or n % b != a % b))
  19.         next
  20.       end
  21.       # 确认 HP 条件
  22.       if self.hp * 100.0 / self.maxhp > action.condition_hp
  23.         next
  24.       end
  25.       # 确认等级条件
  26.       if $game_party.max_level < action.condition_level
  27.         next
  28.       end
  29.       # 确认开关条件
  30.       switch_id = action.condition_switch_id
  31.       if switch_id > 0 and $game_switches[switch_id] == false
  32.         next
  33.       end
  34.       # 符合条件 : 添加本行动
  35.       available_actions.push(action)
  36.       if action.rating > rating_max
  37.         rating_max = action.rating
  38.       end
  39.     end
  40.     # 最大概率值作为 3 合计计算(0 除外)
  41.     ratings_total = 0
  42.     for action in available_actions
  43.       if action.rating > rating_max - 3
  44.         ratings_total += action.rating - (rating_max - 3)
  45.       end
  46.     end
  47.     #下面是我自己做的改动
  48.     if (1..40).to_a.include?(self.id)  #第1至40号敌人
  49.      if rand(100)<50 && self.state?(15) #有15号状态且50%时
  50.           self.current_action.kind = 1
  51.           self.current_action.basic = 0
  52.           self.current_action.skill_id = 8
  53.           self.current_action.decide_random_target_for_enemy
  54.           return
  55.      else
  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.     else
  76.      if ratings_total > 0
  77.       # 生成随机数
  78.       value = rand(ratings_total)
  79.       # 设置对应生成随机数的当前行动
  80.       for action in available_actions
  81.         if action.rating > rating_max - 3
  82.           if value < action.rating - (rating_max - 3)
  83.            self.current_action.kind = action.kind
  84.            self.current_action.basic = action.basic
  85.            self.current_action.skill_id = action.skill_id
  86.            self.current_action.decide_random_target_for_enemy
  87.            return
  88.           else
  89.            value -= action.rating - (rating_max - 3)
  90.           end
  91.         end
  92.       end
  93.      end
  94.     end      
  95.   end
复制代码

点评

大神请问下我这个笨方法还有哪些需要注意的地方啊?  发表于 2022-3-3 16:58
所以人家大大教了你高端实用的方法你为什么又要用笨方法自己搞  发表于 2022-3-3 14:50
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-30 03:09

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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