Axe Software Forums
  Quest Developer Forum
  Question regarding room scripts===>


Author Topic:   Question regarding room scripts===>
Mega posted 10-11-2001 00:39 GMT     
I know that the 'script' command allows you to make certain things happen when a player enters a room. Is there a way to make something happen for ANY room?
For example, suppose you were being chased by someone trying to kill you. You would have to keep moving to avoid being killed, and he would keep following you. If you stayed in any one room for more than one or two turns, he would catch up with you. Therefore, you would need some sort of counter that kept track of how many turns you had spent in the current room. And so, logically, you'd need some sort of "universal room script" that reset that counter any time you left a room and entered a new one. Is there a way to do this?
Tyrant posted 10-11-2001 02:40 GMT          
This doesn't really answer your question, but why not use a timer? As soon as you enter the room, the timer can be triggered. Once it hits 0, the killer gets you. This way, you don't really have to do anything in order to get caught. You could just be sitting there reading a room description, when suddenly, BAM, you're dead! As soon as you leave the room, the timer could be reset or whatever.
Mega posted 10-11-2001 02:49 GMT          
I think I'd rather use a turn counter; but anyway, either of those would still require that either the counter, or the timer, be reset EVERY time you enter a new room, which would need some sort of room script which applied to ALL rooms universally.
Alex posted 10-11-2001 11:27 GMT          
The secret is in the "define game" block's afterturn tag. Try something like this:

startscript set string <oldroom;>

afterturn {
if ( #quest.currentroom# <> #oldroom# ) then {
set numeric <roomturns; 0>
set string <oldroom; #quest.currentroom#>
}
else set numeric <roomturns; %roomturns% + 1>

if ( %roomturns% >= 5 ) then {
' enter player-caught-by-monster script
}
}

Mega posted 10-11-2001 22:01 GMT          
Thanks! I'll give that a try! :-)

Also, I have a related question. This one will probably be much harder. Obviously, if you are being chased, going back the way you came would be even worse than just standing still, because that would be going back toward your pursuer. Is there a way to determine if you are retracing your steps when you enter a room? It needs to still apply if you don't go back immediately (i.e. if you spend a turn or two in the room, and THEN go back the way you came), and if you leave a room through non-directional means (i.e. 'go door' or 'climb stairs' as well as 'east' or 'north')

DarkAng3l posted 10-11-2001 22:13 GMT          
I have a much sillier question: how to set a timer? When I use afterturn, there occures a bug, in which the action who saves my character is done along with the "lose" condition. What can I do about it (Quest 2.1)?
Computer Whizz posted 10-11-2001 22:33 GMT          
You can upgrade to Quest 3.03 and try it then!

I don't think Quest 2.1 HAS a timer available....

Computer Whizz

Alex posted 11-11-2001 12:57 GMT          
quote:

Is there a way to determine if you are retracing your steps when you enter a room? It needs to still apply if you don't go back immediately (i.e. if you spend a turn or two in the room, and THEN go back the way you came), and if you leave a room through non-directional means (i.e. 'go door' or 'climb stairs' as well as 'east' or 'north')

Set a property for each room that's been entered - when going to a new room, use something like "set property <#quest.currentroom#; beenhere>". You can check whether this property is already set when a player enters the room and act accordingly.

Mega posted 11-11-2001 17:48 GMT          
Ohhhh! I didn't know that rooms could HAVE properties! I thought only objects could! Cool, that should work perfectly! And also, I no longer need those invisible "markers" I've been using to show that the room's puzzle has been completed. Thanks for the tip! :-)