Jump to content

get_nearest_char


*i

Recommended Posts

It seems when the get_nearest_char commands are called in a creature script, it returns its own number for its value. The creature running the script was created using the place_monster call.

 

Is anyone else having problems with this?

Link to comment
Share on other sites

You're right! get_nearest_char() and get_nearest_good_char() always return the creature for which the script is running. I think those were mainly for use with terrain scripts, though. But that is unfortunate because then this would be the only good alternative:

 

Code:
i = 0;closest = dist_to_char(i);i = i +1;while (i < 120) {if (dist_to_char(i) < closest)   closest = i;}
Link to comment
Share on other sites

The idea of the "while" is to check the distance of every single possible living monster and keep track of which one is the lowest. An "if" wouldn't really do that.

 

Although, looking at it again, I realize that the "i = i + 1" part is misplaced. It should be inside the "while," or else the thing will loop infinitely.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...