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

Project1

 找回密码
 注册会员
搜索
查看: 3227|回复: 5

[讨论] 敌人行动条件修改

[复制链接]

Lv5.捕梦者

梦石
0
星屑
33038
在线时间
10469 小时
注册时间
2009-3-15
帖子
4756
发表于 2018-12-23 15:50:27 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 soulsaga 于 2018-12-23 23:08 编辑

RUBY 代码复制
  1. STATEIF = [1,2,3]#判断的状态ID
  2.  
  3. class Game_Enemy < Game_Battler
  4. #--------------------------------------------------------------------------
  5. # ● 生成行动
  6. #--------------------------------------------------------------------------
  7. def make_action
  8. # 清除当前行动
  9. self.current_action.clear
  10. # 无法行动的情况
  11. unless self.movable?
  12. # 过程结束
  13. return
  14. end
  15. # 抽取现在有效的行动
  16. available_actions = []
  17. rating_max = 0
  18. for action in self.actions
  19. # 确认回合条件
  20. n = $game_temp.battle_turn
  21. a = action.condition_turn_a
  22. b = action.condition_turn_b
  23. if (b == 0 and n != a) or
  24. (b > 0 and (n < 1 or n < a or n % b != a % b))
  25. next
  26. end
  27. # 确认 HP 条件
  28. if self.hp * 100.0 / self.maxhp > action.condition_hp
  29. next
  30. end
  31. # 确认等级条件
  32. if $game_party.max_level < action.condition_level
  33. next
  34. end
  35. # 确认开关条件
  36. switch_id = action.condition_switch_id
  37. if switch_id > 0 and $game_switches[switch_id] == false
  38. next
  39. end
  40. # 确认状态条件BY:灯笼菜刀王修改
  41. next if $game_switches[switch_id] and (STATEIF & self.states).empty?
  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


用法:敌人行动条件随便打勾一个开关,当敌人拥有1或2或3号状态时才许可使用该技能 1,2,3,可以自行修改

评分

参与人数 2+2 收起 理由
asd5891037 + 1 我很赞同
张咚咚 + 1 精品文章

查看全部评分

Lv4.逐梦者 (版主)

梦石
0
星屑
9467
在线时间
5073 小时
注册时间
2013-6-21
帖子
3580

开拓者贵宾剧作品鉴家

发表于 2018-12-23 22:56:43 | 显示全部楼层
能否加上一些转载的来源呢?

点评

基本是我改的..只是发到群里被脚本大神指点了其他更简浩的用法就改成现在这样了..  发表于 2018-12-24 13:44
按照比较死板的道理说是不能“分享”这种没有注明任何来源的脚本素材。比较好的做法可以是自己重写一个然后按照原创发布来算。  发表于 2018-12-23 23:11
是在群里讨论坛得出来的..  发表于 2018-12-23 23:08
没有来源啊..只是没有分享这个分类又不是原创就只能用转载了..  发表于 2018-12-23 23:03
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-29 08:59

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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