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


Caravel Forum : DROD Boards : Architecture : A bit of scripting help required (Hmm, how to do this?)
New Topic New Poll Post Reply
Poster Message
Chaco
Level: Smitemaster
Rank Points: 3624
Registered: 10-06-2005
IP: Logged

File: Stabbing example.hold (1.7 KB)
Downloaded 42 times.
License: Public Domain
icon A bit of scripting help required (0)  
See attached hold.

For this puzzle that I'm planning on including in my hold, the idea is this. Basically, the NPC will move left and right based on the player's actions. This will be clearly documented.

Anyway, when the player is done moving the NPC around, the idea is that once he steps on the stone square the mimic starts moving forward, and if it stabs the NPC it will stop, face southwest to strike an orb (if there) and then back west again. The idea being you would then have to position the NPC above the orb.

The relevant part of the mimic's code looks like this:
Label MoveWestLoop
If... go to Stop
Wait for event Monster Stabbed
If... go to Stop
Move to (force arrow trap)
Wait 1 Turn
Go to MoveWestLoop
Label Stop
Face counterclockwise
Face clockwise


However, the mimic doesn't seem to be catching on that it's stabbing an NPC. Stabbing an NPC does work in terms of the NPC that's toggling some doors when a monster is stabbed (indicated by roach)

So, any suggestions on how I might be going wrong? How to stop that mimic?

____________________________
Quick links to my stuff (in case you forgot where it was):
Click here to view the secret text

01-20-2007 at 01:58 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
Jason
Level: Smitemaster
Rank Points: 1076
Registered: 05-05-2006
IP: Logged
icon Re: A bit of scripting help required (0)  
An NPC isn't a monster. Try "Wait for NPC" for where the npc will be.

____________________________
Play my holds?
01-20-2007 at 03:09 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
michthro
Level: Smitemaestro
Rank Points: 679
Registered: 05-01-2005
IP: Logged
icon Re: A bit of scripting help required (+1)  
Looks like a bug to me. Stabbing an NPC counts as a monster stabbed with a plain "Wait for event Monster Stabbed", but not with a test, as in "If... go to Stop | Wait for event Monster Stabbed".

You can use another event together with another NPC to get around this. For instance, you have an NPC that toggles the door at (35, 22) when a monster is stabbed, so replace "Wait for event Monster Stabbed" with "Wait for door to Close at (35, 22)". (The door will be open when the NPC is stabbed.)
01-20-2007 at 03:19 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
Chaco
Level: Smitemaster
Rank Points: 3624
Registered: 10-06-2005
IP: Logged
icon Re: A bit of scripting help required (0)  
Alright, that I think I can work in. Thanks for clearing that up michthro.

@jason: yes, but the idea behind the code is that the mimic keeps going west until it either (a) gets stuck in a force arrow trap or (b) stabs an NPC, no matter where the NPC is. You couldn't then use Wait While because it would then find the mimic NPC.

EDIT:

Yep, works like a charm michthro. I like the way said puzzle turned out. :)

____________________________
Quick links to my stuff (in case you forgot where it was):
Click here to view the secret text


[Last edited by Chaco at 01-20-2007 03:25 PM]
01-20-2007 at 03:21 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
schep
Level: Smitemaster
Avatar
Rank Points: 865
Registered: 03-01-2005
IP: Logged
icon Re: A bit of scripting help required (0)  
To be more precise, an NPC being stabbed does generate the 'Monster Stabbed' event. But this is one of those events that can happen after an NPC's script has run, which complicates things. If Beethro, moving mimic, Slayer, or guard does the stabbing, then it happens before NPCs act, and NPCs checking for the event that turn are sure to detect it. If a decoy or just-placed mimic stabbed, then NPCs checking for a stab with "If ... go to" have already executed code assuming no stab happened and won't catch the event, but NPCs checking for a stab without "If ... go to" are still waiting for the event and will detect it and resume, but can't execute any code until the next turn. When it's another NPC that does the stabbing, which of the above cases applies depends on the monster move order for the stabber and the tester.

But the reason this example didn't work had nearly nothing to do with all that. The "Move to" command always ends the NPC's turn. So the NPC in that GoWestLoop doesn't check for a stabbing until the beginning of each turn. In which case, no, nothing has been stabbed this turn.

Anyway, I can't think of any solution better than what was mentioned. (At least, not until TCB gives us "Wait for NPC at relative (-2,0)".) But it may act more obviously if you make sure the stab-detector NPC executes after the moving NPC.
01-21-2007 at 06:04 AM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD Boards : Architecture : A bit of scripting help required (Hmm, how to do this?)
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.