幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1845|回复: 4

[原创]角色AI自动战斗系统0.1

[复制链接]

4

主题

109

帖子

2494

积分

⑥精研

不灌水者

积分
2494
发表于 2006-8-12 16:22:53 | 显示全部楼层 |阅读模式
好像没人写过AI系统吧,,,写了个简单的,所以智商比较低,以后有时间再提高吧~~
  1. #==============================================================================
  2. # ■ AI系统 Ver0.1
  3. #------------------------------------------------------------------------------
  4. # by: 蟋蟀
  5. # blog: [url]http://hi.baidu.com/hdzx[/url]
  6. #==============================================================================
  7. #说明
  8. #插入Main前,先在数据库设置一个叫“自动状态”的状态(改什么名随便你拉)
  9. #记住它的ID,然后设置AUTO=(状态的ID)
  10. #想使某队员处于自动战斗,只要让某队员变为“自动战斗”的状态即可
  11. #目前AI智商为10(跟敌人一样)并且只能攻击和防御
  12. #我以后用空会把智商提高点?
  13. AUTO= id #把id改为“自动战斗”的ID
  14. class Game_Actor
  15.   
  16. def make_action
  17. self.current_action.clear
  18. # 设置对应生成随机数的当前行动
  19. vv=rand(2)
  20. case vv
  21. when 0
  22. self.current_action.kind = 0
  23. self.current_action.basic = 0
  24. when 1
  25. self.current_action.kind = 0
  26. self.current_action.basic = 1
  27. when 2
  28. self.current_action.kind = 1
  29. self.current_action.skill_id = action.skill_id
  30. return
  31. end
  32. end
  33. end
  34. class Scene_Battle
  35. def phase3_next_actor
  36. begin
  37. if @active_battler != nil
  38. @active_battler.blink = false
  39. end
  40. if @actor_index == $game_party.actors.size-1
  41. start_phase4
  42. return
  43. end
  44. @actor_index += 1
  45. @active_battler = $game_party.actors[@actor_index]
  46. @active_battler.blink = true
  47. end until @active_battler.inputable?
  48. if @active_battler.states.include?(AUTO)
  49. @active_battler.make_action
  50. phase3_next_actor
  51. else
  52. phase3_setup_command_window
  53. end
  54. end
  55. def make_basic_action_result
  56. if @active_battler.current_action.basic == 0
  57. @animation1_id = @active_battler.animation1_id
  58. @animation2_id = @active_battler.animation2_id
  59. if @active_battler.is_a?(Game_Enemy)
  60. if @active_battler.restriction == 3
  61. target = $game_troop.random_target_enemy
  62. elsif @active_battler.restriction == 2
  63. target = $game_party.random_target_actor
  64. else
  65. index = @active_battler.current_action.target_index
  66. target = $game_party.smooth_target_actor(index)
  67. end
  68. end
  69. if @active_battler.is_a?(Game_Actor)
  70. if @active_battler.restriction == 3
  71. target = $game_party.random_target_actor
  72. elsif @active_battler.restriction == 2
  73. target = $game_troop.random_target_enemy
  74. elsif @active_battler.states.include?(AUTO)
  75. target = $game_troop.random_target_enemy
  76. else
  77. index = @active_battler.current_action.target_index
  78. target = $game_troop.smooth_target_enemy(index)
  79. end
  80. end
  81. @target_battlers = [target]
  82. for target in @target_battlers
  83. target.attack_effect(@active_battler)
  84. end
  85. return
  86. end
  87. if @active_battler.current_action.basic == 1
  88. @help_window.set_text($data_system.words.guard, 1)
  89. return
  90. end
  91. if @active_battler.is_a?(Game_Enemy) and
  92. @active_battler.current_action.basic == 2
  93. @help_window.set_text("逃跑", 1)
  94. @active_battler.escape
  95. return
  96. end
  97. if @active_battler.current_action.basic == 3
  98. $game_temp.forcing_battler = nil
  99. @phase4_step = 1
  100. return
  101. end
  102. end
  103. end
复制代码
在鄙视中变强
回复

使用道具 举报

1

主题

30

帖子

112

积分

③业余

哇咔咔....

积分
112
发表于 2006-8-12 17:08:23 | 显示全部楼层
[s:1]  好东西.....
回复 支持 反对

使用道具 举报

30

主题

477

帖子

5219

积分

⑦老手

积分
5219
发表于 2006-8-13 21:57:28 | 显示全部楼层
嗯,是个好东西,其实也可以随机采用招式攻击吧?
回复 支持 反对

使用道具 举报

4

主题

109

帖子

2494

积分

⑥精研

不灌水者

积分
2494
 楼主| 发表于 2006-8-13 23:35:28 | 显示全部楼层
可以设置技能,加多点判断就能提高AI智商
不过最近完成游戏中,做完之后就升级一下吧
在鄙视中变强
回复 支持 反对

使用道具 举报

墮天使路 该用户已被删除
发表于 2006-8-15 17:53:28 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2025-6-29 14:39 , Processed in 0.010730 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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