单兵战术:远程不优先打击冲车
本帖最后由 HudsonLee 于 2021-3-1 12:19 编辑分享一段自己写的AI,战役制作里或许会用的上。
逻辑:例遍每个正在战斗的单位,如果这个单位正在攻击冲车和攻城塔,就搜索附近的其他单位攻击。
;[远程不优先打击冲车或攻城塔]
(defconst next-remote-unit-1 1)
(defconst gl-local-total 2)
(defconst shooter-range 6)
(defconst own-defense-tower-id 7)
(defconst enemy-id 8)
(defconst point-x 50)
(defconst point-y 51)
(defrule
(stance-toward 1 ally)
=>
(up-jump-rule 9))
(defrule
(cc-players-unit-type-count 1 battering-ram-line <= 0)
(cc-players-unit-type-count 1 1105 <= 0)
=>
(up-jump-rule 8))
(defrule
(up-object-type-count-total c: castle <= 0)
(up-object-type-count-total c: tower-class <= 0)
(up-object-type-count-total c: town-center <= 0)
(up-object-type-count-total c: scorpion-class <= 0)
(up-object-type-count-total c: archery-class <= 0)
(up-object-type-count-total c: cavalry-cannon-class <= 0)
(up-object-type-count-total c: cavalry-archer-class <= 0)
(up-object-type-count-total c: archery-cannon-class <= 0)
=>
(up-jump-rule 7))
(defrule
(true)
=>
(up-full-reset-search)
(up-filter-include -1 actionid-attack -1 -1)
(up-find-local c: castle c: 240)
(up-find-local c: town-center c: 240)
(up-find-local c: tower-class c: 240)
(up-find-local c: scorpion-class c: 240)
(up-find-local c: archery-class c: 240)
(up-find-local c: cavalry-cannon-class c: 240)
(up-find-local c: cavalry-archer-class c: 240)
(up-find-local c: archery-cannon-class c: 240)
(up-get-search-state gl-local-total))
(defrule
(up-compare-goal gl-local-total g:<= next-remote-unit-1)
=>
(up-modify-goal next-remote-unit-1 c:= 0))
(defrule
(up-compare-goal gl-local-total c:<= 0)
=>
(up-jump-rule 4))
(defrule
(true)
=>
(up-set-target-object search-local g: next-remote-unit-1)
(up-modify-goal next-remote-unit-1 c:+ 1)
(up-get-point position-object point-x)
(up-get-object-data object-data-range shooter-range)
(up-get-object-data object-data-id own-defense-tower-id)
(up-get-object-data object-data-target-id enemy-id)
(up-full-reset-search)
(up-set-target-by-id g: enemy-id))
(defrule
(up-object-data object-data-type != 1258)
(up-object-data object-data-type != 422)
(up-object-data object-data-type != 548)
(up-object-data object-data-type != 1105)
=>
(up-jump-rule 2))
(defrule
(true)
=>
(up-full-reset-search)
(up-set-target-point point-x)
(up-filter-distance c: -1 g: shooter-range)
(set-strategic-number sn-focus-player-number 1)
(up-find-remote c: -1 c: 40)
(up-remove-objects search-remote object-data-type == 1258)
(up-remove-objects search-remote object-data-type == 422)
(up-remove-objects search-remote object-data-type == 548)
(up-remove-objects search-remote object-data-type == 1105)
(up-get-search-state gl-local-total))
(defrule
(up-compare-goal gl-remote-total c:> 0)
=>
;(chat-to-player 1 "远程不优先打击冲车或攻城塔")
(up-clean-search search-remote object-data-hitpoints search-order-asc)
(up-add-object-by-id search-local g: own-defense-tower-id)
(up-target-objects 0 action-default -1 -1))
抢个沙发,这样一来电脑玩家更能有智慧了呢{:149:} 好!
页:
[1]