View previous topic :: View next topic |
Author |
Message |
The Wobbler

Joined: 06 Feb 2003 Posts: 2221
|
Posted: Mon Mar 21, 2005 9:08 pm Post subject: My NPCs are getting out of line. |
|
|
Note from Castle Paradox Administration: | This content has been removed by the user. Contact the original author and link them to this post if you wish to view the original content. Only the author can remove the tags hiding this content. |
|
|
Back to top |
|
 |
phyrfox Avid Player
Joined: 20 Feb 2005 Posts: 96 Location: New York, USA
|
Posted: Mon Mar 21, 2005 10:04 pm Post subject: Re: My NPCs are getting out of line. |
|
|
PHC wrote: | The situation; The game uses a custom menu, activated by an on key press script that runs when the player presses escape or alt. I used a map to represent the menu, and it works perfectly. The problem is that when you exit the menu to return to the map you were just on, all of the NPCs return to their default positions, since the map has reloaded. I tried to get around this by running a plotscript that would record NPC positions before going to the menu, and set them to those positions after exiting.
The "check menu" script (not really important);
Code: | if(key is pressed(key:esc),and,checktag(27))
then(
suspend player
wait(1)
getnpcpositions
themenu
resume player
) |
The "getnpclocations" script;
Code: |
set variable(npcpos0dir,npcdirection(0))
set variable(npcpos0x,npcx(0))
set variable(npcpos0y,npcy(0))
set variable(npcpos1dir,npcdirection(1))
set variable(npcpos1x,npcx(1))
set variable(npcpos1y,npcy(1))
|
This repeats for every npc on the map.
After pressing the "exit menu," a "setnpclocations" script is run;
Code: |
set npc direction(0,npcpos0dir)
set npc position(0,npcpos0x,npcpos0y)
set npc direction(1,npcpos1dir)
set npc position(1,npcpos1x,npcpos1y)
|
The problem; Occasionally, if you go to the menu when an NPC is in the middle of moving, that npc will not be returned to the proper position after exiting the menu. They are often moved a couple of pixels in any given direction, which leads to NPCs being totally unaligned, walking through walls, the player, and each other. I need a way to stop these fiends from going all over the place.
Everything would be quite simple if the next OHR update included the ability to record NPC positions after leaving a map/loading the game. |
My version does just that; it does (or will, anyway) save NPC positions, and any altered objects on a given map, assuming you set up the proper permissions... stay tuned...
~= phyrfox =~ |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Mon Mar 21, 2005 10:21 pm Post subject: |
|
|
One possible problem is that there may be multiple references to the same NPC. You'd do better setting up an array and -- but that would be a much more complicated script.
An easy solution to the problem you're addressing is to suspend npcs and then wait for all before the menu is opened. That way, the NPCs and heroes are allowed to finish their current movement, if any.
If that doesn't work, let me know. _________________
|
|
Back to top |
|
 |
The Wobbler

Joined: 06 Feb 2003 Posts: 2221
|
Posted: Mon Mar 21, 2005 10:58 pm Post subject: |
|
|
Note from Castle Paradox Administration: | This content has been removed by the user. Contact the original author and link them to this post if you wish to view the original content. Only the author can remove the tags hiding this content. |
|
|
Back to top |
|
 |
Leo The wizard of many faces...

Joined: 02 Nov 2004 Posts: 95 Location: Way far up north in Sweden...
|
Posted: Tue Mar 22, 2005 7:44 am Post subject: |
|
|
What about a "suspend npc"s and then a "wait" command to make it wait a few ticks for everything to stop moving? _________________ "A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools."
-Douglas Adams
Download Zander (Swedish)
or Zander (English) |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Tue Mar 22, 2005 8:27 am Post subject: |
|
|
Make sure to resume npcs for your menu if there are any NPCs on the menu map.
Or, in other words:
Code: | if(key is pressed(key:esc),and,checktag(27))
then(
suspend player
suspend npcs ##
wait for all ##
getnpcpositions
resume npcs ##
resume player ##
themenu
) |
(Changes marked.) _________________
|
|
Back to top |
|
 |
The Wobbler

Joined: 06 Feb 2003 Posts: 2221
|
Posted: Tue Mar 22, 2005 1:15 pm Post subject: |
|
|
Note from Castle Paradox Administration: | This content has been removed by the user. Contact the original author and link them to this post if you wish to view the original content. Only the author can remove the tags hiding this content. |
|
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Tue Mar 22, 2005 2:56 pm Post subject: |
|
|
I'll need more info. I'll try to catch you on AIM sometime. _________________
|
|
Back to top |
|
 |
The Wobbler

Joined: 06 Feb 2003 Posts: 2221
|
Posted: Fri Apr 15, 2005 7:58 pm Post subject: |
|
|
Note from Castle Paradox Administration: | This content has been removed by the user. Contact the original author and link them to this post if you wish to view the original content. Only the author can remove the tags hiding this content. |
|
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Fri Apr 15, 2005 8:04 pm Post subject: |
|
|
Oh, heh, I'd forgotten. I'll see if I can get it done this week.
In the meantime, I hope your menu is not what's keeping you from making progress on the game..? _________________
|
|
Back to top |
|
 |
The Wobbler

Joined: 06 Feb 2003 Posts: 2221
|
Posted: Fri Apr 15, 2005 8:15 pm Post subject: |
|
|
Note from Castle Paradox Administration: | This content has been removed by the user. Contact the original author and link them to this post if you wish to view the original content. Only the author can remove the tags hiding this content. |
|
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Fri Apr 15, 2005 10:49 pm Post subject: |
|
|
Funny, that's why I haven't fixed your script.  _________________
|
|
Back to top |
|
 |
The Wobbler

Joined: 06 Feb 2003 Posts: 2221
|
Posted: Fri Apr 15, 2005 11:20 pm Post subject: |
|
|
Note from Castle Paradox Administration: | This content has been removed by the user. Contact the original author and link them to this post if you wish to view the original content. Only the author can remove the tags hiding this content. |
|
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Sat Apr 16, 2005 10:11 am Post subject: |
|
|
That being the case, why don't you resend your script so you don't have to clean it up again when I send it back? I haven't touched it yet and conceivably this'll be a lot easier on both of us. _________________
|
|
Back to top |
|
 |
The Wobbler

Joined: 06 Feb 2003 Posts: 2221
|
Posted: Sat Apr 16, 2005 10:28 am Post subject: |
|
|
Note from Castle Paradox Administration: | This content has been removed by the user. Contact the original author and link them to this post if you wish to view the original content. Only the author can remove the tags hiding this content. |
|
|
Back to top |
|
 |
|