Easygoing Eyebeast *i Posted July 15, 2004 Share Posted July 15, 2004 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 More sharing options...
Well-Actually War Trall Fort Posted July 20, 2004 Share Posted July 20, 2004 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 More sharing options...
Well-Actually War Trall Khoth Posted July 20, 2004 Share Posted July 20, 2004 I assume you mean closest = dist_to_char(i), not closest = i Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted July 20, 2004 Share Posted July 20, 2004 No, because the idea is to get the nearest character number, not the distance to the nearest character. Link to comment Share on other sites More sharing options...
Garrulous Glaahk Eldiran Posted July 21, 2004 Share Posted July 21, 2004 Creature scripts perplex me beyond belief... And if I'm not baffled more than I think I am, I'll allow myself to point out that 'while' doesn't seem necessary there. Wouldn't an 'if' work the same? Or am I just creature-script-inept? Link to comment Share on other sites More sharing options...
Magnificent Ornk Kelandon Posted July 21, 2004 Share Posted July 21, 2004 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 More sharing options...
Garrulous Glaahk Eldiran Posted July 21, 2004 Share Posted July 21, 2004 Ahhh, that makes more sense then. I still don't get what's going on, but it makes more sense. Link to comment Share on other sites More sharing options...
Well-Actually War Trall Fort Posted July 21, 2004 Share Posted July 21, 2004 Oh yes, there are many problems with my code. Code: i = 0;closest = i;while (i < 120) { if (dist_to_char(i) < dist_to_char(closest)); closest = i; i = i + 1; } Link to comment Share on other sites More sharing options...
Recommended Posts