So, Shadow Discorporation (on Telflammar Shadowlord) acquires a random location (GetRandomLocation function from X0_i0_position.nss) 30 feet from the PC. Unfortunately, this does not take into account that players might be jumped behind locked doors or into secret/restricted areas.
Now, I know of the LineOfSightVector function, I could compare the PC's location and the random location and make sure they are in line of sight, however, the NWN Lexicon warns that the LineOfSightVector function is an "expensive function", so I'm afraid to heavily loop a line of sight check with it.
Do you have any suggestions on efficient script logic for this? Maybe I should let it try to gain line of sight via LineOfSightVector something like 5-10 times maximum? Maybe a few times and then try 15 feet a few times, and if it can't find a legal destination it fails?
Just looking for an opinion on what the most efficient means of eliminating or minimizing the (maybe even accidentally) exploitive potential Shadow Discorporation has.