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 (slot-ref actor 'read-text)))
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 like so: "
290 (i "sign form as <my-name-here>")))
292 ;; Object: curio cabinets
293 ;; TODO: respond to attempts to open the curio cabinet
296 #:proxy-items '(lobby:porcelain-doll
298 lobby:tea-set lobby:mustard-pot
299 lobby:head-of-elvis lobby:circuitboard-of-evlis
300 lobby:teletype-scroll lobby:orange-cat-phone)
301 #:name "a curio cabinet"
302 #:goes-by '("curio cabinet" "cabinet" "bricabrac cabinet"
303 "cabinet of curiosities")
305 (format #f " The curio cabinet is full of all sorts of oddities!
306 Something catches your eye!
307 Ooh, ~a!" (random-choice
308 '("a creepy porcelain doll"
309 "assorted 1950s robots"
310 "an exquisite tea set"
311 "an antique mustard pot"
312 "the pickled head of Elvis"
313 "the pickled circuitboard of EVLIS"
314 "a scroll of teletype paper holding the software Four Freedoms"
315 "a telephone shaped like an orange cartoon cat")))))
317 ('lobby:porcelain-doll
318 <cabinet-item> 'lobby
320 #:name "a creepy porcelain doll"
321 #:desc "It strikes you that while the doll is technically well crafted,
322 it's also the stuff of nightmares."
323 #:goes-by '("porcelain doll" "doll"))
325 <cabinet-item> 'lobby
327 #:name "a set of 1950s robots"
328 #:desc "There's a whole set of these 1950s style robots.
329 They seem to be stamped out of tin, and have various decorations of levers
330 and buttons and springs. Some of them have wind-up knobs on them."
331 #:goes-by '("robot" "robots" "1950s robot" "1950s robots"))
333 <cabinet-item> 'lobby
336 #:desc "A complete tea set. Some of the cups are chipped.
337 You can imagine yourself joining a tea party using this set, around a
338 nice table with some doilies, drinking some Earl Grey tea, hot. Mmmm."
339 #:goes-by '("tea set" "tea"))
341 <cabinet-item> 'lobby
343 #:name "a mustard pot"
344 #:desc '((p "It's a mustard pot. I mean, it's kind of cool, it has a
345 nice design, and it's an antique, but you can't imagine putting something
346 like this in a museum.")
347 (p "Ha... imagine that... a mustard museum."))
348 #:goes-by '("mustard pot" "antique mustard pot" "mustard"))
349 ('lobby:head-of-elvis
350 <cabinet-item> 'lobby
352 #:name "the pickled head of Elvis"
353 #:desc '((p "It's a jar full of some briny-looking liquid and...
354 a free floating head. The head looks an awful lot like Elvis, and
355 definitely not the younger Elvis. The hair even somehow maintains
356 that signature swoop while suspended in liquid. But of course it's
358 (p "Oh, wait, it has a label at the bottom which says:
359 \"This is really the head of Elvis\". Well... maybe don't believe
360 everything you read."))
361 #:goes-by '("pickled head of elvis" "pickled head of Elvis"
362 "elvis" "Elvis" "head" "pickled head"))
363 ('lobby:circuitboard-of-evlis
364 <cabinet-item> 'lobby
366 #:name "the pickled circuitboard of Evlis"
367 #:desc '((p "It's a circuitboard from a Lisp Machine called EVLIS.
368 This is quite the find, and you bet just about anyone interested in
369 preserving computer history would love to get their hands on this.")
370 (p "Unfortunately, whatever moron did acquire this has
371 no idea what it means to preserve computers, so here it is floating
372 in some kind of briny liquid. It appears to be heavily corroded.
374 #:goes-by '("pickled circuitboard of evlis" "pickled circuitboard of Evlis"
375 "pickled circuitboard of EVLIS"
376 "evlis" "Evlis" "EVLIS" "circuitboard" "pickled circuitboard"))
377 ('lobby:teletype-scroll
378 <cabinet-item> 'lobby
380 #:name "a scroll of teletype"
381 #:desc '((p "This is a scroll of teletype paper. It's a bit old
382 and yellowed but the type is very legible. It says:")
385 (p (strong "== The four essential freedoms =="))
386 (p "A program is free software if the program's users have
387 the four essential freedoms: ")
388 (ul (li "The freedom to run the program as you wish, for any purpose (freedom 0).")
389 (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.")
390 (li "The freedom to redistribute copies so you can help your neighbor (freedom 2).")
391 (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.")))
392 (p "You get this feeling that ambiguities in the
393 English language surrounding the word 'free' have lead to a lot of terminology debates."))
394 #:goes-by '("scroll of teletype" "scroll of teletype paper" "teletype scroll"
395 "teletype paper" "scroll" "four freedoms"
396 "scroll of teletype paper holding the software Four Freedoms"
397 "scroll of teletype paper holding the software four freedoms"))
398 ('lobby:orange-cat-phone
399 <cabinet-item> 'lobby
401 #:name "a telephone shaped like an orange cartoon cat"
402 #:desc "It's made out of a cheap plastic, and it's very orange.
403 It resembles a striped tabby, and it's eyes hold the emotion of
404 a being both sleepy and smarmy.
405 You suspect that someone, somewhere made a ton of cash on items holding
406 this general shape in the 1990s."
407 #:goes-by '("orange cartoon cat phone" "orange cartoon cat telephone"
408 "orange cat phone" "orange cat telephone"
409 "cartoon cat phone" "cartoon cat"
410 "cat phone" "cat telephone" "phone" "telephone"))))
417 (define-actor <disc-shield> (<gameobj>)
418 ((cmd-take disc-shield-take)))
420 (define* (disc-shield-take gameobj message
422 (player (message-from message)))
423 (create-gameobj <glowing-disc> (gameobj-gm gameobj)
424 player) ;; set loc to player to put in player's inventory
426 #:text '((p "As you attempt to pull the shield / disk platter
427 from the statue a shining outline appears around it... and a
428 completely separate, glowing copy of the disc materializes into your
430 (<- (gameobj-loc gameobj) 'tell-room
431 #:text `(,(mbody-val (<-wait player 'get-name))
432 " pulls on the shield of the statue, and a glowing "
433 "copy of it materializes into their hands!")
435 (<- (gameobj-loc gameobj) 'tell-room
437 '(p "You hear a voice whisper: "
438 (i "\"Share the software... and you'll be free...\""))))
440 ;;; This is the disc that gets put in the player's inventory
441 (define-actor <glowing-disc> (<gameobj>)
442 ((cmd-drop glowing-disc-drop-cmd))
444 #:allocation #:each-subclass
445 #:init-thunk (build-props
446 '((hd-platter? . #t))))
447 (name #:allocation #:each-subclass
448 #:init-value "a glowing disc")
449 (desc #:allocation #:each-subclass
450 #:init-value "A brightly glowing disc. It's shaped like a hard
451 drive platter, not unlike the one from the statue it came from. It's
452 labeled \"RL02.5\".")
453 (goes-by #:init-value '("glowing disc" "glowing platter"
454 "glowing disc platter" "glowing disk platter"
455 "platter" "disc" "disk" "glowing shield")))
457 (define* (glowing-disc-drop-cmd gameobj message
459 (player (message-from message)))
461 #:text "You drop the glowing disc, and it shatters into a million pieces!")
462 (<- (mbody-val (<-wait player 'get-loc)) 'tell-room
463 #:text `(,(mbody-val (<-wait player 'get-name))
464 " drops a glowing disc, and it shatters into a million pieces!")
466 (gameobj-self-destruct gameobj))
471 (define lobby-map-text
474 .----------.----------. : & : .----------.----------.
475 | computer | |& :YOU ARE: &| smoking | *UNDER* |
476 | room + playroom + : HERE : + parlor | *CONS- |
477 | > | |& : : &| | TRUCTION*|
478 '----------'----------'-++-------++-'-------+--'----------'
484 (define grand-hallway
488 #:name "Grand Hallway"
489 #:desc '((p " A majestic red carpet runs down the center of the room.
490 Busts of serious looking people line the walls, but there's no
491 clear indication that they have any logical relation to this place.")
492 (p "In the center is a large statue of a woman in a warrior's
493 pose, but something is strange about her weapon and shield. You wonder what
495 (p "To the south is the lobby. A door to the east is labeled \"smoking
496 room\", while a door to the west is labeled \"playroom\"."))
506 #:to 'smoking-parlor)))
508 <readable> 'grand-hallway
509 #:name "the hotel map"
510 #:desc '("This appears to be a map of the hotel. "
511 "Like the hotel itself, it seems to be "
513 "You could read it if you want to.")
514 #:read-text `(pre ,lobby-map-text)
515 #:goes-by '("map" "hotel map"))
516 ('grand-hallway:carpet
517 <gameobj> 'grand-hallway
518 #:name "the Grand Hallway carpet"
519 #:desc "It's very red, except in the places where it's very worn."
521 #:goes-by '("red carpet" "carpet"))
522 ('grand-hallway:busts
523 <gameobj> 'grand-hallway
524 #:name "the busts of serious people"
525 #:desc "There are about 6 of them in total. They look distinguished
526 but there's no indication of who they are."
528 #:goes-by '("busts" "bust" "busts of serious people" "bust of serious person"))
529 ('grand-hallway:hackthena-statue
530 <proxy-items> 'grand-hallway
531 #:name "the statue of Hackthena"
532 #:desc '((p "The base of the statue says \"Hackthena, guardian of the hacker
533 spirit\". You've heard of Hackthena... not a goddess, but spiritual protector of
534 all good hacks, and legendary hacker herself.")
535 (p "Hackthena holds the form of a human woman. She wears flowing
536 robes, has a pear of curly bovine-esque horns protruding from the sides of her
537 head, wears a pair of horn-rimmed glasses, and appears posed as if for battle.
538 But instead of a weapon, she seems to hold some sort of keyboard. And her
539 shield... well it's round like a shield, but something seems off about it.
540 You'd better take a closer look to be sure."))
541 #:goes-by '("hackthena statue" "hackthena" "statue" "statue of hackthena")
542 #:proxy-items '(grand-hallway:keyboard
543 grand-hallway:disc-platter
544 grand-hallway:hackthena-horns))
545 ('grand-hallway:keyboard
546 <gameobj> 'grand-hallway
547 #:name "a Knight Keyboard"
548 #:desc "Whoa, this isn't just any old keyboard, this is a Knight Keyboard!
549 Any space cadet can see that with that kind of layout a hack-and-slayer could
550 thrash out some serious key-chords like there's no tomorrow. You guess
551 Hackthena must be an emacs user."
556 `("Are you kidding? Do you know how hard it is to find "
557 "a Knight Keyboard? There's no way she's going "
558 "to give that up.")))
559 #:goes-by '("knight keyboard" "keyboard"))
560 ('grand-hallway:hackthena-horns
561 <gameobj> 'grand-hallway
562 #:name "Hackthena's horns"
563 #:desc "They're not unlike a Gnu's horns."
568 `("Are you seriously considering desecrating a statue?")))
569 #:goes-by '("hackthena's horns" "horns" "horns of hacktena"))
570 ('grand-hallway:disc-platter
571 <disc-shield> 'grand-hallway
572 #:name "Hackthena's shield"
573 #:desc "No wonder the \"shield\" looks unusual... it seems to be a hard disk
574 platter! It has \"RL02.5\" written on it. It looks kind of loose."
576 #:goes-by '("hackthena's shield" "shield" "platter" "hard disk platter"))))
586 #:name "The Playroom"
587 #:desc '(p (" There are toys scattered everywhere here. It's really unclear
588 if this room is intended for children or child-like adults.")
589 (" There are doors to both the east and the west."))
596 #:to 'computer-room)))
601 #:desc " It's a little foam cube with googly eyes on it. So cute!")
602 ('playroom:cuddles-plushie
604 #:name "a Cuddles plushie"
605 #:goes-by '("plushie" "cuddles plushie" "cuddles")
607 #:desc " A warm and fuzzy cuddles plushie! It's a cuddlefish!")
610 <container> 'playroom
612 #:goes-by '("toy chest" "chest")
613 #:desc (lambda (toy-chest whos-looking)
614 (let ((contents (gameobj-occupants toy-chest)))
615 `((p "A brightly painted wooden chest. The word \"TOYS\" is "
618 ,(if (eq? contents '())
619 " nothing! It's empty!"
620 `(ul ,(map (lambda (occupant)
622 (<-wait occupant 'get-name))))
623 (gameobj-occupants toy-chest))))))))
627 ;; Things inside the toy chest
628 ('playroom:toy-chest:rubber-duck
629 <gameobj> 'playroom:toy-chest
630 #:name "a rubber duck"
631 #:goes-by '("rubber duck" "duck")
633 #:desc "It's a yellow rubber duck with a bright orange beak.")))
644 ;; ... full of NURPH weapons?
650 (define-class <furniture> (<gameobj>)
651 (sit-phrase #:init-keyword #:sit-phrase)
652 (sit-phrase-third-person #:init-keyword #:sit-phrase-third-person)
653 (sit-name #:init-keyword #:sit-name)
656 #:allocation #:each-subclass
657 #:init-thunk (build-commands
658 ("sit" ((direct-command cmd-sit-furniture)))))
659 (actions #:allocation #:each-subclass
660 #:init-thunk (build-actions
661 (cmd-sit-furniture furniture-cmd-sit))))
663 (define* (furniture-cmd-sit actor message #:key direct-obj)
665 (mbody-val (<-wait (message-from message) 'get-name)))
666 (<- (message-from message) 'tell
667 #:text (format #f "You ~a ~a.\n"
668 (slot-ref actor 'sit-phrase)
669 (slot-ref actor 'sit-name)))
670 (<- (slot-ref actor 'loc) 'tell-room
671 #:text (format #f "~a ~a on ~a.\n"
673 (slot-ref actor 'sit-phrase-third-person)
674 (slot-ref actor 'sit-name))
675 #:exclude (message-from message)))
678 (define smoking-parlor
682 #:name "Smoking Parlor"
684 '((p "This room looks quite posh. There are huge comfy seats you can sit in
685 if you like. Strangely, you see a large sign saying \"No Smoking\". The owners must
686 have installed this place and then changed their mind later.")
687 (p "There's a door to the west leading back to the grand hallway, and
688 a nondescript steel door to the south, leading apparently outside."))
696 ('smoking-parlor:chair
697 <furniture> 'smoking-parlor
698 #:name "a comfy leather chair"
699 #:desc " That leather chair looks really comfy!"
700 #:goes-by '("leather chair" "comfy leather chair" "chair")
701 #:sit-phrase "sink into"
702 #:sit-phrase-third-person "sinks into"
703 #:sit-name "the comfy leather chair")
704 ('smoking-parlor:sofa
705 <furniture> 'smoking-parlor
706 #:name "a plush leather sofa"
707 #:desc " That leather chair looks really comfy!"
708 #:goes-by '("leather sofa" "plush leather sofa" "sofa"
709 "leather couch" "plush leather couch" "couch")
710 #:sit-phrase "sprawl out on"
711 #:sit-phrase-third-person "sprawls out on into"
712 #:sit-name "the plush leather couch")
713 ('smoking-parlor:bar-stool
714 <furniture> 'smoking-parlor
716 #:desc " Conveniently located near the bar! Not the most comfortable
717 seat in the room, though."
718 #:goes-by '("stool" "bar stool" "seat")
719 #:sit-phrase "hop on"
720 #:sit-phrase-third-person "hops onto"
721 #:sit-name "the bar stool")
723 <chatty-npc> 'smoking-parlor
724 #:name "Ford Prefect"
725 #:desc "Just some guy, you know?"
726 #:goes-by '("Ford Prefect" "ford prefect"
727 "frood" "prefect" "ford")
728 #:catchphrases prefect-quotes)
730 ('smoking-parlor:no-smoking-sign
731 <gameobj> 'smoking-parlor
733 #:name "No Smoking Sign"
734 #:desc "This sign says \"No Smoking\" in big, red letters.
735 It has some bits of bubble gum stuck to it... yuck."
736 #:goes-by '("no smoking sign" "sign"))
738 ;; TODO: Cigar dispenser
746 (define-class <desk-clerk> (<gameobj>)
747 ;; The desk clerk has three states:
748 ;; - on-duty: Arrived, and waiting for instructions (and losing patience
750 ;; - slacking: In the break room, probably smoking a cigarette
751 ;; or checking text messages
752 (state #:init-value 'slacking)
753 (commands #:allocation #:each-subclass
756 (("talk" "chat") ((direct-command cmd-chat)))
757 ("ask" ((direct-command cmd-ask-incomplete)
758 (prep-direct-command cmd-ask-about)))
759 ("dismiss" ((direct-command cmd-dismiss)))))
760 (patience #:init-value 0)
761 (actions #:allocation #:each-subclass
762 #:init-thunk (build-actions
763 (init clerk-act-init)
764 (cmd-chat clerk-cmd-chat)
765 (cmd-ask-incomplete clerk-cmd-ask-incomplete)
766 (cmd-ask-about clerk-cmd-ask)
767 (cmd-dismiss clerk-cmd-dismiss)
768 (update-loop clerk-act-update-loop)
769 (be-summoned clerk-act-be-summoned))))
771 (define (clerk-act-init clerk message . _)
772 ;; call the gameobj main init method
773 (gameobj-act-init clerk message)
774 ;; start our main loop
775 (<- (actor-id clerk) 'update-loop))
777 (define clerk-help-topics
779 "Changing your name is easy! We have a clipboard here at the desk
780 where you can make yourself known to other participants in the hotel
781 if you sign it. Try 'sign form as <your-name>', replacing
782 <your-name>, obviously!")
784 "Here are some useful commands you might like to try: chat,
785 go, take, drop, say...")
787 "We hope you enjoy your stay at Hotel Bricabrac. As you may see,
788 our hotel emphasizes interesting experiences over rest and lodging.
789 The origins of the hotel are... unclear... and it has recently come
790 under new... 'management'. But at Hotel Bricabrac we believe these
791 aspects make the hotel into a fun and unique experience! Please,
792 feel free to walk around and explore.")))
795 (define clerk-knows-about
796 "'ask clerk about changing name', 'ask clerk about common commands', and 'ask clerk about the hotel'")
798 (define clerk-general-helpful-line
800 "The clerk says, \"If you need help with anything, feel free to ask me about it.
801 For example, 'ask clerk about changing name'. You can ask me about the following:
802 " clerk-knows-about ".\"\n"))
804 (define clerk-slacking-complaints
805 '("The pay here is absolutely lousy."
806 "The owner here has no idea what they're doing."
807 "Some times you just gotta step away, you know?"
808 "You as exhausted as I am?"
809 "Yeah well, this is just temporary. I'm studying to be a high
810 energy particle physicist. But ya gotta pay the bills, especially
811 with tuition at where it is..."))
813 (define* (clerk-cmd-chat clerk message #:key direct-obj)
814 (match (slot-ref clerk 'state)
816 (<- (message-from message) 'tell
817 #:text clerk-general-helpful-line))
819 (<- (message-from message) 'tell
823 (random-choice clerk-slacking-complaints)
826 (define (clerk-cmd-ask-incomplete clerk message . _)
827 (<- (message-from message) 'tell
828 #:text "The clerk says, \"Ask about what?\"\n"))
830 (define clerk-doesnt-know-text
831 "The clerk apologizes and says she doesn't know about that topic.\n")
833 (define* (clerk-cmd-ask clerk message #:key indir-obj
835 (match (slot-ref clerk 'state)
837 (match (assoc indir-obj clerk-help-topics)
839 (<- (message-from message) 'tell
841 (string-append "The clerk clears her throat and says:\n \""
845 (<- (message-from message) 'tell
846 #:text clerk-doesnt-know-text))))
848 (<- (message-from message) 'tell
849 #:text "The clerk says, \"Sorry, I'm on my break.\"\n"))))
851 (define* (clerk-act-be-summoned clerk message #:key who-summoned)
852 (match (slot-ref clerk 'state)
854 (<- who-summoned 'tell
856 "The clerk tells you as politely as she can that she's already here,
857 so there's no need to ring the bell.\n"))
859 (<- (gameobj-loc clerk) 'tell-room
861 "The clerk's ears perk up, she stamps out a cigarette, and she
862 runs out of the room!\n")
863 (gameobj-set-loc! clerk (dyn-ref clerk 'lobby))
864 (slot-set! clerk 'patience 8)
865 (slot-set! clerk 'state 'on-duty)
866 (<- (gameobj-loc clerk) 'tell-room
869 " Suddenly, a uniformed woman rushes into the room! She's wearing a
870 badge that says \"Desk Clerk\".
871 \"Hello, yes,\" she says between breaths, \"welcome to Hotel Bricabrac!
872 We look forward to your stay. If you'd like help getting acclimated,
873 feel free to ask me. For example, 'ask clerk about changing name'.
874 You can ask me about the following:
875 " clerk-knows-about ".\"\n")))))
877 (define* (clerk-cmd-dismiss clerk message . _)
879 (mbody-val (<-wait (message-from message) 'get-name)))
880 (match (slot-ref clerk 'state)
882 (<- (gameobj-loc clerk) 'tell-room
884 (format #f "\"Thanks ~a!\" says the clerk. \"I have somewhere I need to be.\"
885 The clerk leaves the room in a hurry.\n"
887 #:exclude (actor-id clerk))
888 (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
889 (slot-set! clerk 'state 'slacking)
890 (<- (gameobj-loc clerk) 'tell-room
891 #:text clerk-return-to-slacking-text
892 #:exclude (actor-id clerk)))
894 (<- (message-from message) 'tell
895 #:text "The clerk sternly asks you to not be so dismissive.\n"))))
897 (define clerk-slacking-texts
898 '("The clerk takes a long drag on her cigarette.\n"
899 "The clerk scrolls through text messages on her phone.\n"
900 "The clerk coughs a few times.\n"
901 "The clerk checks her watch and justifies a few more minutes outside.\n"
902 "The clerk fumbles around for a lighter.\n"
903 "The clerk sighs deeply and exhaustedly.\n"
904 "The clerk fumbles around for a cigarette.\n"))
906 (define clerk-working-impatience-texts
907 '("The clerk hums something, but you're not sure what it is."
908 "The clerk attempts to change the overhead music, but the dial seems broken."
909 "The clerk clicks around on the desk computer."
910 "The clerk scribbles an equation on a memo pad, then crosses it out."
911 "The clerk mutters something about the proprietor having no idea how to run a hotel."
912 "The clerk thumbs through a printout of some physics paper."))
914 (define clerk-slack-excuse-text
915 "The desk clerk excuses herself, but says you are welcome to ring the bell
916 if you need further help.")
918 (define clerk-return-to-slacking-text
919 "The desk clerk enters and slams the door behind her.\n")
922 (define (clerk-act-update-loop clerk message)
923 (define (tell-room text)
924 (<- (gameobj-loc clerk) 'tell-room
926 #:exclude (actor-id clerk)))
927 (define (loop-if-not-destructed)
928 (if (not (slot-ref clerk 'destructed))
929 ;; This iterates by "recursing" on itself by calling itself
930 ;; (as the message handler) again. It used to be that we had to do
931 ;; this, because there was a bug where a loop which yielded like this
932 ;; would keep growing the stack due to some parameter goofiness.
933 ;; That's no longer true, but there's an added advantage to this
934 ;; route: it's much more live hackable. If we change the definition
935 ;; of this method, the character will act differently on the next
936 ;; "tick" of the loop.
937 (<- (actor-id clerk) 'update-loop)))
938 (match (slot-ref clerk 'state)
940 (tell-room (random-choice clerk-slacking-texts))
941 (8sleep (+ (random 20) 15))
942 (loop-if-not-destructed))
944 (if (> (slot-ref clerk 'patience) 0)
945 ;; Keep working but lose patience gradually
947 (tell-room (random-choice clerk-working-impatience-texts))
948 (slot-set! clerk 'patience (- (slot-ref clerk 'patience)
950 (8sleep (+ (random 60) 40))
951 (loop-if-not-destructed))
954 (tell-room clerk-slack-excuse-text)
955 ;; back bto the break room
956 (gameobj-set-loc! clerk (dyn-ref clerk 'break-room))
957 (tell-room clerk-return-to-slacking-text)
958 ;; annnnnd back to slacking
959 (slot-set! clerk 'state 'slacking)
960 (8sleep (+ (random 30) 15))
961 (loop-if-not-destructed))))))
968 #:name "Employee Break Room"
969 #:desc " This is less a room and more of an outdoor wire cage. You get
970 a bit of a view of the brick exterior of the building, and a crisp wind blows,
971 whistling, through the openings of the fenced area. Partly smoked cigarettes
972 and various other debris cover the floor.
973 Through the wires you can see... well... hm. It looks oddly like
974 the scenery tapers off nothingness. But that can't be right, can it?"
978 #:to 'smoking-parlor)))
979 ('break-room:desk-clerk
980 <desk-clerk> 'break-room
981 #:name "the hotel desk clerk"
982 #:desc " The hotel clerk is wearing a neatly pressed uniform bearing the
983 hotel insignia. She appears to be rather exhausted."
984 #:goes-by '("hotel desk clerk" "clerk" "desk clerk"))
986 <gameobj> 'break-room
989 #:desc "As you stare into the void, the void stares back into you."
990 #:goes-by '("void" "abyss" "nothingness" "scenery"))
992 <gameobj> 'break-room
994 #:name "break room cage"
995 #:desc "It's a mostly-cubical wire mesh surrounding the break area.
996 You can see through the gaps, but they're too small to put more than a
997 couple of fingers through. There appears to be some wear and tear to
998 the paint, but the wires themselves seem to be unusually sturdy."
999 #:goes-by '("fence" "cage" "wire cage"))))
1003 ;;; Ennpie's Sea Lounge
1004 ;;; -------------------
1010 ;; Our computer and hard drive are based off the PDP-11 and the RL01 /
1011 ;; RL02 disk drives. However we increment both by .5 (a true heresy)
1012 ;; to distinguish both from the real thing.
1014 (define-actor <hard-drive> (<gameobj>)
1015 ((cmd-put-in hard-drive-insert)
1016 (cmd-push-button hard-drive-push-button)
1017 (get-state hard-drive-act-get-state))
1018 (commands #:allocation #:each-subclass
1019 #:init-thunk (build-commands
1020 ("insert" ((prep-indir-command cmd-put-in
1021 '("in" "inside" "into"))))
1022 (("press" "push") ((prep-indir-command cmd-push-button)))))
1023 ;; the state moves from: empty -> with-disc -> loading -> ready
1024 (state #:init-value 'empty
1027 (define (hard-drive-act-get-state hard-drive message)
1028 (<-reply message (.state hard-drive)))
1030 (define* (hard-drive-desc hard-drive #:optional whos-looking)
1031 `((p "The hard drive is labeled \"RL02.5\". It's a little under a meter tall.")
1032 (p "There is a slot where a disk platter could be inserted, "
1033 ,(if (eq? (.state hard-drive) 'empty)
1034 "which is currently empty"
1035 "which contains a glowing platter")
1036 ". There is a LOAD button "
1037 ,(if (member (.state hard-drive) '(empty with-disc))
1039 "which is pressed in and unlit")
1040 ". There is a READY indicator "
1041 ,(if (eq? (.state hard-drive) 'ready)
1044 ,(if (member (.state hard-drive) '(loading ready))
1045 " The machine emits a gentle whirring noise."
1048 (define* (hard-drive-push-button gameobj message
1049 #:key direct-obj indir-obj preposition
1050 (player (message-from message)))
1051 (define (tell-room text)
1052 (<-wait (gameobj-loc gameobj) 'tell-room
1054 (define (tell-room-excluding-player text)
1055 (<-wait (gameobj-loc gameobj) 'tell-room
1059 ((ci-member direct-obj '("button" "load button" "load"))
1060 (tell-room-excluding-player
1061 `(,(mbody-val (<-wait player 'get-name))
1062 " presses the button on the hard disk."))
1064 #:text "You press the button on the hard disk.")
1066 (case (.state gameobj)
1068 ;; I have no idea what this drive did when you didn't have a platter
1069 ;; in it and pressed load, but I know there was a FAULT button.
1070 (tell-room "You hear some movement inside the hard drive...")
1073 '("... but then the FAULT button blinks a couple times. "
1074 "What could be missing?")))
1076 (set! (.state gameobj) 'loading)
1077 (tell-room "The hard disk begins to spin up!")
1079 (set! (.state gameobj) 'ready)
1080 (tell-room "The READY light turns on!"))
1083 #:text '("Pressing the button does nothing right now, "
1084 "but it does feel satisfying.")))))
1087 #:text '("How could you think of pressing anything else "
1088 "but that tantalizing button right in front of you?")))))
1090 (define* (hard-drive-insert gameobj message
1091 #:key direct-obj indir-obj preposition
1092 (player (message-from message)))
1093 (define our-name (slot-ref gameobj 'name))
1097 (for-each (lambda (occupant)
1098 (define goes-by (mbody-val (<-wait occupant 'goes-by)))
1099 (when (ci-member direct-obj goes-by)
1101 (mbody-val (<-wait player 'get-occupants)))
1107 #:text `("You don't seem to have any such " ,direct-obj " to put "
1108 ,preposition " " ,our-name ".")))
1109 ((not (mbody-val (<-wait this-thing 'get-prop 'hd-platter?)))
1111 #:text `("It wouldn't make sense to put "
1112 ,(mbody-val (<-wait this-thing 'get-name))
1113 " " ,preposition " " ,our-name ".")))
1114 ((not (eq? (.state gameobj) 'empty))
1116 #:text "The disk drive already has a platter in it."))
1118 (set! (.state gameobj) 'with-disc)
1120 #:text '((p "You insert the glowing disc into the drive.")
1121 (p "The LOAD button begins to glow."))))))
1124 (define-actor <computer> (<gameobj>)
1125 ((cmd-run-program computer-run-program)
1126 (cmd-run-what (lambda (gameobj message . _)
1127 (<- (message-from message) 'tell
1128 #:text '("The computer is already running, and a program appears "
1130 "you mean to \"run the program on the computer\"")))))
1131 (commands #:allocation #:each-subclass
1132 #:init-thunk (build-commands
1133 ("run" ((prep-indir-command cmd-run-program
1135 (direct-command cmd-run-what))))))
1137 (define* (computer-run-program gameobj message
1138 #:key direct-obj indir-obj preposition
1139 (player (message-from message)))
1141 (mbody-val (<-wait (dyn-ref gameobj 'computer-room:hard-drive) 'get-state)))
1142 (define (tell-room text)
1143 (<-wait (gameobj-loc gameobj) 'tell-room
1145 (define (tell-room-excluding-player text)
1146 (<-wait (gameobj-loc gameobj) 'tell-room
1149 (define (tell-player text)
1150 (<-wait player 'tell
1153 ((ci-member direct-obj '("program"))
1154 (tell-room-excluding-player
1155 `(,(mbody-val (<-wait player 'get-name))
1156 " runs the program loaded on the computer..."))
1157 (tell-player "You run the program on the computer...")
1160 ((not (eq? (hd-state) 'ready))
1161 (tell-room '("... but it errors out. "
1162 "It seems to be complaining about a " (b "DISK ERROR!")
1163 ". It looks like it is missing some essential software.")))
1165 (<- (dyn-ref gameobj 'computer-room:floor-panel) 'open-up))))))
1169 (define-actor <floor-panel> (<gameobj>)
1170 ;; TODO: Add "open" verb, since obviously people will try that
1171 ((open? (lambda (panel message)
1172 (<-reply message (slot-ref panel 'open))))
1173 (open-up floor-panel-open-up))
1174 (open #:init-value #f))
1176 (define (floor-panel-open-up panel message)
1177 (if (slot-ref panel 'open)
1178 (<- (gameobj-loc panel) 'tell-room
1179 #:text '("You hear some gears grind around the hinges of the "
1180 "floor panel, but it appears to already be open."))
1182 (slot-set! panel 'open #t)
1183 (<- (gameobj-loc panel) 'tell-room
1184 #:text '("You hear some gears grind, as the metal panel on "
1185 "the ground opens and reveals a stairwell going down!")))))
1187 (define* (floor-panel-desc panel #:optional whos-looking)
1188 `("It's a large metal panel on the floor in the middle of the room. "
1189 ,(if (slot-ref panel 'open)
1190 '("It's currently wide open, revealing a spiraling staircase "
1191 "which descends into darkness.")
1192 '("It's currently closed shut, but there are clearly hinges, and "
1193 "it seems like there is a mechanism which probably opens it via "
1194 "some automation. What could be down there?"))))
1196 (define computer-room
1200 #:name "Computer Room"
1201 #:desc (lambda (gameobj whos-looking)
1203 (mbody-val (<-wait (dyn-ref gameobj 'computer-room:floor-panel)
1205 `((p "A sizable computer cabinet covers a good portion of the left
1206 wall. It emits a pleasant hum which covers the room like a warm blanket.
1207 Connected to a computer is a large hard drive.")
1208 (p "On the floor is a large steel panel. "
1210 '("It is wide open, exposing a spiral staircase "
1211 "which descends into darkness.")
1212 '("It is closed, but it has hinges which "
1213 "suggest it could be opened.")))))
1220 #:to 'underground-lab
1222 (lambda (exit room whos-exiting)
1224 (mbody-val (<-wait (dyn-ref room 'computer-room:floor-panel)
1227 (values #t "You descend the spiral staircase.")
1228 (values #f '("You'd love to go down, but the only way "
1229 "through is through that metal panel, "
1230 "which seems closed.")))))))
1231 ('computer-room:hard-drive
1232 <hard-drive> 'computer-room
1233 #:name "the hard drive"
1234 #:desc (wrap-apply hard-drive-desc)
1235 #:goes-by '("hard drive" "drive" "hard disk"))
1236 ('computer-room:computer
1237 <computer> 'computer-room
1238 #:name "the computer"
1239 #:desc '((p "It's a coat closet sized computer labeled \"PDP-11.5\". ")
1240 (p "The computer is itself turned on, and it looks like it is "
1241 "all set up for you to run a program on it."))
1242 #:goes-by '("computer"))
1243 ('computer-room:floor-panel
1244 <floor-panel> 'computer-room
1245 #:name "a floor panel"
1246 #:desc (wrap-apply floor-panel-desc)
1248 #:goes-by '("floor panel" "panel"))))
1251 ;;; * UNDERGROUND SECTION OF THE GAME! *
1256 (define underground-map-text
1261 | [8sync Hive] |======' '-_____
1267 .--------------. \\ /
1268 | [Guile Async | .-------+------.
1269 | Museum] | | [Lab] #!#| .-------------.
1270 | @| | MM | |[Federation |
1271 | & ^ +##+@ || < +##| Station]|
1273 | & # | |*You-Are-Here*| '-------------'
1274 | # ^ | #+-------+------'
1275 '-------+------' # #
1279 |@?+%? +#### | ^ f## |
1285 (define underground-lab
1289 #:name "Underground laboratory"
1290 #:desc '("This appears to be some sort of underground laboratory. "
1297 (lambda (exit room whos-exiting)
1298 (values #t "You climb the spiral staircase.")))))
1302 ('underground-lab:map
1303 <readable> 'underground-lab
1304 #:name "the underground map"
1305 #:desc '("This appears to be a map of the surrounding area. "
1306 "You could read it if you want to.")
1307 #:read-text `(pre ,underground-map-text)
1308 #:goes-by '("map" "underground map" "lab map"))))
1319 (append lobby grand-hallway smoking-parlor
1320 playroom break-room computer-room underground-lab))
1322 ;; TODO: Provide command line args
1323 (define (run-game . args)
1324 (run-demo (game-spec) 'lobby #:repl-server #t))