Author Topic: Weapon use order  (Read 3507 times)

Offline Nord

  • Commander
  • *****
  • Posts: 1746
  • The Gate is open.
    • View Profile
Weapon use order
« on: December 19, 2018, 01:24:58 pm »
I can not understand order or better say rating of weapon for AI.
When i give to the unit buitin ranged weapon with snapshot and normal melee weapon, it use both. If builtin ranged weapon have only aimed shot, then unit dont use it, only melee.
Looks like same for normal weapons: if ranged weapon have only aimed shot, then unit will ignore it and use melee (looks strange when the unit with fireball and a knife runs through map to cut someone instead of burn them to ash).
So, there is a question: which order do AI use to choose which weapon to shoot? Maybe some key parameters? If i want to give to a the unit two weapons and want him to use both, what should i do?

Sorry for random articles spelling.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9089
    • View Profile
Re: Weapon use order
« Reply #1 on: December 20, 2018, 11:23:50 am »
VERY roughly:

1. if a unit can do a psi attack, and it has a semi-decent chance to succeed... it will use psi
2. otherwise, if a unit has a blaster launcher and enough waypoints... it will use a blaster
3. otherwise, in OXCE only, if a unit is a sniper and there are some spotted xcom units, it will try sniping
4. otherwise, if a unit has a grenade, and it's worth using, it will try using it
5. otherwise if a unit has any melee or ranged weapon:
- it will calculate melee attack efficiency based on various parameters and roll dice... if rolled, it will try melee first and ranged second, otherwise it will try only ranged
- if there are two ranged weapons, it will use the one that has ammo and a snap shot mode; if both have snap shot mode it will use the quicker one (less TU to shoot)

Offline Nord

  • Commander
  • *****
  • Posts: 1746
  • The Gate is open.
    • View Profile
Re: Weapon use order
« Reply #2 on: December 20, 2018, 01:38:08 pm »
Good.
And by sniping you mean aimed shot to distant target?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9089
    • View Profile
Re: Weapon use order
« Reply #3 on: December 20, 2018, 02:22:32 pm »
Good.
And by sniping you mean aimed shot to distant target?

Yes, a shot beyond the maximum visibility range, or through smoke, or through otherwise obstructed vision.

Not sure if aimed only, I think it can be theoretically also a snapshot or autoshot... but I would have to look at the code to find out.

Offline Nord

  • Commander
  • *****
  • Posts: 1746
  • The Gate is open.
    • View Profile
Re: Weapon use order
« Reply #4 on: December 20, 2018, 03:09:30 pm »
Thanks. This list is really helpful.

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: Weapon use order
« Reply #5 on: December 20, 2018, 06:04:35 pm »
It's not just aimed shot for sniping, the AI does a rough consideration of the number of expected hits per shot type per turn and picks which mode gets the most, with some RNG fuzziness thrown on top for flavor.