Author Topic: [Documentation] AI Support for Limited-Range Weapons  (Read 734 times)

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1718
  • Flamethrowers fry cyberdisk circuits
    • View Profile
[Documentation] AI Support for Limited-Range Weapons
« on: January 31, 2018, 09:29:37 pm »
With the release of OXCE+ 3.10, a few new AI behaviors have been added targeted at improving the enemies' use of weapons that have limited max range or use altered UFO Extender Accuracy ranges. The previous behavior when the AI was attempting to shoot with a weapon beyond its maximum range was that it'd select a firing mode and attempt the shot, but since this was not possible the unit would just stand there. The first change is an override to that behavior - respectMaxRange: true in the ai: ruleset will have the AI skip trying to fire when beyond the maximum range of the weapon, allowing it to move when otherwise it would stand still and attempt impossible shots.  If the original behavior is preferred on a per-unit basis, then waitIfOutsideWeaponRange: true can be set in that unit's ruleset, otherwise it defaults to whatever was chosen for respectMaxRange.

The second change is an extension to how the AI picks which firing mode it uses; the original behavior is to pick the firing mode based on set distances to the target and on whether or not the unit has the TUs to fire.  Setting extendedFireModeChoice: true in the ai: ruleset will make the AI use an algorithm to score each firing mode based on the distance to the target, the accuracy of each shot type at that distance, and the amount of TUs it will take to fire.  A higher score comes from a higher expected amount of damage at that range and means that firing mode will be preferred.  The exact workings of this scoring algorithm are documented with the Scout/Sniper AI feature.  Turning this behavior on overrides respectMaxRange: true (but not waitIfOutsideWeaponRange), as it already includes consideration of the distance to the target.

The last change alters how the AI picks a spot to move to if a unit can't shoot from where it's standing.  When extendedFireModeChoice: true is set and the unit's weapon has a maximum range shorter than the distance to the target, then tiles that are closer to the target will be preferred with an increase in 'score' proportional to the range of the weapon divided by the distance to the target. Note that this does not guarantee the enemy will try to close the distance, it's just a nudge in the right direction.

Here's an example ruleset for all of these features, works best if UFO Extender Accuracy is turned on:
Code: [Select]
ai:
  respectMaxRange: true #overriden by next line, but here for completeness. default false
  extendedFireModeChoice: true #default false

units:
  - type: STR_SECTOID_NAVIGATOR
    waitIfOutsideWeaponRange: true #Sectoid navigators will just stand there if their weapon is short-ranged. default false

items:
  - type: STR_PLASMA_PISTOL
    maxRange: 10 # Aliens will need to move much closer to use their pistols

  - type: STR_PLASMA_RIFLE
    maxRange: 15 # Aliens will need to move somewhat close to user their rifles

  - type: STR_HEAVY_PLASMA
    autoRange: 12 # Prepare for hails of heavy plasma fire ;)
« Last Edit: July 17, 2018, 02:36:53 pm by Meridian »