Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;***BUILD FUNCTIONS***
- ;Init Builders For Each Building
- (defrule
- (true)
- =>
- (set-strategic-number sn-enable-new-building-system 1)
- (set-strategic-number sn-placement-zone-size 0)
- (set-strategic-number sn-placement-fail-delta 0)
- (set-strategic-number sn-placement-to-center 0)
- ;Set Dropoff Distances
- (set-strategic-number sn-dropsite-separation-distance 6)
- (set-strategic-number sn-food-dropsite-distance 10)
- (set-strategic-number sn-wood-dropsite-distance 2)
- (set-strategic-number sn-stone-dropsite-distance 2)
- (set-strategic-number sn-gold-dropsite-distance 2)
- (set-strategic-number sn-camp-max-distance 255)
- ;Build Goals Init
- (set-goal goal-townsize 4)
- (set-goal goal-spacefromself 0)
- (set-goal goal-buildresource -1)
- (set-goal goal-buildgather -1)
- (set-goal goal-build-itteration-cur 0)
- ;Set Point, Start Timer
- (up-copy-point point-build-x point-self-x)
- (up-modify-goal point-build-x g:- goal-townsize)
- (up-modify-goal point-build-y g:- goal-townsize)
- (enable-timer timer-build 3)
- ;Vill Assignments Set
- ; (up-assign-builders c: house c: 3)
- (disable-self)
- )
- ;Add House
- (defrule
- (goal goal-build 0)
- (up-compare-goal goal-townsize <= 6)
- (housing-headroom <= sn-min-pop-head)
- (population-headroom > 0)
- (up-pending-objects c: house < sn-max-pending-house)
- (up-compare-goal flag-market-progress <= 1)
- (timer-triggered timer-build)
- (can-afford-building house)
- =>
- (set-goal goal-build 1)
- (set-goal goal-queued house)
- (chat-local-to-self "House")
- )
- (defrule
- (goal goal-build 0)
- (up-compare-goal goal-townsize > 8)
- (housing-headroom <= sn-min-pop-head)
- (population-headroom > 0)
- (up-pending-objects c: house < sn-max-pending-house)
- (up-compare-goal flag-market-progress <= 1)
- (timer-triggered timer-build)
- (can-afford-building house)
- =>
- (set-goal goal-build 1)
- (set-goal goal-spacefromself 8)
- (set-goal goal-queued house)
- (chat-local-to-self "House")
- )
- (defrule
- (up-compare-goal goal-townsize > 8)
- (civilian-population > 40)
- =>
- ;(up-delete-objects c: house c: 32768)
- (up-full-reset-search)
- (up-set-target-point point-self-x)
- (up-filter-distance c: 1 c: 8)
- (up-find-local c: house c: 1)
- (up-target-objects 1 action-delete -1 -1)
- (disable-self)
- )
- ;Add Mill
- (defrule
- (goal goal-build 0)
- (up-compare-goal goal-townsize > 8)
- (or (housing-headroom > sn-min-pop-head)
- (population-headroom <= 0))
- (up-pending-objects c: mill < sn-max-pending-drop)
- (building-type-count-total mill < goal-max-mills)
- (goal flag-market-progress 0)
- (timer-triggered timer-build)
- (can-afford-building mill)
- =>
- (set-goal goal-build 1)
- (set-goal goal-spacefromself 8)
- (set-goal goal-queued mill)
- (chat-local-to-self "Consecutive Mill")
- )
- (defrule ;Expand Goal goal-max-mills
- (goal goal-build 0)
- (up-compare-goal goal-townsize > 12)
- (or (housing-headroom > sn-min-pop-head)
- (population-headroom <= 0))
- (building-type-count-total farm > goal-increase-mills)
- (timer-triggered timer-build)
- =>
- (up-modify-goal goal-increase-mills c:+ 8)
- (up-modify-goal goal-max-mills c:+ 1)
- (chat-local-to-self "Allowed Extra Mill")
- )
- ;Add Farm
- (defrule
- (goal goal-build 0)
- (idle-farm-count <= sn-min-farm-head)
- (or (housing-headroom > sn-min-pop-head)
- (population-headroom <= 0))
- (building-type-count-total farm g:< goal-max-farms)
- (up-compare-goal flag-market-progress <= 1)
- (timer-triggered timer-build)
- (can-build farm)
- (can-afford-building farm)
- =>
- (set-goal goal-build 1)
- (set-goal goal-spacefromself 0)
- (set-goal goal-spacefromgather 6)
- (set-goal goal-buildgather mill)
- (set-goal goal-queued farm)
- (chat-local-to-self "Farm")
- )
- (defrule
- (resource-found wood)
- (dropsite-min-distance wood > 5)
- (up-compare-goal goal-townsize > 6)
- =>
- (chat-local-to-self "Found Wood, After Town Size 6")
- (disable-self)
- )
- ;Add Lumbercamp
- (defrule
- (goal goal-build 0)
- (resource-found wood)
- (dropsite-min-distance wood > 5)
- (up-compare-goal goal-townsize > 6)
- (or (housing-headroom > sn-min-pop-head)
- (population-headroom <= 0))
- (up-pending-objects c: lumber-camp < sn-max-pending-drop)
- (up-compare-goal flag-market-progress <= 1)
- (timer-triggered timer-build)
- (can-afford-building lumber-camp)
- =>
- (set-goal goal-build 1)
- (set-goal goal-spacefromself 6)
- (set-goal goal-spacefromresource 2)
- (set-goal goal-buildresource wood)
- (set-goal goal-queued lumber-camp)
- (chat-local-to-self "Lumbercamp")
- )
- ;Add Mining-Camp (Gold)
- (defrule
- (goal goal-build 0)
- (resource-found gold)
- (dropsite-min-distance gold > 5)
- (up-compare-goal goal-townsize > 6)
- (or (housing-headroom > sn-min-pop-head)
- (population-headroom <= 0))
- (up-pending-objects c: lumber-camp < sn-max-pending-drop)
- (up-compare-goal flag-market-progress <= 1)
- (timer-triggered timer-build)
- (can-afford-building mining-camp)
- =>
- (set-goal goal-build 1)
- (set-goal goal-spacefromself 6)
- (set-goal goal-spacefromresource 2)
- (set-goal goal-buildresource gold)
- (set-goal goal-queued mining-camp)
- (chat-local-to-self "Mining-Camp (Gold)")
- )
- ;Add Mining-Camp (Stone)
- (defrule
- (goal goal-build 0)
- (resource-found stone)
- (dropsite-min-distance food > 5)
- (up-compare-goal goal-townsize > 6)
- (or (housing-headroom > sn-min-pop-head)
- (population-headroom <= 0))
- (up-pending-objects c: lumber-camp < sn-max-pending-drop)
- (up-compare-goal flag-market-progress <= 1)
- (timer-triggered timer-build)
- (can-afford-building mining-camp)
- =>
- (set-goal goal-build 1)
- (set-goal goal-spacefromself 6)
- (set-goal goal-spacefromresource 4)
- (set-goal goal-buildresource stone)
- (set-goal goal-queued mining-camp)
- (chat-local-to-self "Mining-Camp (Stone)")
- )
- ;Town Size Adjust
- (defrule
- ;(timer-triggered timer-checkspace)
- (building-count-total g:> goal-townmaxbuild)
- =>
- ; (disable-timer timer-checkspace)
- (chat-local-to-self "Town Size Increase")
- (up-chat-data-to-self "goal-townsize: %d" g: goal-townsize)
- (up-chat-data-to-self "goal-townmaxbuild: %d" g: goal-townmaxbuild)
- (up-modify-goal goal-townsize c:+ 2)
- (up-modify-goal goal-townmaxbuild c:* 3)
- (up-modify-goal goal-townmaxbuild c:/ 2)
- ; (enable-timer timer-checkspace 120)
- )
- ;---Init Build---
- (defrule
- (goal goal-build 1)
- (game-time g:> goal-min-time)
- (timer-triggered timer-build)
- (up-compare-goal flag-market-progress <= 1)
- =>
- ;Set Build Start
- (up-copy-point point-startbuild-x point-self-x)
- (up-modify-goal point-startbuild-x g:- goal-townsize)
- (up-modify-goal point-startbuild-y g:- goal-townsize)
- ;Set Build End
- (up-copy-point point-endbuild-x point-self-x)
- (up-modify-goal point-endbuild-x g:+ goal-townsize)
- (up-modify-goal point-endbuild-y g:+ goal-townsize)
- ;Copy In Start, GO!
- (set-goal goal-buildrestriction 0)
- (set-goal goal-build 2)
- ; (chat-local-to-self "Init Build")
- )
- (defrule
- (goal goal-build 2)
- (goal goal-build-itteration-cur 0)
- =>
- (set-goal goal-build-itteration-end 1)
- (set-goal goal-build -1)
- )
- (defrule
- (goal goal-build 2)
- (goal goal-build-itteration-cur 1)
- =>
- (set-goal goal-build-itteration-end 2)
- (set-goal goal-build -1)
- )
- (defrule
- (goal goal-build 2)
- (goal goal-build-itteration-cur 2)
- =>
- (set-goal goal-build-itteration-end 3)
- (set-goal goal-build -1)
- )
- (defrule
- (goal goal-build 2)
- (goal goal-build-itteration-cur 3)
- =>
- (set-goal goal-build-itteration-end 0)
- (set-goal goal-build -1)
- )
- ;---Check Requirements---
- (defrule
- (goal goal-build 1)
- (up-compare-goal flag-market-progress > 1)
- =>
- (disable-timer timer-build)
- (set-goal goal-build 0)
- (set-goal goal-spacefromself 0)
- (set-goal goal-buildresource -1)
- (set-goal goal-buildgather -1)
- (enable-timer timer-build 3)
- )
- (defrule
- (goal goal-build -1)
- ; (timer-triggered timer-build)
- (up-pending-placement g: goal-queued)
- =>
- ; (disable-timer timer-build)
- (up-reset-placement g: goal-queued)
- (set-goal goal-build -2)
- ; (enable-timer timer-build 0)
- ; (chat-local-to-self "Placement Was Pending, Removed")
- )
- (defrule
- (goal goal-build -1)
- ; (timer-triggered timer-build)
- (not (up-pending-placement g: goal-queued))
- =>
- ; (disable-timer timer-build)
- (set-goal goal-build -2)
- ; (enable-timer timer-build 0)
- ; (chat-local-to-self "No Pending Placements")
- )
- ;---Attempt To Let AI Place
- (defrule
- (goal goal-build -2)
- (up-can-build 0 g: goal-queued)
- =>
- (disable-timer timer-build)
- (up-build place-normal 0 g: goal-queued)
- (enable-timer timer-build 2)
- )
- (defrule
- (goal goal-build -2)
- (timer-triggered timer-build)
- (not (up-pending-placement g: goal-queued))
- =>
- (disable-timer timer-build)
- (set-goal goal-build 0)
- (set-goal goal-spacefromself 0)
- (set-goal goal-buildresource -1)
- (set-goal goal-buildgather -1)
- (enable-timer timer-build 3)
- (chat-local-to-self "AI Placement Success")
- )
- (defrule
- (goal goal-build -2)
- (timer-triggered timer-build)
- (up-pending-placement g: goal-queued)
- =>
- (up-reset-placement g: goal-queued)
- (set-goal goal-build 3)
- ; (chat-local-to-self "AI Placement Failed")
- )
- ;---Check If Offset
- (defrule
- (goal goal-build 3)
- (goal goal-build-itteration-cur 0)
- =>
- (set-goal goal-build 5)
- )
- (defrule
- (goal goal-build 3)
- (goal goal-build-itteration-cur 1)
- =>
- ; (set-goal goal-build 6)
- (set-goal goal-build 5)
- )
- (defrule
- (goal goal-build 3)
- (goal goal-build-itteration-cur 2)
- =>
- (set-goal goal-build 5)
- )
- (defrule
- (goal goal-build 3)
- (goal goal-build-itteration-cur 3)
- =>
- ; (set-goal goal-build 6)
- (set-goal goal-build 5)
- )
- ;---Build With Restriction Common---
- (defrule ;Check If Gather Close Enough
- (goal goal-build 4)
- (goal goal-buildrestriction 2)
- ; (timer-triggered timer-build)
- (up-compare-goal goal-buildobject c:>= 0)
- =>
- (disable-timer timer-build)
- (up-build-line point-build-x point-build-x g: goal-queued)
- (set-goal goal-build 0)
- (set-goal goal-spacefromself 0)
- (set-goal goal-buildresource -1)
- (set-goal goal-buildgather -1)
- (enable-timer timer-build 2)
- (chat-local-to-self "Build Set: Resource")
- )
- (defrule ;Check If Resource Too Far
- (up-compare-goal goal-build c:>= 4)
- (goal goal-buildrestriction 2)
- ; (timer-triggered timer-build)
- (up-compare-goal goal-buildobject c:< 0)
- =>
- ; (disable-timer timer-build)
- (set-goal goal-buildrestriction 1)
- (set-goal goal-build 5)
- ; (enable-timer timer-build 0)
- ; (chat-local-to-self "Build Invalid: Restriction")
- )
- ;---Build Check Restriction---
- (defrule ;Check If Can-Build @Resource
- (goal goal-buildrestriction 0)
- (up-compare-goal goal-build >= 5)
- ; (timer-triggered timer-build)
- (up-compare-goal goal-buildresource c:>= 0)
- (up-compare-goal goal-buildgather c:< 0)
- (up-can-build-line 0 point-build-x g: goal-queued)
- =>
- ; (disable-timer timer-build)
- (up-full-reset-search)
- (up-set-target-point point-build-x)
- (up-filter-distance c: 1 g: goal-spacefromresource)
- (up-find-resource g: goal-buildresource c: 1)
- (up-clean-search search-remote object-data-distance search-order-asc)
- (up-set-target-object search-local c: 0)
- (up-get-object-data object-data-id goal-buildobject)
- (set-goal goal-buildrestriction 2)
- (set-goal goal-build 4)
- ; (enable-timer timer-build 0)
- ; (chat-local-to-self "Build Requires Resource")
- )
- (defrule ;Check If Can-Build @Gather[0]
- (goal goal-buildrestriction 0)
- (up-compare-goal goal-build >= 5)
- ; (timer-triggered timer-build)
- (up-compare-goal goal-buildresource c:< 0)
- (up-compare-goal goal-buildgather c:>= 0)
- (up-can-build-line 0 point-build-x g: goal-queued)
- =>
- ; (disable-timer timer-build)
- (up-full-reset-search)
- (up-set-target-point point-build-x)
- (up-filter-distance c: 1 g: goal-spacefromgather)
- (up-find-local c: town-center c: 1)
- (up-clean-search search-local object-data-distance search-order-asc)
- (up-set-target-object search-local c: 0)
- (up-get-object-data object-data-id goal-buildobject)
- (set-goal goal-buildrestriction 3)
- ; (enable-timer timer-build 0)
- ; (chat-local-to-self "Build Requires Gather [0] -> Gather [1]")
- )
- (defrule ;Check If Can-Build @Gather[1]
- (goal goal-buildrestriction 3)
- (up-compare-goal goal-build >= 5)
- ; (timer-triggered timer-build)
- (up-compare-goal goal-buildresource c:< 0)
- (up-compare-goal goal-buildgather c:>= 0)
- (up-compare-goal goal-buildobject c:>= 0)
- (up-can-build-line 0 point-build-x g: goal-queued)
- =>
- (disable-timer timer-build)
- (up-build-line point-build-x point-build-x g: goal-queued)
- (set-goal goal-build 0)
- (set-goal goal-spacefromself 0)
- (set-goal goal-buildresource -1)
- (set-goal goal-buildgather -1)
- (enable-timer timer-build 2)
- (chat-local-to-self "Build Set: Restriction")
- )
- (defrule ;Gather[1] Failed
- (goal goal-buildrestriction 3)
- (up-compare-goal goal-build >= 5)
- ; (timer-triggered timer-build)
- (up-compare-goal goal-buildresource c:< 0)
- (up-compare-goal goal-buildgather c:>= 0)
- (up-compare-goal goal-buildobject c:< 0)
- (up-can-build-line 0 point-build-x g: goal-queued)
- =>
- ; (disable-timer timer-build)
- (up-full-reset-search)
- (up-set-target-point point-build-x)
- (up-filter-distance c: 1 g: goal-spacefromgather)
- (up-find-local g: goal-buildgather c: 1)
- (up-clean-search search-local object-data-distance search-order-asc)
- (up-set-target-object search-local c: 0)
- (up-get-object-data object-data-id goal-buildobject)
- (set-goal goal-buildrestriction 2)
- (set-goal goal-build 4)
- ; (enable-timer timer-build 0)
- ; (chat-local-to-self "Build Requires Gather [1]: Build Check")
- )
- (defrule ;Check If Can-Build @[Resource] + Gather
- (goal goal-buildrestriction 0)
- (up-compare-goal goal-build >= 5)
- ; (timer-triggered timer-build)
- (up-compare-goal goal-buildresource c:>= 0)
- (up-compare-goal goal-buildgather c:>= 0)
- (up-can-build-line 0 point-build-x g: goal-queued)
- =>
- ; (disable-timer timer-build)
- (up-full-reset-search)
- (up-set-target-point point-build-x)
- (up-filter-distance c: 1 g: goal-spacefromresource)
- (up-find-resource g: goal-buildresource c: 1)
- (up-clean-search search-remote object-data-distance search-order-asc)
- (up-set-target-object search-remote c: 0)
- (up-get-object-data object-data-id goal-buildobject)
- (set-goal goal-buildrestriction 2)
- ; (enable-timer timer-build 0)
- ; (chat-local-to-self "Build Requires Resource")
- )
- (defrule ;Check If Can-Build @Resource + [Gather]
- (goal goal-buildrestriction 2)
- (up-compare-goal goal-build >= 5)
- ; (timer-triggered timer-build)
- (up-compare-goal goal-buildresource c:>= 0)
- (up-compare-goal goal-buildgather c:>= 0)
- (up-compare-goal goal-buildobject c:>= 0)
- (up-can-build-line 0 point-build-x g: goal-queued)
- =>
- ; (disable-timer timer-build)
- (up-full-reset-search)
- (up-set-target-point point-build-x)
- (up-filter-distance c: 1 g: goal-spacefromgather)
- (up-find-local g: goal-buildgather c: 1)
- (up-clean-search search-local object-data-distance search-order-asc)
- (up-set-target-object search-local c: 0)
- (up-get-object-data object-data-id goal-buildobject)
- (set-goal goal-buildrestriction 3)
- ; (enable-timer timer-build 0)
- ; (chat-local-to-self "Build Requires Resource")
- )
- (defrule ;Check If Can-Build Without Restriction
- (up-compare-goal goal-build >= 5)
- ; (timer-triggered timer-build)
- (up-compare-goal goal-buildresource c:< 0)
- (up-compare-goal goal-buildgather c:< 0)
- (up-compare-goal point-build-y g:<= point-endbuild-y)
- (up-compare-goal point-build-x g:<= point-endbuild-x)
- (up-point-distance point-build-x point-self-x g:>= goal-spacefromself)
- (up-can-build-line 0 point-build-x g: goal-queued)
- =>
- (disable-timer timer-build)
- (up-build-line point-build-x point-build-x g: goal-queued)
- (set-goal goal-build 0)
- (set-goal goal-spacefromself 0)
- (set-goal goal-buildresource -1)
- (set-goal goal-buildgather -1)
- (enable-timer timer-build 2)
- (chat-local-to-self "Build Set: No Restriction")
- )
- ;---Build Point Invalid, Increment---
- (defrule ;Could Not Build, Increment Y
- (up-compare-goal goal-build >= 5)
- (up-compare-goal point-build-y g:<= point-endbuild-y)
- (up-compare-goal point-build-x g:<= point-endbuild-x)
- (or (goal goal-buildrestriction 1)
- (or (not(up-can-build-line 0 point-build-x g: goal-queued))
- (up-point-distance point-build-x point-self-x g:< goal-spacefromself)))
- =>
- ; (up-modify-goal point-build-y c:+ 2)
- (up-modify-goal point-build-y c:+ 1)
- (set-goal goal-buildrestriction 0)
- ; (chat-local-to-self "Inc. Y")
- )
- (defrule ;Could Not Build, Increment X Without Offset
- (goal goal-build 5)
- (up-compare-goal point-build-y g:> point-endbuild-y)
- (up-compare-goal point-build-x g:<= point-endbuild-x)
- (timer-triggered timer-build)
- =>
- (up-modify-goal point-build-y g:= point-startbuild-y)
- ; (up-modify-goal point-build-x c:+ 2)
- (up-modify-goal point-build-x c:+ 1)
- (set-goal goal-buildrestriction 0)
- (set-goal goal-build 6)
- ; (chat-local-to-self "Inc. X -Offset")
- )
- (defrule ;Could Not Build, Increment X With Offset
- (goal goal-build 6)
- (up-compare-goal point-build-y g:> point-endbuild-y)
- (up-compare-goal point-build-x g:<= point-endbuild-x)
- =>
- (up-modify-goal point-build-y g:= point-startbuild-y)
- ; (up-modify-goal point-build-y c:+ 2)
- (up-modify-goal point-build-y c:+ 1)
- (up-modify-goal point-build-x c:+ 1)
- (set-goal goal-buildrestriction 0)
- (set-goal goal-build 5)
- ; (chat-local-to-self "Inc. X +Offset")
- )
- (defrule ;Failed Itteration 0, Start Itteration 1
- (goal goal-build-itteration-cur 0)
- (up-compare-goal goal-build >= 5)
- (up-compare-goal point-build-x g:> point-endbuild-x)
- =>
- (up-modify-goal point-build-x g:= point-startbuild-x)
- (up-modify-goal point-build-y g:= point-startbuild-y)
- (up-modify-goal point-build-y c:+ 1)
- (set-goal goal-build-itteration-cur 1)
- ; (set-goal goal-build 6)
- (set-goal goal-build 5)
- ; (chat-local-to-self "Reset For Itteration 1")
- )
- (defrule ;Failed Itteration 1, Start Itteration 2
- (goal goal-build-itteration-cur 1)
- (up-compare-goal goal-build >= 5)
- (up-compare-goal point-build-x g:> point-endbuild-x)
- =>
- (up-modify-goal point-build-x g:= point-startbuild-x)
- (up-modify-goal point-build-x c:+ 1)
- (up-modify-goal point-build-y g:= point-startbuild-y)
- (set-goal goal-build-itteration-cur 2)
- (set-goal goal-build 5)
- ; (chat-local-to-self "Reset For Itteration 2")
- )
- (defrule ;Failed Itteration 2, Start Itteration 3
- (goal goal-build-itteration-cur 2)
- (up-compare-goal goal-build >= 5)
- (up-compare-goal point-build-x g:> point-endbuild-x)
- =>
- (up-modify-goal point-build-x g:= point-startbuild-x)
- (up-modify-goal point-build-x c:+ 1)
- (up-modify-goal point-build-y g:= point-startbuild-y)
- (up-modify-goal point-build-y c:+ 1)
- (set-goal goal-build-itteration-cur 3)
- ; (set-goal goal-build 6)
- (set-goal goal-build 5)
- ; (chat-local-to-self "Reset For Itteration 3")
- )
- (defrule ;Failed Itteration 3, Start Itteration 0
- (goal goal-build-itteration-cur 3)
- (up-compare-goal goal-build >= 5)
- (up-compare-goal point-build-x g:> point-endbuild-x)
- =>
- (up-modify-goal point-build-x g:= point-startbuild-x)
- (up-modify-goal point-build-y g:= point-startbuild-y)
- (set-goal goal-build-itteration-cur 0)
- (set-goal goal-build 5)
- ; (chat-local-to-self "Reset For Itteration 0")
- )
- (defrule ;OOB, Obviously No Space
- ; (up-compare-goal goal-build-itteration-cur g:== goal-build-itteration-end)
- (up-compare-goal goal-build >= 5)
- (up-compare-goal point-build-x g:> point-endbuild-x)
- =>
- (disable-timer timer-build)
- (set-goal goal-build 0)
- (set-goal goal-spacefromself 0)
- (set-goal goal-buildresource -1)
- (set-goal goal-buildgather -1)
- (enable-timer timer-build 100)
- (chat-local-to-self "No Space, Retry in 60s")
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement