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

[交流] 防止被敌人放风筝

[复制链接]

11

主题

0

精华

164

积分

男爵

耕战
5
鹰币
30
天龙币
0
回帖
37
附庸关系0
 楼主| 发表于 2020-10-15 14:06:59 | 显示全部楼层 |阅读模式
本帖最后由 仰望坡大刀 于 2020-10-15 14:08 编辑

原理是,找到距离TC最远的部队,然后以这个点为中心搜索12格之内的敌人和我军,如果我军部队小于对方敌军的1半,那就撤退14格。 代码如下。可是为啥操作起来,电脑的部队一直在后撤,即使明显看出来我军部队已经远远大于对方的一半?是哪里出了问题?
  1. ; ====================================================================
  2. ;-----------------------------regroup for large-amount enemy------------------------
  3. ; ====================================================================
  4. (defrule
  5.         (up-compare-goal regroup-large-amount != 1)
  6.         (or        (up-timer-status regroup-large-amount-timer == timer-running)
  7.         (up-point-distance my-precise-army-point-x gl-position-self-x c:<= 30))
  8. =>
  9.         (up-jump-rule 6)
  10. )
  11. (defrule
  12.         (military-population > 1)
  13. =>        (up-full-reset-search)
  14.         (up-set-target-point gl-position-self-x)
  15.         (up-filter-include cmdid-military -1 -1 -1)
  16.         (up-find-local c: all-units-class c: 100)
  17.         (up-remove-objects search-local object-data-action == actionid-explore)
  18.         (up-remove-objects search-local object-data-order == orderid-explore)
  19.         (up-remove-objects search-local object-data-class == monastery-class)
  20.         (up-remove-objects search-local object-data-class == unpacked-trebuchet-class)
  21.         (up-remove-objects search-local object-data-type == battering-ram)
  22.         (up-remove-objects search-local object-data-type == bombard-cannon)
  23.         (up-clean-search search-local object-data-distance search-order-desc)
  24.         (up-set-target-object search-local c: 0)
  25.         (up-get-point position-object my-precise-army-point-x))
  26. (defrule
  27.         (up-timer-status regroup-large-amount-timer != timer-running)
  28.         (up-compare-goal my-precise-army-point-x > -1)
  29. =>        (up-full-reset-search)
  30.         (up-set-target-point my-precise-army-point-x)
  31.         (up-filter-distance c: -1 c: 12)
  32.         (up-filter-include cmdid-military -1 -1 -1)
  33.         (up-find-local c: -1 c: 21)
  34.         (up-find-remote c: -1 c: 40)
  35.         (up-get-search-state gl-local-total))
  36. (defrule
  37.         (up-timer-status regroup-large-amount-timer != timer-running)
  38.         (up-compare-goal gl-local-total > 0)
  39.         (up-compare-goal gl-remote-total > 0)
  40.         (up-compare-goal my-precise-army-point-x > -1)
  41. =>
  42.         (up-modify-goal army-value g:= gl-remote-total)
  43.         (up-modify-goal army-value c:/ 2)
  44.         (up-modify-goal army-value g:- gl-local-total))
  45. (defrule
  46.         (up-timer-status regroup-large-amount-timer != timer-running)
  47.         (up-compare-goal gl-local-total > 0)
  48.         (up-compare-goal gl-remote-total > 0)
  49.         (up-compare-goal my-precise-army-point-x > -1)
  50.         (up-compare-goal army-value >= 0)
  51.         (up-point-distance my-precise-army-point-x gl-position-self-x c:> 30)
  52. =>        (up-full-reset-search)
  53.         (up-filter-include cmdid-military -1 -1 -1)
  54.         (up-find-local c: -1 c: 120)
  55.         (up-get-search-state gl-local-total))
  56. (defrule
  57.         (up-timer-status regroup-large-amount-timer != timer-running)
  58.         (up-compare-goal gl-local-total > 0)
  59.         (up-compare-goal my-precise-army-point-x > -1)
  60.         (up-compare-goal army-value >= 0)
  61.         (up-point-distance my-precise-army-point-x gl-position-self-x c:> 30)
  62. =>       
  63.         (set-goal regroup-large-amount 1)
  64.     (up-copy-point regroup-point-x my-precise-army-point-x)
  65.         (up-lerp-tiles regroup-point-x gl-position-self-x c: 14)
  66.     (up-target-point regroup-point-x action-move formation-line stance-defensive)
  67.     (chat-to-player my-player-number "retreating for large-amount enemy")
  68.         (enable-timer regroup-large-amount-timer 20))
  69. (defrule
  70.     (goal regroup-large-amount 1)
  71.         (up-point-distance my-precise-army-point-x gl-position-self-x c:<= 30)
  72. =>
  73.         (up-set-attack-stance -1 c: stance-aggressive)
  74.         (set-goal regroup-large-amount 0)
  75. )
  76. (defrule
  77.         (or (timer-triggered regroup-large-amount-timer)
  78.         (up-compare-goal threat-time-goal > 6000))
  79. =>
  80.         (up-set-attack-stance -1 c: stance-aggressive)
  81.         (disable-timer regroup-large-amount-timer)
  82. )
复制代码


回复

使用道具 举报

14

主题

0

精华

1165

积分

伯爵

耕战
100
鹰币
320
天龙币
0
回帖
30
附庸关系0
发表于 2021-4-9 00:01:38 | 显示全部楼层
很多goal参数没有声明 默认是0 导致触发无效
回复

使用道具 举报

本版积分规则

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

GMT+8, 2024-11-16 02:56 , Processed in 0.110738 second(s), 36 queries , File On.

Powered by Hawk Studio  QS Security Corp.® Licensed

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

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