Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;------
- ;
- ;------
- ;Generated by AoE2DE AI Builder
- ;***Set Constants***
- ;---GENERAL---
- (defconst yes 1)
- (defconst no 0)
- ;---GOALS---
- (defconst unit1 my-unique-unit-line)
- (defconst unit2 my-unique-unit-line)
- (defconst unit3 monk)
- (defconst unit4 my-unique-unit-line)
- (defconst unit5 my-unique-unit-line)
- (defconst siege1 trebuchet)
- (defconst siege2 trebuchet)
- (defconst siege3 trebuchet)
- (defconst blacksmith-techs 5)
- (defconst military-techs 6)
- (defconst economic-techs 7)
- (defconst university-techs 8)
- (defconst monastery-techs 9)
- (defconst dock-techs 10)
- (defconst house-goal 11)
- (defconst end-age 12)
- (defconst use-market 14)
- (defconst default-resign 15)
- (defconst allow-advancing 16)
- (defconst allow-signal 17)
- (defconst active-at-start 18)
- (defconst activate 19)
- (defconst combi 20)
- (defconst dark 78)
- (defconst df-transit 79)
- (defconst feudal 80)
- (defconst fc-transit 81)
- (defconst castle 82)
- (defconst ci-transit 83)
- (defconst imperial 84)
- ;---POS CONSTS---
- (defconst pos-self 100)
- (defconst pos-self-y 101)
- (defconst pos-obj 102)
- (defconst pos-obj-y 103)
- (defconst pos-tc-x 104)
- (defconst pos-tc-y 105)
- ;---UNIT CONSTS---
- (defconst villager-class 904)
- ;---AGE CONST---
- (defconst game-time 0)
- (defconst current-age 19)
- (defconst imperial-food 1100)
- (defconst imperial-gold 900)
- (defconst castle-food 900)
- (defconst castle-gold 300)
- (defconst feudal-food 550)
- (defconst villager-feudal 4)
- (defconst villager-castle 50)
- ;---ATTACKS---
- (defconst standby 0)
- (defconst offence 1)
- (defconst reset-attack 2)
- (defconst attack-goal 3)
- ;---TIMERS---
- (defconst attack-timer 2)
- (defconst interval-timer 3)
- (defconst timer-build-retry 6)
- (defconst timer-house-retry 7)
- ;---UPGRADES---
- (defconst food-escrow 0)
- (defconst wood-escrow 0)
- (defconst gold-escrow 0)
- (defconst stone-escrow 0)
- ;---SN CONSTS---
- (defconst sn-percent-building-cancellation 60)
- (defconst sn-current-age dark)
- (defconst sn-max-drop-distance 10)
- (defconst sn-max-drop-site 30)
- (defconst sn-max-barracks 0)
- (defconst sn-max-archer 0)
- (defconst sn-max-stable 0)
- (defconst sn-max-siege 0)
- (defconst sn-max-monestry 1)
- (defconst sn-max-tc 1)
- (defconst sn-max-castle 1)
- (defconst sn-max-donjon 0)
- (defconst sn-max-blacksmith 1)
- (defconst sn-max-market 1)
- (defconst sn-max-university 1)
- (defconst sn-max-unit1 0)
- (defconst sn-max-unit2 0)
- (defconst sn-max-unit3 0)
- (defconst sn-max-unit4 0)
- (defconst sn-max-unit5 0)
- (defconst sn-max-unit6 0)
- (defconst sn-max-unit7 0)
- (defconst sn-max-siege1 0)
- (defconst sn-max-siege2 0)
- (defconst sn-max-siege3 0)
- ;---VALID RESEARCH---
- (defconst research-melee-atk 0)
- (defconst research-melee-def 0)
- (defconst research-archer 0)
- (defconst research-cavalry 0)
- (defconst research-siege 0)
- (defconst research-monk 0)
- ;---FLAGS---
- (defconst flag-mill-progress 0)
- (defconst flag-market-progress 0)
- ;---OTHERS---
- (defconst max-vills 100)
- (defconst max-farms 8)
- (defconst max-pending-house 2)
- (defconst min-headroom 5)
- (defconst min-farm-head 2)
- (defconst task-soldiers yes)
- ;***Setup***
- ;---Load Externals---
- ;load extra files. These files are generic and take care of the resigning of the AI, its upgrades and the active use of the market.
- ;Load ZenAI
- (load "ZenAI\UnitComp")
- (load "ZenAI\AgeUp")
- (load "ZenAI\ri_multi")
- ;DEBUG
- (defrule
- (resource-found wood)
- =>
- (chat-local-to-self "Wood Found")
- (disable-self)
- )
- ;***ECO BEHAVIOUR***
- (defrule
- (or
- (game-time > 300)
- (unit-type-count-total villager > 14)
- )
- =>
- (set-strategic-number sn-wood-gatherer-percentage 80)
- (set-strategic-number sn-food-gatherer-percentage 20)
- (set-strategic-number sn-placement-zone-size 15)
- (set-strategic-number sn-maximum-town-size 25)
- (disable-self)
- )
- (defrule
- (or
- (game-time > 600)
- (unit-type-count-total villager > 35)
- )
- =>
- (set-strategic-number sn-wood-gatherer-percentage 70)
- (set-strategic-number sn-food-gatherer-percentage 30)
- (set-strategic-number sn-placement-zone-size 22)
- (set-strategic-number sn-maximum-town-size 30)
- (disable-self)
- )
- (defrule
- (or
- (game-time > 900)
- (unit-type-count-total villager > 45)
- )
- =>
- (set-strategic-number sn-wood-gatherer-percentage 60)
- (set-strategic-number sn-food-gatherer-percentage 40)
- (set-strategic-number sn-placement-zone-size 30)
- (set-strategic-number sn-maximum-town-size 40)
- (disable-self)
- )
- (defrule
- (or
- (game-time > 1200)
- (unit-type-count-total villager > 55)
- )
- =>
- (set-strategic-number sn-percent-civilian-builders 20)
- (set-strategic-number sn-percent-civilian-gatherers 80)
- (set-strategic-number sn-wood-gatherer-percentage 50)
- (set-strategic-number sn-food-gatherer-percentage 50)
- (set-strategic-number sn-placement-zone-size 40)
- (set-strategic-number sn-maximum-town-size 55)
- (disable-self)
- )
- (defrule
- (or
- (game-time > 2400)
- (unit-type-count-total villager > 65)
- )
- =>
- (set-strategic-number sn-percent-civilian-builders 10)
- (set-strategic-number sn-percent-civilian-gatherers 89)
- (set-strategic-number sn-percent-civilian-explorers 1)
- (set-strategic-number sn-number-explore-groups 1)
- (set-strategic-number sn-total-number-explorers 1)
- (disable-self)
- )
- ;***Civ Behaviour***
- ;---DEFAULT BEHAVIOURS---
- ;Set Init SN Values
- (defrule
- (true)
- =>
- (up-change-name -1)
- (set-strategic-number sn-percent-civilian-builders 50)
- (set-strategic-number sn-percent-civilian-gatherers 50)
- (set-strategic-number sn-percent-civilian-explorers 0)
- (set-strategic-number sn-number-explore-groups 0)
- (set-strategic-number sn-total-number-explorers 0)
- (set-strategic-number sn-food-gatherer-percentage 0)
- (set-strategic-number sn-wood-gatherer-percentage 100)
- (set-strategic-number sn-gold-gatherer-percentage 0)
- (set-strategic-number sn-stone-gatherer-percentage 0)
- (set-strategic-number sn-initial-exploration-required 0)
- (set-strategic-number sn-percent-exploration-required 0)
- (set-strategic-number sn-random-placement-factor 0)
- (set-strategic-number sn-placement-zone-size 10)
- (set-goal house-goal 0)
- (enable-timer timer-house-retry 5)
- (disable-self)
- )
- ;Disable first mill if Khmer
- #load-if-defined KHMER-CIV
- (defrule
- (true)
- =>
- (set-strategic-number flag-mill-progress 2)
- );
- #end-if
- ;Build Mill if NOT Khmer
- (defrule
- (and
- (and
- (and
- (and
- (not (civ-selected khmer))
- (building-type-count-total house >= 2)
- )
- (building-type-count-total mill == 0)
- )
- (and
- (up-compare-const flag-mill-progress <= 1)
- (timer-triggered timer-build-retry)
- )
- )
- (up-can-build 0 c: mill)
- )
- =>
- (set-strategic-number flag-mill-progress 1)
- (disable-timer timer-build-retry)
- (enable-timer timer-build-retry 10)
- (up-full-reset-search)
- (up-find-local c: villager-class c: 240)
- (up-set-target-object search-local c: 0)
- (up-get-point position-object pos-obj)
- (up-get-point position-self pos-tc-x)
- (up-lerp-tiles pos-obj pos-tc-x c: -1)
- (up-build-line pos-obj pos-obj c: mill)
- (chat-local-to-self "Building 1st Mill")
- )
- ;(defconst flag-market-progress 0)
- ;Destroy First Mill (Not needed for now, waste of space)
- (defrule
- (building-type-count mill == 1)
- =>
- (set-strategic-number flag-mill-progress 2)
- (delete-building mill)
- (disable-self)
- )
- ;Build 2nd Mill (1st if Khmer)
- (defrule
- (and
- (and
- (and
- (and
- (not (civ-selected khmer))
- (building-type-count-total house >= 2)
- )
- (building-type-count-total mill == 0)
- )
- (or
- (up-compare-const flag-mill-progress == 2)
- (timer-triggered timer-build-retry)
- )
- )
- (up-can-build 0 c: mill)
- )
- =>
- (set-strategic-number flag-mill-progress 3)
- (up-full-reset-search)
- (up-find-local c: villager-class c: 240)
- (up-set-target-object search-local c: 0)
- (up-get-point position-object pos-obj)
- (up-get-point position-self pos-tc-x)
- (up-lerp-tiles pos-obj pos-tc-x c: -1)
- (up-build-line pos-obj pos-obj c: mill)
- (disable-timer timer-build-retry)
- (enable-timer timer-build-retry 10)
- (chat-local-to-self "Building 2nd Mill")
- )
- ;Build Market on Age Up
- (defrule
- (and
- (and
- (current-age == feudal-age)
- (up-can-build 0 c: market)
- )
- (or
- (up-compare-const flag-mill-progress == 3)
- (timer-triggered timer-build-retry)
- )
- )
- =>
- (set-strategic-number flag-mill-progress 4)
- (delete-building town-center)
- (up-set-target-point pos-tc-x)
- (up-build place-point 0 c: market)
- (disable-timer timer-build-retry)
- (enable-timer timer-build-retry 15)
- ;(up-full-reset-search)
- ;(up-find-local c: villager-class c: 240)
- ;(up-set-target-object search-local c: 0)
- ;(up-get-point position-object pos-obj)
- ;(up-get-point position-self pos-tc-x)
- ;(up-lerp-tiles pos-obj pos-tc-x c: -1)
- ;(up-build-line pos-obj pos-obj c: market)
- (chat-local-to-self "Building Market")
- )
- ;Delete 2nd Mill
- (defrule
- (building-type-count-total market == 1)
- =>
- (set-strategic-number flag-mill-progress 5)
- (delete-building mill)
- (disable-self)
- )
- ;First Sale
- (defrule
- (building-type-count market == 1)
- (up-compare-const flag-market-progress == 0)
- (wood-amount >= 400)
- (can-sell-commodity wood)
- =>
- (sell-commodity wood)
- )
- (defrule
- (up-compare-const flag-market-progress == 0)
- (wood-amount < 400)
- =>
- (set-strategic-number flag-market-progress 1)
- )
- ;First Buy Food
- (defrule
- (up-compare-const flag-market-progress == 1)
- (food-amount <= 1500)
- (gold-amount >= 2000)
- (can-buy-commodity food)
- =>
- (sell-commodity food)
- )
- (defrule
- (up-compare-const flag-market-progress == 1)
- (food-amount > 1500)
- (gold-amount < 2000)
- =>
- (set-strategic-number flag-market-progress 2)
- )
- ;First Buy Stone
- (defrule
- (up-compare-const flag-market-progress == 2)
- (stone-amount <= 800)
- (gold-amount >= 2500)
- (can-buy-commodity stone)
- =>
- (sell-commodity stone)
- )
- (defrule
- (up-compare-const flag-market-progress == 2)
- (food-amount > 1500)
- (gold-amount < 2000)
- =>
- (set-strategic-number flag-market-progress 3)
- )
- (defrule
- (up-compare-const flag-market-progress == 3)
- =>
- (set-strategic-number flag-market-progress 4)
- (delete-building market)
- (disable-self)
- )
- ;Rebuild TC
- (defrule
- (and
- (or
- (up-compare-const flag-market-progress == 4)
- (timer-triggered timer-build-retry)
- )
- (up-can-build 0 c: town-center)
- )
- =>
- (set-strategic-number flag-market-progress 5)
- (up-set-target-point pos-tc-x)
- (up-build place-point 0 c: town-center)
- (disable-timer timer-build-retry)
- (enable-timer timer-build-retry 45)
- (chat-local-to-self "Building Town Center")
- )
- ;---Active Behaviour---
- ;when activated the AI will begin to play
- (defrule
- (true)
- =>
- (set-strategic-number sn-mill-max-distance 10)
- (set-strategic-number sn-maximum-gold-drop-distance 10)
- (set-strategic-number sn-maximum-stone-drop-distance 10)
- (set-strategic-number sn-maximum-food-drop-distance 10)
- (set-strategic-number sn-maximum-wood-drop-distance 10)
- (set-strategic-number sn-task-ungrouped-soldiers task-soldiers)
- (disable-self)
- )
- ;***AI Behaviour***
- ;-----Dodging rules-----
- ;ability of the AI to dodge enemy missiles shot at them and maintaining distance when engaging with enemies. The lower the number how better they are at it.
- (defrule
- (difficulty == easiest)
- =>
- (set-difficulty-parameter ability-to-maintain-distance 90)
- (set-difficulty-parameter ability-to-dodge-missiles 90)
- (disable-self)
- )
- (defrule
- (difficulty == easy)
- =>
- (set-difficulty-parameter ability-to-maintain-distance 70)
- (set-difficulty-parameter ability-to-dodge-missiles 70)
- (disable-self)
- )
- (defrule
- (difficulty == moderate)
- =>
- (set-difficulty-parameter ability-to-maintain-distance 50)
- (set-difficulty-parameter ability-to-dodge-missiles 50)
- (disable-self)
- )
- (defrule
- (difficulty == hard)
- =>
- (set-difficulty-parameter ability-to-maintain-distance 30)
- (set-difficulty-parameter ability-to-dodge-missiles 30)
- (disable-self)
- )
- (defrule
- (difficulty == hardest)
- =>
- (set-difficulty-parameter ability-to-maintain-distance 0)
- (set-difficulty-parameter ability-to-dodge-missiles 0)
- (disable-self)
- )
- ;***Production***
- ;---Homebase Stats---
- (defrule
- (true)
- =>
- (set-strategic-number sn-maximum-town-size 40)
- (set-strategic-number sn-camp-max-distance sn-max-drop-distance)
- (set-strategic-number sn-mill-max-distance sn-max-drop-distance)
- (set-strategic-number sn-percent-enemy-sighted-response 50)
- (set-strategic-number sn-enemy-sighted-response-distance 15)
- (set-strategic-number sn-blot-exploration-map 0)
- (set-strategic-number sn-sentry-distance 20)
- (disable-self)
- )
- ;---Farming and Civilians---
- (defrule
- (building-type-count-total farm < max-farms)
- (idle-farm-count <= min-farm-head)
- (can-build farm)
- =>
- (build farm)
- )
- (defrule
- (and
- (unit-type-count-total villager < max-vills)
- (and
- (can-train villager)
- (population-headroom >= 1)
- )
- )
- =>
- (train villager)
- )
- ;---Economic Buildings---
- (defrule
- (building-type-count-total town-center < sn-max-tc)
- (can-build town-center)
- =>
- (build town-center)
- )
- (defrule
- (and
- (goal house-goal 0)
- (and
- (and
- (timer-triggered timer-house-retry)
- (up-pending-objects c: house < max-pending-house)
- )
- (and
- (housing-headroom less-than min-headroom)
- (population-headroom greater-than 0)
- )
- )
- )
- =>
- (set-goal house-goal 1)
- (up-full-reset-search)
- (up-find-local c: villager-class c: 240)
- (up-set-target-object search-local c: 0)
- (up-get-point position-object pos-obj)
- (up-lerp-tiles pos-obj pos-tc-x c: -1)
- (up-build-line pos-obj pos-obj c: house)
- (set-goal house-goal 0)
- (disable-timer timer-house-retry)
- (enable-timer timer-house-retry 15)
- (chat-local-to-self "Added Que - House")
- )
- (defrule
- (building-type-count house > 0)
- (population-headroom <= 0)
- (research-completed ri-nomads)
- =>
- (delete-building house)
- )
- (defrule
- (resource-found wood)
- (dropsite-min-distance wood > 4)
- (building-type-count-total lumber-camp < sn-max-drop-site)
- (can-build lumber-camp)
- =>
- (build lumber-camp)
- )
- (defrule
- (up-compare-const flag-market-progress == 5)
- (building-type-count-total mill < sn-max-drop-site)
- (dropsite-min-distance food > 5)
- (can-build mill)
- =>
- (build mill)
- )
- (defrule
- (resource-found gold)
- (building-type-count-total mining-camp < sn-max-drop-site)
- (dropsite-min-distance gold > 5)
- (can-build mining-camp)
- =>
- (build mining-camp)
- )
- (defrule
- (resource-found stone)
- (building-type-count-total mining-camp < sn-max-drop-site)
- (dropsite-min-distance stone > 5)
- (can-build mining-camp)
- =>
- (build mining-camp)
- )
- ;---Military and Research Buildings---
- (defrule
- (building-type-count-total barracks < sn-max-barracks)
- (can-build barracks)
- =>
- (build barracks)
- )
- (defrule
- (building-type-count-total archery-range < sn-max-archer)
- (can-build archery-range)
- =>
- (build archery-range)
- )
- (defrule
- (building-type-count-total stable < sn-max-stable)
- (can-build stable)
- =>
- (build stable)
- )
- (defrule
- (building-type-count-total siege-workshop < sn-max-siege)
- (can-build siege-workshop)
- =>
- (build siege-workshop)
- )
- (defrule
- (building-type-count-total university < sn-max-university)
- (can-build university)
- =>
- (build university)
- )
- (defrule
- (building-type-count-total blacksmith < sn-max-blacksmith)
- (can-build blacksmith)
- =>
- (build blacksmith)
- )
- (defrule
- (building-type-count-total market < sn-max-market)
- (can-build market)
- =>
- (build market)
- )
- (defrule
- (building-type-count-total monastery < sn-max-monestry)
- (can-build monastery)
- =>
- (build monastery)
- )
- (defrule
- (building-type-count-total castle < sn-max-castle)
- (can-build castle)
- =>
- (build castle)
- )
- (defrule
- (building-type-count-total donjon < sn-max-donjon)
- (can-build donjon)
- =>
- (build donjon)
- )
- ;***Assault rules***
- ;---Assault stats---
- (defrule
- (true)
- =>
- (set-strategic-number sn-do-not-scale-for-difficulty-level no)
- (set-strategic-number sn-wall-targeting-mode yes)
- (disable-self)
- )
- ;-----Offence-----
- ;activate the first attack
- (defrule
- (true)
- =>
- (enable-timer attack-timer 5400)
- (set-goal attack-goal standby)
- (disable-self)
- )
- ;first attack is activated and a new timer is enabled to already activate the next attack later on
- (defrule
- (timer-triggered attack-timer)
- (goal attack-goal standby)
- (military-population >= 10)
- (defend-soldier-count >= 10)
- (not (town-under-attack))
- =>
- (set-strategic-number sn-percent-enemy-sighted-response 60)
- (set-strategic-number sn-enemy-sighted-response-distance 40)
- (set-goal attack-goal offence)
- (disable-timer attack-timer)
- (enable-timer attack-timer 120);Interval between attacks
- )
- ;the ai stops his attacks and resets everything until the next wave
- (defrule
- (timer-triggered interval-timer)
- =>
- (disable-timer interval-timer)
- (set-goal attack-goal standby)
- )
- ;the ai will keep his units at his base when on standby
- (defrule
- (goal attack-goal standby)
- =>
- (set-strategic-number sn-group-form-distance 25)
- (set-strategic-number sn-maximum-attack-group-size 0)
- (set-strategic-number sn-minimum-attack-group-size 0)
- (set-strategic-number sn-number-attack-groups 0)
- (set-strategic-number sn-number-boat-attack-groups 0)
- (set-strategic-number sn-minimum-boat-attack-group-size 0)
- (set-strategic-number sn-maximum-boat-attack-group-size 0)
- (disable-timer interval-timer)
- (enable-timer interval-timer 10)
- ;(set-goal attack-goal reset-attack)
- )
- ;the ai gathers his troops and attacks the enemy with the amount stated below
- (defrule
- (goal attack-goal offence) ;Attacking - Groups
- =>
- (set-strategic-number sn-group-form-distance 30)
- (set-strategic-number sn-number-attack-groups 1)
- (set-strategic-number sn-maximum-attack-group-size 60)
- (set-strategic-number sn-minimum-attack-group-size 60)
- (set-strategic-number sn-number-boat-attack-groups 0)
- (set-strategic-number sn-minimum-boat-attack-group-size 0)
- (set-strategic-number sn-maximum-boat-attack-group-size 0)
- (set-goal attack-goal reset-attack)
- )
- ;***Production2***
- ;---Military---
- (defrule
- (unit-type-count-total unit1 < sn-max-unit1)
- (can-train unit1)
- =>
- (train unit1)
- )
- (defrule
- (unit-type-count-total unit2 < sn-max-unit2)
- (can-train unit2)
- =>
- (train unit2)
- )
- (defrule
- (unit-type-count-total unit3 < sn-max-unit3)
- (can-train unit3)
- =>
- (train unit3)
- )
- (defrule
- (unit-type-count-total unit4 < sn-max-unit4)
- (can-train unit4)
- =>
- (train unit4)
- )
- (defrule
- (unit-type-count-total unit5 < sn-max-unit5)
- (can-train unit5)
- =>
- (train unit5)
- )
- (defrule
- (unit-type-count-total siege1 < sn-max-siege1)
- (can-train siege1)
- =>
- (train siege1)
- )
- (defrule
- (unit-type-count-total siege2 < sn-max-siege2)
- (can-train siege2)
- =>
- (train siege2)
- )
- (defrule
- (unit-type-count-total siege3 < sn-max-siege3)
- (can-train siege3)
- =>
- (train siege3)
- )
- ;***Market sales***
- (defrule
- (up-compare-const flag-market-progress == 5)
- (gold-amount >= 1500)
- (food-amount <= 200)
- (commodity-buying-price food <= 100)
- (can-buy-commodity food)
- =>
- (buy-commodity food)
- )
- (defrule
- (up-compare-const flag-market-progress == 5)
- (gold-amount >= 500)
- (food-amount <= 100)
- (can-buy-commodity food)
- =>
- (buy-commodity food)
- )
- (defrule
- (up-compare-const flag-market-progress == 5)
- (gold-amount >= 2000)
- (stone-amount <= 500)
- (commodity-buying-price stone <= 200)
- (can-buy-commodity stone)
- =>
- (buy-commodity stone)
- )
- (defrule
- (up-compare-const flag-market-progress == 5)
- (gold-amount >= 1500)
- (stone-amount <= 200)
- (commodity-buying-price stone <= 500)
- (can-buy-commodity stone)
- =>
- (buy-commodity stone)
- )
- (defrule
- (up-compare-const flag-market-progress == 5)
- (wood-amount >= 2500)
- (gold-amount < 10000)
- (can-sell-commodity wood)
- =>
- (sell-commodity wood)
- )
- (defrule
- (up-compare-const flag-market-progress == 5)
- (food-amount >= 2500)
- (gold-amount < 10000)
- (can-sell-commodity food)
- =>
- (sell-commodity food)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement