Using a vehicle

Hi everyone! I'm working on a game that requires a car. There are three locations the player can drive between: mayfair_street, soho_street and st_james_park.

At one point in the game, the player will be asked to drive from the park to Soho, and they'll think they're using the exit they've always used, but they'll actually be taken into a maze that has magically been placed between them and their destination. Once the maze is completed, it disappears and the player can move between the three driveable rooms as before. I have the triggering event and the invisible/visible exits issue logic worked out already. (Proud of myself!)

I've written some pseudocode for a drive verb on the car that I believe handles basic navigation between the three driveable locations, and I think it also handles entrance to the maze. Here's the gist with the pseudocode. Once I've figured out how to make the game check which room it's in, I think I can make that work.

My issue is what happens once the player is in the maze. I'll want to move the car and the player (and their friend, who is attached to the player as a follower), from room to room all at once. There are 24 rooms in the maze, and some rooms have up to six exits. Obviously, what I've done in the pseudocode isn't sustainable at this scale.

I'm sure it's clear to you by now that there are commands or functions I could be using that do all this better. What I have is cobbled together from advice to others in old forum posts. Do you have any suggestions that might help me do this more efficiently while limiting car movement to only the three driveable regular rooms and the 24 maze rooms?


Io
Once I've figured out how to make the game check which room it's in, I think I can make that work.

What you want is the parent attribute; parent is the room you're in:

if WhateverObject.parent=DesiredRoom{
DoStuff
}

As for what to do... I guess you could muck around with the player's changedparent attribute, and have there be a Player.Driving boolean. You set it to True when you enter the maze, and the changedparent says:

if Player.Driving=True{
Move Car with the player
}

And when you leave the maze, you set it to false and the stuff stops following you.

Hope this helps!


Thanks for the quick reply! I understand the part about parent attributes (thanks!), but I have to admit that the second part is a little over my head. Does the Player.Driving boolean go in the changedparent attribute? So it would go:

Junie puts Player.Driving boolean on changedparent attribute

Player enters maze; using the exit from the park sets Player.Driving=True

if Player.Driving=True {
     MoveObject (bentley, player.parent)
     }

Does that sound right?


Io

Almost. I mean you'd give the player a seperate Player.Driving boolean in the editor.

The process of entering or leaving the maze changes Player.Driving, and then the changedparent checks whether it's true or false.


Oh, ok! That makes sense. I'll give it a shot, see what happens and report back. Thanks!


I'm making some progress and having fun. Here's a new gist with the completed script for the drive verb on the car. It's working almost as I'd expect it to. Two things:

  1. When player has player2 as a follower, I'm still getting the else if message (line 6) that's meant to show up if player is alone. I checked the debugger, and player2 was definitely in the player.followers list.

  2. There's a geography problem. Soho is east of Mayfair, St. James's Park is southeast of Mayfair, and Soho is northwest of St. James's Park. (See the triangle in your head?) If the player is driving the car, the commands southeast and east (and se and e) both take the car and the party to Soho. But only the first time they try to use those directional commands in Mayfair. If I do se in Mayfair and accidentally find myself in Soho when I should be in St. James's Park and then do w to get back to Mayfair, a second se will take me to St. James's Park as it should. This doesn't happen on foot, so I know it has to be a problem with drive.

Other than this, though, things are great! The Player.Driving boolean io suggested works like a charm in the maze - I'm so pleased!


If you're curious how these fit together, this is the branch I'm working off.


Io
  1. I think the problem is that you're checking if player.followers is player2. Now, maybe Quest can distinguish it, but it seems to me that it's going 'Oh, well player.followers isn't player2. It's a list containing player2, but it's not player2, so run the else if message!'

  2. Whoa, I need to draw this. And even after doing so it's... pretty confounding. Sorry I can't be of more help with this one.


  1. Thanks - I think I see the problem. I'll switch it around a little and see how it goes.

  2. I know! It's a mess. Thanks for looking, though.


  1. Are you saying that when driving the car "se" from Mayfield, it will go to SoHo the first time and St. James' thereafter? Hmm, that is pretty funky.

Are there any firsttime scripts or text processor directives that might be diverting the "drive" verb?

What if you put in a debugging message script when driving "se" from Mayfield, to see if it prints the same the first and second times?

The first time, could there be some script that is moving the car to St. James', and then moving it to SoHo?


Yes, that's what happening. The first time you leave Mayfair in the car, SE will take you to Soho, which is E. If you're not in the car, SE takes you to the park as expected. It's driving me bats.

Those are all interesting, possibilities, Dcoder. I don't think I have any firsttime scripts on any of those rooms, but I'll give it another check. There's some jiggery-pokery around St. James's Park that makes the NE exit go to a place other than Soho IF a certain object is visible, and that object is visible in my testing mess - I didn't think to check what things would do if the trigger object weren't in the park, which was silly of me.

I guess it's just time to do some tinkering!


First thing I notice when I look at your code (did you already fix this?):

      if (IsRegexMatch ("(east|e)", LCase (result))) {
        MoveObject (bentley, soho_street)
        MoveObject (player, soho_street)
        }

      else if (IsRegexMatch ("(southeast|se)", LCase (result))) {
        MoveObject (bentley, st_james_park)
        MoveObject (player, st_james_park)
        }

the else if will never fire. Because the first condition matches any string which contains the letter 'e'; and both "se" and "southeast" have an e in.


I thought that might be happening. I tried putting quotes around the individual inputs to see if that would help, but it threw an error. Is there a better way to use the user input the way I want?


Instead of:

IsRegexMatch ("east|e", LCase (result))

What is the correct syntax to say that result has to be an EXACT match to "east" or "e"?


Ah! Try this:

IsRegexMatch ("^east$|^e$", LCase (result))

or "^(east|e)$"

Or put the southeast one first, because the inputs "east" or "e" don't contain the string "se" to make a false positive.

Or, instead of using get input and making your own parser, you could just change the behaviour of the 'go' command (for example, in the game.enterroom script you could check for some flag to see if the player is driving, and if so move the car to their current location; and lock any exits that aren't accessible to vehicles.


Thank you! Those are all interesting avenues to pursue. Once I get away from work where it's Mac-only and get back home to the PC with Quest, I'll start playing around with those. Thanks for your help!


Ok, big week, very busy. But I've had a chance to look at the suggestions from Dcoder and mrangel in action, and I've got my e/se problem fixed! Thanks for your help.

mrangel, referring back to your comment of Oct. 18, you said:
The process of entering or leaving the maze changes Player.Driving, and then the changedparent checks whether it's true or false.
I've got it so that moving into the first room of the maze sets the player_driving boolean in changedparent to TRUE. I expected that player_driving would remain TRUE until I used the exit that's set to change it to FALSE. Instead, moving to another room in the maze changes it to FALSE. Is there something I don't understand about attribute booleans?

Thanks again for all your help - this has been a lot of fun, even when it's frustrating.


There's not any special behaviour I can think of, but I'm not quite sure what you mean there. Based on your previous comments, I asumed that the driving attribute would be set to true when the player uses the "drive" verb. But I think I don't completely understand your situation. Can you show the code that isn't behaving?


And mostly unrelated, now you've got me wondering about a slightly different way of handling cars.
A bit of an odd way to do it
  • Have a car with a "get in" or "drive" verb that moves the player (and any followers) inside it.
  • Have the car's room description script:
    1. Tell the player they are in a car
    2. Display the description for the parent room
    3. Clone the parent room's exits into the car (possibly filtering them so it only includes by-road exits). The cloned exits should have the script attribute car.parent = this.to so that using them moves the car instead of the player.
  • Have the car's changedparent run ShowRoomDescription().

Ah, I see what you were thinking. I'd rather not have the player have to say "drive sw" throughout this whole maze; I'd like them to just say "sw" and have the car move along with them so long as they were in the maze.

I think I have an idea of where I went wrong. If I can just figure out what problem I was trying to fix when I left the code in this state...


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums