I just encountered a cluster of about a dozen orcs all targetting another orc and just milling about, bumping into each other for dozens of turns - even after hit them all with AOE damage. They were all the same faction (reaction +100) and I'm not sure how they all got targeted on to same friendly npc, but I have seen a similar problem with NPC's keeping the player targeted (like if an undead pc forgets his cloak.)
From engine.ai.simple.lua:
Code: Select all
-- Find an hostile target
-- this requires the ActorFOV interface, or an interface that provides self.fov.actors*
newAI("target_simple", function(self)
if self.ai_target.actor and not self.ai_target.actor.dead and rng.percent(90) then return true end
-- Find closer enemy and target it
-- Get list of actors ordered by distance
local arr = self.fov.actors_dist
local act
for i = 1, #arr do
act = self.fov.actors_dist[i]
-- print("AI looking for target", self.uid, self.name, "::", act.uid, act.name, self.fov.actors[act].sqdist)
-- find the closest enemy
if act and self:reactionToward(act) < 0 and not act.dead then
self:setTarget(act)
self:check("on_acquire_target", act)
return true
end
end
end)