Talk:Alien Inventory Use

From UFOpaedia
Jump to navigation Jump to search


Slot 2, Aiming, Unloading

Aliens must completely ignore the inventory position of all equipment, except those in slot 0 and 1. They simply use slot 2 as the default universal dump where they store stuff whenever they move items out of their hand.

The aliens make no distinction between who owns the weapons (eg human vs alien technology?), so will treat all weapons the same and will fire them based on their available weapon modes. Except aimed. I don't think they know how to use aimed shots - but haven't tested this theory yet.

(By deduction from TUs remaining) they do use Aimed mode but I've only observed it for launchers - all types. This may also explain the unexpected preference for arming unloaded HC-HE over unloaded RL - there were not enough TUs to draw/arm, load and then still get off an Aimed shot with the RL. Spike 04:52, 5 March 2009 (CST)

I don't think the aliens have reason to unload a weapon so they probably won't ever need to do this.

But how do they decide when a weapon takes multiple ammo? I would assume that they just use whatever is loaded. When they do reload the weapon, they might not be terribly fussy with this and go with the one highest up in obdata.dat, basically AP, HE and Incendiary or small rocket, large rocket, incendiary in that order.

With the psi-amp, can the aliens really use this or will the aliens use the MC'd soldier's latent psi abilities just like any other alien? This could be easily tested with one remaining psi alien and a whole army of mediocre psi strength troops - with strong psi skill.

non-standard grenades: Smoke grenade and proximity mine. I have this funny feeling that I have seen them use smoke grenades before, since its mechanics are no different from any other grenade. It just does a different damage type. Proximity mines however are different entirely.

What about blaster launcher dud shells? Do the aliens know how to unload them?

-NKF 00:43, 3 March 2009 (CST)

Concerning Psi: from my tests at the StrategyCore forums years ago, I remember finding that only troopers with a Psi-Amp and under alien control could wage psi-attacks against his ex-buddies. Fairly sure on this. --Zombie 01:14, 3 March 2009 (CST)

Thoughts, and Proposal for AI Unloading/Reloading Test

Given the AI never does anything that could not be immediately lethal to your soldiers, I doubt that the AI has any code in it for using Smoke Grenades, an entirely nonlethal weapon. (This also may be part of why it can't use Stun Rods; they're nonlethal tech the AI normally doesn't even have access to.)

Similarly, since it's pretty well suspected that Prox Grenades were added late in the development, given the shoddy handling of the Prox Grenade matrix, it's unlikely the AI has any code to use them either.

Past that, for loading/unloading, I view it as unlikely...there's only three weapons in the game you'd ever gain a tactical benefit from unloading(unloading an unused clip to store or sell is not a tactical benefit, at least not immediately!), the Rocket Launcher, the Heavy Cannon, and the Auto Cannon. Of course, none of these are normally available to the AI.

Also Blaster Launcher re dud rounds, as noted above - making 4 weapons it is useful to unload. 5, if dud rounds ever happen with a Small Launcher? Spike 19:35, 5 March 2009 (CST)

Overall, I view it as moderately unlikely that the AI would have unloading/reloading code, due to the fact that the number of times the situation would arise is rather low. However, one possibly effective way to test this would be to give the AI(either through MC or by editing the map) no weapons other than Auto Cannon or Heavy Cannons loaded with Incendiary ammunition and carrying a spare clip or two of AP or HE, faced up against a squad of armored X-COM soldiers. Armored X-COM soldiers are immune to fire, so this would force the issue. (The Rocket Launcher could also be used, but due to the fact that the AI can 'unload' the weapon easily by firing the Incendiary rocket, the test results might be weaker.)

If the AI fires Incendiary shells at the armored X-COM agents, or does not fire at all, then it likely possesses no "unloading" code. (The AI may choose not to fire at all if it cannot damage the units; I'm not sure). If, however, your agents start getting pegged with HE or AP ammo(before the first clip runs out!), then it is clear that it can in fact unload and reload weapons. It may be beneficial to amp up the damage on the HE and AP ammo so it can present a threat to the agents. On a final thought, the Debug Mode hex edit would be useful for this test to monitor alien ammunition as well as if/when they reload. Arrow Quivershaft 00:48, 3 March 2009 (CST)

Again, from my tests at the StrategyCore forums (I believe it's in the "Strange Things In X-COM" thread, aliens are able to reload weapons. I know this for a fact. --Zombie 01:14, 3 March 2009 (CST)

I have no doubt the aliens can reload weapons, given they have both the Small Launcher and Blaster Launcher, each one shot weapons which they use often if given the chance. I was more referring to whether the aliens can unload a clip and then load in a new one. Thus why I suggested giving the aliens a useless weapon, with ammo that could then fix this issue, if the alien would only unload the first clip. Or am I misunderstanding what you wrote entirely? Arrow Quivershaft 01:17, 3 March 2009 (CST)

Um, no. I probably misunderstood you. Anyhow, from what I remember, an alien will always exhaust a clip fully before loading in a new spare. --Zombie 01:22, 3 March 2009 (CST)

That's what I figure too, since the number of times the situation would come up is so small its hard to justify the AI code for it. But I figure it should be tested nonetheless. Arrow Quivershaft 01:25, 3 March 2009 (CST)

Dud clips might be a good test. Just make a battlescape save, then edit the obpos.dat file and set the loaded ammo clips for all alien weapons to 0.
Also just tried the smoke grenades. No, they can't use them. It might be either one of two scenarios. They are only familiar with grenades set to their default HE setting and not smoke or proximity (being later additions - so it's "alien" to them). Or the usage of some obdata slots are hidden to them. Similar how only select special items have their menus available to the player. -NKF 01:27, 3 March 2009 (CST)

Ok in 2 out of 2 tests (!) a Sectoid Navigator armed with an unloaded Auto Cannon and a selection of HE and IN clips, loaded the HE clip both times. Between the 2 tests I reversed the position of the 2 clips ( 1 in backpack, 1 in belt) in case they were just loading the first clip in the slot list. It does look like they favour HE. Alien Intel is better than we thought - they know the strengths and weaknesses of our weapons, and their troops are trained to use them!

Sadly we did not pack any AP rounds in the assault ship - the quartermaster muttered something about them being "obsolete now dat you apes got da Heavy Lasers". (Time to break out BB's editor for some more extensive testing.)

A couple of tentative observations on loading / reloading. The aliens don't reload immediately, they continue on their patrol route (or retreat?) and only reload when they spot a target. This might be a good tactic since if they spot a human, other aliens can attack the target by various means. A hive mentality at work! Spike 11:20, 3 March 2009 (CST)

Spike: Good job! That is helpful, but try to get an AP clip in there. Perhaps the alien loads the highest clip in the order. HE is before IN, and AP is before HE. Alternately, I saw a hack that edited the game to HE was the preeminent clip used by the game over AP(in order that the game would auto-load HE clips into weapons). Another suggestion: Try again by giving the alien the Autocannon with the IN clip already loaded in, along with a spare HE clip, and see what happens. Arrow Quivershaft 11:55, 3 March 2009 (CST)

AI Weapon Preferences

I'm not sure I want to try every combination of preferences but here are a few AI preferences I've tested so far:

  • Loaded AC-I prefered vs reload with AC-HE
  • Loaded AC-I prefered vs Laser Rifle (always loaded)
  • Loaded HC-HE prefered to RL loaded with Lg Rocket!!! Maybe due to range, or TUs, or ???
  • Choice of rocket types:
    • Small then Large then Incendiary (regardless of placement order in inventory)
  • Generally seems to prefer a loaded weapon to one that needs loading but...
  • Prefers to load and fire a Rocket Launcher vs using an already loaded Pistol!

The testing is pretty sloppy and basic so far. Usually one target but sometimes multiple bunched targets in sight. Usually but not always changing the order of weapons in inventory to see if that makes a difference. I don't think it does. I don't think 'selecting' (as for a Soldier) has any effect. But possibly once an alien gets started with a weapon it might stick with it, so I try to start again from scratch (no weapons) when testing.

Spike 18:47, 3 March 2009 (CST)

Based on your result you got with the Rocket Launcher, I suspect it is simply using available ammunition in the order presented in OBDATA.DAT. This would also imply that it will prefer to load AP clips into the AC and HC over HE clips. This would also imply the computer cannot unload weapons, which isn't surprising. Arrow Quivershaft 20:26, 3 March 2009 (CST)

Yes! Testing your theory's prediction I found agreement:

  • Ammo is loaded in this preference order: AC, HE, IN
  • HC-AP is preferred to AC-AP

Both results follow OBDATA order.

So far so good. But also some anomies:

  • HC-AP is loaded in preference to Rifle. Logical but not OBDATA order.
  • Unloaded HC is loaded with AP and fired, in preference to an already-loaded Rifle.
  • Heavy Plasma is loaded in preference to Rocket Launcher
  • But an already loaded Rocket Launcher (Sm Rocket in the test) is fired (Aimed x 1) in preference to loading and firing a Heavy Plasma (Snap x 2).

So the jury's still out and more data is needed. It could be an OBDATA-like list such as used by the Equip screen defaults / 80 item limit. (I should check that list from Base Defence). It could even be some kind of basic firepower calculation, eg damage per round vs # of rounds that can be fired?

Spike 03:45, 4 March 2009 (CST)

I didn't mean to imply that the AI would always choose weapons based on the order on OBDATA. I meant that when it was presented with multiple ammo forms for the same weapon, it would load based on which came first in OBDATA. I figure the AI has some weapons calculations. I would say that perhaps it draws out of the list that determines the order in which weapons spawn, like in a Base Defense. But it can't be doing that, because then it would choose the Laser Rifle in preference to most other weapons. Though I wonder if the reason it ignores the Laser Rifle has something to do with the fact that the AI might be reading the Laser weapons as having 0 ammunition, and unable to find a clip, discards it as useless in preference to the weapon that is loaded or it can load? (And before you bring up terror units, I'll note that the weapons of the non-melee terror units do indeed have ammunition; they have 254 ammo, if I recall. Far more than they'll ever need in a single mission.) Arrow Quivershaft 19:07, 4 March 2009 (CST)

AI Weapon Preferences Table

Weapons ranked in order of preference for use by the AI. See below for method and limitations.

Weapon-Ammo    Pre-use   Base Dmg
Blaster Lchr   Loaded    200  HE
Hvy Plasma     Loaded    115
RocketLchr-Lg  Loaded    100  HE
Heavy Laser    Loaded     85
Small Lchr     Loaded     90  STUN
Plasma Rifle   Loaded     80
Laser Rifle    Loaded     60
RocketLchr-Sm  Unloaded   75  HE
RocketLchr-In  Unloaded   90  IN
Plasma Pistol  Loaded     52
Laser Pistol   Loaded     46
HC-AP          Loaded     56
HC-HE          Unloaded   52  HE
HC-IN          Unloaded   60  IN
AC-AP          Loaded     42
Rifle          Loaded     30
AC-HE          Unloaded   44  HE
AC-IN          Unloaded   48  IN
Pistol         Loaded     26

Method and Limitations

One alien (Sectoid Navigator, Superhuman difficulty, Jan '99)was stacked with one each of every weapon, ammo and explosive type, all weapons loaded and all grenades primed (except Alien Grenade). This was achieved by using BB's editor to reduce the weight and dimensions of each item to 1 Weight, 1x1 Size. BB's editor was used to create the items and move them into inventory slots. All inventory slots were used, except that weapons/explosives were not placed in any of the Hand slots, and no items were placed in the Right Hand slot. After a weapon was drawn and fired by the AI, it was returned to inventory by Mind Control (or discarded, if all ammo types for that weapon had been tested). AP was initially loaded into the AC and HC. Large Rocket was initially loaded in Rocket Launcher. Throughout the test, there were multiple (mostly) unarmoured human targets in view of the alien at a short but HE-safe range (in a Skyranger). Mind control was used after each test fire, to verify what weapon the alien had used. All moves of weapons into hands, firing, and any new ammo loading was done by the AI, not under human Mind Control.


  • The list above is pretty much in reverse order of base damage, with some slight anomalies that need accounting for.
    • Heavy Laser (D=85) was drawn and fired in preference to drawing and firing a Small Launcher (D=90 STUN). Why? A preference for lethal damage? Because the Launcher is a one shot weapon? TU cost of drawing it?
    • Plasma Pistol (D=52) and then Laser Pistol (D=46) were both drawn and fired in preference to drawing and firing a loaded HC-AP with greater Base Damage (D=56). Why? (Maybe due to higher TU costs to draw the HC from the backpack - see below)
  • @NKF: this list seems to show the AI does not discriminate against pistol-type weapons. It treats them fairly, based on their Base Damage. If anything it might slightly favour them. And possibly the same or similar rules are used to arm humans in the Equip Screen.
It's possible that the pistol preference "feature" is only a rule for arming X-COM units during the pre-battle to battle phase. In fact, I'm starting to believe that this was introduced in CE - and wasn't present in the Dos games, as I haven't noticed it in the dos version which I've been puttering around with recently for an all-pistol mod I'm working on (very slowly!) -NKF 13:17, 7 March 2009 (CST)
  • Within multi-ammo weapons (AC HC RL), ammo-type preference seems (from previous tests) to be in OBDATA order
  • As an extra test: a loaded Pistol, when placed in the Right Hand, was fired in preference to all other (loaded) weapons in inventory. This implies any loaded weapon in the hand is preferred to any other weapon in inventory (possibly subject to target's armour level?)
  • After the Blaster Launcher was drawn and fired, with its remaining TUs the alien "pocketed" the empty weapon in Slot 2, and equipped the Heavy Plasma in its right hand. All under AI control. This gave the misleading appearance that the alien had 'cheated' and fired the Blaster from its "magic pocket", slot 2.
  • Remember this is against unarmoured targets. With Psi, the AI preys on weak targets. Similarly, with more heavily armoured targets, its weapon choice might change - more testing needed.
  • The AI does not decline to fire on a target even if it has no chance of damage. My 2 Psi troopers at the back of the bus had 255 all round and under armour. The alien kept firing at them with whatever it had, even down to Pistol, despite having zero chance of causing damage.
  • Interestingly the only weapons that did damage the 255-armoured troops were the IN rounds.
  • BB's editor has a quirk that newly spawned ammo all has 255 capacity. This is treated as infinite, with the capacity counting into negative values - even for rockets. Actually this is quite helpful for test purposes, as it stops the AI from deeming one-shot weapons to be empty and swapping them out before the turn is over (as with the Blaster Launcher, which for some reason is not affected by this quirk)
  • No grenades or explosives were ever used by the AI. Not sure why, as clearly aliens do use grenades. Possibly it is because I had already primed them, and the detonation turn had expired by the time they became the alien's "best" weapons? However, I didn't prime the Alien Grenade (since we know aliens can do that themselves) and it didn't get used either. Even when I put primed grenades in the hands of otherwise weaponless aliens, they did not use the grenades. (Maybe only the heavily armoured troops were still alive at this point?) Re-testing needed.
  • I intend to repeat the test using a total of 9 AC/HC/RL, one loaded with each ammo type (3 x 3). It didn't occur to me that this is feasible, and a better controlled test.
  • I wonder if a Soldier would've behaved differently. Maybe only Soldiers have the logic to throw grenades? Do MC'd humans use grenades?
  • Next time I will try not priming the grenades beforehand in case that makes a difference.

Spike 08:29, 6 March 2009 (CST)

Just a question here. In what order did you place the weapons in the leg slot? If the slot is a stack (like in computer science terminology FILO: First In, Last Out), then the alien may be ignoring the actual weapon/weapon strengths and just grabs whatever is at the top of the stack. Though, I seem to recall aliens being able to access all of it's inventory no matter where it may be in the stack order. --Zombie 10:01, 6 March 2009 (CST)
Might have misunderstood what you said above Spike. To verify, you just placed the reduced-size/weight items into various slots around the aliens body? So you didn't actually stack all the weapons into one inventory slot? I would think that stacking everything into the leg slot and letting the alien pick and choose what it wants from there would have fewer unknowns since they don't carry stuff in the other areas of the body. Don't know whether a test like this can be taken as 100% true if it's basing the conclusion off a scenario which would never happen (not stacked into the normal slot). Anyway, something to think about. --Zombie 11:37, 6 March 2009 (CST)
Obviously your soldiers were in Coveralls, since any X-COM manufactured armor renders troopers immune to fire and smoke damage. Burn damage from being on fire ignores armor values, as shown by the fact that a burning tank steadily loses HP, despite having armor well above 10(the maximum burn damage per turn), and a damage resistance to incendiary.
On a note, Zombie makes a good point. It would be a far longer test series, but if you only gave the alien two weapons at a time, you could stuff them into the magic pocket after the size edit and use that to establsh priority. IE: "The alien selected the Plasma Pistol over the Rifle. So the Plasma Pistol should also be selected over AC-HE. AC-IN, and the Pistol. As for the grenades, the AI does not use grenades with massive frequency; they only usually do it if you've got careless unit clustering. Arrow Quivershaft 13:06, 6 March 2009 (CST)

AQ the test method you describe is highly rigorous but has N! (N-factorial) test cases. I think my method is elegant in comparison as it has only N test cases. I won't be doing N! any time soon! :) Spike 13:41, 6 March 2009 (CST)

Sorry if that comment was a bit brusque AQ - I was ever so slightly drunk when I wrote it! Also I think the number of combinations is not quite N! but closer to N-perm-2 which is still very large but not ridiculous. Anyway I will press on. I've discovered BB's editor will allow me to put multiple items in the same slot, so I can also follow Zombie's suggestion and put every item in Slot 2, as the game normally does. As well as putting in 9 loaded multi-ammo weapons (AC HC RL x AP HE IN), I am going to put a reload in for every weapon. This nearly doubles the number of test cases but gives a comprehensive picture of whether the AI would rather reload the weapon it has in hand, or downgrade to a lesser (but loaded) weapon in inventory.

And as I write that I can see a problem with my method on the first test, that is related to inventory placement. If the AI follows the TU rules for moving equipment around - and I think it does - some locations are more expensive to move from than others. So for example, everything in the backpack would be at a disadvantage. If the AI uses the TU cost in its calculations, that would affect its choices. Even if it doesn't factor the TU costs of item movement into its calculations, it could affect what actually happens, eg whether the alien has enough TUs to fire, and in which mode. Since the AI likes Aimed fire for some weapons at least, this could be significant. Anyway, luckily I can put all the weapons in Slot 2, just like "real life", and so get around this problem.

Watch this space for results! Spike 09:06, 7 March 2009 (CST)

An interesting test would be to swap the stats for, say, the Plasma Pistol and Plasma Rifle (and the clips) in obdata.dat, then run some tests to see whether that plays any role. Probably doesn't if the AI is picking based on damage. Or another similar test would be to "up" the damage of a Plasma Pistol to that of the Plasma Rifle, then compare the two. --Zombie 10:01, 7 March 2009 (CST)
Very good suggestion. I tried a few things. Hacking the Pistol to D=254, the Blaster Launcher is still used first. However the Pistol is used 2nd. If you hack HC-HE to D=253, HC is used first - in preference to Blaster or hacked Pistol. Sounds like some kind of extra weighting or hard coding is given to HE or Area Effect weapons. Or maybe just to the Blaster Launcher. I'll keep investigating. Spike 13:40, 7 March 2009 (CST)
Hmmm, very interesting. One other idea is to hack the damage of the Plasma Pistol Clip to HE (ave dam=200) and compare that to the Blaster. :) --Zombie 13:50, 7 March 2009 (CST)
Spike: No offense taken. I knew it was a rigorous test, and I didn't even interpret it as rough. So no harm, no foul. As for HE weapons getting a boost over others, this makes sense to me. HE weapons offer both the ability to kill more than one enemy with a single shot, and also allow you to hurt or kill the enemy even on near misses. And while the maximum damage is lower, so is the variability; it's guaranteed to have a non-zero damage roll. So a 115 damage HE weapon is more or less by definition more powerful on a single shot than a Heavy Plasma, since you have AoE, multikill potential, and guaranteed damage on a hit(presuming armor doesn't zero it out.) You also get on a close hit to apply the damage against Under Armor, which is uniformly the weakest facing on all X-COM armor. Arrow Quivershaft 04:11, 8 March 2009 (CDT)

Re-Test Results

I retested this with a better setup: placing all weapons in Slot 2, and with all ammo types initially loaded into a weapon (eg 3 ACs, 3 HCs, 3 RLs were carried, each loaded with a different ammo type). I also provided a 'reload' for each ammo type to see the preference for reloading an expended weapon vs using an already pre-loaded one.

On the downside, I still did not fully control the tactical environment (targets presented to the alien etc). I'm not sure I controlled the reloading options - sometimes there was an empty weapon in hand, sometimes the empty weapon was in inventory. Sometimes I made mistakes like dropping a weapon before checking if the AI would reload - I tried to backtrack on these but may not be 100%. Lastly, I was plagued with crashes, no doubt due to extensive editing of the game files (using BB's Editor). To complete the 40 test cases I probably had 60-100 crashes. There were definitely some 'bad records' in the game files - records that even crashed the BB Editor when I tried to look at them - and this may have influenced the AI behaviour.

Having said all that, the results strongly reinforce the view that the AI chooses loaded weapons from Slot 2, in reverse order of Base Damage (highest first). Stun and Incendiary types seem to be at a slight discount (no more than 15%) on their Dmg - or maybe the use of those weapons is influenced by the tactical situation. There is no discernable premium for HE, Area Effect, or auto-capable weapons. Nor is there much evidence of a premium for using a multi-shot weapon over a one-shot weapon. In reloading weapons, I didn't see the clear pattern of "OBDATA order" that I thought I saw before. Nor did I see a clear pattern of "Dmg order" for reloading. In many cases, if there was an unloaded weapon (and ammo) in inventory with at leat 15-30% greater Dmg than the most powerful loaded weapon, the unloaded weapon would be loaded and used in preference to the weaker loaded weapon. However, this was not 100% consistent and there were significant counter-examples (notably Laser Rifle(D60) used over unloaded Plasma Rifle(D80) @+33%; Rifle(D30) used over unloaded AC-AP(D42) @ +40%).

The strong general rule is that loaded weapons are used in reverse Dmg order, highest Dmg to lowest Dmg. The only minor exceptions to this are for Stun and Incendiary rounds, and these are minor and also not in every case.

One notable difference was that a loaded Pistol in the right hand was not fired, but replaced by the loaded Blaster Launcher (which was fired). The only explanation I can think of is that if the AI has a loaded weapon in hand, it only checks Slot 2 for better weapons, not the whole inventory. Either that or there was a TU calculation such that Aimed fire would not be possible. The AI definitely prefers Aimed fire with one shot launcher weapons. It also seems to wait in Reaction fire a lot with launcher weapons (or waiting for enough targets?). Afaik, in my previous test the loaded Blaster Launcher was on the belt, which is the same TU cost (4) as drawing from Slot 2. Maybe the AI has a zero TU cost to draw from Slot 2 - I didn't specifically check this, but the general impression I got was that the AI does not cheat on inventory move TU costs, it only "cheats" on inventory placement rules.

Anyway I digress! The next steps, as suggested by Zombie and AQ, would be to study in detail the 'boundary cases', i.e. pairs of weapon-ammo combinations that deviate from the general rule. As they suggest probably editing Dmg values and damage types is the best way to determine the finer-grained rules for AI weapon preference. There may indeed be factors from the tactical situation and definitely factors from target characteristics (e.g. armour) that are taken into account by the AI.

(I'll post the new table data up later. I really want to use one of those snazzy sortable tables instead of my usual crude ascii table. If anyone wants the test rig (40 weapons on one alien), you can have it, just drop me a note and I will upload it - but as noted above the game data files seem pretty unstable.)

Spike 09:15, 8 March 2009 (CDT)

Aliens Use TUs to Reload

Seen this multiple times now, costing exactly 15 TUs as expected. (Based on known starting TUs, known firing costs, observed shots fired, and remaining TUs.)

This is not to say they never cheat. But at least when they have an unloaded weapon and spare ammo in normal inventory slots, they reload like humans. Not to say they might not cheat when weapons and ammo are in the "magic" slots. And also when the are initially set up, with unloaded weapons - do they load before they first fire?

Spike 03:45, 4 March 2009 (CST)

Cheat Detection Tests

This should be easy. I set the Alien's TUs to just enough to fire the weapon, not enough to load it. If the Alien still fires, looks like a cheat. If not, keep increasing TUs until he fires, to verify the Alien's TU cost of loading the weapon. Similar principle for detecting if they cheat on inventory move TU costs. First though we need to find out in what circumstances (if any) the AI moves items. Spike 18:47, 3 March 2009 (CST)

What about about switching to and from grenades? I know for certain that they'll shift the weapon to their magic slot to arm the grenade. Had this happen with an MC'd unit who ended up throwing a grenade at his allies. Finding the rocket launcher strapped to the solider's leg the turn later when I recovered him was a bit of a shock the first time I saw it!
I recall seeing aliens/MC'd units toss a grenade but end the turn without re-arming the weapon. This suggests that arming and throwing the grenade must've left them without sufficient TUs to put the weapon back. -NKF 05:04, 4 March 2009 (CST)

Interesting. The fact they even bother to move the weapon out of their hand before arming the grenade suggests they would otherwise get a penalty on the (grenade) attack - else why bother? Spike 05:21, 4 March 2009 (CST)

I have NEVER seen an alien holding an item of any type in its Left Hand slot(barring occasions where I placed the item there). Perhaps the AI is not programmed to use the Left Hand slot, so it has to move the weapon into the pocket to use the grenade because it can't use the left hand? Given the aliens never carry more than one firearm, and their only off-hand item is the Alien Grenade, this would be something the programmers might have skipped as not really being needed, especially in context that the AI would probably quickly stuff the grenade into that slot and thus ruin its own accuracy. Arrow Quivershaft 19:07, 4 March 2009 (CST)
Good points. Yes,Lasers are unique in having infinite ammo and the AI may see that as "no ammo", at least when making equip/arm decisions. Aliens will fire a Laser (tried all 3 types) but perhaps only if you put it in their hand. I didn't test it starting out in a backpack etc. Some more testing would be good, eg would the AI prefer a loaded Rifle to a Laser Rifle. Or try it in TFTD, where Gauss Rifles require clips.
Aliens can and will also fire a weapon from their left hand under AI control; and pick their preferred weapon if they have weapons in both hands, but as you say the AI itself never seems to place anything in Left Hand.
On the grenade question, I don't think accuracy of the grenade throw is affected by a weapon in the other hand (right?) but the AI programmers may be trying to avoid something else. Maybe if it has a weapon in its hand and does not complete the draw-prime-throw sequence with the grenade, it goes back to using the primary weapon therafter - at a permanent penalty. Speculation but easily tested. anyway, the current approach by the AI works fine, and actually I've always thought priming a grenade with a rifle in your hand was dubious. Maybe only humans have the ability to pull rings out with our teeth! Spike 15:52, 5 March 2009 (CST)
I've seen the aliens use lasers too, but that was under mind control and that was the only weapon they had available. As for the left hand, perhaps the AI is not programmed to put items there. If it was, perhaps the AI would hold the grenade in its left hand at all times, not even primed to throw or needed, and thusly incur a -20% accuracy to its main plasma weapon(presuming it's not the Plasma Pistol). This would obviously be undesireable! Arrow Quivershaft 16:03, 5 March 2009 (CST)
Yes that makes sense. By the way, to be clear I have seen Aliens fire all 3 laser weapon types under AI control. But I haven't checked if they would actually equip the weapon under AI control - TBD. Spike 19:35, 5 March 2009 (CST)
Sorry, I was unclear. What I MEANT to say was, "I have seen the AI use the Laser Pistol and Laser Rifle when I used Mind Control to give it that weapon in order to do experience training." The AI had no difficulty using the laser weapon while under AI control, but this may be the fact that the weapon was already in their hands and I'd made them discard their plasma weapon and any grenades. I think the "can't see the ammo" explanation may well be part of why it deprioritizes Laser weapons.
I'm running some more thorough tests now, and I have seen the AI pull a Heavy Laser out of an inventory slot to fire it. I have a test rig where an alien has EVERY weapon and grenade, loaded / primed, in his inventory. I'm running them down to see what order he prefers to use them in. (Of course, it might depend on target characteristics such as armour). So far it's looking like it might be just in Base Damage order - highest first. Spike 22:46, 5 March 2009 (CST)
Also, as another note, I think Seb76's Alien Pets mod is in fact part of the OTHER debug mode. The first debug mode lets you see all alien actions and use their TUs at the end of the turn if they have any left. The second, which I'm referring to, gives the entire alien turn over to the human player. But in this second debug mode, the aliens spawn with no gear whatsoever, IE: The equipping routine never runs. I'm wondering if Alien Pets runs this second debug mode and then force-runs the equipment routine for the aliens. Arrow Quivershaft 21:43, 5 March 2009 (CST)
From your description, it sounds like Seb76 uses the first mode. With his Alien Pets, you get to run the aliens with any remaining TUs they have, after the AI moves them. Spike 22:46, 5 March 2009 (CST)

Honest AI?

From observations (not rigorous tests) I am beginning to think that the AI sticks to the TU rules for inventory, and only 'cheats' in that it stores everything in the same "magic" inventory slot. But it looks like the AI pays 4 TU to pull items out of this slot, 15 TU to reload a weapon, 50% TU (?) to prime grenades, etc. If it does not have sufficient TUs, the AI doesn't perform the action.

Spike 19:35, 5 March 2009 (CST)

Human Inventory AI

It is not only Alien inventory that is managed by the AI - human inventory is as well. During the Equip phase of each mission, the AI assigns weapons and equipment to Soldiers from the available pool on the transport. It is interesting to compare this with AI management of Alien inventory. Clearly the processes are different, but there may be some common logic. In particular, perhaps the AI uses logic from the Soldier Equip phase, when deciding which weapons to use (on mind-controlled humans or, less commonly, on ex-mind-controlled aliens). Both sets of decisions span nearly the whole range of weapons in the game. Necessarily since late in the game Soldiers will be armed almost entirely with Alien weapons. This is why I suspect there may be some common or re-used logic. I'm going to research what we already know about the human-arming AI.

Melee Aliens With Guns

As detailed here, Chryssalids that end up with weapons can indeed reaction fire. I figure the same holds for Reapers, Silacoids and Zombies; the alien won't fire the gun normally but will if you provoke reaction fire. This is liable to be a nonissue with Silacoids and Zombies, due to their low TUs and sluggish reactions. The Reaper is a bit more of a threat, with higher reactions and more TUs. As predicted by Murphy, the one melee alien that can naturally(albeit by a glitch) end up holding a gun is also the most dangerous; Chryssalids have a rather long TU bar and a very high reaction stat(at least for the aliens), meaning they'll often get a chance to shoot at you if they have a gun. Of course, all of these aliens have a 0 for Firing Accuracy, so they're relying entirely on luck to hit you.

On an alternate idea to explain why the Chryssalid never shoots, if it is indeed shown that melee aliens can shoot guns during the Alien Turn if they have them, is that perhaps the Chryssalid deems its melee weapon to be better. It's been shown elsewhere on the wiki that Chryssalids actually do weapon damage with their melee attack(which is ridiculously powerful) and the game zombifies any soldier killed by the attack. I can't find this research right now, though, so if someone does come across it, please remind me where it is! Arrow Quivershaft 17:59, 12 March 2009 (CDT)

What happens if the melee alien is fenced in, does it just get stuck or does it fire? Jasonred 03:43, 13 March 2009 (CDT)

Just speculation on reaction fire mechanics in general. I think it's an automatic reaction that works with any unit in the game regardless of the unit's ability (or lack of ability) to attack with a ranged weapon. As long as a unit's got a ranged weapon, and it's in its waiting phase, it can use reaction fire given all the right conditions are met.

With the civilians, I guess any unit that's not "us" is deemed a target to them, hence why they open fire on X-COM and alien alike. However, the civilian AI routine can't use any deliberate attacks. (say, would giving an alien to the civilians cause them to exhibit similar behaviour?)

The same could be true for melee aliens. They may favour their melee attack (or only have routines for attacking with melee) during their movement turn, but they will freely attack via reaction fire freely because it is an automatic reaction for all off-turn units. That's how I see it anyway. -NKF 05:27, 13 March 2009 (CDT)

I think that's right unfortunately. I pinned a Pistol-packing Reaper by zapping his Maximum Energy to zero, and he still only fired at me when I walked in front of him during his reaction phase - never on his phase. I wonder if armed Civilians would purposefully fire their weapons on their turn, if they were under Alien mind control (somehow?). I think I read somewhere the Civilian 'turn' is a third turn, separate from the Alien and XCOM turns. Someone did a mod for armed civilians so maybe this was all figured out. Spike 05:56, 13 March 2009 (CDT)
The Civilian turn is separate from the alien turn, yes. Arrow Quivershaft 06:00, 13 March 2009 (CDT)
They might act differently when their PATHING is blocked, and when their ENERGY is too low. It might seem the same thing to us, but it might look totally different in lines of code. Better pin them with fences or low hedges to make sure, Spike.
And you're pretty much spot on regarding Reaction Fire. ... Reaction fire is a hard coded kettle of fish which has it's own unique implications. Remember, Reaction Fire allows you to shoot Underwater only weapons above ground, and allows you to fire Blaster Bombs as... is it snap shot or aimed shot?
Jasonred 06:22, 13 March 2009 (CDT)
Good suggestion. I gave him his energy back and built a fence around him - one he could still see through to reaction fire - but he still didn't fire on his turn. I even gave him a big pen with room to move around in, same effect. Oh well! Spike 08:49, 13 March 2009 (CDT)

I did some trials on this way back in '04 at the StrategyCore forums. I believe it can be found in the "Rifle butt to the face" thread. Melee-only aliens never use handheld weapons during their turn. They much prefer to charge you and use HTH. (Tests performed on unedited Chryssalids in an alien base with long corridors). --Zombie 11:29, 13 March 2009 (CDT)

Old Discussion

Aliens Deploying Without Weapons

(It appeared aliens were deploying with all their items, including all weapons and clips, stored in their slot 2 "magic pocket". Turns out not to be true. Here is the discussion thread ...) Spike 19:35, 5 March 2009 (CST)

IF THIS IS TRUE there are some major tactical implications. If Aliens deploy without weapons loaded and no weapons in their hands they have a serious disadvantage. This is a 19 TU deficit in any 'encounter' situation on the Alien's turn. Even more significant, it suggests a (weapon carrying) Alien will never reaction-fire unless that Alien has previously encountered a human enemy in its own turn phase, and had sufficient TUs left to draw and load its weapon.

This suggests that very aggressive 'lightning raid' tactics are likely to be successful, as Aliens reaction fire will be minimal and counter-attacks will be hampered.

It also suggests another tactic of waiting inside a vehicle until large numbers of unarmed aliens are milling around inside, then bursting out and killing them all with impunity.

Both tactics should work particularly well when the Aliens have no terror units with built-in weapons.

Spike 13:24, 4 March 2009 (CST)

No. Save game at start of turn one before doing anything, then turn-swap. Aliens will have loaded weapons equipped (basically, turn 1 is the only time all of them have three reaction shots).
I sometimes hack Turn 1 so that any alien that could reaction-fire at the exit is facing the exit. This makes the difficulty somewhat more credible. -- Zaimoni 11:42, 5 March 2009 (CST)

HOWEVER, I do not believe this is the case!!!

On EVERY mission I play, the aliens begin the battle with full TUs, and weapons loaded and in their hands. This is evidenced by the ridiculous number of times many commanders have had troops step off the transport and immediately killed by enemy reaction fire.

In fact, it is so bad that I usually only move my troops off the transport on turn 2.

Personally, the only time I have found an empty handed alien is: after he has thrown a grenade.

Jasonred 11:03, 5 March 2009 (CST)

OK this is very interesting as I observe different results. Are either of you using XComUtil? I am using a Win Collectors Edition version, via Seb76's loader, no XComUtil,and I see all the aliens with all their equipment in "magic" slot 2 at the start of the game. Nothing in their hands until they spot a human. Maybe a bug in Seb76's loader? Maybe a difference with DOS versions, or XComUtil? Spike 11:57, 5 March 2009 (CST)

NOTHING in their hands until they spot a human??? ... Spike. Are you playing on Easy? ... Cause in your game, it sounds like the aliens would almost never reaction fire, super sitting ducks... In my games, when I shoot at an alien during turn 1, and they survive, they invariably SHOOT BACK. ... So, what happens when 1 alien spots a human? Do all the other aliens arm themselves, or just that 1 alien? ... Curious... Jasonred 13:12, 5 March 2009 (CST)

Spike my friend, you broke the first cardinal rule of testing: you didn't use an unmodified version of the game. Tsk, tsk, tsk. Who knows what Seb's loader does exactly? Sometimes he's not even sure if his loader is bug-free. LOL. Anyway, my experience is the same as Jasonred's: aliens start with guns in their hands already loaded. The only time when a weapon is placed on the leg is after a grenade has been thrown. --Zombie 15:36, 5 March 2009 (CST)
Yes you're probably right. There's a difficulty here though, it's hard to tell. Seb76's loader is the easiest way to see what the AI is doing, because it shows you their turns. The only other way I know of to see the enemy turns is with XComUtil. I take it as read what Zaimoni is saying, that aliens start out armed in turn 1 of an XComUtil "switch sides" game. But do we know that it's not XComUtil that is 'fixing' the aliens so they have loaded guns in their hands at the start?
But I guess we have all experienced reaction fire when exiting the ramp so that does suggest that aliens start out armed. That has to be the presumption. Up to me to prove the contrary I guess, if I can. I suspect you are right though and it is probably some artefact of Seb76's loader. Spike 15:49, 5 March 2009 (CST)
The aliens start out armed in all matches I've seen; I never deploy on turn one. On a note, Seb's 'view everything on the battlescape' option is in fact an automated version of the Debug Mode I mentioned earlier which can be easily done with a bit of hex-editing skill. I'm not sure of the programmer Debug mode counts as unmodified, but I'm just explaining. Perhaps test with a personal hex edit instead of Seb's loader to find out. Arrow Quivershaft 16:03, 5 March 2009 (CST)

The debug thing probably isn't to blame as it just shows what is going on behind the fog-of-war and aliens turn. However, alien weapons do not start out on the leg, only in the hand, so another part of the loader is messing with alien inventories. That we can be fairly sure on. Otherwise this would be a case of the Heisenberg Uncertainty Principle where trying to view something actually changes its state. I doubt quantum physics plays a role here either. LOL. --Zombie 16:23, 5 March 2009 (CST)

Hum actually the debug thing is to blame as it skips the alien equiping phase. I think it also disables reaction fire... If you feel like hex-editing, nop this and the equiping phase will be done...
.text:0041C4E6 0F 85 98 00 00 00 jnz continue
BTW, I'd say it takes 3 TUs for the aliens to take something in their hand. Seb76 18:12, 8 March 2009 (CDT)

Edit: I just remembered a post by Bomb Bloke over at the StrategyCore Forums a while back: "By the way, clips don't get loaded into weapons until the battle actually starts. When the gear is assigned to aliens, they all go to their leg slot (number 2)." *Shrugs* You would think that when the battle starts the weapons are all loaded and in the proper area. However, I still don't really understand how stuff could be in the leg slot and yet, when you view it via MC, everything is in it's place...

If I remember correctly, Bomb Bloke's reference was in regards to the missdat files with the pre-battle version of the unit and object reference files (unitpos and obpos). They start un-initialized and all the objects are in storage (their magic pocket) - in a manner of speaking. When the battle actually starts, then the game assigns the proper equipment to all the aliens - slotting them into the hand as necessary. -NKF 22:42, 5 March 2009 (CST)

OK, unsurprisingly you guys are all correct - it's the Seb76 loader causing this phenomenon. I checked in an unmodified game. OK well I used a game editor to get a super-squad of flying Psi-Masters, but the executable was not modified. As of t1, using lots of Mind Control I was able to identify plenty of aliens who had not seen any human unit, who had not expended any TUs, and they were all fully armed.

Sounds like Bomb Bloke's remark (quoted above) is a valuable clue. Perhaps Seb76's loader is picking up on a pre-battle state when all alien equipment is still loaded into slot 2, and somehow his loader is then inadvertently skipping or bypassing a 'startup' step in the code which moves the aliens' weapons from slot 2 into hands (and clips into weapons). In fact what is probably happening is:

  1. Battlescape starts with Seb76 "Alien Pets=1"
  2. This marks all aliens as being under human control
  3. Therefore the aliens get bypassed by whatever routine is supposed to put armed weapons in their hands
  4. I save the game, set Alien Pets=0 and reload, releasing the Aliens to AI control, but the damage is done - they are unarmed

I can test this easily by starting a new mission with Alien Pets=0, saving on turn 1, then reloading with Alien Pets=1

BTW this also probably means I'm wrong about putting equipment onto terror units. I'll check again with Mind Control to see. A cautionary tale! Hopefully most of the other research on this page still stands though. I hope! Spike 17:20, 5 March 2009 (CST)

Alien Encumbrance Glitch?

(An unexplained bug, not well defined enough for meaningful discussion)

My next trials were frustrated. I couldn't find my copy of BB's map editor so instead I tried to rank a Laser Rifle against an unloaded HC-HE. (The alien picked a loaded HC-HE over a Laser Rifle (LR) every time, regardless of what was in which hand and whether or not that weapon was "selected").

But then I was stymied when my test Alien ran out of TUs. The weight of HC, HE clip, an alien clip and the LR was over 2x its strength (32 I think). Which sounds wrong. Even more wrong, its TUs were down to about 20-30% (not the expected 50%), 12-17, and didnt seem to be regenerating at all. So it couldn't load or fire either weapon.

All of which got me wondering if there aren't other factors in TUs, Encumbrance and recovery for aliens: maybe the size factors and unitref(45) factors get used somehow? Otherwise I can't really explain why this unwounded Sectoid was basically paralysed by the weight of human equipment. Anyone got any ideas?

One thing that just occurred to me: maybe there is a bug such that weight does not get subtracted when aliens drop things, but still gets added when they pick things up. An understandable bug since that would hardly ever happen. I will check that too.

Spike 14:33, 3 March 2009 (CST)

Might I suggest using Mutons for further tests? They have a Strength of 70, and are rather easy to Mind Control. Arrow Quivershaft 15:45, 3 March 2009 (CST)

Well I still don't know what exactly was happening. I checked and the weights are the same for Aliens when you add stuff and when you drop it. But for some reason this little Sectoid just ran out of TUs like he had a punctured tire. It did seem to be somehow connected to loading him up with Encumbrance above his Strength. Maybe.

Anyway I used BB's excellent map editor and gave my test subject some steroids (more Strength) and the problem seems to have gone away. I now have a test rig with him sitting on a stack of every weapon and item in the game, ready to try them all out.

Spike 18:47, 3 March 2009 (CST)

MOVE - Reply to Zombie - and don't try resolving page-level edit conflicts in a 40-character window on a mobile phone browser!!

Yes you understood correctly, I had one item per slot, rather than all items in one slot (slot 2). I agree putting all items in slot 2 would be a better test, more like normal situation and also fewer unknowns: but I was not confident with a hex editor and the BB editor does not afaik allow you to specify a specific slot for multiple items.

Having said that, in a small number of previous tests I reversed the slot order of weapons and saw no difference in the order they were equipped by the AI. Also the full table fairly strongly follows a rule of "sort by descending Base Damage". So I am moderately confident of the assumption that slot number is not a major determinant of weapon selection preference. But more testing would be wise.

To answer your specific question, I stashed the weapons in inventory in a fairly random order, not in Dmg or in OBDATA order. All the multi-type ammo was in the backpack, most of the multi-type and launcher weapons (5) were on the belt, misc weapons and grenades on legs and shoulders.

Keep in mind the AI needs to handle MC'd humans as well as aliens. While alien inventory is incredibly simplistic - one weapon in hand, all ammo and grenades in Slot 2 - human inventory is complex. It's possible there are 2 rulesets, one for alien AI and one for MC'd human AI. But a simpler bet is that the AI scans OBPOS, looking for some criterion like Base Dmg & whether it's loaded, to discriminate the best weapon.

What is interesting is that the AI during MC often 'trades up' from the currently in-hand weapon to e.g. a Rocket Launcher, in order to do more damage. That needs looking into.

Spike 13:29, 6 March 2009 (CST)