View previous topic :: View next topic |
Author |
Message |
Mr B
Joined: 20 Mar 2003 Posts: 382
|
Posted: Mon Oct 24, 2005 1:31 pm Post subject: Stop NPC |
|
|
Hey folks,
Is there a command (or sequence of commands) that makes an NPC stop in its tracks?
My problem is, I want an NPC to walk from A to B. However, an event may occur at any time in between, at which time I want the NPC to stop and do something else. Since the event is player-controlled, I don't know when (or even if) it will happen.
At this point, the only thing I can think to do is this:
Code: | walk NPC to(NPC x(it),NPC y(it)) |
However, this is rather clunky, and may cause the NPC to "backtrack" to the tile it is walking off of (if it's walking east or south).
What I really want it to do is finish its walk action to the next whole tile, then do whatever it was going to do.
Any suggestions?
Thanks,
-B |
|
Back to top |
|
 |
Iblis Ghost Cat

Joined: 26 May 2003 Posts: 1233 Location: Your brain
|
Posted: Mon Oct 24, 2005 2:01 pm Post subject: |
|
|
Perhaps you could walk the NPC one tile at a time, and check whether the event occurs inbetween steps. I'm not sure whether this would allow for smooth movement though. _________________ Locked
OHR Piano |
|
Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Mon Oct 24, 2005 2:12 pm Post subject: stopping an NPC |
|
|
You can cancel a "walk NPC" command by giving the same NPC another walk command
Code: |
walk NPC (0,south,10)
wait(random(10,40))
walk NPC (0,south,0)
|
|
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Mon Oct 24, 2005 2:14 pm Post subject: |
|
|
Metamorphosis did this. Use walknpc with the distance parameter 0. (I'd have to go back and check the script on it, honestly, but I think that does it. The script file is included with the game IIRC.) _________________
|
|
Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Tue Oct 25, 2005 8:36 am Post subject: |
|
|
This would make the NPC stop on the tile that it is currently walking onto, it seems. If instead one wants the NPC to stop on the pixel, what could be done? Perhaps changing said NPC's speed to 0...? |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Tue Oct 25, 2005 9:49 am Post subject: |
|
|
No, it makes him stop where he is. This can muck up your game if used incorrectly, but it is the foundation of the game Metamorphosis, a SoM-style game released before pixel movement was available. _________________
|
|
Back to top |
|
 |
Mr B
Joined: 20 Mar 2003 Posts: 382
|
Posted: Tue Oct 25, 2005 3:34 pm Post subject: |
|
|
Iblis wrote: | Perhaps you could walk the NPC one tile at a time, and check whether the event occurs inbetween steps. I'm not sure whether this would allow for smooth movement though. |
This would ordinarily be a good idea, but in this case I already have a continuously-looping script with a large number of if-then statements. Moving the NPC like this would, I think, simply overwhelm the script. In another application it would work pretty well, I think.
Moogle1 wrote: | Metamorphosis did this. Use walknpc with the distance parameter 0. (I'd have to go back and check the script on it, honestly, but I think that does it. The script file is included with the game IIRC.) |
Unfortunately, I need to have tile-based movement for this specific application.
I think I know what I will do. Thanks for the suggestions, guys. |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Tue Oct 25, 2005 7:16 pm Post subject: |
|
|
No, that IS tile-based movement. While he's moving, tell him to walk in that direction with distance 0. _________________
|
|
Back to top |
|
 |
|