 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
G-Wreck OHRRPGCE Game Designer

Joined: 28 Feb 2010 Posts: 32 Location: Oklahoma
|
Posted: Thu Jul 22, 2010 7:51 am Post subject: Moving Lots of NPCs at Once |
|
|
I need to move several copies of the same NPC at the same time, in the same direction.
I read a page somewhere on the wiki about how to do this, but for the life of me I can't find it.
Here's the script I'm using to do this:
Code: |
#This script is supposed to walk all copies of NPC 9 down 100 spaces at the same time.
plotscript,song,begin
variable(loop,green count,green note)
green note := NPC copy count(9)
for(loop,0,green count)
do (
green note := NPC reference(9,loop)
walk NPC(green note,down,100)
)
end |
I have speeds set for the NPCs (at 4 if it matters), so I know they're able to move, but usually only the first copy actually does anything. Any ideas where I went wrong? _________________ Syzygy - .01% (Extremely Random Number)
Finishing the main story arcs and gameplay elements before I do anything else. |
|
Back to top |
|
 |
Calehay ...yeah. Class B Minstrel

Joined: 07 Jul 2004 Posts: 549
|
Posted: Thu Jul 22, 2010 12:44 pm Post subject: |
|
|
It looks like if you swapped the "green note" and "green count" variables in the for loop, it would work fine. _________________ Calehay |
|
Back to top |
|
 |
G-Wreck OHRRPGCE Game Designer

Joined: 28 Feb 2010 Posts: 32 Location: Oklahoma
|
Posted: Thu Jul 22, 2010 8:57 pm Post subject: |
|
|
And you were right, thank you. _________________ Syzygy - .01% (Extremely Random Number)
Finishing the main story arcs and gameplay elements before I do anything else. |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Thu Jul 22, 2010 10:35 pm Post subject: |
|
|
There's another bug:
Code: | for(loop,0,green count) |
should be
Code: | for(loop,0,green count--1) |
Otherwise, you'll find that "NPC reference(9,loop)" returns 0 for the extra "loop" value, which causes it to walk the first copy of NPC ID 0!
To understand why the "--1" is needed, realise that if there are 5 copies of the NPC, then they are numbered (for the purpose of the "NPC reference" command) 0, 1, 2, 3, 4. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
|
|
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
|