翔鹰帝国网|帝国时代论坛|帝国时代系列|神话时代
 找回密码
 注册翔鹰会员(昵称)
搜索
查看: 440|回复: 2

[交流] 单兵战术:远程不优先打击冲车

[复制链接]

21

主题

3

精华

1万

积分

征服者

耕战
3476
鹰币
2266
天龙币
0
回帖
221

第十三届火箭筒杯季军

附庸关系9
 楼主| 发表于 2021-2-28 23:03:18 | 显示全部楼层 |阅读模式
本帖最后由 HudsonLee 于 2021-3-1 12:19 编辑

分享一段自己写的AI,战役制作里或许会用的上。

逻辑:例遍每个正在战斗的单位,如果这个单位正在攻击冲车和攻城塔,就搜索附近的其他单位攻击。

  1. ;[远程不优先打击冲车或攻城塔]

  2. (defconst next-remote-unit-1 1)
  3. (defconst gl-local-total 2)
  4. (defconst shooter-range 6)
  5. (defconst own-defense-tower-id 7)
  6. (defconst enemy-id 8)
  7. (defconst point-x 50)
  8. (defconst point-y 51)

  9. (defrule
  10.     (stance-toward 1 ally)
  11. =>  
  12.     (up-jump-rule 9))
  13. (defrule
  14.     (cc-players-unit-type-count 1 battering-ram-line <= 0)
  15.     (cc-players-unit-type-count 1 1105 <= 0)
  16. =>  
  17.     (up-jump-rule 8))
  18. (defrule
  19.     (up-object-type-count-total c: castle <= 0)
  20.     (up-object-type-count-total c: tower-class <= 0)
  21.     (up-object-type-count-total c: town-center <= 0)
  22.     (up-object-type-count-total c: scorpion-class <= 0)
  23.     (up-object-type-count-total c: archery-class <= 0)
  24.     (up-object-type-count-total c: cavalry-cannon-class <= 0)
  25.     (up-object-type-count-total c: cavalry-archer-class <= 0)
  26.     (up-object-type-count-total c: archery-cannon-class <= 0)
  27. =>  
  28.     (up-jump-rule 7))
  29. (defrule
  30.     (true)
  31. =>
  32.     (up-full-reset-search)
  33.     (up-filter-include -1 actionid-attack -1 -1)
  34.     (up-find-local c: castle c: 240)
  35.     (up-find-local c: town-center c: 240)
  36.     (up-find-local c: tower-class c: 240)
  37.     (up-find-local c: scorpion-class c: 240)
  38.     (up-find-local c: archery-class c: 240)
  39.     (up-find-local c: cavalry-cannon-class c: 240)
  40.     (up-find-local c: cavalry-archer-class c: 240)
  41.     (up-find-local c: archery-cannon-class c: 240)
  42.     (up-get-search-state gl-local-total))
  43. (defrule
  44.     (up-compare-goal gl-local-total g:<= next-remote-unit-1)
  45. =>
  46.     (up-modify-goal next-remote-unit-1 c:= 0))
  47. (defrule
  48.     (up-compare-goal gl-local-total c:<= 0)
  49. =>  
  50.     (up-jump-rule 4))
  51. (defrule
  52.     (true)
  53. =>
  54.     (up-set-target-object search-local g: next-remote-unit-1)
  55.     (up-modify-goal next-remote-unit-1 c:+ 1)
  56.     (up-get-point position-object point-x)
  57.     (up-get-object-data object-data-range shooter-range)
  58.     (up-get-object-data object-data-id own-defense-tower-id)
  59.     (up-get-object-data object-data-target-id enemy-id)
  60.     (up-full-reset-search)
  61.     (up-set-target-by-id g: enemy-id))
  62. (defrule
  63.     (up-object-data object-data-type != 1258)
  64.     (up-object-data object-data-type != 422)
  65.     (up-object-data object-data-type != 548)
  66.     (up-object-data object-data-type != 1105)
  67. =>
  68.     (up-jump-rule 2))
  69. (defrule
  70.     (true)
  71. =>
  72.     (up-full-reset-search)
  73.     (up-set-target-point point-x)
  74.     (up-filter-distance c: -1 g: shooter-range)
  75.     (set-strategic-number sn-focus-player-number 1)
  76.     (up-find-remote c: -1 c: 40)
  77.     (up-remove-objects search-remote object-data-type == 1258)
  78.     (up-remove-objects search-remote object-data-type == 422)
  79.     (up-remove-objects search-remote object-data-type == 548)
  80.     (up-remove-objects search-remote object-data-type == 1105)
  81.     (up-get-search-state gl-local-total))
  82. (defrule
  83.     (up-compare-goal gl-remote-total c:> 0)
  84. =>
  85.     ;(chat-to-player 1 "远程不优先打击冲车或攻城塔")
  86.     (up-clean-search search-remote object-data-hitpoints search-order-asc)
  87.     (up-add-object-by-id search-local g: own-defense-tower-id)
  88.     (up-target-objects 0 action-default -1 -1))
复制代码





评分

参与人数 1耕战 +50 鹰币 +500 收起 理由
cxt + 50 + 500 原创精华

查看全部评分

![/url]
回复

使用道具 举报

18

主题

1

精华

8614

积分

宗主教

耕战
1420
鹰币
134895
天龙币
0
回帖
396

翔鹰建站十周年纪念章

附庸关系4
发表于 2021-2-28 23:47:58 | 显示全部楼层
抢个沙发,这样一来电脑玩家更能有智慧了呢
回复

使用道具 举报

117

主题

9

精华

9万

积分

教皇

Wolotine

耕战
17250
鹰币
546210
天龙币
0
回帖
1571

翔鹰建站十周年纪念章小评论家第十二届火箭筒杯最佳新人第十三届火箭筒杯亚军第十三届火箭筒杯亚军赌徒勋章第八届战鹰杯单人赛冠军

附庸关系11
发表于 2021-2-28 23:48:42 | 显示全部楼层
好!
回复

使用道具 举报

本版积分规则

排行榜|小黑屋|翔鹰帝国

GMT+8, 2024-11-21 16:52 , Processed in 0.163317 second(s), 50 queries , File On.

Powered by Hawk Studio  QS Security Corp.® Licensed

Copyright © 2001-2023, Hawkaoe.net All Rights Reserved

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