Easygoing Eyebeast Jerakeen Posted April 29, 2011 Share Posted April 29, 2011 I want character 16 to go to a waypoint when the party first arrives, so this is what I did: Quote: beginstate START_STATE; // This state is called every turn the party is in this town. if (get_flag(2,0) == 0) approach_waypoint(16,0,0); if ((dist_to_waypoint(16,0) == 0) && (get_flag(2,0) == 0)) { set_flag(2,0,1); The thing is, it only works about 80% of the time. Occasionally he just wanders off for a while and then comes back later. It's literally just two spaces away and there's no obstruction. Am I doing something wrong or is this just an innate peculiarity of the engine? Quote Link to comment Share on other sites More sharing options...
Well-Actually War Trall Niemand Posted April 29, 2011 Share Posted April 29, 2011 I'm not sure if it matters, but looking at some of my code I've usually used a value of 1 for the third parameter of approach_waypoint (the distance to approach within). It might also be a good idea to check the return value of the approach_waypoint call so that you can know within the script whether the character decided to move or not. Also, just as a sanity check: if you based this script on basicnpc, are you certain that you either removed the fidgeting and return-to-start code, or made sure that the code you showed above comes before it? Quote Link to comment Share on other sites More sharing options...
Easygoing Eyebeast Jerakeen Posted April 29, 2011 Author Share Posted April 29, 2011 Oh, no, I should have specified that this was in the town script. So I should put it in the creature script? That's probably my problem right there. Edit: That seems to have done the trick. I had stolen that code directly out of Outpost Valley, but I guess in that circumstance it didn't matter if the character wandered a bit, since the party was locked in a cell at the time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.