;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; World Specializations ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define *closets* (list loc:closet1 loc:closet2 loc:closet3)) (add-command obj:coke 'context '(get coke) "get coke Get a Coca-cola from the coke machine" (lambda (plyr inp) (if (> 5 (maxload plyr)) "You're carrying too much to get a coke" (let ((coke (make :nick '(can coke) :name "Can of Coca-cola" :location plyr :size 5 :description (echos "A nice refreshing can of Coca-cola. Of course, you" "drink it for the taste, not the caffeine.")))) (add-command coke 'items '(drink coke) "drink coke Drink the can of Coca-cola" (lambda (plyr inp) (tell plyr "You down an entire can of Coca-cola.") (destroy coke) (tell plyr "That was refreshing... you feel awake!"))) "You get a can of Coca-cola from the coke machine.")))) (add-command obj:cookie 'items '(eat cookie) "eat cookie Eat the fortune cookie" (lambda (plyr inp) (tell plyr "You eat the fortune cookie. Inside there") (tell plyr "is a fortune, which reads:") (tell plyr "\"Many doors will open for you.") (tell plyr " Lucky numbers: 1 2 4 5\"") (destroy obj:cookie) (transfer obj:fortune (location obj:fortune) plyr) (set! (visible obj:fortune) #t) #t)) (defmethod (message (p = chr:pikachu) (from ) (type = 'enter) (msg )) (tell from "Pikachu looks cute and smiles at you invitingly")) (add-command chr:pikachu 'context '(stroke pikachu) "stroke pikachu You carefully stroke Pikachu's fur" (lambda (plyr inp) (insert-event 3 (thunk (tell plyr (echos "As you stroke Pikachu's fur," "you enjoy the feeling of" "20,000 volts of electricity" "coursing through your body.")))) (insert-event 6 (thunk (shout plyr (echos "AAAAAHHHHH!!!!" "I've been shocked!!!")))) (insert-event 7 (thunk (tell plyr "You've been shocked by Pikachu"))) 8)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Game instance ;;; Every time the game starts, we have to initialize it with a random ;;; game instance. The person who did it is chosen from *game* along ;;; with the incriminating questions. ;;; ;;; The murder weapon is chosen, and the description of the corpse is ;;; set accordingly. The corpse is randomly placed in a closet, and ;;; the key to the closet is chosen at random between the current ;;; two possibilities. ;;; ;;; The place is chosen at random, and a poster is placed somewhere. (define (define-game) (let* ((game (random-elt *game*)) (weapon (random-elt *weapons*)) (loc (random-elt *location*)) (closet (random-elt *closets*)) ;; accuse checks whether solution declared by player is correct (accuse (lambda ((animate ) (culprit )) (and (eq? (location animate) loc) (memq weapon (contents animate)) (eq? culprit (murderer game))))) (poster-loc (random-elt (list loc:hallway3 loc:vending loc:lobby))) (poster-msg (random-elt *clue-poster-messages*))) ;; place clue poster (make :name "poster" :nick '(poster) :location poster-loc :description (add poster-msg " " (name loc))) ;; place corpse (make :name "corpse" :nick '(corpse) :location closet :description (effect weapon) :size 180) ;; determine body concealment method--key or code lock (cond ((even? (random 2)) ; flip a coin ;; code locks (map (lambda (x) (set! (locks x) (list (lambda (a) (memq obj:fortune (contents a))))) (set! (reason x) (echos "You cannot remember the code for" "the codelock on the closet door."))) *closet-doors*) (destroy obj:key)) ;; key locks (else (map (lambda (x) (set! (locks x) (list (lambda (a) (memq obj:key (contents a))))) (set! (reason x) (echos "You do not have the key to" "the closet door."))) *closet-doors*) (destroy obj:cookie) (destroy obj:fortune) (add-command obj:knife 'items (list 'cut symbol?) "cut Use the knife to cut something open" (lambda (plyr inp) (cond ((eq? (nick-find (second inp) (contents (location plyr))) obj:stumpy) (transfer obj:key (location obj:key) loc:elevator) "You cut open stumpy and find a key.") (else "Watch what you do with that thing!")))))) ;; replace default vanilla questions with clue questions (when (first (mquestions game)) (set! (first (questions (murderer game))) (first (mquestions game)))) (when (second (mquestions game)) (set! (second (questions (murderer game))) (second (mquestions game)))) (when (first (s1questions game)) (set! (first (questions (secondary1 game))) (first (s1questions game)))) (when (second (s1questions game)) (set! (second (questions (secondary1 game))) (second (s1questions game)))) (when (first (s2questions game)) (set! (first (questions (secondary2 game))) (first (s2questions game)))) (when (second (s2questions game)) (set! (second (questions (secondary2 game))) (second (s2questions game)))) ;; set accuse function (add-player-command 'commands (list 'accuse symbol?) "accuse declare solution" (lambda (plyr inp) (let* ((accused (nick-find (second inp) *characters*)) (verdict (and accused (accuse plyr accused)))) (cond ((not accused) (echos "There isn't any" (second inp) "to accuse.")) (verdict (win-sequence plyr (murderer game) weapon loc)) (else (lose-sequence plyr accused (murderer game) weapon loc)))))))) (define (win-sequence plyr murderer weapon location) (let ((ending (find-if (lambda (x) (eq? murderer (accused x))) *ending*))) (tell plyr "") (tell plyr (true-ending ending)) (tell plyr "") (tell plyr "You win.") (logoff plyr))) (define (lose-sequence plyr suspect murderer weapon location) (let ((ending (find-if (lambda (x) (eq? suspect (accused x))) *ending*))) (when ending (tell plyr "") (tell plyr (false-ending ending))) (tell plyr "") (tell plyr "You lose.") (logoff plyr)))