;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; World Specializations ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; An example - specialize the toilet... ;;; Only one person inside. (defmethod (transfer (p ) (f ) (t = loc:toilet)) (if (some player? (contents t)) (begin (tell p "The door locked, you knock but there's no answer.") (place-message t "You hear someone knocking on the door." #f #f) #t) (call-next-method))) ;;; Make sound when anyone goes out. (defmethod (transfer (p ) (f = loc:toilet) (t )) (tell p "You flush the water.") (place-message t "You hear the sound of water flushing in the toilet." p #f) (call-next-method)) ;;; Add a hidden command (add-player-command "piss" "" (lambda (plyr inp) (if (eq? (location plyr) loc:toilet) (begin (tell plyr "You start pissing.") (insert-event 1 (lambda () (tell plyr "Ahhhh..."))) (insert-event 4 ; takes time to feel good (lambda () (tell plyr "You feel relieved."))) 5) "Here?"))) ;;;; Specialize the transfers ;;; Cannot pass through the forest unless Ni Knight's have shrubbery. (defmethod (transfer (p ) (f = loc:forest) (t )) (if (or (eq? t loc:village) (memq obj:shrubbery (contents chr:ni-knights)) (eq? (location chr:ni-knights) *null-place*)) (call-next-method) (begin (tell p "You hear Ni! Ni! Pangs of anguish pass through you.") (tell p "Suddenly you decide you should get a shrubbery.") #t))) ;;; This avoids automated characters from falling into the gorge of ;;; eternal peril or microsoft. (defmethod (transfer (a ) (f ) (t = loc:peril)) #t) (defmethod (transfer (a ) (f ) (t = loc:microsoft)) #t) ;;; If Bunny is Dead, you can move on. (defmethod (transfer (p ) (f = loc:cave) (t )) (if (or (eq? t loc:valley) (eq? (location chr:bunny) *null-place*)) (call-next-method) (begin (tell p "As you try to sneak passed the bunny, he attacks.") (tell p "You run away - escaping an almost certain death.") #t))) ;;; The bridgekeeper stops you from crossing the bridge. (defmethod (transfer (p ) (f = loc:bridge) (t = loc:lake)) (if (eq? (location chr:bridgekeeper) *null-place*) (call-next-method) (begin (tell p "The bridgekeeper stops you and says 'Stop. Who would") (tell p "cross the Bridge of Death must answer me these") (tell p "questions three, ere the other side he see.' You feel") (tell p "like killing him.") #t))) ;;; Don't lose the boat (defmethod (transfer (o = obj:boat) (f ) (t = loc:aaaagh)) (transfer o f loc:earth)) ;;; Need a boat to cross the lake. ;;; Arrest the player if s/he isn't innoncent. (defmethod (transfer (p ) (f = loc:lake) (t = loc:aaaagh)) (if (memq obj:boat (contents p)) (begin (call-next-method) (unless (and (memq obj:coconut (contents chr:police)) (memq obj:horse (contents chr:police))) (tell p "You have been arrested by the police for murder.") (transfer p loc:aaaagh loc:station)) #t) (begin (tell p "You begin to swim accross the lake. At first, the water") (tell p "is warm and the sky beautiful. Slowly, surely, the sky") (tell p "begins to darken. Your eyes begin to well up slowly.") (tell p "You realize that the lake-source cooling system has") (tell p "caused massive pollution. As your eyes seal shut,") (tell p "these images start to float in front of your eyes.") (tell p "Janet Reno and Dan Quayle ... what *are* they doing?") (tell p "Suddenly they twist together into this long-necked,") (tell p "vicious ... It's the Loch Ness monster. Scared beyond") (tell p "your wits, you begin to doggy paddle back to the shore.") (tell p "You are washed back upon the beach, and exhausted. You") (tell p "begin to curse the CS 212 course staff for making this") (tell p "problem set so hard. You begin to halucinate lambdas") (tell p "and Holy Grails. You must be completely bonkers.") (tell p "Finally, you go unconscious...") (insert-event 10 ; You're unconcious (lambda () (tell p "Slowly, you come back to your senses..."))) 11))) (defmethod (transfer (o = obj:grail) (c = chr:frenchie) (p )) (call-next-method) (for-each (lambda (x) (for-each (lambda (p) (tell p (add " " x))) *players*)) '("NEWS REPORT: So for the first time in ages, someone has" "finally found the Holy Grail. Quick, grab it...." "Now the world continues on.... After all, it's just a" "cup... And if you don't think so, you can just fight" "amongst yourselves to get it!"))) ;;;; Specialize the fighting (defmethod (fight (a ) (f = chr:black-knight)) (if (or (memq obj:sword (contents a)) (memq obj:excalibur (contents a))) (call-next-method) (begin (tell a "After watching the Black Knight mollify his opponent,") (tell a "the Green Knight, you think twice about engaging in a") (tell a "conflict with him without having the proper armaments.") #t))) (defmethod (fight (a ) (f = chr:bill)) (let ((w (find-weapon a))) (cond ((eq? w #f) (call-next-method)) ((eq? w obj:manual) (tell a "With the power of CS212 and good programming, you") (tell a "are able to defeat this evil being") (kill f) #t) (else (tell a "Ha, ha, you can't fight me with that") (tell a "Bill frightens you and you drop your weapon.") (tell a "He now tries to covert you to the MS way.") (transfer w a (location a)) (call-next-method))))) (defmethod (fight (a ) (f = chr:bunny)) (let ((w (find-weapon a))) (cond ((eq? w #f) (call-next-method)) ((eq? 'grenade (nick w)) (tell a "You count - 1... 2... 5... No, 3 - 3...") (tell a "Once again the Lord hath blessed thee.") (transfer w a *null-place*) (kill f) #t) (else (tell a "Despite Tim's warning you, you decide to fight") (tell a "the mighty bunny of Caerbannog. Only problem") (tell a "is when you approach the bunny, you forget to") (tell a "bring along your weapon. Tim begins to laugh.") (transfer w a (location a)) (call-next-method))))) (defmethod (fight (a ) (f = chr:rbg)) (let ((w (find-weapon a))) (when (and w (eq? 'grenade (nick w))) (tell a "Random Bad Guy is just too powerful to be affected by") (tell a "the Holy Hand Grenade. Might try something better next") (tell a "time, but you still decide to fight him with your") (tell a "bare hands. Wow, you're brave....") (transfer w a (location a))) (call-next-method))) (defmethod (fight (a ) (f = chr:bridgekeeper)) (let ((w (find-weapon a))) (when (and w (eq? w obj:accent)) (tell a "So, you like got to answer these questions, or you're") (tell a "gonna, like, get thrown into this perilous gorge, and") (tell a "it's really dark down there. But you're gonna like try") (tell a "to fight this guy anyway... I, like, wouldn't....") (transfer w a (location a))) (call-next-method))) (defmethod (fight (a ) (f = chr:taunter)) (let ((w (find-weapon a))) (when w (tell a "You silly English k-nnnnnigget, I blow my nose at you") (tell a (random-elt (list "Go and boil your bottom, sons of a silly person." (add "Your mother was a hamster & your father smelt of" "elderberries!") "I one more time, mac, unclog my nose in your direction" "I fart in your general direction!"))) (tell a "Now, go away, or I shall taunt you a second time-a!") (transfer w a (location a))) (call-next-method))) ;;; Need to get rid of both instances of the french taunter (defmethod (kill (a = chr:frenchie)) (call-next-method) ;; could use a (kill chr:taunter) but this will display a second ;; message and also leave a second corpse, so this hack goes around ;; this. (let ((t chr:taunter)) (for-each (lambda (o) (transfer o t (location t))) (contents t)) (set! (contents (location t)) (remq t (contents (location t)))) (set! (location t) *null-place*))) (defmethod (fight (a ) (f = chr:ni-knights)) (if (memq obj:shrubbery (contents f)) (call-next-method) (begin (tell a "Ni! Ni! Ni! Ni......") (tell a "You fall to your knees cringing in pain - it's awful") (tell a "The pain is too much and you black out") (insert-event 10 ; You're unconcious (lambda () (tell a "You awaken, thankful to still be alive."))) 11))) (defmethod (fight (a ) (p = chr:police)) (begin (tell a "Fighting the power really isn't that good of an idea.") (tell a "After all, who would keep order if the police, weren't") (tell a "here. Think about it!") #f)) ;;; Specialize object transfers and requests (defmethod (transfer (obj = obj:shrubbery) (from ) (to = chr:ni-knights)) (call-next-method) (set! (nick to) 'former-ni-knights) (set! (name to) "Knights who say Ecky-ecky-ecky-ecky-pikang-...") (set! (description to) '("After getting a shrubbery, these knights who once bore the" "sacred word \"Ni\", changed their name to the Knights who say" "Ecky-ecky-ecky-ecky-pikang-zoop-boing-goodem-zoo-owli-zhiv"))) (defmethod (message (c ) (from ) (type = 'tell) (msg )) (let ((says (lambda (x) (tell from (echos (name c) "says:" x))))) (cond ((equal? msg "shrubbery?") (cond ((eq? c chr:ni-knights) (says "We want a shrubbery")) ((memq obj:shrubbery (contents c)) (if (memq obj:quest (contents from)) (begin (says "Yes, I have a shrubbery. Here take it!") (transfer obj:shrubbery c from)) (says "I only help those who have money, or have a quest?"))) (else (says "Who sent you? I don't know anything")))) ((equal? msg "horse?") (cond ((eq? c chr:police) (says "We're looking for someone who was riding a horse")) ((memq obj:horse (contents c)) (says "Yeah, so I have a horse, what of it?") (fight c from)) (else (says "I don't have a horse!")))) ((equal? msg "quest?") (cond ((memq obj:quest (contents c)) (let* ((l (location c)) (knights (filter (lambda (x) (instance-of? x )) (contents l))) (leaders (map leader knights))) (if (memq from leaders) (begin (says "I ordain you with this quest, now go...") (transfer obj:quest c from) (unless (eq? (location chr:frank) *null-place*) (kill chr:frank) (for-each (lambda (x) (for-each (lambda (p) (tell p (add " " x))) *players*)) '("NEWS REPORT: We interupt your currently scheduled" "game, to tell you that Frank, the famous historian," "has been killed by an unknown assasin." "You may now continue with your game...")))) (says "You are not yet ready to complete a quest...")))) (else (says "You have time to go on a quest?")))) ((equal? msg "excalibur?") (cond ((memq obj:excalibur (contents c)) (says "I bestow upon you Excalibur...") (transfer obj:excalibur c from)) (else (says "So you want to be king? Bug off!")))) ((equal? msg "pass?") (cond ((eq? c chr:ni-knights) (says "You must bring us a shrubbery") (tell from " >>>ASK AROUND - keyword: shrubbery?<<<")) ((eq? c chr:roger) (says "I'll give you a shrubbery if you have a quest") (tell from " >>>ASK AROUND - keyword: quest?<<<")) ((eq? c chr:police) (for-each (lambda (x) (says x)) '("We're investigating the murder of Frank. His wife gave" "us a sketch of you. An eye witness says the assailant" "was riding a horse. Since we can't locate your horse" "we can't detain you, but don't leave the area..." "If you can help us locate the assailant, we'd appreciate" "your help.... Bring us the horse if you find him dead")) (tell from " >>>ASK AROUND - keyword: horse?<<<")) ((instance-of? c ) (says "Put 'em up! Or are you scared?")) (else (says "I'm not in your way! You're in my way...")))))))