aliens

Author Topic: How do aliens interact with ammunition?  (Read 6699 times)

Offline Keth01

  • Captain
  • ***
  • Posts: 50
    • View Profile
How do aliens interact with ammunition?
« on: April 05, 2018, 10:24:10 am »

If an alien is equipped with a weapon that has multiple ammo types, and has multiple types of ammo in inventory (let's say hypothetically an autocannon with incendiary and AP ammo objects) how does the game behave?

I'm planning on modding in more ammunition types for the small launcher (well, a small-launcher equivalent weapon) and I'm interested in whether the aliens could actually benefit from this on the battlescape.

Also, do aliens actually use up shots from ammo they carry? I suspect not as I can't remember finding a non-full weapon but I also haven't been looking too closely.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9091
    • View Profile
Re: How do aliens interact with ammunition?
« Reply #1 on: April 05, 2018, 10:46:57 am »
They don't unload/change ammo.

They can reload if the gun is empty.

And yes, they shoot as long as they have ammo... finding an empty heavy plasma is rare, because usually you don't allow them to fire 35-times :)

Offline Keth01

  • Captain
  • ***
  • Posts: 50
    • View Profile
Re: How do aliens interact with ammunition?
« Reply #2 on: April 05, 2018, 12:41:16 pm »

Thanks! So essentially, if I assign the alien an equipment set with the type of ammo I want it to use, that's what it'll load, simple as that?

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11722
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: How do aliens interact with ammunition?
« Reply #3 on: April 05, 2018, 02:28:49 pm »
If an alien uses an Auto-Cannon and needs to reload, and has both AP and HE clips in the inventory, how is it decided which clip type is used first?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9091
    • View Profile
Re: How do aliens interact with ammunition?
« Reply #4 on: April 05, 2018, 02:54:14 pm »
There is no preference... whatever is found first when going through inventory slots is used.

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: How do aliens interact with ammunition?
« Reply #5 on: April 05, 2018, 02:59:10 pm »
There is preference for items that are in inventory slots that cost the least to move to the hand, if somehow you give the AI enough items to use more than hands and belt.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9091
    • View Profile
Re: How do aliens interact with ammunition?
« Reply #6 on: April 05, 2018, 03:15:06 pm »
I assumed this was a question for OXC (not for OXCE), in which case all reload costs 15 TU and there is no preference (accidental or intentional).

As for OXCE/OXCE+, the least costly reload would be chosen... if there are multiple such reloads, again no preference.

KZad Bhat

  • Guest
Re: How do aliens interact with ammunition?
« Reply #7 on: April 05, 2018, 11:37:08 pm »
Would it be more accurate to say that it would carry through a set order of the inventory? Say, not only by order of quickest to retrieve, but then also within that in order from space to space, looking much like from top left to the right then down.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9091
    • View Profile
Re: How do aliens interact with ammunition?
« Reply #8 on: April 05, 2018, 11:53:30 pm »
It iterates via items in the unit's inventory, not via inventory slots.

Whoever still wonders, here's the code: https://github.com/SupSuper/OpenXcom/blob/master/src/Savegame/BattleUnit.cpp#L2041

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: How do aliens interact with ammunition?
« Reply #9 on: April 06, 2018, 07:12:01 am »
yeah, order as listed in the ruleset = order of precedence

Offline Keth01

  • Captain
  • ***
  • Posts: 50
    • View Profile
Re: How do aliens interact with ammunition?
« Reply #10 on: April 06, 2018, 09:09:41 am »
So, as a follow on, if I wanted the aliens to do more damage with a weapon than XCOM does (say it's the late game and I want to up damage but not switch to 'all heavy plasma all the time')
I could create a non-recoverable ammo type that does the damage I want, make sure it's listed ahead of the regular ammo in the list order, and then when I give it to aliens alongside the regular clip they'll use it and reap the benefits but it will never become 'visible' to the player? They'll find a gun and regular ammo as expected?

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11722
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: How do aliens interact with ammunition?
« Reply #11 on: April 06, 2018, 10:58:22 am »
yeah, order as listed in the ruleset = order of precedence

You mean in alienDeployments?

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: How do aliens interact with ammunition?
« Reply #12 on: April 06, 2018, 11:21:20 am »
You mean in alienDeployments?

So, as a follow on, if I wanted the aliens to do more damage with a weapon than XCOM does (say it's the late game and I want to up damage but not switch to 'all heavy plasma all the time')
I could create a non-recoverable ammo type that does the damage I want, make sure it's listed ahead of the regular ammo in the list order, and then when I give it to aliens alongside the regular clip they'll use it and reap the benefits but it will never become 'visible' to the player? They'll find a gun and regular ammo as expected?

yes.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11722
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: How do aliens interact with ammunition?
« Reply #13 on: April 06, 2018, 03:21:11 pm »