View previous topic :: View next topic |
Author |
Message |
Onlyoneinall Bug finder
Joined: 16 Jul 2005 Posts: 746
|
Posted: Tue May 06, 2008 2:22 am Post subject: Screwed up NPC references? |
|
|
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 |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Tue May 06, 2008 2:55 am Post subject: |
|
|
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 |
|
 |
Onlyoneinall Bug finder
Joined: 16 Jul 2005 Posts: 746
|
|
Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Tue May 06, 2008 3:17 pm Post subject: |
|
|
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 |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Wed May 07, 2008 12:07 am Post subject: |
|
|
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. 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 |
|
 |
Onlyoneinall Bug finder
Joined: 16 Jul 2005 Posts: 746
|
Posted: Thu May 08, 2008 6:20 pm Post subject: |
|
|
Thank you! 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 |
|
 |
|