A Collection of Helpful Info and Tips

This page is just an assortment of helpful informative posts that are stored here for your information. They may eventually be converted into their own guide someday.

Table of Contents


How Local Targets Are Chosen

The strategic number scripter64 talks about below is sn-local-targeting-mode.

Question from Finaldeath: Link

Local targeting specifically affects TSA when the units are not attacking the targeted building, and when reacting to a unit under attack (in the required sn-enemy-sighted-response-distance) right?

If so this will really help. I presume siege weapons (specifically the ones hardcoded as "attacking buildings" - Petards, Trebuchets, Rams and Cannon Galleons) still act as normal and ignore this. :)

Thanks a lot - any improvement to those things are really nice and get over my befuddlement of AI armies doing silly things. I hope this puts the nail into the figurative coffin of "target evaluation SNs work" camp now :) since essentially that is what they were described as doing - this exact kind of thing.

One thing before I test it fully - what weight does the factors add? Is it a mere +1? or +50% or something? If I set it to 1 ("deal most damage") and set Rams to priority 11 and everything else to priory -1 (including buildings) will it target Rams still? for instance will Pikemen ignore the Knights and attack the Rams?

Answer from scripter64: Link

Probably, yes, to the first question. It's the general targeting system, unrelated to attack groups, attack-now, and defensive TSA building targeting, which is used to go after nearby targets. With sn:1, the true attack value (attack+bonuses-armor) * 3 + offensive-priority-value = weight. If the true attack value is <= 1, then -5 weight is used instead. For sn:2, these things only apply if the target has >= 40 base pierce armor; otherwise, sn:2 = sn:0. In other words, sn:2 is primarily for defense from things like rams coming for your trebuchets, etc. With sn:1, you might get the best behavior.

In addition, from the hard-coded 1.0c local targeting system, 5 weight is given to the current target, 0-75 weight based on distance (nearest available target is 75, farthest is 0), and 0-10 weight is given to time to eliminate the target based on number of hits and reload time. After all weights are added together, the target with the highest weight is attacked.

However, units that don't move have reduced priority compared to units that move, except rams, cannon galleons, petards, and trebuchets have this ordering reversed and prioritize units that don't move first.


How Attack Groups Select Targets

scripter64 shared how attack groups select targets for attack. This only applies to attack groups formed when sn-number-attack-groups is > 0 or attacks started with attack-now.

Original source of description: Link

How the attack group (and attack-now lol) system selects targets:

  1. group requests targeting
  2. get group characteristics:
    • is this a water group?
    • is there a unit in the group that targets only buildings? (sn-free-siege-targeting is checked here)
    • other stuff lol
  3. if this is a warship group, the effective range of the group is calculated based on sn-warship-targeting-mode
  4. loop through all available targets on the map for this group
  5. fill a list with all acceptable targets
  6. sort the list by offensive priorities/special-attack-type
  7. FINAL CHECK, where it used the shortest range unit to determine if a target in the list is reachable/acceptable
    • now changed to longest range for warship groups
    • land groups are still checked based on shortest range
  8. send group to attack the final target

Controlled Building Placement System (up-build place-control)

Here is an explanation of how the controlled building placement system works when you use place-control with the up-build command. The placement region set by sn-placement-zone-size expands by 1 per building every 7 "internal" passes. These internal passes usually happen ~10 times for each AI script pass.

This explains it better than I can:

Blue: home town center (red around it on the last series is the farm zone)
Red: target-player focus (or map center if target doesn't exist)
Green: possible placement region that expands each pass.

There are 3 series in the image with 4 passes each. I hope it's easy to visualize how they would continue to expand.


Villager Retasking Conditions

From scripter64 in 2011: Link

A retasking event will occur for a villager when they:

  • Are required on a different resource (gatherer-percentage sns)
  • Can't reach their target resource
  • Finish constructing a building
  • Have just been trained
  • Are attacked by something

Boar Hunting With Strategic Numbers

From scripter64 in 2011: Link

Here are a few example scenarios, so you can see how the various hunting sns combine to affect behavior. Villagers that are instantly retasked to provide assistance to the original hunter, due to sn-minimum-boar-hunt-group-size, may already be part of the hunting group, if sn-minimum-number-hunters has requested them up front.

Scenario #1

- sn-enable-boar-hunting: 0
- sn-minimum-boar-hunt-group-size: 0
- sn-minimum-number-hunters: 0
Result:
- Behavior is identical to pre-patch.
- Deer may be hunted after higher priority food sources.

Scenario #2

- sn-enable-boar-hunting: 0
- sn-minimum-boar-hunt-group-size: 0
- sn-minimum-number-hunters: 2
Result:
- 2 villagers will be forced to hunt deer after a retasking event is triggered.

Scenario #3

- sn-enable-boar-hunting: 1
- sn-minimum-boar-hunt-group-size: 4
- sn-minimum-number-hunters: 0
Result:
- Villagers may hunt boar or deer after higher priority sources.
- If boar hunting begins, 3 villagers will be instantly retasked to assist.

Scenario #4

- sn-enable-boar-hunting: 1
- sn-minimum-boar-hunt-group-size: 4
- sn-minimum-number-hunters: 4
Result:
- 4 villagers will be forced to hunt boar or deer.
- If boar hunting begins, 3 villagers will be instantly retasked to assist.

Scenario #5

- sn-enable-boar-hunting: 2
- sn-minimum-boar-hunt-group-size: 4
- sn-minimum-number-hunters: 0
Result:
- Villagers may hunt boar exclusively after higher priority sources.
- If boar hunting begins, 3 villagers will be instantly retasked to assist.

Scenario #6

- sn-enable-boar-hunting: 2
- sn-minimum-boar-hunt-group-size: 4
- sn-minimum-number-hunters: 4
Result:
- 4 villagers will be forced to hunt boar exclusively, ignoring deer.
- If boar hunting begins, 3 villagers will be instantly retasked to assist.

Scenario #7

- sn-enable-boar-hunting: 2
- sn-minimum-boar-hunt-group-size: 0
- sn-minimum-number-hunters: 4
Result:
- 4 villagers will be forced to hunt boar exclusively, ignoring deer.
- If boar hunting begins, no villagers will intentionally be retasked to assist.

Scenario #8

- sn-enable-boar-hunting: 2
- sn-minimum-boar-hunt-group-size: 0
- sn-minimum-number-hunters: 0
Result:
- Villagers may hunt boar exclusively after higher priority sources.
- If boar hunting begins, no villagers will intentionally be retasked to assist.


Building Construction Min/Max Distances

According to a list posted by scripter64 in 2011 (Link), the min and max distances buildings can be built with the 1.0c build command or (up-build place-normal) vary according to how the buildings are assigned to various groups:

Group 1: min: 7, max: sn-camp-max-distance

  • mining-camp

Group 2: min: 4, max: sn-mill-max-distance

  • mill

Group 3: min: sn-minimum-town-size, max: sn-maximum-town-size

  • watch-tower
  • guard-tower
  • keep
  • bombard-tower

Group 4: min: sn-minimum-town-size, max: sn-maximum-town-size

  • palisade-wall
  • stone-wall
  • fortified-wall

Group 5: min: 4, max: sn-maximum-town-size

  • Everything else

Group 6: min: 4, max: sn-maximum-town-size

  • wonder

Group 7: min: 4, max: sn-maximum-town-size

  • dock

Group 8: min: 4, max: sn-maximum-town-size

  • farm

Group 9: min: 4, max: sn-maximum-town-size

  • town-center

Group 10: min: 4, max: sn-maximum-town-size

  • house

Group 11: min: 7, max: sn-camp-max-distance

  • lumber-camp

Group 12: min: sn-maximum-town-size, max: sn-maximum-town-size * 2

  • outpost

Explanation of Building System

Here's an explanation by scripter64 of the 1.0c building system and how he changed it to fix the bug where buildings occasionally wouldn't get built for the rest of the game. It's possible the Userpatch building system has changed since this 2011 post.

I'll explain the cause by explaining how the build system works:

  • AI requests building
  • add building to build list, set flag to block activity until the next rule pass, set flag to block this building
  • found location to place building, activity block probably expired, building-specific block still active
  • building-type-count-total building + 1
  • building-type-count building + 1
  • processing
  • building-type-count-total building - 1
  • building-type-count building - 1
  • processing
  • building-type-count-total building + 1
  • building-type-count building + 1
  • processing
  • building-type-count building - 1
  • after the above: building-type-count-total is +1, building-specific block is active
  • villager is constructing...
  • building is finished
  • building-type-count building + 1
  • building-specific block is disabled

Now you can see what happens if the process is interrupted: the building-specific block is never removed. I changed the process to conditionally remove the block after the building foundation is placed, instead of after it has completed, if the user has opted in to the new system.


How to Garrison Sheep in Gurjara Mills

The Dynasties of India DLC for DE added the Gurjaras civilization which allows them to garrison sheep in mills to generate food like relics stored in monasteries. offwo gave instructions on how to garrison sheep in mills and how to overcome the default behavior where buildings without a gather point placed on itself will immediately ungarrison units when not under attack.

One other thing I should mention: to garrison sheep in mills as Gurjaras you should either use up-garrison + up-gather-inside or DUC. If you use DUC you will also need to use action-gather [with up-target-objects] to set the gather point of the mill to itself, otherwise the sheep get instantly ejected.