Error report: Even if an entity moves along Y-axis, function GetPlayerDistance(e) gives the original Y-coordinate of the entity. If I want to test whether the entity is for example 100 units away from the player, as soon as the entity has descended or ascended 100 units in the Y-axis, the program thinks the entity is more than 100 units away from the player even if player and the entity are standing next to each other.
Repeatable: Always. And since the problem with AI and stairs is even mentioned in the feature vote, I'm probably not the first one to encounter this.
Howto: Add these lines to ai_fantasycharacter.lua (or some other that wants to follow you but doesn't shoot):
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 100 then
Prompt("Hi, I'm less than 100 units away from you.")
end
Let the entity follow you down the hill. In some point the prompt disappears (as well as anything you wanted the entity do when it's near to player).
Workaround: Use this instead of GetPlayerDistance().
function TestPlayerDistance(e)
-- Test the distance between player and entity (ignore Y coordinate that doesn't seem to work correctly)
DistanceX = (g_Entity[e]['x'] - g_PlayerPosX)
DistanceZ = (g_Entity[e]['z'] - g_PlayerPosZ)
return math.sqrt(math.abs(DistanceX*DistanceX)+math.abs(DistanceZ*DistanceZ));
end