Re: [CODE] Vehicle Code

From: Chris Jacobson (fear@ATHENET.NET)
Date: 08/10/98


On 8/10/98 8:59 PM, Phillip A. Ames (kirk47@JUNO.COM) stated:

>Hey everybody...  Upon downloading Chris Jacobson's vehicle code, and
>with some help from him, I've gotten it working.  However, now I'd like
>to expand it to include checks for whether or not it's a space vehicle or
>ground vehicle.  I've gotten it to 99% work, but still have one problem
>that's bugging me.  Space vehicles can drive into space and ground rooms,
>and ground vehicles can only drive into ground rooms, so they work...
>Below is the system of checks I use to determine if the vehicle can go
>that direction or not.  If anyone can tell why this problem is occuring,
>I'd be grateful, and if you want the code I've added to this to get it
>this far, just send me a private e-mail.  Thanks in advance!

I supported terrain types in my current incarnation of the vehicles
(which is far advanced beyond the old patch, but relies heavily on my own
MUD's design so I can't make a patch), using a bitvector in a value
field.  I also do vehicle size, so large vehicles cannot go inside small
ones (we had people driving a capital class ship, Motava, inside
dropships, then flying the dropships to the planet... and the Motava is
deep-space and orbit only).

Anyways, I used a bitvector, thus allowing more configurable vehicles,
rather than using many vehicle types which end up adding a lot of extra
code.

Heres a sample:

        } else if ((dir = search_block(arg1, dirs, FALSE)) >= 0) {      // Drive in a
direction...
                /* Ok we found the direction! */
                if (!ch || (dir < 0) || (dir >= NUM_OF_DIRS) || (IN_ROOM(vehicle) ==
NOWHERE))
                        /* But something is invalid */
                        send_to_char("Sorry, an internal error has occurred.\r\n", ch);
                else if (!CAN_GO(vehicle, dir)) // But there is no exit that way */
                        send_to_char("Alas, you cannot go that way...\r\n", ch);
                else if (EXIT_FLAGGED(EXIT(vehicle, dir), EX_CLOSED)) { // But the door
is closed
                        if (EXIT(vehicle, dir)->GetKeyword())
                                act("The $F seems to be closed.", FALSE, ch, 0, const_cast<char
*>(EXIT(vehicle, dir)->GetKeyword()), TO_CHAR);
                        else
                                act("It seems to be closed.", FALSE, ch, 0, 0, TO_CHAR);
                } else if (!ROOM_FLAGGED(EXIT(vehicle, dir)->to_room, ROOM_VEHICLE) ||
                                EXIT_FLAGGED(EXIT(vehicle, dir), EX_NOVEHICLES))        // But the vehicle
can't go that way */
                        send_to_char("The vehicle can't manage that terrain.\r\n", ch);
                else if (ROOM_SECT(EXIT(vehicle, dir)->to_room) == SECT_FLYING &&
                                !VEHICLE_FLAGGED(vehicle, VEHICLE_AIR)) {
                        /* This vehicle isn't a flying vehicle */
                        if (ROOM_SECT(IN_ROOM(vehicle)) == SECT_SPACE)
                                act("The $o can't enter the atmosphere.", FALSE, ch, vehicle, 0,
TO_CHAR);
                        else
                                act("The $o can't fly.", FALSE, ch, vehicle, 0, TO_CHAR);
                } else if ((ROOM_SECT(EXIT(vehicle, dir)->to_room) ==
SECT_WATER_NOSWIM) &&
                                !VEHICLE_FLAGGED(vehicle, VEHICLE_WATER | VEHICLE_SUBMERGE))
                        /* This vehicle isn't a water vehicle */
                        act("The $o can't go in such deep water!", FALSE, ch, vehicle, 0,
TO_CHAR);
                else if ((ROOM_SECT(EXIT(vehicle, dir)->to_room) == SECT_UNDERWATER) &&
                                !VEHICLE_FLAGGED(vehicle, VEHICLE_SUBMERGE))
                        act("The $o can't go underwater!", FALSE, ch, vehicle, 0, TO_CHAR);
                else if (ROOM_SECT(EXIT(vehicle, dir)->to_room) == SECT_DEEPSPACE &&
                                        !VEHICLE_FLAGGED(vehicle, VEHICLE_INTERSTELLAR))
                        /* This vehicle isn't a space vehicle */
                        act("The $o can't go into space!", FALSE, ch, vehicle, 0, TO_CHAR);
                else if (ROOM_SECT(EXIT(vehicle, dir)->to_room) == SECT_SPACE &&
                                !VEHICLE_FLAGGED(vehicle, VEHICLE_SPACE))
                        act("The $o cannot handle space travel.", FALSE, ch, vehicle, 0,
TO_CHAR);
                else if ((ROOM_SECT(EXIT(vehicle, dir)->to_room) > SECT_FIELD) &&
                                (ROOM_SECT(EXIT(vehicle, dir)->to_room) <= SECT_MOUNTAIN) &&
                                !VEHICLE_FLAGGED(vehicle, VEHICLE_GROUND))
                        act("The $o cannot land on that terrain.", FALSE, ch, vehicle, 0,
TO_CHAR);
                else {  //      But nothing!  Let's go that way!


- Chris Jacobson


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST