!--------------------------------------! ! METAGAME! ! ! by Rami Hamadeh ! ! University of Michigan - Dearborn ! ! CIS 487 Fall 2002 Dr.Maxim ! ! October 16, 2002 ! !Text-based Adventure Game using Inform! !--------------------------------------! Constant Story "Metagame!"; Constant Headline "^By Rami Hamadeh (2002)^^ It is a beautiful day outside and you are bathing in the sun's rays with nothing on your mind. You feel free from any headaches and worries.^ The birds are singing, your children are playing happily in the finely sandy beach.^ RING RING RING! The alarm clock shouts at you to wake up.^ So you smack it off and realize that you are still tired, have a huge headache, and you are in your undies!^ Your heart begins to race as you look at your alarm clock, this time without smacking it, and realize that the time is 12:00 P.M. and that you have an assignment due in 4 hours!!!^^"; Constant MAX_SCORE 10; Serial "021012"; Release 1; Include "Parser"; Include "VerbLib"; !-------------------------------------- !Global Variables !-------------------------------------- !240 minutes = 4 hours left till its due !time remaining in minutes Global timeleft=240; !percent of assignment done 0-100 Global percentdone=0; !t/f if read the assignment sheet Global readassignment=0; !t/f if person is clothed Global clothed=0; !t/f if drank alcohol Global drankvodka=0; !t/f if drank energy drink Global drankredbull=0; !t/f if took energy pill Global tookenergypill=0; !t/f if took headache medicine Global tookheadachepill=0; !the time that person drank liquid Global timedrank=0; !-------------------------------------- [ Initialise; location = Room; ]; !-------------------------------------- [ PrintRank; print ", earning you the rank of "; if (score >= 10) "an A+."; if (score >= 8) "a B."; if (score >= 6) "a C."; if (score >= 4) "a D."; if (score >= 2) "an E, you failed."; "beyond failure, sorry."; ]; !-------------------------------------- !First location object: Room !-------------------------------------- Object Room "Room" with description "The kitchen is to the west. The bathroom is due North.", w_to Kitchen, n_to Bathroom, has light; Object -> computer "computer" with name "computer", with description "This is your computer, it is always on. Use it! C'mon get to work!", before [; use: if (readassignment==1) { !use the computer an hour at a time if (timeleft >= 60) !full points { !completion = 10% + vodka effect + redbull effect + pill effects percentdone = percentdone + (10) + (drankvodka*-10) + (drankredbull*25) + (tookheadachepill*5) + (tookenergypill*15); timeleft=timeleft-60; } else !fractional points { percentdone = percentdone + (((10) + (drankvodka*-10) + (drankredbull*25) + (tookheadachepill*5) + (tookenergypill*15))*timeleft)/(60); timeleft=0; } print "Used the computer for an hour. Taking a break now.^"; check(); !check and print game status ""; } else { timeleft=timeleft-5; !5 minutes go by print "Consider reading the assignement sheet first."; check(); ""; } ]; Object -> clothes "bunch of clothes" with name "clothes", description "There are clothes randomly thrown around the room, some of them are clean enough to wear.", after [; wear: clothed=1; timeleft=timeleft-5; !5 minutes go by print "Mmmm... Warm!"; check(); !check and print game status ""; remove: clothed=0; timeleft=timeleft-5; !5 minutes go by print "Heh...underwear is more comfortable anyways."; check(); !check and print game status ""; ], has clothing; Attribute legible; Object -> assignment "Assignment Sheet" with name "Assignment Sheet" "sheet" "assignment", with description "The assignment sheet is a simple piece of paper with words on it.", before [; Consult,Read: timeleft=timeleft-5; readassignment=1; !5 minutes go by print "^ CIS 487/587 Assignment 1", "^ Fall 2002^^ This assignment will give you an opportunity to write a piece of interactive fiction. This will involve creating both a virtual world and a story in which the player must overcome conflicts to achieve goals and win the game.^"; check(); !check and print game status ""; Tear: remove assignment; deadflag=1; score=0; !game over "You rip the assignment into infinitely many tiny pieces that disintegrate before your eyes.^ You decide not to do the assignment and fail. Thus...."; ], has legible; !-------------------------------------- !Second location object: Bathroom !-------------------------------------- Object Bathroom "Bathroom" with description "The bathroom has a wonderful view. You see a toilet and a medicine cabinet.^Your room is to the South.", s_to Room, has light; Object -> toilet "Toilet" with name "toilet", with description "Typical. Don't worry, the seat is down.", before [; use: timeleft=timeleft-5; !5 minutes go by timedrank=0; print "Ahhhhhhhh, much better :)^"; check(); !check and print game status ""; ]; Object -> cabinet "Medicine Cabinet" with name "Medicine Cabinet" "cabinet" "medicine", with description "A typical medicine cabinet.", when_open "The medicine cabinet is now open.", when_closed "The medicine cabinet is closed.", has static container openable; Object -> -> headachepill "Headache Pill" with name "headache pill" "hpill" "headache", with description "An Acetaminophen Headache pill.", before [; take, use: remove self; timeleft=timeleft-5; !5 minutes go by tookheadachepill=1; print "'Ahhhhh. My head feels much better now!' You say.^"; check(); !check and print game status ""; ], has edible; Object -> -> energypill "Energy Pill" with name "Energy pill" "epill" "energy", with description "An all-natural energy pill.", before [; take,use: remove self; timeleft=timeleft-5; !5 minutes go by tookenergypill=1; if (drankredbull==0) { print "All of a sudden your eyes are wide open and you begin to twitch.^"; check(); !check and print game status ""; } else { print "ULTRATWITCHING!!! MUST CODE!!!^"; check(); !check and print game status ""; } ]; !-------------------------------------- !Third location object: Kitchen !-------------------------------------- Object Kitchen "Kitchen" with description "The kitchen is very large. You see a fridge and a freezer.^Your room is to the East.", e_to Room, has light; Object -> fridge "fridge" with name "fridge", with description "A typical fridge.", when_open "The fridge is now open.", when_closed "The fridge is closed.", has static container openable; Attribute drinkable; Object -> -> redbull "can of redbull energy drink" with name "redbull", with description "A can of Redbull Energy Drink.", before [; timeleft=timeleft-5; !5 minutes go by Drink, use: remove self; drankredbull=1; if (timedrank==0) timedrank=timeleft; if (tookenergypill==0) { print "^Mmmmmm! All of a sudden your eyes are wide open and you begin to twitch.^ 'OH MY GOD,' you say, 'RED BULL GIVES YOU WINGSSSSSSSS!!'^ Better get coding ;-)^"; check(); !check and print game status ""; } else { print "ULTRATWITCHING!!! MUST CODE!!!^"; check(); !check and print game status ""; } ], has drinkable; Object -> freezer "freezer" with name "freezer", with description "A typical freezer.", when_open "The freezer is now open.", when_closed "The freezer is closed.", has static container openable; Object -> -> vodka "bottle of vodka" with name "A small bottle of Vodka" "vodka", with description "A small bottle of Vodka.", before [; timeleft=timeleft-5; !5 minutes go by Drink, use: remove self; drankvodka=1; if (timedrank==0) timedrank=timeleft; print "^WHOA!! You drank the entire thing! You party animal! Good luck finishing the program now!^"; check(); !check and print game status ""; ], has drinkable; !-------------------------------------- !Functions !-------------------------------------- !checks if the game needs to be ended !deadflag is an inform-made variable !0=alive 1=dead, 2=winner [check; if(check_explode()) { print_score(); deadflag=1; } else if(check_end()) { score=percentdone/10; if(score >= 6) !70% complete or more { print_score(); deadflag=2; } else !or else you lose the game { print_score(); deadflag=1; } } else { print_score(); rfalse; } ]; !-------------------------------------- !checks if time has expired, or if the assignment is completed [check_end; if (timeleft==0 || percentdone >=100) { percentdone=100; rtrue; } else rfalse; ]; !-------------------------------------- !checks for bladder explosion, 2 hours after first drink [check_explode; if ( (timedrank-timeleft) >= 60 && (timedrank-timeleft) < 120 ) print "^You suddenly get the chills, with sharp pains in your abdomen.^"; if (timedrank-timeleft >=120) { print "^You didn't listen to your body. Your bladder explodes. All signs of not-so-intelligent-life are gone."; return true; } else rfalse; ]; !-------------------------------------- !print to the screen the time remaining and percent completion [print_score; print "^ +------------------------------------------------^", " | Percent of assignment completed: ", percentdone, "%^", " | Time remaining until it is due: ", timeleft, " minutes^", " +------------------------------------------------"; rtrue; ]; !-------------------------------------- !Extended Grammar !-------------------------------------- ! Added function ReadSub so that the property 'before' can use it. The default, ! if there is no 'before read', is to examine the object. ! [ ReadSub; <>; ]; [ UseSub; "You can't use that"; ]; [ TearSub; "You can't tear that"; ]; Include "Grammar"; Extend "read" first * legible -> Read; Verb "tear" * noun -> Tear; Verb "use" * noun -> Use;