1 ;;; Mudsync --- Live hackable MUD
2 ;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org>
4 ;;; This file is part of Mudsync.
6 ;;; Mudsync is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or
9 ;;; (at your option) any later version.
11 ;;; Mudsync is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ;;; General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with Mudsync. If not, see <http://www.gnu.org/licenses/>.
21 (use-modules (mudsync)
32 ;;; Utilities, useful or otherwise
33 ;;; ==============================
35 (set! *random-state* (random-state-from-platform))
37 (define (random-choice lst)
38 (list-ref lst (random (length lst))))
40 ;; list of lists, lol.
41 (define-syntax-rule (lol (list-contents ...) ...)
42 (list (list list-contents ...) ...))
45 ;;; Some simple object types.
46 ;;; =========================
48 (define-class <readable> (<gameobj>)
49 (read-text #:init-value "All it says is: \"Blah blah blah.\""
50 #:init-keyword #:read-text)
52 #:allocation #:each-subclass
53 #:init-thunk (build-commands
54 ("read" ((direct-command cmd-read)))))
55 (actions #:allocation #:each-subclass
56 #:init-thunk (build-actions
57 (cmd-read readable-cmd-read))))
59 (define (readable-cmd-read actor message)
60 (<- (message-from message) 'tell
61 #:text (string-append (slot-ref actor 'read-text) "\n")))
64 ;; This one allows you to take from items that are proxied by it
65 (define-actor <proxy-items> (<gameobj>)
66 ((cmd-take-from take-from-proxy))
67 (proxy-items #:init-keyword #:proxy-items))
69 (define* (take-from-proxy gameobj message
70 #:key direct-obj indir-obj preposition
71 (player (message-from message)))
76 (define obj-id (dyn-ref gameobj obj-sym))
78 (mbody-val (<-wait obj-id 'goes-by)))
79 (when (ci-member direct-obj goes-by)
80 (<- obj-id 'cmd-take #:direct-obj direct-obj #:player player)
82 (slot-ref gameobj 'proxy-items))
85 #:text `("You don't see any such " ,direct-obj " to take "
86 ,preposition " " ,(slot-ref gameobj 'name) ".")))))
93 (define (npc-chat-randomly actor message . _)
95 (format #f "~a says: \"~a\"\n"
96 (slot-ref actor 'name)
97 (random-choice (slot-ref actor 'catchphrases))))
98 (<- (message-from message) 'tell
101 (define hotel-owner-grumps
102 '("Eight sinks! Eight sinks! And I couldn't unwind them..."
103 "Don't mind the mess. I built this place on a dare, you
105 "(*tearfully*) Here, take this parenthesis. May it serve
107 "I gotta get back to the goblin farm soon..."
108 "Oh, but I was going to make a mansion... a great,
109 beautiful mansion! Full of ghosts! Now all I have is this cruddy
110 mo... hotel. Oh... If only I had more time!"
111 "I told them to paint more of the walls purple.
112 Why didn't they listen?"
113 "Listen to that overhead muzak. Whoever made that doesn't
114 know how to compose very well! Have you heard of the bands 'fmt'
115 or 'skribe'? Now *that's* composition!"))
117 (define-class <chatty-npc> (<gameobj>)
118 (catchphrases #:init-value '("Blarga blarga blarga!")
119 #:init-keyword #:catchphrases)
121 #:allocation #:each-subclass
122 #:init-thunk (build-commands
123 (("chat" "talk") ((direct-command cmd-chat)))))
124 (actions #:allocation #:each-subclass
127 (cmd-chat npc-chat-randomly))))
129 (define-class <sign-in-form> (<gameobj>)
131 #:allocation #:each-subclass
132 #:init-thunk (build-commands
133 ("sign" ((prep-direct-command cmd-sign-form '("as"))))))
135 (actions #:allocation #:each-subclass
136 #:init-thunk (build-actions
137 (cmd-sign-form sign-cmd-sign-in))))
141 (sre->irregex '(: alpha (** 1 14 (or alphanum "-" "_")))))
143 (define forbidden-words
144 (append article preposition
145 '("and" "or" "but" "admin")))
147 (define (valid-name? name)
148 (and (irregex-match name-sre name)
149 (not (member name forbidden-words))))
151 (define* (sign-cmd-sign-in actor message
152 #:key direct-obj indir-obj preposition)
154 (mbody-val (<-wait (message-from message) 'get-name)))
155 (define name indir-obj)
156 (if (valid-name? indir-obj)
158 (<-wait (message-from message) 'set-name! name)
159 (<- (slot-ref actor 'loc) 'tell-room
160 #:text (format #f "~a signs the form!\n~a is now known as ~a\n"
161 old-name old-name name)))
162 (<- (message-from message) 'tell
163 #:text "Sorry, that's not a valid name.
164 Alphanumerics, _ and - only, 2-15 characters, starts with an alphabetic
168 (define-class <summoning-bell> (<gameobj>)
169 (summons #:init-keyword #:summons)
172 #:allocation #:each-subclass
173 #:init-thunk (build-commands
174 ("ring" ((direct-command cmd-ring)))))
175 (actions #:allocation #:each-subclass
176 #:init-thunk (build-actions
177 (cmd-ring summoning-bell-cmd-ring))))
179 (define* (summoning-bell-cmd-ring bell message . _)
180 ;; Call back to actor who invoked this message handler
181 ;; and find out their name. We'll call *their* get-name message
182 ;; handler... meanwhile, this procedure suspends until we get
185 (mbody-val (<-wait (message-from message) 'get-name)))
187 ;; Now we'll invoke the "tell" message handler on the player
188 ;; who rang us, displaying this text on their screen.
189 ;; This one just uses <- instead of <-wait, since we don't
190 ;; care when it's delivered; we're not following up on it.
191 (<- (message-from message) 'tell
192 #:text "*ring ring!* You ring the bell!\n")
193 ;; We also want everyone else in the room to "hear" the bell,
194 ;; but they get a different message since they aren't the ones
195 ;; ringing it. Notice here's where we make use of the invoker's
196 ;; name as extracted and assigned to the who-rang variable.
197 ;; Notice how we send this message to our "location", which
198 ;; forwards it to the rest of the occupants in the room.
199 (<- (gameobj-loc bell) 'tell-room
201 (format #f "*ring ring!* ~a rings the bell!\n"
203 #:exclude (message-from message))
204 ;; Now we perform the primary task of the bell, which is to summon
205 ;; the "clerk" character to the room. (This is configurable,
206 ;; so we dynamically look up their address.)
207 (<- (dyn-ref bell (slot-ref bell 'summons)) 'be-summoned
208 #:who-summoned (message-from message)))
211 (define prefect-quotes
212 '("I'm a frood who really knows where my towel is!"
213 "On no account allow a Vogon to read poetry at you."
214 "Time is an illusion, lunchtime doubly so!"
215 "How can you have money if none of you produces anything?"
216 "On no account allow Arthur to request tea on this ship."))
218 (define-class <cabinet-item> (<gameobj>)
219 (take-me? #:init-value
222 `("Hm, well... the cabinet is locked and the properitor "
223 "is right over there.")))))
231 '((p "You're in some sort of hotel lobby. You see a large sign hanging "
232 "over the desk that says \"Hotel Bricabrac\". On the desk is a bell "
233 "that says \"'ring bell' for service\". Terrible music plays from a speaker "
234 "somewhere overhead. "
235 "The room is lined with various curio cabinets, filled with all sorts "
236 "of kitschy junk. It looks like whoever decorated this place had great "
237 "ambitions, but actually assembled it all in a hurry and used whatever "
238 "kind of objects they found lying around.")
239 (p "There's a door to the north leading to some kind of hallway."))
243 #:to 'grand-hallway)))
247 #:name "a frumpy fellow"
249 '((p " Whoever this is, they looks totally exhausted. They're
250 collapsed into the only comfortable looking chair in the room and you
251 don't get the sense that they're likely to move any time soon.
252 You notice they're wearing a sticker badly adhesed to their clothing
253 which says \"Hotel Proprietor\", but they look so disorganized that you
254 think that can't possibly be true... can it?
255 Despite their exhaustion, you sense they'd be happy to chat with you,
256 though the conversation may be a bit one sided."))
257 #:goes-by '("frumpy fellow" "fellow"
258 "Chris Webber" ; heh, did you rtfc? or was it so obvious?
259 "hotel proprietor" "proprietor")
260 #:catchphrases hotel-owner-grumps)
264 #:name "the Hotel Bricabrac sign"
265 #:desc " It strikes you that there's something funny going on with this sign.
266 Sure enough, if you look at it hard enough, you can tell that someone
267 hastily painted over an existing sign and changed the \"M\" to an \"H\".
269 #:read-text " All it says is \"Hotel Bricabrac\" in smudged, hasty text."
273 "hotel bricabrac sign"
277 <summoning-bell> 'lobby
278 #:name "a shiny brass bell"
279 #:goes-by '("shiny brass bell" "shiny bell" "brass bell" "bell")
280 #:desc " A shiny brass bell. Inscribed on its wooden base is the text
281 \"ring me for service\". You probably could \"ring the bell\" if you
283 #:summons 'break-room:desk-clerk)
286 <sign-in-form> 'lobby
287 #:name "sign-in form"
288 #:goes-by '("sign-in form" "form" "signin form")
289 #:desc "It looks like you could sign this form and set your name.")
291 ;; Object: curio cabinets
292 ;; TODO: respond to attempts to open the curio cabinet
295 #:proxy-items '(lobby:porcelain-doll
297 lobby:tea-set lobby:mustard-pot
298 lobby:head-of-elvis lobby:circuitboard-of-evlis
299 lobby:teletype-scroll lobby:orange-cat-phone)
300 #:name "a curio cabinet"
301 #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet"
302 "cabinet of curiosities")
304 (format #f " The curio cabinet is full of all sorts of oddities!
305 Something catches your eye!
306 Ooh, ~a!" (random-choice
307 '("a creepy porcelain doll"
308 "assorted 1950s robots"
309 "an exquisite tea set"
310 "an antique mustard pot"
311 "the pickled head of Elvis"
312 "the pickled circuitboard of EVLIS"
313 "a scroll of teletype paper holding the software Four Freedoms"
314 "a telephone shaped like an orange cartoon cat")))))
316 ('lobby:porcelain-doll
317 <cabinet-item> 'lobby
319 #:name "a creepy porcelain doll"
320 #:desc "It strikes you that while the doll is technically well crafted,
321 it's also the stuff of nightmares."
322 #:goes-by '("porcelain doll" "doll"))
324 <cabinet-item> 'lobby
326 #:name "a set of 1950s robots"
327 #:desc "There's a whole set of these 1950s style robots.
328 They seem to be stamped out of tin, and have various decorations of levers
329 and buttons and springs. Some of them have wind-up knobs on them."
330 #:goes-by '("robot" "robots" "1950s robot" "1950s robots"))
332 <cabinet-item> 'lobby
335 #:desc "A complete tea set. Some of the cups are chipped.
336 You can imagine yourself joining a tea party using this set, around a
337 nice table with some doilies, drinking some Earl Grey tea, hot. Mmmm."
338 #:goes-by '("tea set" "tea"))
340 <cabinet-item> 'lobby
342 #:name "a mustard pot"
343 #:desc '((p "It's a mustard pot. I mean, it's kind of cool, it has a
344 nice design, and it's an antique, but you can't imagine putting something
345 like this in a museum.")
346 (p "Ha... imagine that... a mustard museum."))
347 #:goes-by '("mustard pot" "antique mustard pot" "mustard"))
348 ('lobby:head-of-elvis
349 <cabinet-item> 'lobby
351 #:name "the pickled head of Elvis"
352 #:desc '((p "It's a jar full of some briny-looking liquid and...
353 a free floating head. The head looks an awful lot like Elvis, and
354 definitely not the younger Elvis. The hair even somehow maintains
355 that signature swoop while suspended in liquid. But of course it's
357 (p "Oh, wait, it has a label at the bottom which says:
358 \"This is really the head of Elvis\". Well... maybe don't believe
359 everything you read."))
360 #:goes-by '("pickled head of elvis" "pickled head of Elvis"
361 "elvis" "Elvis" "head" "pickled head"))
362 ('lobby:circuitboard-of-evlis
363 <cabinet-item> 'lobby
365 #:name "the pickled circuitboard of Evlis"
366 #:desc '((p "It's a circuitboard from a Lisp Machine called EVLIS.
367 This is quite the find, and you bet just about anyone interested in
368 preserving computer history would love to get their hands on this.")
369 (p "Unfortunately, whatever moron did acquire this has
370 no idea what it means to preserve computers, so here it is floating
371 in some kind of briny liquid. It appears to be heavily corroded.
373 #:goes-by '("pickled circuitboard of evlis" "pickled circuitboard of Evlis"
374 "pickled circuitboard of EVLIS"
375 "evlis" "Evlis" "EVLIS" "circuitboard" "pickled circuitboard"))
376 ('lobby:teletype-scroll
377 <cabinet-item> 'lobby
379 #:name "a scroll of teletype"
380 #:desc '((p "This is a scroll of teletype paper. It's a bit old
381 and yellowed but the type is very legible. It says:")
384 (p (strong "== The four essential freedoms =="))
385 (p "A program is free software if the program's users have
386 the four essential freedoms: ")
387 (ul (li "The freedom to run the program as you wish, for any purpose (freedom 0).")
388 (li "The freedom to study how the program works, and change it so it does your computing as you wish (freedom 1). Access to the source code is a precondition for this.")
389 (li "The freedom to redistribute copies so you can help your neighbor (freedom 2).")
390 (li "The freedom to distribute copies of your modified versions to others (freedom 3). By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this.")))
391 (p "You get this feeling that ambiguities in the
392 English language surrounding the word 'free' have lead to a lot of terminology debates."))
393 #:goes-by '("scroll of teletype" "scroll of teletype paper" "teletype scroll"
394 "teletype paper" "scroll" "four freedoms"
395 "scroll of teletype paper holding the software Four Freedoms"
396 "scroll of teletype paper holding the software four freedoms"))
397 ('lobby:orange-cat-phone
398 <cabinet-item> 'lobby
400 #:name "a telephone shaped like an orange cartoon cat"
401 #:desc "It's made out of a cheap plastic, and it's very orange.
402 It resembles a striped tabby, and it's eyes hold the emotion of
403 a being both sleepy and smarmy.
404 You suspect that someone, somewhere made a ton of cash on items holding
405 this general shape in the 1990s."
406 #:goes-by '("orange cartoon cat phone" "orange cartoon cat telephone"
407 "orange cat phone" "orange cat telephone"
408 "cartoon cat phone" "cartoon cat"
409 "cat phone" "cat telephone" "phone" "telephone"))))
416 (define-actor <disc-shield> (<gameobj>)
417 ((cmd-take disc-shield-take)))
419 (define* (disc-shield-take gameobj message
421 (player (message-from message)))
422 (create-gameobj <glowing-disc> (gameobj-gm gameobj)
423 player) ;; set loc to player to put in player's inventory
425 #:text '((p "As you attempt to pull the shield / disk platter
426 from the statue a shining outline appears around it... and a
427 completely separate, glowing copy of the disc materializes into your
429 (<- (gameobj-loc gameobj) 'tell-room
430 #:text `(,(mbody-val (<-wait player 'get-name))
431 " pulls on the shield of the statue, and a glowing "
432 "copy of it materializes into their hands!")
434 (<- (gameobj-loc gameobj) 'tell-room
436 '(p "You hear a voice whisper: "
437 (i "\"Share the software... and you'll be free...\""))))
439 ;;; This is the disc that gets put in the player's inventory
440 (define-actor <glowing-disc> (<gameobj>)
441 ((cmd-drop glowing-disc-drop-cmd))
443 #:allocation #:each-subclass
444 #:init-thunk (build-props
445 '((hd-platter? . #t))))
446 (name #:allocation #:each-subclass
447 #:init-value "a glowing disc")
448 (desc #:allocation #:each-subclass
449 #:init-value "A brightly glowing disc. It's shaped like a hard
450 drive platter, not unlike the one from the statue it came from. It's
451 labeled \"RL02.5\".")
452 (goes-by #:init-value '("glowing disc" "glowing platter"
453 "glowing disc platter" "glowing disk platter"
454 "platter" "disc" "disk" "glowing shield")))
456 (define* (glowing-disc-drop-cmd gameobj message
458 (player (message-from message)))
460 #:text "You drop the glowing disc, and it shatters into a million pieces!")
461 (<- (mbody-val (<-wait player 'get-loc)) 'tell-room
462 #:text `(,(mbody-val (<-wait player 'get-name))
463 " drops a glowing disc, and it shatters into a million pieces!")
465 (gameobj-self-destruct gameobj))
467 (define grand-hallway
471 #:name "Grand Hallway"
472 #:desc '((p " A majestic red carpet runs down the center of the room.
473 Busts of serious looking people line the walls, but there's no
474 clear indication that they have any logical relation to this place.")
475 (p "In the center is a large statue of a woman in a warrior's
476 pose, but something is strange about her weapon and shield. You wonder what
478 (p "To the south is the lobby. A door to the east is labeled \"smoking
479 room\", while a door to the west is labeled \"playroom\"."))
489 #:to 'smoking-parlor)))
490 ('grand-hallway:carpet
491 <gameobj> 'grand-hallway
492 #:name "the Grand Hallway carpet"
493 #:desc "It's very red, except in the places where it's very worn."
495 #:goes-by '("red carpet" "carpet"))
496 ('grand-hallway:busts
497 <gameobj> 'grand-hallway
498 #:name "the busts of serious people"
499 #:desc "There are about 6 of them in total. They look distinguished
500 but there's no indication of who they are."
502 #:goes-by '("busts" "bust" "busts of serious people" "bust of serious person"))
503 ('grand-hallway:hackthena-statue
504 <proxy-items> 'grand-hallway
505 #:name "the statue of Hackthena"
506 #:desc '((p "The base of the statue says \"Hackthena, guardian of the hacker
507 spirit\". You've heard of Hackthena... not a goddess, but spiritual protector of
508 all good hacks, and legendary hacker herself.")
509 (p "Hackthena holds the form of a human woman. She wears flowing
510 robes, has a pear of curly bovine-esque horns protruding from the sides of her
511 head, wears a pair of horn-rimmed glasses, and appears posed as if for battle.
512 But instead of a weapon, she seems to hold some sort of keyboard. And her
513 shield... well it's round like a shield, but something seems off about it.
514 You'd better take a closer look to be sure."))
515 #:goes-by '("hackthena statue" "hackthena" "statue" "statue of hackthena")
516 #:proxy-items '(grand-hallway:keyboard
517 grand-hallway:disc-platter
518 grand-hallway:hackthena-horns))
519 ('grand-hallway:keyboard
520 <gameobj> 'grand-hallway
521 #:name "a Knight Keyboard"
522 #:desc "Whoa, this isn't just any old keyboard, this is a Knight Keyboard!
523 Any space cadet can see that with that kind of layout a hack-and-slayer could
524 thrash out some serious key-chords like there's no tomorrow. You guess
525 Hackthena must be an emacs user."
530 `("Are you kidding? Do you know how hard it is to find "
531 "a Knight Keyboard? There's no way she's going "
532 "to give that up.")))
533 #:goes-by '("knight keyboard" "keyboard"))
534 ('grand-hallway:hackthena-horns
535 <gameobj> 'grand-hallway
536 #:name "Hackthena's horns"
537 #:desc "They're not unlike a Gnu's horns."
542 `("Are you seriously considering desecrating a statue?")))
543 #:goes-by '("hackthena's horns" "horns" "horns of hacktena"))
544 ('grand-hallway:disc-platter
545 <disc-shield> 'grand-hallway
546 #:name "Hackthena's shield"
547 #:desc "No wonder the \"shield\" looks unusual... it seems to be a hard disk
548 platter! It has \"RL02.5\" written on it. It looks kind of loose."
550 #:goes-by '("hackthena's shield" "shield" "platter" "hard disk platter"))))
560 #:name "The Playroom"
561 #:desc '(p (" There are toys scattered everywhere here. It's really unclear
562 if this room is intended for children or child-like adults.")
563 (" There are doors to both the east and the west."))
570 #:to 'computer-room)))
575 #:desc " It's a little foam cube with googly eyes on it. So cute!")
576 ('playroom:cuddles-plushie
578 #:name "a Cuddles plushie"
579 #:goes-by '("plushie" "cuddles plushie" "cuddles")
581 #:desc " A warm and fuzzy cuddles plushie! It's a cuddlefish!")
584 <container> 'playroom
586 #:goes-by '("toy chest" "chest")
587 #:desc (lambda (toy-chest whos-looking)
588 (let ((contents (gameobj-occupants toy-chest)))
589 `((p "A brightly painted wooden chest. The word \"TOYS\" is "
592 ,(if (eq? contents '())
593 " nothing! It's empty!"
594 `(ul ,(map (lambda (occupant)
596 (<-wait occupant 'get-name))))
597 (gameobj-occupants toy-chest))))))))
601 ;; Things inside the toy chest
602 ('playroom:toy-chest:rubber-duck
603 <gameobj> 'playroom:toy-chest
604 #:name "a rubber duck"
605 #:goes-by '("rubber duck" "duck")
607 #:desc "It's a yellow rubber duck with a bright orange beak.")))
618 ;; ... full of NURPH weapons?
624 (define-class <furniture> (<gameobj>)
625 (sit-phrase #:init-keyword #:sit-phrase)
626 (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
627 (sit-name #:init-keyword #:sit-name)
630 #:allocation #:each-subclass
631 #:init-thunk (build-commands
632 ("sit" ((direct-command cmd-sit-furniture)))))
633 (actions #:allocation #:each-subclass
634 #:init-thunk (build-actions
635 (cmd-sit-furniture furniture-cmd-sit))))
637 (define* (furniture-cmd-sit actor message #:key direct-obj)
639 (mbody-val (<-wait (message-from message) 'get-name)))
640 (<- (message-from message) 'tell
641 #:text (format #f "You ~a ~a.\n"
642 (slot-ref actor 'sit-phrase)
643 (slot-ref actor 'sit-name)))
644 (<- (slot-ref actor 'loc) 'tell-room
645 #:text (format #f "~a ~a on ~a.\n"
647 (slot-ref actor 'sit-phrase-third-person)
648 (slot-ref actor 'sit-name))
649 #:exclude (message-from message)))
652 (define smoking-parlor
656 #:name "Smoking Parlor"
658 '((p "This room looks quite posh. There are huge comfy seats you can sit in
659 if you like. Strangely, you see a large sign saying \"No Smoking\". The owners must
660 have installed this place and then changed their mind later.")
661 (p "There's a door to the west leading back to the grand hallway, and
662 a nondescript steel door to the south, leading apparently outside."))
670 ('smoking-parlor:chair
671 <furniture> 'smoking-parlor
672 #:name "a comfy leather chair"
673 #:desc " That leather chair looks really comfy!"
674 #:goes-by '("leather chair" "comfy leather chair" "chair")
675 #:sit-phrase "sink into"
676 #:sit-phrase-third-person "sinks into"
677 #:sit-name "the comfy leather chair")
678 ('smoking-parlor:sofa
679 <furniture> 'smoking-parlor
680 #:name "a plush leather sofa"
681 #:desc " That leather chair looks really comfy!"
682 #:goes-by '("leather sofa" "plush leather sofa" "sofa"
683 "leather couch" "plush leather couch" "couch")
684 #:sit-phrase "sprawl out on"
685 #:sit-phrase-third-person "sprawls out on into"
686 #:sit-name "the plush leather couch")
687 ('smoking-parlor:bar-stool
688 <furniture> 'smoking-parlor
690 #:desc " Conveniently located near the bar! Not the most comfortable
691 seat in the room, though."
692 #:goes-by '("stool" "bar stool" "seat")
693 #:sit-phrase "hop on"
694 #:sit-phrase-third-person "hops onto"
695 #:sit-name "the bar stool")
697 <chatty-npc> 'smoking-parlor
698 #:name "Ford Prefect"
699 #:desc "Just some guy, you know?"
700 #:goes-by '("Ford Prefect" "ford prefect"
701 "frood" "prefect" "ford")
702 #:catchphrases prefect-quotes)
704 ('smoking-parlor:no-smoking-sign
705 <gameobj> 'smoking-parlor
707 #:name "No Smoking Sign"
708 #:desc "This sign says \"No Smoking\" in big, red letters.
709 It has some bits of bubble gum stuck to it... yuck."
710 #:goes-by '("no smoking sign" "sign"))
712 ;; TODO: Cigar dispenser
720 (define-class <desk-clerk> (<gameobj>)
721 ;; The desk clerk has three states:
722 ;; - on-duty: Arrived, and waiting for instructions (and losing patience
724 ;; - slacking: In the break room, probably smoking a cigarette
725 ;; or checking text messages
726 (state #:init-value 'slacking)
727 (commands #:allocation #:each-subclass
730 (("talk" "chat") ((direct-command cmd-chat)))
731 ("ask" ((direct-command cmd-ask-incomplete)
732 (prep-direct-command cmd-ask-about)))
733 ("dismiss" ((direct-command cmd-dismiss)))))
734 (patience #:init-value 0)
735 (actions #:allocation #:each-subclass
736 #:init-thunk (build-actions
737 (init clerk-act-init)
738 (cmd-chat clerk-cmd-chat)
739 (cmd-ask-incomplete clerk-cmd-ask-incomplete)
740 (cmd-ask-about clerk-cmd-ask)
741 (cmd-dismiss clerk-cmd-dismiss)
742 (update-loop clerk-act-update-loop)
743 (be-summoned clerk-act-be-summoned))))
745 (define (clerk-act-init clerk message . _)
746 ;; call the gameobj main init method
747 (gameobj-act-init clerk message)
748 ;; start our main loop
749 (<- (actor-id clerk) 'update-loop))
751 (define clerk-help-topics
753 "Changing your name is easy! We have a clipboard here at the desk
754 where you can make yourself known to other participants in the hotel
755 if you sign it. Try 'sign form as <your-name>', replacing
756 <your-name>, obviously!")
758 "Here are some useful commands you might like to try: chat,
759 go, take, drop, say...")
761 "We hope you enjoy your stay at Hotel Bricabrac. As you may see,
762 our hotel emphasizes interesting experiences over rest and lodging.
763 The origins of the hotel are... unclear... and it has recently come
764 under new... 'management'. But at Hotel Bricabrac we believe these
765 aspects make the hotel into a fun and unique experience! Please,
766 feel free to walk around and explore.")))
769 (define clerk-knows-about
770 "'ask clerk about changing name', 'ask clerk about common commands', and 'ask clerk about the hotel'")
772 (define clerk-general-helpful-line
774 "The clerk says, \"If you need help with anything, feel free to ask me about it.
775 For example, 'ask clerk about changing name'. You can ask me about the following:
776 " clerk-knows-about ".\"\n"))
778 (define clerk-slacking-complaints
779 '("The pay here is absolutely lousy."
780 "The owner here has no idea what they're doing."
781 "Some times you just gotta step away, you know?"
782 "You as exhausted as I am?"
783 "Yeah well, this is just temporary. I'm studying to be a high
784 energy particle physicist. But ya gotta pay the bills, especially
785 with tuition at where it is..."))
787 (define* (clerk-cmd-chat clerk message #:key direct-obj)
788 (match (slot-ref clerk 'state)
790 (<- (message-from message) 'tell
791 #:text clerk-general-helpful-line))
793 (<- (message-from message) 'tell
797 (random-choice clerk-slacking-complaints)
800 (define (clerk-cmd-ask-incomplete clerk message . _)
801 (<- (message-from message) 'tell
802 #:text "The clerk says, \"Ask about what?\"\n"))
804 (define clerk-doesnt-know-text
805 "The clerk apologizes and says she doesn't know about that topic.\n")
807 (define* (clerk-cmd-ask clerk message #:key indir-obj
809 (match (slot-ref clerk 'state)
811 (match (assoc indir-obj clerk-help-topics)
813 (<- (message-from message) 'tell
815 (string-append "The clerk clears her throat and says:\n \""
819 (<- (message-from message) 'tell
820 #:text clerk-doesnt-know-text))))
822 (<- (message-from message) 'tell
823 #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
825 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
826 (match (slot-ref clerk 'state)
828 (<- who-summoned 'tell
830 "The clerk tells you as politely as she can that she's already here,
831 so there's no need to ring the bell.\n"))
833 (<- (gameobj-loc clerk) 'tell-room
835 "The clerk's ears perk up, she stamps out a cigarette, and she
836 runs out of the room!\n")
837 (gameobj-set-loc! clerk (dyn-ref clerk 'lobby))
838 (slot-set! clerk 'patience 8)
839 (slot-set! clerk 'state 'on-duty)
840 (<- (gameobj-loc clerk) 'tell-room
843 " Suddenly, a uniformed woman rushes into the room! She's wearing a
844 badge that says \"Desk Clerk\".
845 \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
846 We look forward to your stay. If you'd like help getting acclimated,
847 feel free to ask me. For example, 'ask clerk about changing name'.
848 You can ask me about the following:
849 " clerk-knows-about ".\"\n")))))
851 (define* (clerk-cmd-dismiss clerk message . _)
853 (mbody-val (<-wait (message-from message) 'get-name)))
854 (match (slot-ref clerk 'state)
856 (<- (gameobj-loc clerk) 'tell-room
858 (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
859 The clerk leaves the room in a hurry.\n"
861 #:exclude (actor-id clerk))
862 (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
863 (slot-set! clerk 'state 'slacking)
864 (<- (gameobj-loc clerk) 'tell-room
865 #:text clerk-return-to-slacking-text
866 #:exclude (actor-id clerk)))
868 (<- (message-from message) 'tell
869 #:text "The clerk sternly asks you to not be so dismissive.\n"))))
871 (define clerk-slacking-texts
872 '("The clerk takes a long drag on her cigarette.\n"
873 "The clerk scrolls through text messages on her phone.\n"
874 "The clerk coughs a few times.\n"
875 "The clerk checks her watch and justifies a few more minutes outside.\n"
876 "The clerk fumbles around for a lighter.\n"
877 "The clerk sighs deeply and exhaustedly.\n"
878 "The clerk fumbles around for a cigarette.\n"))
880 (define clerk-working-impatience-texts
881 '("The clerk hums something, but you're not sure what it is."
882 "The clerk attempts to change the overhead music, but the dial seems broken."
883 "The clerk clicks around on the desk computer."
884 "The clerk scribbles an equation on a memo pad, then crosses it out."
885 "The clerk mutters something about the proprietor having no idea how to run a hotel."
886 "The clerk thumbs through a printout of some physics paper."))
888 (define clerk-slack-excuse-text
889 "The desk clerk excuses herself, but says you are welcome to ring the bell
890 if you need further help.")
892 (define clerk-return-to-slacking-text
893 "The desk clerk enters and slams the door behind her.\n")
896 (define (clerk-act-update-loop clerk message)
897 (define (tell-room text)
898 (<- (gameobj-loc clerk) 'tell-room
900 #:exclude (actor-id clerk)))
901 (define (loop-if-not-destructed)
902 (if (not (slot-ref clerk 'destructed))
903 ;; This iterates by "recursing" on itself by calling itself
904 ;; (as the message handler) again. It used to be that we had to do
905 ;; this, because there was a bug where a loop which yielded like this
906 ;; would keep growing the stack due to some parameter goofiness.
907 ;; That's no longer true, but there's an added advantage to this
908 ;; route: it's much more live hackable. If we change the definition
909 ;; of this method, the character will act differently on the next
910 ;; "tick" of the loop.
911 (<- (actor-id clerk) 'update-loop)))
912 (match (slot-ref clerk 'state)
914 (tell-room (random-choice clerk-slacking-texts))
915 (8sleep (+ (random 20) 15))
916 (loop-if-not-destructed))
918 (if (> (slot-ref clerk 'patience) 0)
919 ;; Keep working but lose patience gradually
921 (tell-room (random-choice clerk-working-impatience-texts))
922 (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
924 (8sleep (+ (random 60) 40))
925 (loop-if-not-destructed))
928 (tell-room clerk-slack-excuse-text)
929 ;; back bto the break room
930 (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
931 (tell-room clerk-return-to-slacking-text)
932 ;; annnnnd back to slacking
933 (slot-set! clerk 'state 'slacking)
934 (8sleep (+ (random 30) 15))
935 (loop-if-not-destructed))))))
942 #:name "Employee Break Room"
943 #:desc " This is less a room and more of an outdoor wire cage. You get
944 a bit of a view of the brick exterior of the building, and a crisp wind blows,
945 whistling, through the openings of the fenced area. Partly smoked cigarettes
946 and various other debris cover the floor.
947 Through the wires you can see... well... hm. It looks oddly like
948 the scenery tapers off nothingness. But that can't be right, can it?"
952 #:to 'smoking-parlor)))
953 ('break-room:desk-clerk
954 <desk-clerk> 'break-room
955 #:name "the hotel desk clerk"
956 #:desc " The hotel clerk is wearing a neatly pressed uniform bearing the
957 hotel insignia. She appears to be rather exhausted."
958 #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))
960 <gameobj> 'break-room
963 #:desc "As you stare into the void, the void stares back into you."
964 #:goes-by '("void" "abyss" "nothingness" "scenery"))
966 <gameobj> 'break-room
968 #:name "break room cage"
969 #:desc "It's a mostly-cubical wire mesh surrounding the break area.
970 You can see through the gaps, but they're too small to put more than a
971 couple of fingers through. There appears to be some wear and tear to
972 the paint, but the wires themselves seem to be unusually sturdy."
973 #:goes-by '("fence" "cage" "wire cage"))))
977 ;;; Ennpie's Sea Lounge
978 ;;; -------------------
984 ;; Our computer and hard drive are based off the PDP-11 and the RL01 /
985 ;; RL02 disk drives. However we increment both by .5 (a true heresy)
986 ;; to distinguish both from the real thing.
988 (define-actor <hard-drive> (<gameobj>)
989 ((cmd-put-in hard-drive-insert)
990 (cmd-push-button hard-drive-push-button)
991 (get-state hard-drive-act-get-state))
992 (commands #:allocation #:each-subclass
993 #:init-thunk (build-commands
994 ("insert" ((prep-indir-command cmd-put-in
995 '("in" "inside" "into"))))
996 (("press" "push") ((prep-indir-command cmd-push-button)))))
997 ;; the state moves from: empty -> with-disc -> loading -> ready
998 (state #:init-value 'empty
1001 (define (hard-drive-act-get-state hard-drive message)
1002 (<-reply message (.state hard-drive)))
1004 (define* (hard-drive-desc hard-drive #:optional whos-looking)
1005 `((p "The hard drive is labeled \"RL02.5\". It's a little under a meter tall.")
1006 (p "There is a slot where a disk platter could be inserted, "
1007 ,(if (eq? (.state hard-drive) 'empty)
1008 "which is currently empty"
1009 "which contains a glowing platter")
1010 ". There is a LOAD button "
1011 ,(if (member (.state hard-drive) '(empty with-disc))
1013 "which is pressed in and unlit")
1014 ". There is a READY indicator "
1015 ,(if (eq? (.state hard-drive) 'ready)
1018 ,(if (member (.state hard-drive) '(loading ready))
1019 " The machine emits a gentle whirring noise."
1022 (define* (hard-drive-push-button gameobj message
1023 #:key direct-obj indir-obj preposition
1024 (player (message-from message)))
1025 (define (tell-room text)
1026 (<- (gameobj-loc gameobj) 'tell-room
1028 (define (tell-room-excluding-player text)
1029 (<- (gameobj-loc gameobj) 'tell-room
1033 ((ci-member direct-obj '("button" "load button" "load"))
1034 (tell-room-excluding-player
1035 `(,(mbody-val (<-wait player 'get-name))
1036 " presses the button on the hard disk."))
1038 #:text "You press the button on the hard disk.")
1040 (case (.state gameobj)
1042 ;; I have no idea what this drive did when you didn't have a platter
1043 ;; in it and pressed load, but I know there was a FAULT button.
1044 (tell-room "You hear some movement inside the hard drive...")
1047 '("... but then the FAULT button blinks a couple times. "
1048 "What could be missing?")))
1050 (set! (.state gameobj) 'loading)
1051 (tell-room "The hard disk begins to spin up!")
1053 (set! (.state gameobj) 'ready)
1054 (tell-room "The READY light turns on!"))
1057 #:text '("Pressing the button does nothing right now, "
1058 "but it does feel satisfying.")))))
1061 #:text '("How could you think of pressing anything else "
1062 "but that tantalizing button right in front of you?")))))
1064 (define* (hard-drive-insert gameobj message
1065 #:key direct-obj indir-obj preposition
1066 (player (message-from message)))
1067 (define our-name (slot-ref gameobj 'name))
1071 (for-each (lambda (occupant)
1072 (define goes-by (mbody-val (<-wait occupant 'goes-by)))
1073 (when (ci-member direct-obj goes-by)
1075 (mbody-val (<-wait player 'get-occupants)))
1081 #:text `("You don't seem to have any such " ,direct-obj " to put "
1082 ,preposition " " ,our-name ".")))
1083 ((not (mbody-val (<-wait this-thing 'get-prop 'hd-platter?)))
1085 #:text `("It wouldn't make sense to put "
1086 ,(mbody-val (<-wait this-thing 'get-name))
1087 " " ,preposition " " ,our-name ".")))
1088 ((not (eq? (.state gameobj) 'empty))
1090 #:text "The disk drive already has a platter in it."))
1092 (set! (.state gameobj) 'with-disc)
1094 #:text '((p "You insert the glowing disc into the drive.")
1095 (p "The LOAD button begins to glow."))))))
1097 (define computer-room
1101 #:name "Computer Room"
1102 #:desc '((p "A sizable computer cabinet covers a good portion of the left
1103 wall. It emits a pleasant hum which covers the room like a warm blanket.
1104 Connected to a computer is a large hard drive.")
1105 (p "On the floor is a large steel panel. It is closed, but it has
1106 hinges which suggest it could be opened."))
1111 ('computer-room:hard-drive
1112 <hard-drive> 'computer-room
1113 #:name "a hard drive"
1114 #:desc (wrap-apply hard-drive-desc)
1115 #:goes-by '("hard drive" "drive" "hard disk"))))
1123 (append lobby grand-hallway smoking-parlor
1124 playroom break-room computer-room))
1126 ;; TODO: Provide command line args
1127 (define (run-game . args)
1128 (run-demo (game-spec) 'lobby #:repl-server #t))