So I was snooping through Arkngthand today when I noticed that enemy NPCs were getting into an endless loop of combat/no combat running in and out of my line of sight. To reproduce run command
Code: Select all
player->positioncell 175 2376 903 -28 "Arkngthand, Hall of Centrifuge"
stay put, and wait for someone to notice you. (Interestingly this issue doesn't show up on Debug builds due to slower execution therefore fewer AI calls)
I have tracked down the issue to the MWMechanics::canFight function in aicombataction.cpp, specifically this bit (lines 459-460 on my current Git mirror):
download gimp
Code: Select all
if (getDistanceMinusHalfExtents(actor, enemy, true) <= 0.0f)
return false;
The result is that enemies far below you at a steep angle will stop fighting because getDistanceMinusHalfExtents here calculates Euclidean distance minus vertical distance. Can anyone say as to why this function is used to calculate whether combat is feasible? MiroslavR, perhaps you could bring some light?