There's a chapter array at 1D3A60 that controls the AI's ability to use Door Keys, Lockpicks, and Antitoxins.
Bit 01 = Enable Door Key in chapter. Bit 02 = Enable Lockpick in chapter. Bit 04 = Enable Antitoxin in chapter.
All FE7 chapters allow the AI to use Lockpicks and Antitoxins.
Chapters that prohibit AI from using Door Keys: 6, 17, 23x, 27 Jerme, 32x.
How exactly do these items get used? Please don't ask me that. It's complex and messy. Well, here is my current theory based on what I have observed and tested so far...
Door Key, Lockpick(1), Antitoxin conditions:
1. Primary AI (AI1) fails. Generally, this happens when the unit has no target for attack, steal, staff. AI1 0x06 always fails.
2. Secondary AI (AI2) fails or AI2 = 0x04 (brigand AI) or AI2 = 0x05 (thief AI). AI2 0x00 fails when the unit has no available path to foes due to walls/terrain. AI2 0x03 always fails.
3. AI1 cannot be 0x03, 0x04, 0x05 (action without movement) and AI4 cannot be 0x20.
4. Item cannot be disabled by the chapter array.
Door Key: Move towards doors and open.
Lockpick(1): Move towards doors/chests and open (requires STEAL ability).
Antitoxin: If poisoned, retreat and cure poison.
If unit has multiple of these items that can be used, priority is given to the lowest in inventory.
Then if AI2 = 0x04 (brigand AI) or 0x05 (thief AI) and none of the above items were used:
Chest Key (1-use): Move towards chests and open.
Lockpick(2): Move towards CHESTS (not doors) and open (requires STEAL ability).
Note: the chapter's item bans do not apply to the Lockpick here.
Usage priority to the top Lockpick/Chest Key in inventory.
The Chest Key with 5-uses cannot be used by the AI.
Note that there are 2 opportunities to use Lockpicks
Lockpick(1): Can open both doors and chests, but can be blocked by the item ban.
Lockpick(2): Requires brigand/thief AI, can only open chests, and is unaffected by the item ban.
So, a thief carrying a Lockpick in a chapter with Lockpicks disabled = a thief that will only open chests and will ignore all doors.
A thief with Door Key + Chest Key will be absolutely determined to use the Door Key before opening any chests. This is due to the Door Key check always occurring before the Chest Key check.
Why did I say Lockpick AI requires the steal ability?
Class/char ability 0x08 (Lockpick): Determines whether to gray out Lockpick in inventory and if the player units can use it. For AI-controlled units, the game mistakenly checks class/char ability 0x04 (steal) for Lockpick functionality. This means enemy/NPC Assassins cannot use Lockpicks by default.
If enemies aren't using Door Keys at all, check the chapter's item ban list. If you want attack-in-range enemies to hold/drop Door Keys without using them, you will need to disable Door Keys.
Door Keys with common AI:
Enemies with "aggressive AI" (00/00) should never use Door Keys unless they are put in a locked room away from the player units.
Enemies with "attack-in-range AI" (00/03) will actually leave their positions and move towards doors if Door Keys aren't disabled for the chapter.
Enemies with "stand still AI" (03/03) should never use Door Keys regardless of the item settings for chapter.
Enemies with "thief AI" (06/05) and carrying a combo of Door Keys + Chest Keys will seek to use Door Keys before using Chest Keys.
FE7 Door Key, Lockpick, Antitoxin AI Editor
Enable item for AI
0x01 Door Key
0x03 Door Key, Lockpick
0x05 Door Key, Antitoxin
0x06 Lockpick, Antitoxin
0x07 Door Key, Lockpick, Antitoxin