! Interactive Fiction Game ! Mikhail Ansolis ! CIS 587 ! 10/16/02 Constant Story "Space Escape"; Constant Headline "^Escape from the space station... or die!^"; Constant DEBUG; ! This teaches the parser that TAKE ALL action does not refer to scenery objects [ ChooseObjects obj code; if (code < 2) { if (obj has scenery) return 2; rfalse; } return 1; ]; Include "parser"; Include "verblib"; Include "grammar"; !!!!!!!!!The Hall with the Crowbar and Three Doors!!!!!!!!!!!!! Object Hall "Hall" has light with name "hall", !initial "The doors appear to be locked", description "You are in a spacious hall. You can see three doors in front of you: the blue door to the south leads to the walk-in closet, the green door to the east leads to the decompression chamber, and the red door to the north leads to the storage room", n_to RedDoor, s_to BlueDoor, e_to GreenDoor; ! This is used to open the green door Object bar "crowbar" Hall with description "It's a wrecking bar. You can open or unlock something with it", name 'crowbar' 'wrecking' 'bar', before [; Take: if (Accumulator in player && bar notin player) "You can't take the crowbar while you are holding a heavy accumulator with both hands"; ]; ! The door between the Hall and the Chamber Object GreenDoor "green door" with description "It's just a heavy green door", name 'door' 'green', found_in Hall Chamber, door_to [; if (self in Hall) return Chamber; return Hall; ], door_dir [; if (self in Hall) return e_to; return w_to; ], before [; Open: if (Accumulator in player && self hasnt open) "You can't open a door while you are holding a heavy accumulator with both hands"; if (bar in player && self has locked) { give self open; give self ~locked; "You smash open the green door with the crowbar"; } if (AirSwitch hasnt on) "You hear a voice saying that the door cannot be opened until the pressure on both sides of the door is equal"; ], has static door openable lockable locked scenery; ! The door between the Hall and the Store Room Object RedDoor "red door" with description "It's just a red door. Looks like it leads to a store room", name 'door' 'red', found_in Hall StoreRoom, door_to [; if (self in Hall) return StoreRoom; return Hall; ], door_dir [; if (self in Hall) return n_to; return s_to; ], with_key bar, before [; Open: if (Accumulator in player && self hasnt open) "You can't open a door while you are holding a heavy accumulator with both hands"; ], has static door openable ~open scenery; ! The door between the Hall and the Closet Object BlueDoor "blue door" with description "It's just a blue door. Looks like it leads to a walk-in closet", name 'door' 'blue', found_in Hall Closet, door_to [; if (self in Hall) return Closet; return Hall; ], door_dir [; if (self in Hall) return s_to; return n_to; ], with_key bar, before [; Open: if (Accumulator in player && self hasnt open) "You can't open a door while you are holding a heavy accumulator with both hands"; ], has static door openable ~open scenery; !!!!!!!!!!!The Store Room with Accumulator and Space Suit in It!!!!!!!!!!!!! Object StoreRoom "store room" has light with name 'store' 'room', description "It's a small store room and you can see lots of stuff lying around", s_to Hall; ! This is used to power-up the spaceship Object Accumulator "accumulator" StoreRoom with name 'accumulator', description "It's an accumulator used to start the engine of a space ship It's very heavy and carrying it around would be difficult"; ! This is used to walk in the space/vacuum Object Suit "space suit" StoreRoom with name 'space' 'suit' 'spacesuit' 'space-suit', description "It's a space suit It will provide you with air and normal pressue", before [; Take: if (Accumulator in player && Suit notin player) "You can't take the space suit while you are holding a heavy accumulator with both hands"; Wear: if (children(player) > 1 && Suit hasnt worn) "You can't put on a space suit while you are carrying things"; Disrobe: if (Accumulator in player && Suit has worn) "You cannot take off the space suit while holding the accumulator"; if (location == Chamber && AirSwitch hasnt on || location == Corridor || location == Ship1 || location == Ship2 || location == Ship3) { deadflag = true; "You took off the spacesuit in the vacuum. You immediately suffocate and die. Better luck next time... Loser!"; } ], has clothing; !!!!!!!!!!!!!The Closet with Note and Key in It!!!!!!!!!!!!!!!!!!!!! Object Closet "walk-in closet" has light with name 'closet', description "This small dark closet is a perfect place to hide stuff...", n_to Hall; ! This note informes the user that they have to find thesmallest spaceship ! and uncovers the key under it when looked under or taken Object Note "note" Closet with description "It's a note and somebody wrote something on it", name 'note', before [; Take: if (Accumulator in player && Note notin player) "You can't take the note while you are holding a heavy accumulator with both hands"; if (self hasnt general) { move Key to Closet; give self general; } LookUnder: if (Accumulator in player && Note notin player) "You can't do that while you are holding a heavy accumulator with both hands"; !if player hasn't moved neither note nor key if (note hasnt moved && Key hasnt moved) { move Key to Closet; give self general; !the key has been revealed to player "Under the note you discover a key^ It looks like an ignition key for a space ship"; } Examine: if (note notin player) "You can't read the note at this angle"; else "The note says that the fastest spaceship is the smallest one, and the other spaceships are not designed for intergalactic flights at all"; ]; ! This key is needed to start a spaceship's engine ! Initially, it's not found anywhere Object Key "key" with description "It's a key^ It looks like an ignition key for a spaceship.", name 'ignition' 'key', before [; Take: if (Accumulator in player && Key notin player) "You can't take the key while you are holding a heavy accumulator with both hands"; ]; !!!!!!!!!!!The Deconmpression Chamber with Air Switch in It!!!!!!!!!!!!! Object Chamber "Decompression Chamber" has light with name 'chamber' 'decompression', description "This decompression chamber is used to equalize the air pressue with the the pressue in the next room. Behind you is the green door and in front of you is the yellow door.^ You can see a switch on the wall", w_to GreenDoor, e_to YellowDoor; ! This is needed to change the air pressure: On = air, off = vacuum Object AirSwitch "air switch" Chamber with name 'switch' 'air', description "This switch lets air in or forces it out to make the air pressure inside equal to the pressure outside", before [; SwitchOn, SwitchOff: if (GreenDoor has open || YellowDoor has open) "The voice from the speaker announces that the compressor will not work until the decompression chamber is closed"; ], after [; SwitchOn: "As you switch the air switch on, the pressure start to normalize"; SwitchOff: print "The compressor starts drawing the air out of the chamber and you get surrounded by cold vacuum...^"; if (Suit hasnt worn) { deadflag = true; "You are not wearing the space suit - you DIE!!!"; } return 1; ], has switchable static on scenery; !!!!!!!!The Yellow Door and the Service Corridor It Leads To!!!!!!!! ! The door between the Decompression Chamber and the Service Corridor Object YellowDoor "yellow door" with description "It's just a yellow door", name 'door' 'yellow', found_in Chamber Corridor, door_to [; if (self in Chamber) return Corridor; return Chamber; ], door_dir [; if (self in Chamber) return e_to; return w_to; ], before [; Open: if (Accumulator in player && self hasnt open) "You can't open a door while you are holding a heavy accumulator with both hands"; if (GreenDoor has open) "You hear a voice saying that the door cannot be opened until the pressure on both sides of the door is equal"; if (Suit hasnt worn) { deadflag = true; "The air quickly escapes from the chamber through the door and you suffocate in the vacuum. Too bad you didn't wear a space suit"; } ], after [; Open: if (AirSwitch has on && Suit has worn) { print "The air from inside the chamber starts to escape in the vacuum of the service corridor^It's good that you're wearing a space suit^You get blown away to the service corridor^"; PlayerTo(Corridor); rtrue; } ], has static door openable ~open scenery; Object Corridor "Service Corridor" has light with name 'corridor', description "This corridor leads to three spaceships: white, silver, and gold^ The entrances to them are white, silver, and gold hatches", n_to Hatch1, e_to Hatch2, s_to Hatch3, w_to YellowDoor; !!!!!!!!!!!!!!!The Three Ships!!!!!!!!!!!!!!!!!!! Object Ship1 "White Ship" with name 'white' 'ship', description "You are inside the white spaceship^ On the wall next to the entrance you see a serial number tag^ Further you find an ignition lock", s_to Hatch1, has light; ! This is the fastest spaceship Object Ship2 "Silver Ship" with name 'silver' 'ship', description "You are inside the silver spaceship^ On the wall next to the entrance you see a serial number tag^ Further you find an ignition lock", w_to Hatch2, has light; Object Ship3 "Gold Ship" with name 'gold' 'golden' 'ship', description "You are inside the gold spaceship^ On the wall next to the entrance you see a serial number tag^ Further you find an ignition lock", n_to Hatch3, has light; !!!!!!!!!!!!!The Three Hatches Leading to Each Ship!!!!!!!!!!!!!!!!!!! Object Hatch1 "white hatch" with name 'hatch' 'white', description "It's a white hatch, the white spaceship entrance", found_in Ship1 Corridor, door_to [; if (self in Ship1) return Corridor; return Ship1;], door_dir [; if (self in Corridor) return n_to; return s_to;], has static door openable open scenery; Object Hatch2 "silver hatch" with name 'hatch' 'silver', description "It's a silver hatch, the silver spaceship entrance", found_in Ship2 Corridor, door_to [; if (self in Ship2) return Corridor; return Ship2;], door_dir [; if (self in Corridor) return e_to; return w_to;], has static door openable open scenery; Object Hatch3 "gold hatch" with name 'hatch' 'gold' 'golden', description "It's a gold hatch, the gold spaceship entrance", found_in Ship3 Corridor, door_to [; if (self in Ship3) return Corridor; return Ship3;], door_dir [; if (self in Corridor) return s_to; return n_to;], has static door openable open scenery; !!!!!!!A Serial Number Tag and Manual Found in Each Spaceship!!!!!!!! Object Tag "serial number tag" with name 'tag' 'serial' 'number', description [; if (self in Ship1) "The serial number on the tag is XGHR222993"; if (self in Ship2) "The serial number on the tag is WGYR343344"; if (self in Ship3) "The serial number on the tag is YTRE464644"; ], found_in Ship1 Ship2 Ship3, has static scenery; Object Manual "manual" with name 'manual' 'book', description "The title of the book is Space Ship Operation Manual and it looks like reading it will help you to refresh your memory after spending so much time behind the bars...", before [; Examine: if (Accumulator in player && self notin player) "You can't read a book while you are holding a heavy accumulator with both hands"; "The manual states that the sizes of ships increase with serial numbers in alphabetical order"; Take: if (Accumulator in player && self notin player) "You can't take a book while you are holding a heavy accumulator with both hands"; ], found_in Ship1 Ship2 Ship3; ! Putting the ignition key in the wrong ignition lock makes you lose the game ! If you put the key in the lock on the fastest spaceship, you'll win Object Lock "ignition lock" with name 'ignition' 'lock', description "it's an ignition lock used to power the spaceship up", found_in Ship1 Ship2 Ship3, before [; Receive: if (noun ~= Key) "No, those things don't belong there..."; if (Accumulator notin player && Accumulator notin location) "The engin doesn't start. Looks like there is no power. Probably all the accumulators were removed as a security measure"; if (noun == Key) { print "It's good that you had the accumulator with you because accumulators were removed from all spaceships as a security measure against people like you. "; if (location == Ship2) { deadflag = 2; "Happily you fly away in the fastest spceship and nobody can go after you. In several years you come back, fight the bad guys, save the world, and live happily ever after :)"; } else { deadflag = true; "Happily you fly away but...^ Unfortunately, this spaceship is not the fastest ship around here, so you got caught and they made you watch the Golf Chennel for the rest of your life. Loser!^ Let somebody else save the world!^Or try again..."; } } ], has static container scenery; [ Initialise; location = Hall; ! The initial location for the game print "Things in a galaxy far, far away have gotten out of control and you went there to check things out, kill the bad guys, and still their money... and save the world. Agian. The bad guys didn't like you and put you in jail. Like always, you managed to escape. You can get to a friendly galaxy only on the fastest of all spaceships docked to the space station where you currently are...^Go find it!^^"; ];