Author Topic: [DONE] [Suggestion] Option for AI to pick up weapons more actively  (Read 725 times)

Online Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 5557
  • Aaand we're back!
    • View Profile
    • My Wiki
requested by luke83
« Last Edit: February 22, 2019, 12:16:41 pm by Meridian »

Online Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 5557
  • Aaand we're back!
    • View Profile
    • My Wiki
Re: [Suggestion] Option for AI to pick up weapons more actively
« Reply #1 on: February 05, 2019, 02:11:12 pm »
There is a new setting in "units" ruleset.

Code: [Select]
units:
  - type: STR_SECTOID_SOLDIER
    pickUpWeaponsMoreActively: -1    # -1 (default) = take global setting, 0 = disabled, 1 = enabled

and a global setting:

Code: [Select]
ai:
  pickUpWeaponsMoreActively: false   # default is false

There is also an existing attraction attribute on the items:

Code: [Select]
items:
  - type: STR_HEAVY_PLASMA
    attraction: 10
  - type: STR_HEAVY_PLASMA_CLIP
    attraction: 10

When the "pickUpWeaponsMoreActively" is activated, the algorithm removes the following vanilla limitations:
1. aliens can pick up items even if they see an xcom unit
2. aliens can pick up any weapon, not only those dropped during alien turn
3. alien terrorists can pick up items too

Item attraction attribute needs to be higher than 0.
Distance is also considered, the final_attraction = attraction / (distance*2 + 1)

I.e. to pick up items:
- 0 tiles away you need attraction >= 1
- 1 tile away you need attraction >= 3
- 2 tiles away you need attraction >= 5
- 3 tiles away you need attraction >= 7
- etc.

Item with highest final_attraction is chosen.

Note: in vanilla the numbers would need to be even higher, because there was one more check (which is now turned off for units with "pickUpWeaponsMoreActively")...  "attraction - (distance*2) > 5" needed to be true

--------------

However, even with these limitations removed, the outcome would barely change, since the AI is mostly in Escape mode when it doesn't have a weapon and it would take at least 2-3 turns to start shooting:
1. one full turn to go to the weapon (even if it's just 1 tile away)
2. one full turn to pick up a weapon and continue escaping
3. one to many turns to reconsider escape strategy to combat strategy and start shooting

So I have changed the AI strategy too (only for units with "pickUpWeaponsMoreActively" activated):
- walking to the weapon doesn't end the alien turn anymore
- picking up a weapon causes alien to reconsider its strategy... and hopefully start shooting instead of running away (not guaranteed)

Feedback welcome.
« Last Edit: February 05, 2019, 02:14:39 pm by Meridian »

niculinux

  • Guest
Re: [Suggestion] Option for AI to pick up weapons more actively
« Reply #2 on: February 18, 2019, 11:46:47 am »
I really like that, but I've been playng lately to xpiratex 0.99J.11 (oxce 5.2, 21-Jan-2019 experimental build) and enemies did not pick up weapons at all. Maybe in the mod it is disabled?