Constant Story "Alien Rescue^"; Constant Headline "by Jaidev^^"; Attribute NoteTorn; Attribute Main_Key; Attribute PwdFound; Global TriesUsed; Global Max_Tries; Global Heavy_Obj_In_Hand; Global QuestionUsed; Global CriticalStateEntered; Global BulletsLeft; CONSTANT Time_Inc = 0; !These are the libraries that are referenced by the compiler. Include "parser"; Include "verblib"; Include "grammar"; !************************ Front Porch ***************************************** !This defines the front porch. Object Front_Porch "Front Porch" has light, with name "Front" "Porch", description "The front porch is well lit. You can see the front door to the north of you and a mailbox next to you. There is huge doormat near the front door. You have never seen such a huge doormat... but it is lovely. Looking at the doormat... you get a feeling that no one has ever stepped on it! You think to yourself... ~Am I on a wild goose chase?~.", in_to Front_Door, n_to Front_Door; !************************ Mail Box ***************************************** !This defines the front porch. Object MailBox "mailbox" Front_Porch with name "mail" "box" "mailbox", close, description "", before [; Examine: if(mailbox has open && note in mailbox) "^The mailbox has a note in it."; "^The mailbox has dust on it and is closed."; Open: if(mailbox has open) { print "^The mailbox is already opened!^"; rtrue; } if(note in mailBox) { move note to player; give mailbox open; print "^There is a note in the mailbox. You pick it up hoping that it will help you find the key.^"; rtrue; } "^There is nothing in the mailbox!^"; Close: if(mailbox has open) { give mailbox ~open; "^You closed the mailbox.^"; } "^The mailbox is already closed.^"; ], when_open "There is an open mailbox here.", when_closed "There is a closed mailbox here.", has static concealed container openable light; !************************ Global fn used to print the reaction on finding note/key ***************************************** !this will print the reaction when the front door key/clue is found [PrintKeyFoundReaction state; if(state == 0) { "^The note says - ~The key is under the doormat!~^"; } if(state == 1) { print "^The note says - ~The key is under the doormat!~ ^You are glad and a bit surprised to find this note! You think - ^~Could Dustbin be so careless? Or is it just my luck?~ "; } if(state == 2) { print "Good job... though pretty obvious... you did not have to hunt much! ^You are glad and a bit surprised that you have found the key so easily. "; } "You have got the confidence to solve this case easily- after all it was too simple to find the key!^"; ]; !************************ Note found in the mailbox ***************************************** Attribute legible; !This defines the front porch. Object Note "note" MailBox with name "note" "letter", description "", before [; if(self has NoteTorn) "The note has been torn!"; if(note in mailbox) { print "Mail box has a note."; return; } Consult,Read: if(note in player && self hasnt general) { give self general; PrintKeyFoundReaction(1); rtrue; } if(note in player && self has general) { PrintKeyFoundReaction(0); rtrue; } tear: if(note in player && note has general) { give self NoteTorn; "You tear the note as you don't need it anymore!"; } if(note in player && note hasnt general) { give self NoteTorn; "You have torn the note without reading it! Well... that was careless!"; } ], has concealed legible; !************************ doormat ***************************************** !This defines the front porch. Object Doormat "doormat" Front_Porch with name "doormat" "mat", description "Its a beautiful doormat!", before [; LookUnder: if(player in self) "^You are standing on the rug... I hope you don't want to hurt yourself! Not when all hope lies on you to save this country!^"; if(player has Main_Key) "^Gosh... the doormat is too heavy. But you manage to lift it a little. You look under it but there is nothing else that can help you.^"; give player Main_Key; move key to player; give self ~Main_Key; give self general; print "^Gosh... the doormat is too heavy. But you manage to lift it a little. You look under it... jackpot - you have the key to the front door!"; if(note has general ) !if the note has been read "Well... after all the note was not a joke!^"; PrintKeyFoundReaction(2); rtrue; take, push, pull: "^The mat is too heavy to do such a thing!^"; ], has supporter static concealed enterable legible Main_Key; !************************ key ***************************************** !This defines the front porch. Object Key "Key" with name "key", description "", before [x; take: if(doormat has Main_Key) "^You have not found the key yet!^"; if(player has Main_Key) "^You already have the key!^"; x = Location; if(x has Main_Key) { move key to player; give x ~Main_Key; give player Main_Key; "^You take the key hoping that it would come in handy later.^"; } drop: if(Player has Main_Key) { x = Location; move key to x; give x Main_Key; give player ~Main_Key; "^Hope you did the right thing by dropping the key. What if you need it again?^"; } "^You need to have the key to drop or throw it!^"; ], has concealed; !************************ DrawingRoom ***************************************** Object Living_Room "Living Room" with name "room" "living", description "You are in the living room of the house. The living room is well lit. There is absolutely no furniture around. Things are scattered around. You see a 27 inch television. To the East is the kitchen and North is the corridor.", s_to Front_Door, out_to Front_Door, e_to Kitchen, n_to Corridor, has light supporter; !************************ Vodka ***************************************** Object Vodka "Russian Vodka [Vodka]" Living_Room has edible, with name "vodka" "bottle", description "There is a bottle of authentic Russian Vodka. It is irresistible!", before [x; examine: if(self hasnt general) { "^This authentic Russian Vodka is irresistible... too bad u r on duty!"; } "^The bottle is empty. Not even a drop of vodka is left!"; take: if(vodka in player ) "^You already have the vodka bottle in your hand!"; if(Heavy_Obj_In_Hand > 1) "^Your hands are full!"; if(self hasnt general) { Heavy_Obj_In_Hand = Heavy_Obj_In_Hand + 1; move vodka to player; "^This authentic Russian Vodka is irresistible... too bad u r on duty!"; } "^The bottle is empty. Not even a drop of vodka is left!"; drop: if(vodka in player) { x = location; Heavy_Obj_In_Hand = Heavy_Obj_In_Hand - 1; move vodka to x; "^You drop the bottle onto the floor.!"; } "^You do not have the vodka bottle."; empty: if(self hasnt general) { give self general; "^You pour the vodka all over the floor! What a waste!"; } eat: print "^You can only drink or taste this."; return 1; taste: if(vodka notin player) "^You need to have the bottle to taste!"; if( self hasnt general ) { "^You taste a little bit of vodka. There is something fishy going on.... ofcourse.... its poisoned. You spit it off immeadiately and thank your stars that you did not gulp it down!"; } "^There is nothing in the bottle to drink!"; drink: if(vodka notin player) "^You need to have the bottle to drink!"; if( self hasnt general ) { give self general; print "^You pour the vodka down ur throat. Cool man... u r not goin' anywhere!!!"; style reverse; print "^You start to choke and repent drinking the vodka! But... it is too late. It was poisoned. You choke to death!"; print "^^****You have lost!****^ You have disappointed us. Was Vodka more important than saving the world? .... well obvious answer!!!! ^Bye Bye!!^"; deadflag = 1; return 0; } "^There is nothing in the bottle to drink!"; ]; !************************ Television ***************************************** Object Television "Television" Living_Room has static switchable, with name "tv" "television", description "", before [; examine: "Television is covered with dust. There is no hope of it working!"; ], after [; switchon: "^The television has konked off. What else could be expected here!"; switchoff: "^Why bother.... it does not make any difference. You r just wasting ur time!"; ], when_on "The television has been switched on... but it is not surprising that it does not work!", when_off "Television is switched off!"; !************************ Torch ***************************************** Object Torch "Torch" Living_Room has switchable, with name "torch", description "^There is torch lying on the ground", MaxTurnsForTorch 6, TorchTurn 0, before [x; examine: if(self hasnt on) "^The torch is currently switched off!"; if( self.TorchTurn > self.MaxTurnsForTorch ) "^The torch does not work anymore. Told you to use it cautiously!"; if( self.TorchTurn > self.MaxTurnsForTorch-5 ) "^The torch light is now pretty dim. Use the torch cautiously!"; if( self.TorchTurn < self.MaxTurnsForTorch ) "^The light is sufficient to look around the dark rooms!"; take: if(torch in player ) "^You already have the torch in your hand!"; if(Heavy_Obj_In_Hand > 1) "^Your hands are full!"; Heavy_Obj_In_Hand = Heavy_Obj_In_Hand + 1; move torch to player; if(self hasnt on) "^The torch is currently switched off!"; if( self.TorchTurn > self.MaxTurnsForTorch ) "^The torch does not work anymore. Told you to use it cautiously!"; if( self.TorchTurn > self.MaxTurnsForTorch-5 ) "^The torch light is now pretty dim. Use the torch cautiously!"; if( self.TorchTurn < self.MaxTurnsForTorch ) "^The light is sufficient to look around the dark rooms!"; drop: if(torch in player) { x = location; Heavy_Obj_In_Hand = Heavy_Obj_In_Hand - 1; move torch to x; "^You drop the torch onto the floor.!"; } "^You do not have the torch."; ], after [; switchon: if(self.TorchTurn <= self.MaxTurnsForTorch) { give self light; StartDaemon(self); if( self.TorchTurn > self.MaxTurnsForTorch-3 ) "^The torch light is now pretty dim. Use the torch cautiously!^"; print "^Thankfully the torch works!^"; if(player in den && self has light) { style reverse; print " Wait... did I say thankfully! Oops... sorry! Dustbin can easily see you thanks to the torch. He shoots at you. It was amateurish to have the torch on in the den! You tried your best though!"; print "^^****You have lost!****^ You just got shot. Now there is no way to save the Earth!^Bye Bye!!^"; deadflag = 1; return 1; } return 0; } "^The torch is of no use now. I told you to use it with caution!^"; switchoff: give self ~light; StopDaemon(self); ], daemon [; if(self hasnt light) return 1; self.TorchTurn = self.TorchTurn + 1; !print "^**** Torch power = ", self.TorchTurn, " ***^"; if(self.TorchTurn > self.MaxTurnsForTorch) { give self ~light; "^Yikes.... the damn torch stopped working!^"; } if( self.TorchTurn > self.MaxTurnsForTorch-5 ) "^The torch light is now pretty dim. Use the torch cautiously!^"; ]; !************************ kitchen ***************************************** Object Kitchen "kitchen" with name "kitchen", description "To the west is the living room.", describe [; if(torch in player && torch has on) { "^You are in the kitchen. There are no lights at all in the kitchen. Fortunately, you have the torch. There is not even an utensil around.^"; } return 1; ], w_to Living_Room; !************************ hammer ***************************************** Object Hammer "Hammer" Kitchen has , with name "hammer", description "", before [x; examine: "^The hammer looks pretty heavy."; take: if(hammer in player ) "^You already have the hammer in your hand!"; if(Heavy_Obj_In_Hand > 1) "^Your hands are full!"; Heavy_Obj_In_Hand = Heavy_Obj_In_Hand + 1; move hammer to player; "^The hammer is pretty heavy!"; drop: if(hammer in player) { x = location; Heavy_Obj_In_Hand = Heavy_Obj_In_Hand - 1; move hammer to x; "^You drop the hammer onto the floor."; } "^You do not have the torch."; ]; !************************ gun ***************************************** Object gun "gun" has concealed, with name "gun", description "", before [x; examine: "^The gun is loaded!"; take: if(gun in player ) "^You already have the gun in your hand!"; if(Heavy_Obj_In_Hand > 1) "^Your hands are full!"; Heavy_Obj_In_Hand = Heavy_Obj_In_Hand + 1; move gun to player; "^You have the gun with you now!"; drop: if(gun in player) { x = location; Heavy_Obj_In_Hand = Heavy_Obj_In_Hand - 1; move gun to x; "^You drop the gun to the floor."; } "^You do not have the gun."; ]; !************************ den ***************************************** Object den "den" with name "den", description "", describe [; print "You are in the den. There are no lights in the room, but the street lights outside help you a bit in looking around."; print "^You can hear some weird sounds... must be the alien! You hear DustBin Laden's voice. He is muttering something... he is caught by surprise. You are doing great till now... but be careful!!^"; if(torch in player && torch has light) { style reverse; print "Dustbin can easily see you thanks to the torch. He shoots at you. It was amateur to enter the den with the torch on! You tried your best though!"; print "^****You have lost!****^You just got shot. Now there is no way to save the Earth!^Bye Bye!!^"; deadflag = 1; return 0; } if(torch in player && torch hasnt on) print "Luckily you have not kept the torch on. Else Dustbin would have shot you by now. You hear some shooting and you take cover."; return 1; ], s_to DenDoor; !************************ bedroom ***************************************** Array pwd1 string "lagos"; Array pwd2 string "lisbon"; Array pwd3 string "nairobi"; Array pwd4 string "stockholm"; [DisplayQuestion; switch(QuestionUsed) { 1: print "Capital of Nigeria!!!"; 2: print "Capital of Portugal!!!"; 3: print "Capital of Kenya!!!"; 4: print "Capital of Sweden!!!"; } ]; Object Bedroom "Bedroom" with name "bedroom", description "To the west is the corridor.", describe [; if(torch in player && torch has on ) { !Let the element of surprise be expressed once. print "^You are in the bedroom. There are no lights at all in the bedroom. Fortunately, you have the torch."; if(self hasnt general) { give self general; print"There is nothing around. ^Wait... there is something scribbled on the wall. It says - ~"; DisplayQuestion(); " ~ ^Now could that be the password?"; } print"There is something scribbled on the wall. It says - ~"; DisplayQuestion(); " ~ ^"; } return 1; ], e_to Corridor; !************************ corridor ***************************************** Object Corridor "Corridor" with name "corridor", description "You are in the corridor. To the south is the living room. To the north is the den [you can hear some voices from the den!]. To the west is a bedroom", s_to Living_Room, n_to DenDoor, w_to BedRoom, has light; !************************ Den Door ***************************************** !Global fn used check if the pwd is correct [ParsePwd str pwd i; if(str->1 ~= pwd->0) return 0; for (i = 1: i <= str->1: i++ ) { if( str->(i+1) ~= pwd->i ) return 0; } return 1; ]; !Global fn used to input the pwd [GetPwd pwd buffer; print "^Enter password ^"; buffer->0 = 60; read buffer 60; if( ParsePwd(buffer, pwd) == 0 ) { give player ~PwdFound; "^Wrong Password! Door remains locked!^"; } give player PwdFound; "^Correct Password..... the door opens slowly!^"; ]; !Global fns used to output approp text when den door is opened or closed. [PrintWhenDenDoorOpen; print "The den door is open."; if(player in Den) " To the south you see the corridor."; " To the north you see the den"; ]; [PrintWhenDenDoorClosed; print "The den door is closed."; if(player in Den) " To the south you see the den door."; " To the west is the bedroom. To the south is living room."; ]; !Represents the den door. Object DenDoor "door to den" has static door openable lockable locked, with name "door" "den_door", description "The den door is made of brass and has a lock that needs a password.", before [x; Examine: "The den door is made of brass and has a lock that needs a password."; open: if(self hasnt locked) { "^The door is already open.^"; } switch(QuestionUsed) { 1:GetPwd(pwd1); 2:GetPwd(pwd2); 3:GetPwd(pwd3); 4:GetPwd(pwd4); } if(player has PwdFound) { give self general; give self ~locked; CriticalStateEntered = 1; } return 0; close: if(self hasnt locked) { x = location; give self locked; return 0; } "^The door is already closed.^"; ], after [; open: if(player in Den) "^To the south you see the corridor.^"; "^To the north you see the den^"; ], when_open [; PrintWhenDenDoorOpen();], when_closed [; PrintWhenDenDoorClosed();], door_to [; if (location==Corridor) return Den; return Corridor; ], door_dir [; if (location==Corridor) return n_to; return s_to; ], found_in Corridor Den; !************************ Front Door ***************************************** !Global fns used by front door [PrintWhenFrontDoorOpen; print "The front door is open."; if(player in Living_Room) " To the south you see the front porch."; " To the north you see the living room"; ]; [PrintWhenFrontDoorClosed; print "The front door is closed."; if(Doormat hasnt general) " Now where could you find the key?"; if(player in Living_Room) " To the south you see the front door"; " To the north you see the living room"; ]; !Represents the front door. Object Front_Door "front door" has static door openable lockable locked, with name "door", description "The front door is made of brass.", before [x; unlock, open: if(player has Main_Key && self has locked) { print "^You unlock the front door and open it."; give self general; give self open; give self ~locked; return 1; } if(self hasnt locked) { "^The door is already open.^"; } lock, close: if(self hasnt locked) { print "^You close the front door and it is locked."; x = location; give self locked; give self ~open; return 1; } "^The door is already closed.^"; ], after [; open: if(player in Living_Room) "^To the south you see the front porch.^"; "^To the north you see the living room^"; ], when_open [; PrintWhenFrontDoorOpen();], when_closed [; PrintWhenFrontDoorClosed();], door_to [; if (location==Front_Porch) return Living_Room; return Front_Porch; ], door_dir [; if (location==Front_Porch) return n_to; return s_to; ], with_key key, found_in Front_Porch Living_Room; !************************ Alien ***************************************** !Alien Object Alien "Alien" has animate concealed, with name "Alien", description "", life [; Answer, Ask, Tell: "^He does not understand you!"; ], before [; shoot, attack: if(BulletsLeft == 0) { "^You do not have bullets left!"; } print "^You shoot at the alien and kill him."; style bold; print"^Wow... you have the guts to disobey the orders of not shooting at the alien [even to remove your frustration!]. Well fortunately, you get shot by Laden... instead of being torchered by every person on Planet Cubata and Earth!"; deadflag = 1; print "^^****You have lost!***^Bye Bye!!^"; return 1; ]; !************************ Dust Bin Laden ***************************************** !Terrorist Object DustBinLaden "DustBinLaden" has animate light concealed, with name "Terrorist" "DustBin" "Laden" "DustBinLaden", description "", life [; Answer, Ask, Tell: "^He least bit interested in striking a conversation... he wants to shoot you first!"; ], before [; shoot, attack: if(BulletsLeft == 0) { "^You do not have bullets left!"; } print "^You shoot at him."; if(CriticalStateEntered > 4) { print " You miss him."; BulletsLeft = BulletsLeft - 1; if(BulletsLeft > 0) print" You shoot again.... but same result! "; " Can't blame yourself... he is quick! Now you have no bullets left!^"; } style bold; print"^Wow... that was a nice shot! You have got him in between his eyes! Hurray... you have saved the world!!"; print"^ You take the alien and leave the building with a big smile. The chief of Cubata planet has given you a 2 days - 3 nights package vacation to Planet Cubata!"; deadflag = 2; print "^^****You have won!****^Good Job!^Bye Bye!!^"; return 1; ]; !************************ Turn Tracker ***************************************** !Used for keeping track of the turns Object TurnTracker "TurnTracker" !has static, with name "TurnTracker", time_left, time_out [TriesRemain; if(CriticalStateEntered > 0) { if(CriticalStateEntered > 4) { style reverse; print "^Watchout.... bullet is heading towards you! Bam! You wasted too much time!"; print "^^****You have lost!****^ You just got shot and now there is no way to save the World!^Bye Bye!!^"; deadflag = 1; return 0; } CriticalStateEntered = CriticalStateEntered + 1; } TriesUsed = TriesUsed + 1; TriesRemain = Max_Tries - TriesUsed; if(TriesUsed == Max_Tries) { deadflag = 1; style reverse; print "^^****You have lost!****^ You have used all your turns and were still unsuccessful.Now there is no way to save the Earth!^Bye Bye!!^"; return 0; } if(TriesUsed > Max_Tries - 5 && self hasnt general) { style bold; give self general; print "^*********You have ", TriesRemain ," more turns remaining! Please save the world!*********^"; } StartTimer(self, Time_Inc); ]; !************************ Global fn used to get the difficulty level ***************************************** [GetDifficultyLevel text_array; text_array->0 = 3; print "^Enter the difficulty level :"; print "^Enter a ---- for Amateur [Default]."; print "^Enter b ---- for Expert."; print "^"; read text_array 0; if(text_array->2 == 'b') { Max_Tries = 10; print "^You have chosen the ~Expert level~. You have ", Max_Tries, " turns to save the world!^"; return 2; } Max_Tries = 25; print "^You have chosen the ~Amateaur level~. You have ", Max_Tries, " turns to save the world!^"; return 1; ]; !************************ Initialise ***************************************** !The Initialization routine is run at the start of the program automatically. [Initialise; lookmode=2; !Verbose mode: every time player enters a room, he gets a full description location = Front_Porch; !The starting place is front porch. move gun to player; move DustBinLaden to Den; move Alien to Den; !The following is printed as an introduction. print"^^An Alien space ship from Cubata planet crashed into the coast of Miami killing all except one cute little Alien. Before the coast guards could rescue this alien... the notorious terrorist Dustbin Laden (who was trying to enter the country on his boat, to spread terror) snatches this cute little alien and escapes. Soon a demand for 300,000,000,000$ and dreaded nuclear weapons is received by President Lewinsky. Situation worsens when the Chief of Cubata planet threatens the President to destroy the world, if the alien is not returned by dawn. ^^After consulting with his advisors, it has been decided that there is only one person who could come to the rescue. Being the best in the entire force and after handling the previous case of Elian Gonzalez[who was also an alien for the IRS department!], you are the chosen one! Your mission is to rescue the Alien from the clutches of Dustbin Laden, who is hiding in a remote building close to Florida. ^^You are near the front porch and pretty disappointed that you have not been allowed to carry state of the art weapons. You have a gun which has only 2 bullets... so use it with caution!"; StartTimer(TurnTracker, Time_Inc); TriesUsed =0; QuestionUsed = random(4); CriticalStateEntered = 0; BulletsLeft = 2; Heavy_Obj_In_Hand = 1; GetDifficultyLevel(); "^"; ]; !************************ Custom actions - Tear and Read ***************************************** !The tear action is defined for tearing the note in the mailbox [TearSub; "Tearing... nope that is not allowed.";]; verb "tear" * noun -> tear; [ShootSub; if(gun in player) { if(BulletsLeft > 0) { BulletsLeft = BulletsLeft - 1; "^You shoot... but nothing is achieved. You have just wasted a bullet and a turn. To top it all... you missed ur target too!"; } "^You have no bullets left!"; } "^You cannot shoot without a gun!"; ]; verb "shoot" * noun -> shoot; [ ReadSub; <>; ]; Extend "read" first * legible -> Read;