Jump to content

Waypoint question


Recommended Posts

I want character 16 to go to a waypoint when the party first arrives, so this is what I did:


beginstate START_STATE;

// This state is called every turn the party is in this town.

if (get_flag(2,0) == 0)



if ((dist_to_waypoint(16,0) == 0) && (get_flag(2,0) == 0)) {




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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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. smile

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...