1.) You're looping through all the characters in your game. Maybe it would be better to check if the character is actually in the same room as the player first.
2.) What's wrong with the commented code? It should work well in most cases and be a LOT faster.
Thx, checking for the npcs in the current room, brings a lot of performance, i think it could work this way.
@Khris: Your modules are also running in the back (POV and NoMouse) you know

, so i guess there is too much going on with the innefficient while loops..
Thx for your suggestion, i will merge all the ideas and see if i can make this construct working.
@Crimson:
function ROC_FUNC_Get_Distance_From(this Character*, Character*c) {
float dx = IntToFloat(c.x - this.x);
float dy = IntToFloat(c.y - this.y);
float dis = Maths.Sqrt(dx*dx + dy*dy);
return FloatToInt(dis, eRoundNearest);
}
edit:THX, it works now, without stucking.