Announcement: Why not try our official idea generator for inspiration when making puzzles?


Caravel Forum : DROD Boards : Architecture : If...GoTo Scripting
New Topic New Poll Post Reply
Poster Message
nickcoffey
Level: Goblin
Rank Points: 27
Registered: 04-18-2006
IP: Logged

File: room.jpg (140.9 KB)
Downloaded 56 times.
License: Public Domain
icon If...GoTo Scripting (0)  
Hello.

I am interested in having a roach stay hidden until Beethro strays off of the cement path. At that point, I would like the roach to become visible and to attack. Below is the script I've used and attached is a picture of the room.

When I run the room and walk onto the grass, the roach does not appear. I'm sure it's just a question of my not having mastered the order in which commands need to be entered (oh, how I wish I could use Perl-style commands), but if anyone could guide me in the right direction, I'd appreciate it. Thanks!

=====
  If ... go to "attack" :
  Wait for player at (29,7)-(29,9)
  If ... go to "attack" :
  Wait for player at (31,5)-(31,9)
  If ... go to "attack" :
  Wait for player at (5,4)-(30,4)
  If ... go to "attack" :
  Wait for player at (7,6)-(28,6)
  If ... go to "attack" :
  Wait for player at (4,5)-(4,26)
  If ... go to "attack" :
  Wait for player at (6,7)-(6,24)
  If ... go to "attack" :
  Wait for player at (5,27)-(36,27)
  If ... go to "attack" :
  Wait for player at (7,25)-(36,25)
Label "attack"
  Turn into monster
  Appear
=====

-Nick
05-18-2006 at 07:42 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
krammer
Level: Smitemaster
Avatar
Rank Points: 904
Registered: 02-12-2003
IP: Logged
icon Re: If...GoTo Scripting (+1)  
First, I think you have to appear before you can turn into monster, but I'm not sure.

Second, if that is your script as it stands, then the roach will appear regardless because the script will pass through all the checks, then blindly execute the "appear" command that follows. You need to add a "Start" label or such at the beginning, and a "Wait 1 turn", "GoTo Start" before the "attack" label. Otherwise it looks fine.

____________________________
+++ Divide by Cucumber Error +++ Please Reinstall Universe and Reboot +++

"Oook!"
05-18-2006 at 07:50 PM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
nickcoffey
Level: Goblin
Rank Points: 27
Registered: 04-18-2006
IP: Logged
icon Re: If...GoTo Scripting (0)  
Okay, I added the Start label to have the script treat this as a loop and I added speeches to help me see where I am in the code, so that I now have:
Label "start"
  Speech Beethro, "we're at start"
  Wait for turn 1
  Speech Beethro, "we just waited one turn"
  If ... go to "attack" :         |
  Wait for player at (#,#)-(#,#)  | Same stuff 8 times.
  [...]                           |
  Speech Beethro, "we're about to go back to start"
  Go to "start"
Label "attack"
  Speech Beethro, "we're at attack"
  Appear
  Speech Beethro, "we just appeared"
  Turn into monster
  Speech Beethro, "we just turned into a monster"

When I execute this, I get the dialog from the Start label, but if I step onto the grass (and yes, I have the right squares coded), those speeches continue and the Attack label is never reached. Why not?

Edit: I just started the level and pressed 5 once. The following text looped three times automatically, then stopped, even when I started to walk: "we're at start," "we just waited one turn," "we're about to go back to start."

-Nick

[Last edited by nickcoffey at 05-18-2006 08:33 PM]
05-18-2006 at 08:29 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
coppro
Level: Smitemaster
Rank Points: 1308
Registered: 11-24-2005
IP: Logged
icon Re: If...GoTo Scripting (0)  
You need a Wait 1 turn command before the goto, or else the game sees an infinite loop and shuts it off.
05-18-2006 at 08:33 PM
View Profile Show all user's posts Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: If...GoTo Scripting (0)  
coppro wrote:
You need a Wait 1 turn command before the goto, or else the game sees an infinite loop and shuts it off.
Right. That is, instead of "Wait for turn 1", use "Wait 1 turn", and it's probably better to place it right before the "GoTo start" instead of at the beginning of the loop. That way all the checks are made, and then if nothing happens it will wait until the next turn to check again. Otherwise, it doesn't perform the checks the first turn in the room. (This might not matter in this case, of course.)

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.
05-18-2006 at 08:47 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
nickcoffey
Level: Goblin
Rank Points: 27
Registered: 04-18-2006
IP: Logged
icon Re: If...GoTo Scripting (0)  
Okay, my problem was not having the right Wait command. Now, however, the text appears on turn 1, not on turn 2, and again on turns 3, 4, 5...

I just realized why the speeches don't work when the Character turns into a monster, but why don't the first two speeches ("we're at attack," "we just appeared") work? It's still a scripted character at these points.

I'm going to create a makeshift one-room hold for this; one moment...
05-18-2006 at 08:58 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
nickcoffey
Level: Goblin
Rank Points: 27
Registered: 04-18-2006
IP: Logged

File: Keep off the Grass.hold (1.5 KB)
Downloaded 39 times.
License: Public Domain
icon Re: If...GoTo Scripting (0)  
Here is a hold with the script in question.

1. Why does the speech not appear during turn #2?
2. Why do the first two speeches of the Attack label not appear?

-Nick
05-18-2006 at 09:09 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
Sergenth
Level: Master Delver
Rank Points: 296
Registered: 05-04-2005
IP: Logged
icon Re: If...GoTo Scripting (0)  
If you want the roaches to talk as they attack, you will need to create a duplicate roach script NPC and instead of having it turn into a monster, stay invisible and project speech onto the appearing roach, using the "CUSTOM" speaker type in the speech dialog menu.

This way, the text will follow the roach as it moves.

If you want more than one roach to say attack, make a separate speech command NPC for each talking roach and offset each one by consecutive thousandths of a second, like this:

Speech at (20,13), 1, "Attack!"

... other NPC

Speech at (17:19), 2, "Attack!

... and so on


It doesn't seem to work for me if the first speech NPC has a delay of zero, even if the second one has a delay of 1.
05-18-2006 at 09:31 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
nickcoffey
Level: Goblin
Rank Points: 27
Registered: 04-18-2006
IP: Logged
icon Re: If...GoTo Scripting (0)  
Okay, that's good news to know for later if I need to throw a voice, as it were.

As for the speechlessness on turn 2, I won't actually have speech during the grass-stepping checks, but it's more of the programmer in me wanting to know why only turn 2 is being skipped. I currently have:
Label "start"
  Speech "start"
  (Eight If...goto "attack" things)
  Speech "wait a turn; go to start"
  Wait 1 turn(s)
  Go to "start"
Label "attack"
  Speech at (9,1), "blah"
  Wait 1 turn(s)
  Appear
It works on turn 1, turn 3, turn 4, turn 5... Bugger all!
05-18-2006 at 10:56 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
Sergenth
Level: Master Delver
Rank Points: 296
Registered: 05-04-2005
IP: Logged

File: Sergenths Keep off the Grass Example.hold (2.9 KB)
Downloaded 41 times.
License: Public Domain
icon Re: If...GoTo Scripting (+1)  
I'm uploading the Attack Speech thing... someone else may want to see it. I finally learned what the "Custom" speaker type REALLY does thanks to this topic :)

Nick, I'm testing out the turn 2 problem you're having. In your hold, if I press f5 and start beethro at the edge of the square, and then step off the square on my first turn (the roaches second turn)... the roach NPCs don't detect it and stay invisible.

Then, if I step out of the sensor boundary that you created around the rock square, they'll never detect me (unless I step back into the sensor ring).

The "turn 2" problem seems to affect more than speech.

[Last edited by Sergenth at 05-18-2006 11:18 PM]
05-18-2006 at 11:16 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
nickcoffey
Level: Goblin
Rank Points: 27
Registered: 04-18-2006
IP: Logged
icon Re: If...GoTo Scripting (0)  
Sergenth wrote:
Then, if I step out of the sensor boundary that you created around the rock square, they'll never detect me.
Exactly. It's as if there might be an off-by-one error in the CPP code itself.
05-18-2006 at 11:20 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: If...GoTo Scripting (+1)  
nickcoffey wrote:
Sergenth wrote:
Then, if I step out of the sensor boundary that you created around the rock square, they'll never detect me.
Exactly. It's as if there might be an off-by-one error in the CPP code itself.
Yes, I think this is a bug in the game code that occurs for Wait 1 turn commands after the very first turn in the room. However, I'm guessing existing holds use this (buggy) behavior for scripted story stuff to work properly and I'd be reluctant to fix it and risk breaking some published rooms (maybe in some official holds too...who knows). If there's a way to confirm that fixing this wouldn't break published room scripts, then I'd fix it sometime soon.

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.
05-19-2006 at 12:01 AM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
nickcoffey
Level: Goblin
Rank Points: 27
Registered: 04-18-2006
IP: Logged
icon Re: If...GoTo Scripting (0)  
Sounds good. I just changed the layout a little bit and added some walls so that the user is forced to go forward at least one step before being able to walk onto the grass if he or she so chooses.

All's well that ends well. :)

Edit and PS: Thanks to all for participating in figuring these things out.

[Last edited by nickcoffey at 05-19-2006 12:17 AM]
05-19-2006 at 12:14 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD Boards : Architecture : If...GoTo Scripting
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.