Bug #4304

"Follow" not working as a second AI package

Added by rot tor 2 months ago. Updated about 1 month ago.

Target version:
Start date:
% Done:


Operating system:


When both AI_Wander and AI_Follow packages are defined in the CS, the Follow has no effect in OpenMW.

Tested with a creature and with a Follow package targeted on "player", but the effect will be the same with NPCs. I find 25 NPCs in Morrowind.esm with both AI_W and AI_F packages defined. This is especially relevant for some Morag Tong quests in which NPCs are supposed to defend the target even if the player made the NPC attack first.

To reproduce:

coc "Vivec, St. Olms Haunted Manor"

find NPC "Dram Bero"

startcombat player

(or taunt or frenzy him)
Vanilla: the other 2 NPCs attack the player too.

(for a creature and with a Follow package targeted on "player": in vanilla they only adopt "follow" behaviour to defend the player in combat and will otherwise stay/return to their place, which makes it possible for a mod to make creature guards, despite two bugs/drawbacks: the creature will follow when player uses a load door near them, and the creature permanently follows if a Command spell is used)


#1 Updated by Andrei Kortunov about 1 month ago

  • Status changed from New to Confirmed
  • Operating system changed from Windows to Other

Looks like there is a bug in Actors::getActorsSidingWith.
Allofich made an assumption: an actor counts as siding with this actor if Follow or Escort is the current or first real AI package in AI sequence.(this commit).
This assumption can be wrong. I guess the "if the actor has the Follow or Escort package with this actor as a target" would be more logical, but I am not not sure how exactly vanilla Morrowind behaves.

Also it is not clear what an engine supposed to do if you cast a Command spell on such NPC.
How original game behaves:
1. Normally getcurrentaipackage shows 0 (Wander)
2. If you cast a Command spell:
2.1. getcurrentaipackage can show -1 (the AiSequence was screwed up).
2.2. getcurrentaipackage can show 3 (Follower), but NPC follows an original leader instead of caster.

#2 Updated by Andrei Kortunov about 1 month ago

An another related unclear case: when an actor has several AiFollow packages, but leaders are fighting each other.

#3 Updated by Andrei Kortunov about 1 month ago

Also makes sense to check if OpenMW actually reads all packages from ESM.

#4 Updated by Andrei Kortunov about 1 month ago

Well, OpenMW reads records correcly. This check causes the issue.
An engine encounters the AiWander package first and does not consider the NPC as follower.

#5 Updated by Andrei Kortunov about 1 month ago

This check causes the issue.

Sorry, I was blind. This line.

Also available in: Atom PDF