 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
Smeargle
Joined: 09 Jun 2008 Posts: 25
|
Posted: Mon Jun 09, 2008 2:34 pm Post subject: npc at spot |
|
|
what does npc at spot() return if there is no npc there |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Mon Jun 09, 2008 2:50 pm Post subject: |
|
|
Pretty sure it's 0 (same thing as false). _________________
|
|
Back to top |
|
 |
Smeargle
Joined: 09 Jun 2008 Posts: 25
|
Posted: Mon Jun 09, 2008 3:07 pm Post subject: |
|
|
Does that mean it works as the reference for the npc at 0 on the npc editor |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Mon Jun 09, 2008 3:12 pm Post subject: |
|
|
You don't need to know this, but all references are negative numbers. If you use a positive number or 0, the engine interprets it as an npc ID (not a reference) and uses the first copy of that NPC it can find. So if I wrote this script:
Code: | walk npc (npc at spot(5, 5), right, 2) |
and there was no NPC at (5,5), then some copy of NPC 0 on the map would walk right two spaces. This would be the correct way to do it:
Code: | if (npc at spot(5,5)) then (walk npc (npc at spot(5, 5), right, 2)) |
_________________
|
|
Back to top |
|
 |
Smeargle
Joined: 09 Jun 2008 Posts: 25
|
Posted: Mon Jun 09, 2008 3:53 pm Post subject: |
|
|
Thanks, good to know...
Knowing that I now have no idea what might be wrong with this script.
This script is my attempt to "trick" the npc limit of 32 in that I am trying
to make lots of copy's of one npc say different stuff. It is supposed to
check the squares around the hero for a npc and then show a text box
depending on its X and Y location. It is set to run when you use the npc.
Code: |
#These plotscritps will control what diffrent characters say when they talk to them
#sages!
plotscript, sagefind, begin
variable(sage)
suspend player
if (npc at spot((hero x(me) -- 1), hero y(me))) then(sage := npc at spot ((hero x(me) -- 1), hero y(me)))
else (if (npc at spot((hero x(me) + 1), hero y(me))) then(sage := npc at spot ((hero x(me) + 1), hero y(me)))
else (if (npc at spot(hero x(me), (hero y(me) -- 1))) then(sage := npc at spot(hero x(me), (hero y(me) -- 1)))
else(if (npc at spot(hero x(me), (hero y(me) + 1))) then(sage := npc at spot(hero x(me), (hero y(me) + 1)))
)
)
)
resume player
sagesay(npc x(sage), npc y(sage))
end
plotscript, sagesay, sx=0, sy=0, begin
if(sx == 18, and, sy == 12) then (
show text box(21)
) #end of then
if(sx == 13, and, sy == 12) then (
show text box(21)
) #end of then
if(sx == 12, and, sy == 9) then (
show text box(21)
) #end of then
if(sx == 12, and, sy == 8) then (
show text box(21)
) #end of then
if(sx == 14, and, sy == 7) then (
show text box(21)
) #end of then
if(sx == 18, and, sy == 7) then (
show text box(21)
) #end of then
if(sx == 20, and, sy == 8) then (
show text box(21)
) #end of then
if(sx == 20, and, sy == 10) then (
show text box(21)
) #end of then
else(show value(sx, and, sy), wait(5), show no value)
end
|
* they all say the same thing because I haven't gotten around to writing
individual things for them to say |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Mon Jun 09, 2008 4:09 pm Post subject: |
|
|
What actually happens when you run it? Try adding the line show value(sage) into your sagefind script.
Also, the NPC limit is 36 (0-35). I doubt this makes a difference as far as your script is concerned.
More to the point, though, there's an easier way of doing this. Try this:
Code: | plotscript, sagefind, begin
variable(sx, sy)
sx := hero x
sy := hero y
if (hero direction == west) then (sx -=1)
if (hero direction == east) then (sx += 1)
if (hero direction == south) then (sy += 1)
if (hero direction == north) then (sy -= 1)
sagesay(sx, sy)
end |
Of course, this assumes the player is facing the NPC he's talking to. _________________
|
|
Back to top |
|
 |
Smeargle
Joined: 09 Jun 2008 Posts: 25
|
Posted: Mon Jun 09, 2008 4:35 pm Post subject: |
|
|
I did as you said and it is now a lot easier to read, but I am getting the
same results. (by the way the showvalue at the end of sagesay prints out
0, I am not sure exactly why)
I must of got 32 from 32767 |
|
Back to top |
|
 |
Smeargle
Joined: 09 Jun 2008 Posts: 25
|
Posted: Mon Jun 09, 2008 6:32 pm Post subject: |
|
|
(sorry about posting twice, for some reason I can't edit)
changed the code a little to show variables better
sx is always 0
sy is always the npc reference (i.e. -6) |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Mon Jun 09, 2008 7:12 pm Post subject: |
|
|
Your NPCs are calling sagesay instead of sagefind, I bet. _________________
|
|
Back to top |
|
 |
Smeargle
Joined: 09 Jun 2008 Posts: 25
|
Posted: Mon Jun 09, 2008 7:29 pm Post subject: |
|
|
your right.... my bad
thanks though |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Thu Jun 12, 2008 5:36 am Post subject: |
|
|
Code: | if(sx == 20, and, sy == 10) then (
show text box(21)
) #end of then
else(show value(sx, and, sy), wait(5), show no value) |
This else block is attached to the last if. If you want something to happen if none of the if's match, the easiest way to do that would probably be to put an exit script in each if.
I'm afraid you can't show two numbers at once so easily. and does a bitwise and on two numbers. Just show them separately, or create and show a string.
BTW, there's an even easier way to write sagefind (or call sagesay directly):
Code: | plotscript, sagefind, dummy arg, npcref, begin
sagesay(npc x(npcref), npc y(npcref))
end |
_________________ "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
|