View previous topic :: View next topic |
Author |
Message |
Bagne ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA

Joined: 19 Feb 2003 Posts: 518 Location: Halifax
|
Posted: Sun Nov 01, 2009 6:04 pm Post subject: Suspend NPC |
|
|
When I use "suspend NPCs", does this also suspend NPC use?
That is to say, if I walk up to a suspended NPC and hit space, what will happen?
If "suspend NPCs" doesn't work, is there a way to suspend NPC use? _________________ Working on rain and cloud formation |
|
Back to top |
|
 |
Baconlabs PURPLE IS MANLY

Joined: 15 Mar 2009 Posts: 335 Location: Tennessee
|
Posted: Sun Nov 01, 2009 6:17 pm Post subject: |
|
|
I don't think so.
What you're thinking of can be accomplished with a (large) list of Alter NPC commands, varying based on just what you don't want the player to do with certain NPCs. To my knowledge there is no catch-all "stop NPC interaction" command, but don't take my word for it.
This page lists about all you can do with Alter NPC commands, ranging from NPC pictures to move types to what happens when activated to how it's activated. |
|
Back to top |
|
 |
Bagne ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA

Joined: 19 Feb 2003 Posts: 518 Location: Halifax
|
Posted: Sun Nov 01, 2009 7:00 pm Post subject: |
|
|
Ok thanks.
Shoot.
Makes things harder than I anticipated :-) _________________ Working on rain and cloud formation |
|
Back to top |
|
 |
TwinHamster ♫ Furious souls, burn eternally! ♫

Joined: 07 Mar 2004 Posts: 1352
|
Posted: Sun Nov 01, 2009 7:25 pm Post subject: |
|
|
Loops make tedious stuff like this a bit easier ;)
This example only works with text boxes, but the same idea would function for virtually every other NPC stat.
Code: |
script, Erase all Speech, begin
variable (counter)
while (counter << 100)
do(
#Back up, explained below.
write global (100 + Counter, read NPC (Counter,NPCstat:display text)
#Sets all text boxes as 0
Alter NPC (counter, NPCstat:display text, 0)
#The loop never ends without this!
Increment (counter)
)
end |
However, if you want this to be a toggle-effect, you'll probably need a bunch of global variables to record the text boxes for when you want them back.
If this is the case, the reverse of the above script would be:
Code: |
#Global variables 100-199 have been reserved, theoretically.
#Feel free to use much fewer if you don't have that many NPC's.
script, Return all Speech, begin
variable (counter)
while (counter << 100)
do(
#Sets all text boxes to the back-ups.
Alter NPC (counter, NPCstat:display text, read global (100 + Counter))
#The loop never ends without this!
Increment (counter)
)
end |
|
|
Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Sun Nov 01, 2009 7:28 pm Post subject: |
|
|
Where's TMC? He'd tell you that it's easy - have a tag named "No Using NPCs" or something like this, and then have an on keypress script:
Code: |
if(checktag(tag:No Using NPCs), and,
(key is pressed (spacebar), or, key is pressed (enter))
), then
begin
suspend player
wait(1)
resume player
end
|
Two things to note:
1. "spacebar" and "enter" won't actually work there, but I'm guessing you get the idea
2. This is untested and just a guess as to what TMC would say, so hopefully he doesn't come in here, see something wrong, and hate me, haha _________________ My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161
This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Sun Nov 01, 2009 8:55 pm Post subject: |
|
|
Hahah!
Maybe it's not usually mentioned, but you ought to use a while loop to wait until the player stops holding down the key. The 'Permit double triggering of scripts' bitset is off by default, which will prevent the keypress handler from running again next tick, because it'll still be running (cleaning up with resumeplayer). Turning on the bitset solves the problem, but then the interpreter overflows if you hold down the key for several seconds.
Enough theory:
Code: | if(checktag(tag:No Using NPCs)) then, begin
while(key is pressed (key:space) || key is pressed (key:enter)) do, begin
suspend player
wait(1)
resume player
end
end |
_________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
Bagne ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA

Joined: 19 Feb 2003 Posts: 518 Location: Halifax
|
Posted: Mon Nov 02, 2009 4:24 am Post subject: |
|
|
Ooh ....
Are you suggesting that instead of suspending the NPCs, I suspend the player, and let him/her move around with an "on keypress" script for each direction?
That could work.
I was thinking of letting the player cast a sort of "ethereal" spell.
It suspends everything, and you can't interact with anything, but you can walk ahead and see what's there without triggering any battles, traps, etc. _________________ Working on rain and cloud formation |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Mon Nov 02, 2009 5:24 am Post subject: |
|
|
No, that's not how it works. You'll want to suspend NPCs as well. You don't suspend the player totally, the script only blocks attempts to use the use keys by suspending the player just when they are pressed. Also, I just realised that msw made the mistake of forgetting the ctrl key. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
Bagne ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA

Joined: 19 Feb 2003 Posts: 518 Location: Halifax
|
Posted: Mon Nov 02, 2009 6:15 am Post subject: |
|
|
Ooh oh.
Weird.
Ok, It think I get it.
Wait, no I don't.
The computer's checking the "suspend NPCs tag" every time I hit space, so why do I need to suspend the player?
Is it because the keypress script isn't wrapping the-stuff-that-normally-happens-when-I-hit-space? _________________ Working on rain and cloud formation |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Mon Nov 02, 2009 6:28 am Post subject: |
|
|
You do sound really confused. 'Suspend NPCs' only prevents NPCs from moving automatically. The script prevents the space and enter keys from activating npcs. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
Bagne ALL YOUR NUDIBRANCH ARE BELONG TO GASTROPODA

Joined: 19 Feb 2003 Posts: 518 Location: Halifax
|
Posted: Mon Nov 02, 2009 8:01 am Post subject: |
|
|
Right.
What I've been wondering is why the player is suspended for a tick.
I was confused because I was under the impression that the key-press script is triggered *instead* of the normal space/enter NPC activation.
But now I'm guessing that's not the case: both are triggered, and so the key-press script has to suppress the NPC activation of the other.
If I'm still sounding completely confused, don't worry about it :-)
I'll just shut up and try out the scripts.
Thanks for your help. _________________ Working on rain and cloud formation |
|
Back to top |
|
 |
msw188
Joined: 02 Jul 2003 Posts: 1041
|
Posted: Mon Nov 02, 2009 11:34 am Post subject: |
|
|
You've got it Bagne - on-keypress scripts do not replace the effect of the keypress, they are just initiated first, and then the normal effect of the keypress is done as well. This is why you do not need to script in the movement keys, you only need to block the 'using' keys.
And yeah, I forgot about Ctrl, even though I use that the most when I'm actually playing an Ohr game. _________________ My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161
This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Mon Nov 02, 2009 1:17 pm Post subject: |
|
|
The only problem with that script is that the player will be unable to move if he holds down space. Also, problems if your main menu has background scripts enabled (this is not the case by default). _________________
|
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Tue Nov 03, 2009 2:39 am Post subject: |
|
|
Yes, you are no longer allowed to lean on your spacebar without reason.
I'm pretty sure that suspending player doesn't affect menus or anything else besides movement, npc activation, and opening the menu. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
|