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

Screwed up NPC references?

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Onlyoneinall
Bug finder




Joined: 16 Jul 2005
Posts: 746

PostPosted: Tue May 06, 2008 2:22 am    Post subject: Screwed up NPC references? Reply with quote

I don't often use NPC references, but I'm working on something right now that makes usage of it a lot easier.. at least it should.

The problem is this:

example:

set variable (MIKE, NPC reference,0)
set variable (TODD, NPC reference,1)

and I run a script..

set NPC position (MIKE, 4,0)
walk NPC (MIKE,south,1)

and it'll run fine. But then I use a door to switch to another map that has NPC 0 still MIKE and NPC 1 still TODD. BUT... say I have that same script run again without again setting the variables, it'll have some random other NPC instead of MIKE set in the position, and then it won't behave correctly (Say TODD is what Custom puts instead and TODD has a speed of 0, he won't move).

However, if I set the variables again for the references, then it'll work.

What am I overlooking or doing wrong? It seems to me I shouldn't have to set them over and over each time a door is used/a new map is entered. I should also note that I put them down as global variables.
_________________
http://www.castleparadox.com/gamelist-display.php?game=750 Bloodlust Demo 1.00

Back to top
View user's profile Send private message Send e-mail
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Tue May 06, 2008 2:55 am    Post subject: Reply with quote

This is a misunderstanding of NPC references. An NPC reference refers to a particular NPC instance (copy) on the map. If you change map, then you are dealing with a completely different set of NPCs, and old references are garbage.

If you are using the same ID numbers for identical NPC definitions across maps, why not use those instead? That is a perfectly good solution as long as you only have 1 copy of each of those NPCs.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Onlyoneinall
Bug finder




Joined: 16 Jul 2005
Posts: 746

PostPosted: Tue May 06, 2008 12:47 pm    Post subject: Reply with quote

Ah, well it's that I have about 20 different NPCs, so referring to them by name is a lot easier than by number. Raspberry! Is that what you meant?
_________________
http://www.castleparadox.com/gamelist-display.php?game=750 Bloodlust Demo 1.00

Back to top
View user's profile Send private message Send e-mail
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Tue May 06, 2008 3:17 pm    Post subject: Reply with quote

Code:

set variable (MIKE, NPC reference,0)
set variable (TODD, NPC reference,1)


This is not how you use "NPC reference"... in fact, using "NPC reference" this way really *should* produce an error message for calling the command with no arguments. (unfortunately we don't have support for non-optional arguments on built-in commands)

Try something more like:

Code:

set variable (MIKE, NPC reference(0))
set variable (TODD, NPC reference(1))


Although I would actually write it like this myself:

Code:

MIKE := NPC reference(0)
TODD := NPC reference(1)


I never did understand why people love the old fashioned "set variable" so much better than :=
Back to top
View user's profile Send private message Send e-mail Visit poster's website
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Wed May 07, 2008 12:07 am    Post subject: Reply with quote

Onlyoneinall wrote:
Ah, well it's that I have about 20 different NPCs, so referring to them by name is a lot easier than by number. Raspberry! Is that what you meant?


Well... no, I meant that you could just set some variables to the NPC ID numbers instead of the NPC references:

Code:
MIKE := 0
TODD := 1


But if these never change from map to map, you might as well just use constants:

Code:
define constant (
  0, MIKE
  1, TODD
)


Which is the least work.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Onlyoneinall
Bug finder




Joined: 16 Jul 2005
Posts: 746

PostPosted: Thu May 08, 2008 6:20 pm    Post subject: Reply with quote

Thank you! Happy That has saved me the trouble of referencing the NPCs over and over again.

Also James, I was not aware that set variable and := were interchangeable.
_________________
http://www.castleparadox.com/gamelist-display.php?game=750 Bloodlust Demo 1.00

Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
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