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

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9055
    • View Profile
requested by luke83
« Last Edit: February 22, 2019, 12:16:41 pm by Meridian »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9055
    • View Profile
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 2 global settings:

Code: [Select]
ai:
  pickUpWeaponsMoreActively: false      # for aliens, default is false
  pickUpWeaponsMoreActivelyCiv: false   # for civilians, 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: May 19, 2020, 08:53:47 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?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9055
    • View Profile
Re: [Suggestion] Option for AI to pick up weapons more actively
« Reply #3 on: May 14, 2020, 07:52:49 pm »
There is a new setting in "units" ruleset.

Since OXCE v6.5, this option applies also to civilian AI, not only to alien AI.

Offline Finnik

  • Commander
  • *****
  • Posts: 505
  • Finnik#0257
    • View Profile
Re: [DONE] [Suggestion] Option for AI to pick up weapons more actively
« Reply #4 on: May 14, 2020, 08:07:09 pm »
So by default civilians inherit a global setting and in order to keep behavior that was before 6.5 I would need to set up `pickUpWeaponsMoreActively: 0` for all civilian units if I don't want them to shoot plasma rifles (even if I can't do that yet)?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9055
    • View Profile
Re: [DONE] [Suggestion] Option for AI to pick up weapons more actively
« Reply #5 on: May 19, 2020, 08:52:10 pm »
Yes.
Or change the global setting back to default and only use unit settings.

EDIT: Since OXCE v6.5.1, the original global setting will apply again only to alien AI. Civilian AI will have its own global setting "pickUpWeaponsMoreActivelyCiv".
« Last Edit: May 19, 2020, 09:17:56 pm by Meridian »

Offline Finnik

  • Commander
  • *****
  • Posts: 505
  • Finnik#0257
    • View Profile
Re: [DONE] [Suggestion] Option for AI to pick up weapons more actively
« Reply #6 on: May 24, 2020, 08:48:02 pm »
TY! 6.5.0 update would force me to set this option to false (or code that myself, but I'm afraid to go to AI part), as I don't want civilians shooting plasma when I cant (I have alien weapons that humans cant use by lore).