Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

My NPCs are getting out of line.
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
The Wobbler




Joined: 06 Feb 2003
Posts: 2221

PostPosted: Mon Mar 21, 2005 9:08 pm    Post subject: My NPCs are getting out of line. Reply with quote

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
View user's profile Send private message
phyrfox
Avid Player




Joined: 20 Feb 2005
Posts: 96
Location: New York, USA

PostPosted: Mon Mar 21, 2005 10:04 pm    Post subject: Re: My NPCs are getting out of line. Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Mon Mar 21, 2005 10:21 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
The Wobbler




Joined: 06 Feb 2003
Posts: 2221

PostPosted: Mon Mar 21, 2005 10:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
Leo
The wizard of many faces...




Joined: 02 Nov 2004
Posts: 95
Location: Way far up north in Sweden...

PostPosted: Tue Mar 22, 2005 7:44 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Tue Mar 22, 2005 8:27 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
The Wobbler




Joined: 06 Feb 2003
Posts: 2221

PostPosted: Tue Mar 22, 2005 1:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Tue Mar 22, 2005 2:56 pm    Post subject: Reply with quote

I'll need more info. I'll try to catch you on AIM sometime.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
The Wobbler




Joined: 06 Feb 2003
Posts: 2221

PostPosted: Fri Apr 15, 2005 7:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Fri Apr 15, 2005 8:04 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
The Wobbler




Joined: 06 Feb 2003
Posts: 2221

PostPosted: Fri Apr 15, 2005 8:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Fri Apr 15, 2005 10:49 pm    Post subject: Reply with quote

Funny, that's why I haven't fixed your script. XD
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
The Wobbler




Joined: 06 Feb 2003
Posts: 2221

PostPosted: Fri Apr 15, 2005 11:20 pm    Post subject: Reply with quote

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
View user's profile Send private message
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Sat Apr 16, 2005 10:11 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website AIM Address
The Wobbler




Joined: 06 Feb 2003
Posts: 2221

PostPosted: Sat Apr 16, 2005 10:28 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group