| 1 |
/* Copyright (c) 1988-2000 by Michael J. Roberts. All Rights Reserved. */ |
| 2 |
/* |
| 3 |
adv.t - standard adventure definitions for TADS games |
| 4 |
Version 2.5.17 |
| 5 |
|
| 6 |
This file is part of TADS: The Text Adventure Development System. |
| 7 |
Please see the file LICENSE.TAD (which should be part of the TADS |
| 8 |
distribution) for information on copying and using TADS. |
| 9 |
|
| 10 |
You may modify and use this file in any way you want, provided that |
| 11 |
if you redistribute modified copies of this file in source form, the |
| 12 |
copies must include the original copyright notice (including this |
| 13 |
paragraph), and must be clearly marked as modified from the original |
| 14 |
version. |
| 15 |
|
| 16 |
This file defines the basic classes and functions used by most TADS |
| 17 |
adventure games. It is generally #include'd at the start of each game |
| 18 |
source file. |
| 19 |
*/ |
| 20 |
|
| 21 |
/* parse adv.t using normal TADS operators */ |
| 22 |
#pragma C- |
| 23 |
|
| 24 |
|
| 25 |
/* ------------------------------------------------------------------------ */ |
| 26 |
/* |
| 27 |
* Constants for parser status codes. These codes are passed to |
| 28 |
* parseError and parseErrorParam to indicate which message these |
| 29 |
* routines should display. In addition, these codes are returned by |
| 30 |
* parserResolveObjects. |
| 31 |
*/ |
| 32 |
|
| 33 |
#define PRS_SUCCESS 0 /* success */ |
| 34 |
|
| 35 |
#define PRSERR_BAD_PUNCT 1 /* I don't understand the punctuation */ |
| 36 |
#define PRSERR_UNK_WORD 2 /* I don't know the word */ |
| 37 |
#define PRSERR_TOO_MANY_OBJS 3 /* The word refers to too many objects */ |
| 38 |
#define PRSERR_ALL_OF 4 /* You left something out after "all of" */ |
| 39 |
#define PRSERR_BOTH_OF 5 /* You left something out after "both of" */ |
| 40 |
#define PRSERR_OF_NOUN 6 /* Expected a noun after "of" */ |
| 41 |
#define PRSERR_ART_NOUN 7 /* An article must be followed by a noun */ |
| 42 |
#define PRSERR_DONT_SEE_ANY 9 /* I don't see any %s here */ |
| 43 |
#define PRSERR_TOO_MANY_OBJS2 10 /* Referring to too many objects with %s */ |
| 44 |
#define PRSERR_TOO_MANY_OBJS3 11 /* Referring to too many objects */ |
| 45 |
#define PRSERR_ONE_ACTOR 12 /* You can only speak to one person */ |
| 46 |
#define PRSERR_DONT_KNOW_REF 13 /* Don't know what you're referring to */ |
| 47 |
#define PRSERR_DONT_KNOW_REF2 14 /* Don't know what you're referring to */ |
| 48 |
#define PRSERR_DONT_SEE_REF 15 /* Don't see what you're referring to */ |
| 49 |
#define PRSERR_DONT_SEE_ANY2 16 /* You don't see any %s here */ |
| 50 |
#define PRSERR_NO_MULTI_IO 25 /* can't use multiple indirect objects */ |
| 51 |
#define PRSERR_NO_AGAIN 26 /* There's no command to repeat */ |
| 52 |
#define PRSERR_BAD_AGAIN 27 /* You can't repeat that command */ |
| 53 |
#define PRSERR_NO_MULTI 28 /* can't use multiple objects w/this cmd */ |
| 54 |
#define PRSERR_ANY_OF 29 /* You left something out after "any of" */ |
| 55 |
#define PRSERR_ONLY_SEE 30 /* I only see %d of those */ |
| 56 |
#define PRSERR_CANT_TALK 31 /* You can't talk to that */ |
| 57 |
#define PRSERR_INT_PPC_INV 32 /* internal: invalid preparseCmd list */ |
| 58 |
#define PRSERR_INT_PPC_LONG 33 /* internal: preparseCmd command too long */ |
| 59 |
#define PRSERR_INT_PPC_LOOP 34 /* internal: preparseCmd loop */ |
| 60 |
#define PRSERR_DONT_SEE_ANY_MORE 38 /* You don't see that here any more */ |
| 61 |
#define PRSERR_DONT_SEE_THAT 39 /* You don't see that here */ |
| 62 |
|
| 63 |
#define PRSERR_NO_NEW_NUM 40 /* can't create new numbered object */ |
| 64 |
#define PRSERR_BAD_DIS_STAT 41 /* invalid status from disambigXobj */ |
| 65 |
#define PRSERR_EMPTY_DISAMBIG 42 /* empty response to disambig query */ |
| 66 |
#define PRSERR_DISAMBIG_RETRY 43 /* retry object disambig response as cmd */ |
| 67 |
#define PRSERR_AMBIGUOUS 44 /* objects still ambiguous */ |
| 68 |
#define PRSERR_OOPS_UPDATE 45 /* command corrected by "oops" */ |
| 69 |
|
| 70 |
#define PRSERR_TRY_AGAIN 100 /* Let's try it again... */ |
| 71 |
#define PRSERR_WHICH_PFX 101 /* Which %s do you mean... */ |
| 72 |
#define PRSERR_WHICH_COMMA 102 /* (comma) */ |
| 73 |
#define PRSERR_WHICH_OR 103 /* ...or... */ |
| 74 |
#define PRSERR_WHICH_QUESTION 104 /* (question mark) */ |
| 75 |
|
| 76 |
#define PRSERR_DONTKNOW_PFX 110 /* I don't know how to... */ |
| 77 |
#define PRSERR_DONTKNOW_SPC 111 /* (space) */ |
| 78 |
#define PRSERR_DONTKNOW_ANY 112 /* ...anything */ |
| 79 |
#define PRSERR_DONTKNOW_TO 113 /* ...to... */ |
| 80 |
#define PRSERR_DONTKNOW_SPC2 114 /* (space) */ |
| 81 |
#define PRSERR_DONTKNOW_END 115 /* (period) */ |
| 82 |
|
| 83 |
#define PRSERR_MULTI 120 /* (colon) for multiple-object prefix */ |
| 84 |
|
| 85 |
#define PRSERR_ASSUME_OPEN 130 /* (open paren) for defaulted objects */ |
| 86 |
#define PRSERR_ASSUME_CLOSE 131 /* (close paren) */ |
| 87 |
#define PRSERR_ASSUME_SPC 132 /* (space) */ |
| 88 |
|
| 89 |
#define PRSERR_WHAT_PFX 140 /* What do you want to... */ |
| 90 |
#define PRSERR_WHAT_IT 141 /* ...it... */ |
| 91 |
#define PRSERR_WHAT_TO 142 /* ...to... */ |
| 92 |
#define PRSERR_WHAT_END 143 /* (question mark) */ |
| 93 |
#define PRSERR_WHAT_THEM 144 /* ...them... */ |
| 94 |
#define PRSERR_WHAT_HIM 145 /* ...him... */ |
| 95 |
#define PRSERR_WHAT_HER 146 /* ...her... */ |
| 96 |
#define PRSERR_WHAT_THEM2 147 /* ...them... */ |
| 97 |
#define PRSERR_WHAT_PFX2 148 /* What do you want... */ |
| 98 |
#define PRSERR_WHAT_TOSPC 149 /* ...to... */ |
| 99 |
|
| 100 |
#define PRSERR_MORE_SPECIFIC 160 /* you'll have to be more specific */ |
| 101 |
|
| 102 |
#define PRSERR_NOREACH_MULTI 200 /* (colon) for prefixing unreachables */ |
| 103 |
|
| 104 |
|
| 105 |
/* ------------------------------------------------------------------------ */ |
| 106 |
/* |
| 107 |
* constants for the event codes returned by the inputevent() intrinsic |
| 108 |
* function |
| 109 |
*/ |
| 110 |
#define INPUT_EVENT_KEY 1 |
| 111 |
#define INPUT_EVENT_TIMEOUT 2 |
| 112 |
#define INPUT_EVENT_HREF 3 |
| 113 |
#define INPUT_EVENT_NOTIMEOUT 4 |
| 114 |
#define INPUT_EVENT_EOF 5 |
| 115 |
|
| 116 |
/* |
| 117 |
* constants for inputdialog() |
| 118 |
*/ |
| 119 |
#define INDLG_OK 1 |
| 120 |
#define INDLG_OKCANCEL 2 |
| 121 |
#define INDLG_YESNO 3 |
| 122 |
#define INDLG_YESNOCANCEL 4 |
| 123 |
|
| 124 |
#define INDLG_ICON_NONE 0 |
| 125 |
#define INDLG_ICON_WARNING 1 |
| 126 |
#define INDLG_ICON_INFO 2 |
| 127 |
#define INDLG_ICON_QUESTION 3 |
| 128 |
#define INDLG_ICON_ERROR 4 |
| 129 |
|
| 130 |
#define INDLG_LBL_OK 1 |
| 131 |
#define INDLG_LBL_CANCEL 2 |
| 132 |
#define INDLG_LBL_YES 3 |
| 133 |
#define INDLG_LBL_NO 4 |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
/* |
| 138 |
* constants for gettime() type codes |
| 139 |
*/ |
| 140 |
#define GETTIME_DATE_AND_TIME 1 |
| 141 |
#define GETTIME_TICKS 2 |
| 142 |
|
| 143 |
/* |
| 144 |
* constants for askfile() prompt type codes |
| 145 |
*/ |
| 146 |
#define ASKFILE_PROMPT_OPEN 1 /* open an existing file for reading */ |
| 147 |
#define ASKFILE_PROMPT_SAVE 2 /* save to the file */ |
| 148 |
|
| 149 |
/* |
| 150 |
* constants for askfile() flags |
| 151 |
*/ |
| 152 |
#define ASKFILE_EXT_RESULT 1 /* extended result codes */ |
| 153 |
|
| 154 |
/* |
| 155 |
* askfile() return codes - these are returned in the first element of |
| 156 |
* the list returned from askfile() when ASKFILE_EXT_RESULT is used in |
| 157 |
* the 'flags' parameter |
| 158 |
*/ |
| 159 |
#define ASKFILE_SUCCESS 0 /* success - 2nd list element is filename */ |
| 160 |
#define ASKFILE_FAILURE 1 /* an error occurred asking for a file */ |
| 161 |
#define ASKFILE_CANCEL 2 /* player canceled the file selector */ |
| 162 |
|
| 163 |
|
| 164 |
/* |
| 165 |
* constants for askfile() file type codes |
| 166 |
*/ |
| 167 |
#define FILE_TYPE_GAME 0 /* a game data file (.gam) */ |
| 168 |
#define FILE_TYPE_SAVE 1 /* a saved game (.sav) */ |
| 169 |
#define FILE_TYPE_LOG 2 /* a transcript (log) file */ |
| 170 |
#define FILE_TYPE_DATA 4 /* general data file (used for fopen()) */ |
| 171 |
#define FILE_TYPE_CMD 5 /* command input file */ |
| 172 |
#define FILE_TYPE_TEXT 7 /* text file */ |
| 173 |
#define FILE_TYPE_BIN 8 /* binary data file */ |
| 174 |
#define FILE_TYPE_UNKNOWN 11 /* unknown file type */ |
| 175 |
|
| 176 |
/* |
| 177 |
* constants for execCommand() flags |
| 178 |
*/ |
| 179 |
#define EC_HIDE_SUCCESS 1 /* hide success messages */ |
| 180 |
#define EC_HIDE_ERROR 2 /* hide error messages */ |
| 181 |
#define EC_SKIP_VALIDDO 4 /* skip direct object validation */ |
| 182 |
#define EC_SKIP_VALIDIO 8 /* skip indirect object validation */ |
| 183 |
|
| 184 |
/* |
| 185 |
* constants for execCommand() return codes |
| 186 |
*/ |
| 187 |
#define EC_SUCCESS 0 /* successful completion */ |
| 188 |
#define EC_EXIT 1013 /* "exit" executed */ |
| 189 |
#define EC_ABORT 1014 /* "abort" executed */ |
| 190 |
#define EC_ASKDO 1015 /* "askdo" executed */ |
| 191 |
#define EC_ASKIO 1016 /* "askio" executed */ |
| 192 |
#define EC_EXITOBJ 1019 /* "exitobj" executed */ |
| 193 |
#define EC_INVAL_SYNTAX 1200 /* invalid sentence structure */ |
| 194 |
#define EC_VERDO_FAILED 1201 /* verDoVerb failed */ |
| 195 |
#define EC_VERIO_FAILED 1202 /* verIoVerb failed */ |
| 196 |
#define EC_NO_VERDO 1203 /* no verDoVerb method defined */ |
| 197 |
#define EC_NO_VERIO 1204 /* no verIoVerb method defined */ |
| 198 |
#define EC_INVAL_DOBJ 1205 /* direct object validation failed */ |
| 199 |
#define EC_INVAL_IOBJ 1206 /* indirect object validation failed */ |
| 200 |
|
| 201 |
/* |
| 202 |
* constants for parserGetObj object codes |
| 203 |
*/ |
| 204 |
#define PO_ACTOR 1 /* actor */ |
| 205 |
#define PO_VERB 2 /* deepverb object */ |
| 206 |
#define PO_DOBJ 3 /* direct object */ |
| 207 |
#define PO_PREP 4 /* preposition object (introducing indirect object) */ |
| 208 |
#define PO_IOBJ 5 /* indirect object */ |
| 209 |
#define PO_IT 6 /* get the "it" object */ |
| 210 |
#define PO_HIM 7 /* get the "him" object */ |
| 211 |
#define PO_HER 8 /* get the "her" object */ |
| 212 |
#define PO_THEM 9 /* get the "them" object */ |
| 213 |
|
| 214 |
/* |
| 215 |
* constants for parseNounPhrase return codes |
| 216 |
*/ |
| 217 |
#define PNP_ERROR 1 /* noun phrase syntax error */ |
| 218 |
#define PNP_USE_DEFAULT 2 /* use default processing */ |
| 219 |
|
| 220 |
/* |
| 221 |
* constants for disambigDobj and disambigIobj status codes |
| 222 |
*/ |
| 223 |
#define DISAMBIG_CONTINUE 1 /* continue disambiguation for this list */ |
| 224 |
#define DISAMBIG_DONE 2 /* list is fully resolved */ |
| 225 |
#define DISAMBIG_ERROR 3 /* disambiguation failed; abort command */ |
| 226 |
#define DISAMBIG_PARSE_RESP 4 /* parse interactive response string */ |
| 227 |
#define DISAMBIG_PROMPTED 5 /* prompted for response, but didn't read it */ |
| 228 |
|
| 229 |
/* |
| 230 |
* Parser word types. These values may be combined, since a given word |
| 231 |
* may appear in the dictionary with multiple types. To test for a |
| 232 |
* particular type, use the bitwise AND operator: |
| 233 |
* |
| 234 |
* ((typ & PRSTYP_NOUN) != 0). |
| 235 |
*/ |
| 236 |
#define PRSTYP_ARTICLE 1 /* the, a, an */ |
| 237 |
#define PRSTYP_ADJ 2 /* adjective */ |
| 238 |
#define PRSTYP_NOUN 4 /* noun */ |
| 239 |
#define PRSTYP_PREP 8 /* preposition */ |
| 240 |
#define PRSTYP_VERB 16 /* verb */ |
| 241 |
#define PRSTYP_SPEC 32 /* special words - "of", ",", ".", etc. */ |
| 242 |
#define PRSTYP_PLURAL 64 /* plural */ |
| 243 |
#define PRSTYP_UNKNOWN 128 /* word is not in dictionary */ |
| 244 |
|
| 245 |
/* |
| 246 |
* Parser noun-phrase flags. These values may be combined; to test for |
| 247 |
* a single flag, use the bitwise AND operator: |
| 248 |
* |
| 249 |
* ((flag & PRSFLG_UNKNOWN) != 0) |
| 250 |
*/ |
| 251 |
#define PRSFLG_ALL 1 /* "all" */ |
| 252 |
#define PRSFLG_EXCEPT 2 /* "except" or "but" (used in "all except ...") */ |
| 253 |
#define PRSFLG_IT 4 /* "it" */ |
| 254 |
#define PRSFLG_THEM 8 /* "them" */ |
| 255 |
#define PRSFLG_NUM 16 /* a number */ |
| 256 |
#define PRSFLG_COUNT 32 /* noun phrase uses a count - "3 coins" */ |
| 257 |
#define PRSFLG_PLURAL 64 /* noun phrase is a plural usage - "the coins" */ |
| 258 |
#define PRSFLG_ANY 128 /* noun phrase uses "any" - "any coin" */ |
| 259 |
#define PRSFLG_HIM 256 /* "him" */ |
| 260 |
#define PRSFLG_HER 512 /* "her" */ |
| 261 |
#define PRSFLG_STR 1024 /* a quoted string */ |
| 262 |
#define PRSFLG_UNKNOWN 2048 /* noun phrase contains an unknown word */ |
| 263 |
#define PRSFLG_ENDADJ 4096 /* noun phrase ends in an adjective */ |
| 264 |
#define PRSFLG_TRUNC 8192 /* noun phrase uses a truncated word */ |
| 265 |
|
| 266 |
|
| 267 |
/* |
| 268 |
* Constants for parserResolveObjects usage codes |
| 269 |
*/ |
| 270 |
#define PRO_RESOLVE_DOBJ 1 /* direct object */ |
| 271 |
#define PRO_RESOLVE_IOBJ 2 /* indirect object */ |
| 272 |
#define PRO_RESOLVE_ACTOR 3 /* actor */ |
| 273 |
|
| 274 |
|
| 275 |
/* |
| 276 |
* Constants for result codes from restore() |
| 277 |
*/ |
| 278 |
#define RESTORE_SUCCESS 0 /* success */ |
| 279 |
#define RESTORE_FILE_NOT_FOUND 1 /* file not found */ |
| 280 |
#define RESTORE_NOT_SAVE_FILE 2 /* not a saved game file */ |
| 281 |
#define RESTORE_BAD_FMT_VSN 3 /* incompatible file format version */ |
| 282 |
#define RESTORE_BAD_GAME_VSN 4 /* file saved by another game or version */ |
| 283 |
#define RESTORE_READ_ERROR 5 /* error reading from the file */ |
| 284 |
#define RESTORE_NO_PARAM_FILE 6 /* no parameter file for restore(nil) */ |
| 285 |
|
| 286 |
/* |
| 287 |
* Constants for defined() function. When passed as the optional third |
| 288 |
* argument to defined(), these flags specify what type of information |
| 289 |
* is returned from defined(). |
| 290 |
* |
| 291 |
* By default, defined(obj, &prop) returns true if the property is |
| 292 |
* defined or inherited by the object, nil if not. The DEFINED_ANY flag |
| 293 |
* has the same effect. |
| 294 |
* |
| 295 |
* When DEFINED_DIRECTLY is used, the function returns true only if the |
| 296 |
* property is directly defined by the object, not merely inherited from |
| 297 |
* a superclass. |
| 298 |
* |
| 299 |
* When DEFINED_INHERITS is used, the function returns true only if the |
| 300 |
* property is inherited from a superclass, and returns nil if the |
| 301 |
* property isn't defined at all or is defined directly by the object. |
| 302 |
* |
| 303 |
* When DEFINED_GET_CLASS is used, the function returns the object that |
| 304 |
* actually defines the property; this will be the object itself if the |
| 305 |
* object overrides the property, otherwise it will be the superclass |
| 306 |
* from which the object inherits the property. The function returns |
| 307 |
* nil if the property isn't defined or inherited at all for the object. |
| 308 |
*/ |
| 309 |
#define DEFINED_ANY 1 /* default: property is defined or inherited */ |
| 310 |
#define DEFINED_DIRECTLY 2 /* defined directly by the object */ |
| 311 |
#define DEFINED_INHERITS 3 /* inherited, not defined directly */ |
| 312 |
#define DEFINED_GET_CLASS 4 /* get the defining class */ |
| 313 |
|
| 314 |
/* |
| 315 |
* Constants for datatype() and proptype() |
| 316 |
*/ |
| 317 |
#define DTY_NUMBER 1 /* number */ |
| 318 |
#define DTY_OBJECT 2 /* object */ |
| 319 |
#define DTY_SSTRING 3 /* single-quoted string value */ |
| 320 |
#define DTY_NIL 5 /* nil */ |
| 321 |
#define DTY_CODE 6 /* method code */ |
| 322 |
#define DTY_LIST 7 /* list */ |
| 323 |
#define DTY_TRUE 8 /* true */ |
| 324 |
#define DTY_DSTRING 9 /* double-quoted string */ |
| 325 |
#define DTY_FUNCPTR 10 /* function pointer */ |
| 326 |
#define DTY_PROP 13 /* property pointer */ |
| 327 |
|
| 328 |
|
| 329 |
/* ------------------------------------------------------------------------ */ |
| 330 |
/* |
| 331 |
* Define compound prepositions. Since prepositions that appear in |
| 332 |
* parsed sentences must be single words, we must define any logical |
| 333 |
* prepositions that consist of two or more words here. Note that |
| 334 |
* only two words can be pasted together at once; to paste more, use |
| 335 |
* a second step. For example, 'out from under' must be defined in |
| 336 |
* two steps: |
| 337 |
* |
| 338 |
* compoundWord 'out' 'from' 'outfrom'; |
| 339 |
* compoundWord 'outfrom' 'under' 'outfromunder'; |
| 340 |
* |
| 341 |
* Listed below are the compound prepositions that were built in to |
| 342 |
* version 1.0 of the TADS run-time. |
| 343 |
*/ |
| 344 |
compoundWord 'on' 'to' 'onto'; /* on to --> onto */ |
| 345 |
compoundWord 'in' 'to' 'into'; /* in to --> into */ |
| 346 |
compoundWord 'in' 'between' 'inbetween'; /* and so forth */ |
| 347 |
compoundWord 'down' 'in' 'downin'; |
| 348 |
compoundWord 'down' 'on' 'downon'; |
| 349 |
compoundWord 'up' 'on' 'upon'; |
| 350 |
compoundWord 'out' 'of' 'outof'; |
| 351 |
compoundWord 'off' 'of' 'offof'; |
| 352 |
compoundWord 'i' 'wide' 'i_wide'; |
| 353 |
compoundWord 'invent' 'wide' 'i_wide'; |
| 354 |
compoundWord 'inventory' 'wide' 'i_wide'; |
| 355 |
compoundWord 'i' 'tall' 'i_tall'; |
| 356 |
compoundWord 'invent' 'tall' 'i_tall'; |
| 357 |
compoundWord 'inventory' 'tall' 'i_tall'; |
| 358 |
; |
| 359 |
|
| 360 |
/* |
| 361 |
* Format strings: these associate keywords with properties. When |
| 362 |
* a keyword appears in output between percent signs (%), the matching |
| 363 |
* property of the current command's actor is evaluated and substituted |
| 364 |
* for the keyword (and the percent signs). For example, if you have: |
| 365 |
* |
| 366 |
* formatstring 'you' fmtYou; |
| 367 |
* |
| 368 |
* and the command being processed is: |
| 369 |
* |
| 370 |
* fred, pick up the paper |
| 371 |
* |
| 372 |
* and the "fred" actor has fmtYou = "he", and this string is output: |
| 373 |
* |
| 374 |
* "%You% can't see that here." |
| 375 |
* |
| 376 |
* Then the actual output is: "He can't see that here." |
| 377 |
* |
| 378 |
* The format strings are chosen to look like normal output (minus the |
| 379 |
* percent signs, of course) when the actor is the player character (Me). |
| 380 |
*/ |
| 381 |
formatstring 'you' fmtYou; |
| 382 |
formatstring 'your' fmtYour; |
| 383 |
formatstring 'you\'re' fmtYoure; |
| 384 |
formatstring 'youm' fmtYoum; |
| 385 |
formatstring 'you\'ve' fmtYouve; |
| 386 |
formatstring 's' fmtS; |
| 387 |
formatstring 'es' fmtEs; |
| 388 |
formatstring 'have' fmtHave; |
| 389 |
formatstring 'do' fmtDo; |
| 390 |
formatstring 'are' fmtAre; |
| 391 |
formatstring 'me' fmtMe; |
| 392 |
; |
| 393 |
|
| 394 |
/* |
| 395 |
* Special Word List: This list defines the special words that the |
| 396 |
* parser needs for input commands. If the list is not provided, the |
| 397 |
* parser uses the old defaults. The list below is the same as the old |
| 398 |
* defaults. Note - the words in this list must appear in the order |
| 399 |
* shown below. |
| 400 |
*/ |
| 401 |
specialWords |
| 402 |
'of', /* used in phrases such as "piece of paper" */ |
| 403 |
'and', /* conjunction for noun lists or to separate commands */ |
| 404 |
'then', /* conjunction to separate commands */ |
| 405 |
'all' = 'everything', /* refers to every accessible object */ |
| 406 |
'both', /* used with plurals, or to answer disambiguation questions */ |
| 407 |
'but' = 'except', /* used to exclude items from ALL */ |
| 408 |
'one', /* used to answer questions: "the red one" */ |
| 409 |
'ones', /* likewise for plurals: "the blue ones" */ |
| 410 |
'it' = 'there', /* refers to last single direct object used */ |
| 411 |
'them', /* refers to last direct object list */ |
| 412 |
'him', /* refers to last masculine actor mentioned */ |
| 413 |
'her', /* refers to last feminine actor mentioned */ |
| 414 |
'any' = 'either' /* pick object arbitrarily from ambiguous list */ |
| 415 |
; |
| 416 |
|
| 417 |
/* |
| 418 |
* Forward-declare functions. This is not required in most cases, |
| 419 |
* but it doesn't hurt. Providing these forward declarations ensures |
| 420 |
* that the compiler knows that we want these symbols to refer to |
| 421 |
* functions rather than objects. |
| 422 |
*/ |
| 423 |
checkDoor: function; |
| 424 |
checkReach: function; |
| 425 |
itemcnt: function; |
| 426 |
isIndistinguishable: function; |
| 427 |
sayPrefixCount: function; |
| 428 |
listcont: function; |
| 429 |
nestlistcont: function; |
| 430 |
listcontcont: function; |
| 431 |
turncount: function; |
| 432 |
addweight: function; |
| 433 |
addbulk: function; |
| 434 |
incscore: function; |
| 435 |
darkTravel: function; |
| 436 |
scoreRank: function; |
| 437 |
terminate: function; |
| 438 |
goToSleep: function; |
| 439 |
initSearch: function; |
| 440 |
reachableList: function; |
| 441 |
initRestart: function; |
| 442 |
contentsListable: function; |
| 443 |
; |
| 444 |
|
| 445 |
/* |
| 446 |
* inputline: function |
| 447 |
* |
| 448 |
* This is a simple cover function for the built-in function input(). |
| 449 |
* This cover function switches to the 'TADS-Input' font when running in |
| 450 |
* HTML mode, so that input explicitly read through this function appears |
| 451 |
* in the same input font that is used for normal command-line input. |
| 452 |
*/ |
| 453 |
inputline: function |
| 454 |
{ |
| 455 |
local ret; |
| 456 |
local html_mode; |
| 457 |
|
| 458 |
/* note whether we're in HTML mode */ |
| 459 |
html_mode := (systemInfo(__SYSINFO_SYSINFO) = true |
| 460 |
&& systemInfo(__SYSINFO_HTML_MODE)); |
| 461 |
|
| 462 |
/* if in HTML mode, switch to TADS-Input font */ |
| 463 |
if (html_mode) |
| 464 |
"<font face='TADS-Input'>"; |
| 465 |
|
| 466 |
/* read the input */ |
| 467 |
ret := input(); |
| 468 |
|
| 469 |
/* exit TADS-Input font mode if appropriate */ |
| 470 |
if (html_mode) |
| 471 |
"</font>"; |
| 472 |
|
| 473 |
/* return the line of text */ |
| 474 |
return ret; |
| 475 |
} |
| 476 |
|
| 477 |
/* |
| 478 |
* _rand: function(x) |
| 479 |
* |
| 480 |
* This is a modified version of the built-in random number generator, which |
| 481 |
* may improve upon the standard random number generator's statistical |
| 482 |
* performance in many cases. To use this replacement, simply call _rand |
| 483 |
* instead of rand in your code. |
| 484 |
*/ |
| 485 |
_rand: function(x) |
| 486 |
{ |
| 487 |
return (((rand(16*x)-1)/16)+1); |
| 488 |
} |
| 489 |
|
| 490 |
/* |
| 491 |
* initRestart - flag when a restart has occurred by setting a flag |
| 492 |
* in global. |
| 493 |
*/ |
| 494 |
initRestart: function(parm) |
| 495 |
{ |
| 496 |
global.restarting := true; |
| 497 |
} |
| 498 |
|
| 499 |
/* |
| 500 |
* checkDoor: if the door d is open, this function silently returns |
| 501 |
* the room r. Otherwise, print a message ("The door is closed.") and |
| 502 |
* return nil. |
| 503 |
*/ |
| 504 |
checkDoor: function(d, r) |
| 505 |
{ |
| 506 |
if (d.isopen) |
| 507 |
return r; |
| 508 |
else |
| 509 |
{ |
| 510 |
setit(d); |
| 511 |
caps(); d.thedesc; " <<d.isdesc>> closed. "; |
| 512 |
return nil; |
| 513 |
} |
| 514 |
} |
| 515 |
|
| 516 |
/* |
| 517 |
* checkReach: determines whether the object obj can be reached by |
| 518 |
* actor in location loc, using the verb v. This routine returns true |
| 519 |
* if obj is a special object (numObj or strObj), if obj is in actor's |
| 520 |
* inventory or actor's location, or if it's in the 'reachable' list for |
| 521 |
* loc. |
| 522 |
*/ |
| 523 |
checkReach: function(loc, actor, v, obj) |
| 524 |
{ |
| 525 |
if (obj = numObj or obj = strObj) |
| 526 |
return; |
| 527 |
if (not (actor.isCarrying(obj) or obj.isIn(actor.location))) |
| 528 |
{ |
| 529 |
if (find(loc.reachable, obj) <> nil) |
| 530 |
return; |
| 531 |
"%You% can't reach "; obj.thedesc; " from "; loc.thedesc; ". "; |
| 532 |
exit; |
| 533 |
} |
| 534 |
} |
| 535 |
|
| 536 |
/* |
| 537 |
* isIndistinguishable: function(obj1, obj2) |
| 538 |
* |
| 539 |
* Returns true if the two objects are indistinguishable for the purposes |
| 540 |
* of listing. The two objects are equivalent if they both have the |
| 541 |
* isEquivalent property set to true, they both have the same immediate |
| 542 |
* superclass, and their other listing properties match (in particular, |
| 543 |
* isworn and (islamp and islit) match for both objects). |
| 544 |
*/ |
| 545 |
isIndistinguishable: function(obj1, obj2) |
| 546 |
{ |
| 547 |
return (firstsc(obj1) = firstsc(obj2) |
| 548 |
and obj1.isworn = obj2.isworn |
| 549 |
and ((obj1.islamp and obj1.islit) |
| 550 |
= (obj2.islamp and obj2.islit))); |
| 551 |
} |
| 552 |
|
| 553 |
|
| 554 |
/* |
| 555 |
* itemcnt: function(list) |
| 556 |
* |
| 557 |
* Returns a count of the "listable" objects in list. An |
| 558 |
* object is listable (that is, it shows up in a room's description) |
| 559 |
* if its isListed property is true. This function is |
| 560 |
* useful for determining how many objects (if any) will be listed |
| 561 |
* in a room's description. Indistinguishable items are counted as |
| 562 |
* a single item (two items are indistinguishable if they both have |
| 563 |
* the same immediate superclass, and their isEquivalent properties |
| 564 |
* are both true. |
| 565 |
*/ |
| 566 |
itemcnt: function(list) |
| 567 |
{ |
| 568 |
local cnt, tot, i, obj, j; |
| 569 |
|
| 570 |
tot := length(list); |
| 571 |
for (i := 1, cnt := 0 ; i <= tot ; ++i) |
| 572 |
{ |
| 573 |
/* only consider this item if it's to be listed */ |
| 574 |
obj := list[i]; |
| 575 |
if (obj.isListed) |
| 576 |
{ |
| 577 |
/* |
| 578 |
* see if there are other equivalent items later in the |
| 579 |
* list - if so, don't count it (this ensures that each such |
| 580 |
* item is counted only once, since only the last such item |
| 581 |
* in the list will be counted) |
| 582 |
*/ |
| 583 |
if (obj.isEquivalent) |
| 584 |
{ |
| 585 |
local sc; |
| 586 |
|
| 587 |
sc := firstsc(obj); |
| 588 |
for (j := i + 1 ; j <= tot ; ++j) |
| 589 |
{ |
| 590 |
if (isIndistinguishable(obj, list[j])) |
| 591 |
goto skip_this_item; |
| 592 |
} |
| 593 |
} |
| 594 |
|
| 595 |
/* count this item */ |
| 596 |
++cnt; |
| 597 |
|
| 598 |
skip_this_item: ; |
| 599 |
} |
| 600 |
} |
| 601 |
return cnt; |
| 602 |
} |
| 603 |
|
| 604 |
/* |
| 605 |
* sayPrefixCount: function(cnt) |
| 606 |
* |
| 607 |
* This function displays a count (suitable for use in listcont when |
| 608 |
* showing the number of equivalent items. We display the count spelled out |
| 609 |
* if it's a small number, otherwise we just display the digits of the |
| 610 |
* number. |
| 611 |
*/ |
| 612 |
sayPrefixCount: function(cnt) |
| 613 |
{ |
| 614 |
if (cnt <= 20) |
| 615 |
say(['one' 'two' 'three' 'four' 'five' |
| 616 |
'six' 'seven' 'eight' 'nine' 'ten' |
| 617 |
'eleven' 'twelve' 'thirteen' 'fourteen' 'fifteen' |
| 618 |
'sixteen' 'seventeen' 'eighteen' 'nineteen' 'twenty'][cnt]); |
| 619 |
else |
| 620 |
say(cnt); |
| 621 |
} |
| 622 |
|
| 623 |
/* |
| 624 |
* listcontgen: function(obj, flags, indent) |
| 625 |
* |
| 626 |
* This is a general-purpose object lister routine; the other object lister |
| 627 |
* routines call this routine to do their work. This function can take an |
| 628 |
* object, in which case it lists the contents of the object, or it can take |
| 629 |
* a list, in which case it simply lists the items in the list. The flags |
| 630 |
* parameter specifies what to do. LCG_TALL makes the function display a "tall" |
| 631 |
* listing, with one object per line; if LCG_TALL isn't specified, the function |
| 632 |
* displays a "wide" listing, showing the objects as a comma-separated list. |
| 633 |
* When LCG_TALL is specified, the indent parameter indicates how many |
| 634 |
* tab levels to indent the current level of listing, allowing recursive calls |
| 635 |
* to display the contents of listed objects. LCG_CHECKVIS makes the function |
| 636 |
* check the visibility of the top-level object before listing its contents. |
| 637 |
* LCG_RECURSE indicates that we should recursively list the contents of the |
| 638 |
* objects we list; we'll use the same flags on recursive calls, and use one |
| 639 |
* higher indent level. LCG_CHECKLIST specifies that we should check |
| 640 |
* the listability of any recursive contents before listing them, using |
| 641 |
* the standard contentsListable() test. To specify multiple flags, combine |
| 642 |
* them with the bitwise-or (|) operator. |
| 643 |
*/ |
| 644 |
#define LCG_TALL 1 |
| 645 |
#define LCG_CHECKVIS 2 |
| 646 |
#define LCG_RECURSE 4 |
| 647 |
#define LCG_CHECKLIST 8 |
| 648 |
listcontgen: function(obj, flags, indent) |
| 649 |
{ |
| 650 |
local i, count, tot, list, cur, disptot, prefix_count; |
| 651 |
|
| 652 |
/* |
| 653 |
* Get the list. If the "obj" parameter is already a list, use it |
| 654 |
* directly; otherwise, list the contents of the object. |
| 655 |
*/ |
| 656 |
switch(datatype(obj)) |
| 657 |
{ |
| 658 |
case 2: |
| 659 |
/* it's an object - list its contents */ |
| 660 |
list := obj.contents; |
| 661 |
|
| 662 |
/* |
| 663 |
* if the CHECKVIS flag is specified, check to make sure the |
| 664 |
* contents of the object are visible; if they're not, don't |
| 665 |
* list anything |
| 666 |
*/ |
| 667 |
if ((flags & LCG_CHECKVIS) != 0) |
| 668 |
{ |
| 669 |
local contvis; |
| 670 |
|
| 671 |
/* determine whether the contents are visible */ |
| 672 |
contvis := (!isclass(obj, openable) |
| 673 |
|| (isclass(obj, openable) && obj.isopen) |
| 674 |
|| obj.contentsVisible); |
| 675 |
|
| 676 |
/* if they're not visible, don't list the contents */ |
| 677 |
if (!contvis) |
| 678 |
return; |
| 679 |
} |
| 680 |
break; |
| 681 |
|
| 682 |
case 7: |
| 683 |
/* it's already a list */ |
| 684 |
list := obj; |
| 685 |
break; |
| 686 |
|
| 687 |
default: |
| 688 |
/* ignore other types entirely */ |
| 689 |
return; |
| 690 |
} |
| 691 |
|
| 692 |
/* count the items in the list */ |
| 693 |
tot := length(list); |
| 694 |
|
| 695 |
/* we haven't displayed anything yet */ |
| 696 |
count := 0; |
| 697 |
|
| 698 |
/* |
| 699 |
* Count how many items we're going to display -- this may be fewer |
| 700 |
* than the number of items in the list, because some items might |
| 701 |
* not be listed at all (isListed = nil), and we'll list each group |
| 702 |
* of equivalent objects with a single display item (with a count of |
| 703 |
* the number of equivalent objets) |
| 704 |
*/ |
| 705 |
disptot := itemcnt(list); |
| 706 |
|
| 707 |
/* iterate through the list */ |
| 708 |
for (i := 1 ; i <= tot ; ++i) |
| 709 |
{ |
| 710 |
/* get the current object */ |
| 711 |
cur := list[i]; |
| 712 |
|
| 713 |
/* if this object is to be listed, figure out how to show it */ |
| 714 |
if (cur.isListed) |
| 715 |
{ |
| 716 |
/* presume there is only one such object (i.e., no equivalents) */ |
| 717 |
prefix_count := 1; |
| 718 |
|
| 719 |
/* |
| 720 |
* if this is one of more than one equivalent items, list it |
| 721 |
* only if it's the first one, and show the number of such |
| 722 |
* items along with the first one |
| 723 |
*/ |
| 724 |
if (cur.isEquivalent) |
| 725 |
{ |
| 726 |
local before, after; |
| 727 |
local j; |
| 728 |
local sc; |
| 729 |
|
| 730 |
/* get this object's superclass */ |
| 731 |
sc := firstsc(cur); |
| 732 |
|
| 733 |
/* scan for other objects equivalent to this one */ |
| 734 |
for (before := after := 0, j := 1 ; j <= tot ; ++j) |
| 735 |
{ |
| 736 |
if (isIndistinguishable(cur, list[j])) |
| 737 |
{ |
| 738 |
if (j < i) |
| 739 |
{ |
| 740 |
/* |
| 741 |
* note that objects precede this one, and |
| 742 |
* then look no further, since we're just |
| 743 |
* going to skip this item anyway |
| 744 |
*/ |
| 745 |
++before; |
| 746 |
break; |
| 747 |
} |
| 748 |
else |
| 749 |
++after; |
| 750 |
} |
| 751 |
} |
| 752 |
|
| 753 |
/* |
| 754 |
* if there are multiple such objects, and this is the |
| 755 |
* first such object, list it with the count prefixed; |
| 756 |
* if there are multiple and this isn't the first one, |
| 757 |
* skip it; otherwise, go on as normal |
| 758 |
*/ |
| 759 |
if (before = 0) |
| 760 |
prefix_count := after; |
| 761 |
else |
| 762 |
continue; |
| 763 |
} |
| 764 |
|
| 765 |
/* display the appropriate separator before this item */ |
| 766 |
if ((flags & LCG_TALL) != 0) |
| 767 |
{ |
| 768 |
local j; |
| 769 |
|
| 770 |
/* tall listing - indent to the desired level */ |
| 771 |
"\n"; |
| 772 |
for (j := 1; j <= indent; ++j) |
| 773 |
"\t"; |
| 774 |
} |
| 775 |
else |
| 776 |
{ |
| 777 |
/* |
| 778 |
* "wide" (paragraph-style) listing - add a comma, and |
| 779 |
* possibly "and", if this isn't the first item |
| 780 |
*/ |
| 781 |
if (count > 0) |
| 782 |
{ |
| 783 |
if (count+1 < disptot) |
| 784 |
", "; |
| 785 |
else if (count = 1) |
| 786 |
" and "; |
| 787 |
else |
| 788 |
", and "; |
| 789 |
} |
| 790 |
} |
| 791 |
|
| 792 |
/* list the object, along with the number of such items */ |
| 793 |
if (prefix_count = 1) |
| 794 |
{ |
| 795 |
/* there's only one object - show the singular description */ |
| 796 |
cur.adesc; |
| 797 |
} |
| 798 |
else |
| 799 |
{ |
| 800 |
/* |
| 801 |
* there are multiple equivalents for this object - |
| 802 |
* display the number of the items and the plural |
| 803 |
* description |
| 804 |
*/ |
| 805 |
sayPrefixCount(prefix_count); " "; |
| 806 |
cur.pluraldesc; |
| 807 |
} |
| 808 |
|
| 809 |
/* show any additional information about the item */ |
| 810 |
if (cur.isworn) |
| 811 |
" (being worn)"; |
| 812 |
if (cur.islamp and cur.islit) |
| 813 |
" (providing light)"; |
| 814 |
|
| 815 |
/* increment the number of displayed items */ |
| 816 |
++count; |
| 817 |
|
| 818 |
/* |
| 819 |
* If this is a "tall" listing, and there's at least one item |
| 820 |
* contained inside the current item, list the item's |
| 821 |
* contents recursively, indented one level deeper. |
| 822 |
* |
| 823 |
* If the 'check visibility' flag is set, then only proceed |
| 824 |
* with the sublisting if the contents are listable. |
| 825 |
*/ |
| 826 |
if ((flags & LCG_RECURSE) != 0 |
| 827 |
&& itemcnt(cur.contents) != 0 |
| 828 |
&& ((flags & LCG_CHECKLIST) = 0 || contentsListable(cur))) |
| 829 |
{ |
| 830 |
/* |
| 831 |
* if this is a "wide" listing, show the contents in |
| 832 |
* parentheses |
| 833 |
*/ |
| 834 |
if ((flags & LCG_TALL) = 0) |
| 835 |
{ |
| 836 |
if (cur.issurface) |
| 837 |
" (upon which %you% see%s% "; |
| 838 |
else |
| 839 |
" (which contains "; |
| 840 |
} |
| 841 |
|
| 842 |
/* show the recursive listing, indented one level deeper */ |
| 843 |
listcontgen(cur, flags, indent + 1); |
| 844 |
|
| 845 |
/* close the parenthetical, if we opened one */ |
| 846 |
if ((flags & LCG_TALL) = 0) |
| 847 |
")"; |
| 848 |
} |
| 849 |
} |
| 850 |
} |
| 851 |
} |
| 852 |
|
| 853 |
/* |
| 854 |
* listcont: function(obj) |
| 855 |
* |
| 856 |
* This function displays the contents of an object, separated by |
| 857 |
* commas. The thedesc properties of the contents are used. |
| 858 |
* It is up to the caller to provide the introduction to the list |
| 859 |
* (usually something to the effect of "The box contains" is |
| 860 |
* displayed before calling listcont) and finishing the |
| 861 |
* sentence (usually by displaying a period). An object is listed |
| 862 |
* only if its isListed property is true. If there are |
| 863 |
* multiple indistinguishable items in the list, the items are |
| 864 |
* listed only once (with the number of the items). |
| 865 |
*/ |
| 866 |
listcont: function(obj) |
| 867 |
{ |
| 868 |
/* use the general-purpose contents lister to show a "wide" listing */ |
| 869 |
listcontgen(obj, 0, 0); |
| 870 |
} |
| 871 |
|
| 872 |
/* |
| 873 |
* nestlistcont: function(obj, depth) |
| 874 |
* |
| 875 |
* This function will produce a nested listing of the contents of obj. |
| 876 |
* It will recurse down into the objects contents until the list is |
| 877 |
* exhausted. An object's contents are listed only if they are |
| 878 |
* considered visible by the normal visibility rules. The depth |
| 879 |
* parameter is used to control the tabbing of the listing: an initial |
| 880 |
* value of 1 will produce a listing with indented top-level contents, |
| 881 |
* which is normally what you want, but 0 might also be desirable |
| 882 |
* desirable in certain cases. |
| 883 |
*/ |
| 884 |
nestlistcont: function(obj, depth) |
| 885 |
{ |
| 886 |
/* |
| 887 |
* use the general-purpose contents lister to show a "tall" listing, |
| 888 |
* recursing into contents of the items in the list |
| 889 |
*/ |
| 890 |
listcontgen(obj, LCG_TALL | LCG_RECURSE | LCG_CHECKLIST, depth); |
| 891 |
} |
| 892 |
|
| 893 |
/* |
| 894 |
* contentsListable: are the contents of the given object listable in an |
| 895 |
* inventory or description list? Returns true if the object's contents |
| 896 |
* are visible and it's not a "quiet" container/surface. |
| 897 |
*/ |
| 898 |
contentsListable: function(obj) |
| 899 |
{ |
| 900 |
/* check to see if it's a surface or container */ |
| 901 |
if (obj.issurface) |
| 902 |
{ |
| 903 |
/* surface - list the contents unless it's a "quiet" surface */ |
| 904 |
return (not obj.isqsurface); |
| 905 |
} |
| 906 |
else |
| 907 |
{ |
| 908 |
/* |
| 909 |
* container - list the contents if the container makes its |
| 910 |
* contents visible and it's not a "quiet" container |
| 911 |
*/ |
| 912 |
return (obj.contentsVisible and not obj.isqcontainer); |
| 913 |
} |
| 914 |
} |
| 915 |
|
| 916 |
/* |
| 917 |
* showcontcont: list the contents of the object, plus the contents of |
| 918 |
* an fixeditem's contained by the object. A complete sentence is shown. |
| 919 |
* This is an internal routine used by listcontcont and listfixedcontcont. |
| 920 |
*/ |
| 921 |
showcontcont: function(obj) |
| 922 |
{ |
| 923 |
/* show obj's direct contents, if it has any and they're listable */ |
| 924 |
if (itemcnt(obj.contents) != 0 && contentsListable(obj)) |
| 925 |
{ |
| 926 |
if (obj.issurface) |
| 927 |
{ |
| 928 |
"Sitting on "; obj.thedesc;" is "; listcont(obj); |
| 929 |
". "; |
| 930 |
} |
| 931 |
else |
| 932 |
{ |
| 933 |
caps(); |
| 934 |
obj.thedesc; " seem"; |
| 935 |
if (!obj.isThem) "s"; |
| 936 |
" to contain "; |
| 937 |
listcont(obj); |
| 938 |
". "; |
| 939 |
} |
| 940 |
} |
| 941 |
|
| 942 |
/* |
| 943 |
* show the contents of the fixed contents if obj's contents are |
| 944 |
* themselves listable |
| 945 |
*/ |
| 946 |
if (contentsListable(obj)) |
| 947 |
listfixedcontcont(obj); |
| 948 |
} |
| 949 |
|
| 950 |
/* |
| 951 |
* listfixedcontcont: function(obj) |
| 952 |
* |
| 953 |
* List the contents of the contents of any fixeditem objects |
| 954 |
* in the contents list of the object obj. This routine |
| 955 |
* makes sure that all objects that can be taken are listed somewhere |
| 956 |
* in a room's description. This routine recurses down the contents |
| 957 |
* tree, following each branch until either something has been listed |
| 958 |
* or the branch ends without anything being listable. This routine |
| 959 |
* displays a complete sentence, so no introductory or closing text |
| 960 |
* is needed. |
| 961 |
*/ |
| 962 |
listfixedcontcont: function(obj) |
| 963 |
{ |
| 964 |
local list, i, tot, thisobj; |
| 965 |
|
| 966 |
list := obj.contents; |
| 967 |
tot := length(list); |
| 968 |
i := 1; |
| 969 |
while (i <= tot) |
| 970 |
{ |
| 971 |
thisobj := list[i]; |
| 972 |
if (thisobj.isfixed and thisobj.contentsVisible and |
| 973 |
not thisobj.isqcontainer) |
| 974 |
showcontcont(thisobj); |
| 975 |
i := i + 1; |
| 976 |
} |
| 977 |
} |
| 978 |
|
| 979 |
/* |
| 980 |
* listcontcont: function(obj) |
| 981 |
* |
| 982 |
* This function lists the contents of the contents of an object. |
| 983 |
* It displays full sentences, so no introductory or closing text |
| 984 |
* is required. Any item in the contents list of the object |
| 985 |
* obj whose contentsVisible property is true has |
| 986 |
* its contents listed. An Object whose isqcontainer or |
| 987 |
* isqsurface property is true will not have its |
| 988 |
* contents listed. |
| 989 |
*/ |
| 990 |
listcontcont: function(obj) |
| 991 |
{ |
| 992 |
local list, i, tot; |
| 993 |
|
| 994 |
list := obj.contents; |
| 995 |
tot := length(list); |
| 996 |
i := 1; |
| 997 |
while (i <= tot) |
| 998 |
{ |
| 999 |
showcontcont(list[i]); |
| 1000 |
i := i + 1; |
| 1001 |
} |
| 1002 |
} |
| 1003 |
|
| 1004 |
/* |
| 1005 |
* scoreStatus: function(points, turns) |
| 1006 |
* |
| 1007 |
* This function updates the score on the status line. This implementation |
| 1008 |
* simply calls the built-in function setscore() with the same information. |
| 1009 |
* The call to setscore() has been isolated in this function to make it |
| 1010 |
* easier to replace with a customized version; to replace the status line |
| 1011 |
* score display, simply replace this routine. |
| 1012 |
*/ |
| 1013 |
scoreStatus: function(points, turns) |
| 1014 |
{ |
| 1015 |
/* get the formatted score string, and set the score to that value */ |
| 1016 |
setscore(scoreFormat(points, turns)); |
| 1017 |
} |
| 1018 |
|
| 1019 |
/* |
| 1020 |
* scoreValue: function(points, turns) |
| 1021 |
* |
| 1022 |
* This function returns the formatted display string to show in the right |
| 1023 |
* half of the status line, where the score and turn count are normally |
| 1024 |
* displayed. If you wantd to display a different type of information in |
| 1025 |
* the right half of the status line, you can override this function to |
| 1026 |
* return the string you wish to display. |
| 1027 |
*/ |
| 1028 |
scoreFormat: function(points, turns) |
| 1029 |
{ |
| 1030 |
/* return a string with the standard points/turns display */ |
| 1031 |
return cvtstr(points) + '/' + cvtstr(turns); |
| 1032 |
} |
| 1033 |
|
| 1034 |
/* |
| 1035 |
* turncount: function(parm) |
| 1036 |
* |
| 1037 |
* This function can be used as a daemon (normally set up in the init |
| 1038 |
* function) to update the turn counter after each turn. This routine |
| 1039 |
* increments global.turnsofar, and then calls setscore to |
| 1040 |
* update the status line with the new turn count. |
| 1041 |
*/ |
| 1042 |
turncount: function(parm) |
| 1043 |
{ |
| 1044 |
incturn(); |
| 1045 |
global.turnsofar := global.turnsofar + 1; |
| 1046 |
scoreStatus(global.score, global.turnsofar); |
| 1047 |
} |
| 1048 |
|
| 1049 |
/* |
| 1050 |
* addweight: function(list) |
| 1051 |
* |
| 1052 |
* Adds the weights of the objects in list and returns the sum. |
| 1053 |
* The weight of an object is given by its weight property. This |
| 1054 |
* routine includes the weights of all of the contents of each object, |
| 1055 |
* and the weights of their contents, and so forth. |
| 1056 |
*/ |
| 1057 |
addweight: function(l) |
| 1058 |
{ |
| 1059 |
local tot, i, c, totweight; |
| 1060 |
|
| 1061 |
tot := length(l); |
| 1062 |
i := 1; |
| 1063 |
totweight := 0; |
| 1064 |
while (i <= tot) |
| 1065 |
{ |
| 1066 |
c := l[i]; |
| 1067 |
totweight := totweight + c.weight; |
| 1068 |
if (length(c.contents)) |
| 1069 |
totweight := totweight + addweight(c.contents); |
| 1070 |
i := i + 1; |
| 1071 |
} |
| 1072 |
return totweight; |
| 1073 |
} |
| 1074 |
|
| 1075 |
/* |
| 1076 |
* addbulk: function(list) |
| 1077 |
* |
| 1078 |
* This function returns the sum of the bulks (given by the bulk |
| 1079 |
* property) of each object in list. The value returned includes |
| 1080 |
* only the bulk of each object in the list, and not of the contents |
| 1081 |
* of the objects, as it is assumed that an object does not change in |
| 1082 |
* size when something is put inside it. You can easily change this |
| 1083 |
* assumption for special objects (such as a bag that stretches as |
| 1084 |
* things are put inside) by writing an appropriate bulk method |
| 1085 |
* for that object. |
| 1086 |
*/ |
| 1087 |
addbulk: function(list) |
| 1088 |
{ |
| 1089 |
local i, tot, totbulk, rem, cur; |
| 1090 |
|
| 1091 |
tot := length(list); |
| 1092 |
i := 1; |
| 1093 |
totbulk := 0; |
| 1094 |
while(i <= tot) |
| 1095 |
{ |
| 1096 |
cur := list[i]; |
| 1097 |
if (not cur.isworn) |
| 1098 |
totbulk := totbulk + cur.bulk; |
| 1099 |
i := i + 1; |
| 1100 |
} |
| 1101 |
return totbulk; |
| 1102 |
} |
| 1103 |
|
| 1104 |
/* |
| 1105 |
* incscore: function(amount) |
| 1106 |
* |
| 1107 |
* Adds amount to the total score, and updates the status line |
| 1108 |
* to reflect the new score. The total score is kept in global.score. |
| 1109 |
* Always use this routine rather than changing global.score |
| 1110 |
* directly, since this routine ensures that the status line is |
| 1111 |
* updated with the new value. |
| 1112 |
*/ |
| 1113 |
incscore: function(amount) |
| 1114 |
{ |
| 1115 |
global.score := global.score + amount; |
| 1116 |
scoreStatus(global.score, global.turnsofar); |
| 1117 |
} |
| 1118 |
|
| 1119 |
/* |
| 1120 |
* initSearch: function |
| 1121 |
* |
| 1122 |
* Initializes the containers of objects with a searchLoc, underLoc, |
| 1123 |
* and behindLoc by setting up searchCont, underCont, and |
| 1124 |
* behindCont lists, respectively. You should call this function once in |
| 1125 |
* your preinit (or init, if you prefer) function to ensure that |
| 1126 |
* the underable, behindable, and searchable objects are set up correctly. |
| 1127 |
* |
| 1128 |
* As a bonus, we take this opportunity to initialize global.floatingList |
| 1129 |
* with a list of all objects of class floatingItem. It is necessary to |
| 1130 |
* initialize this list, so that validDoList and validIoList include objects |
| 1131 |
* with variable location properties. Note that, for this to work, |
| 1132 |
* all objects with variable location properties must be declared |
| 1133 |
* to be of class floatingItem. |
| 1134 |
*/ |
| 1135 |
initSearch: function |
| 1136 |
{ |
| 1137 |
local o; |
| 1138 |
|
| 1139 |
o := firstobj(hiddenItem); |
| 1140 |
while (o <> nil) |
| 1141 |
{ |
| 1142 |
if (o.searchLoc) |
| 1143 |
o.searchLoc.searchCont := o.searchLoc.searchCont + o; |
| 1144 |
else if (o.underLoc) |
| 1145 |
o.underLoc.underCont := o.underLoc.underCont + o; |
| 1146 |
else if (o.behindLoc) |
| 1147 |
o.behindLoc.behindCont := o.behindLoc.behindCont + o; |
| 1148 |
o := nextobj(o, hiddenItem); |
| 1149 |
} |
| 1150 |
|
| 1151 |
global.floatingList := []; |
| 1152 |
for (o := firstobj(floatingItem) ; o ; o := nextobj(o, floatingItem)) |
| 1153 |
global.floatingList += o; |
| 1154 |
} |
| 1155 |
|
| 1156 |
/* |
| 1157 |
* reachableList: function |
| 1158 |
* |
| 1159 |
* Returns a list of all the objects reachable from a given object. |
| 1160 |
* That is, if the object is open or is not an openable, it returns the |
| 1161 |
* contents of the object, plus the reachableList result of each object; |
| 1162 |
* if the object is closed, it returns an empty list. |
| 1163 |
*/ |
| 1164 |
reachableList: function(obj) |
| 1165 |
{ |
| 1166 |
local ret := []; |
| 1167 |
local i, lst, len; |
| 1168 |
|
| 1169 |
if (not isclass(obj, openable) |
| 1170 |
or (isclass(obj, openable) and obj.isopen)) |
| 1171 |
{ |
| 1172 |
lst := obj.contents; |
| 1173 |
len := length(lst); |
| 1174 |
ret += lst; |
| 1175 |
for (i := 1 ; i <= len ; ++i) |
| 1176 |
ret += reachableList(lst[i]); |
| 1177 |
} |
| 1178 |
|
| 1179 |
return ret; |
| 1180 |
} |
| 1181 |
|
| 1182 |
/* |
| 1183 |
* visibleList: function |
| 1184 |
* |
| 1185 |
* This function is similar to reachableList, but returns the |
| 1186 |
* list of objects visible within a given object. |
| 1187 |
*/ |
| 1188 |
visibleList: function(obj, actor) |
| 1189 |
{ |
| 1190 |
local ret := []; |
| 1191 |
local i, lst, len; |
| 1192 |
|
| 1193 |
/* don't look in "nil" objects */ |
| 1194 |
if (obj = nil) |
| 1195 |
return ret; |
| 1196 |
|
| 1197 |
/* |
| 1198 |
* get the object's contents if it's not openable at all (in which |
| 1199 |
* case we assume its contents are visible unconditionally), or if |
| 1200 |
* it's openable and it's currently open, or if it's openable and |
| 1201 |
* its contents are explicitly visible (which will be the case for |
| 1202 |
* transparent openables whether they're opened or closed) |
| 1203 |
*/ |
| 1204 |
if (not isclass(obj, openable) |
| 1205 |
or (isclass(obj, openable) and obj.isopen) |
| 1206 |
or obj.contentsVisible) |
| 1207 |
{ |
| 1208 |
lst := obj.contents; |
| 1209 |
len := length(lst); |
| 1210 |
ret += lst; |
| 1211 |
for (i := 1 ; i <= len ; ++i) |
| 1212 |
{ |
| 1213 |
/* recurse into this object, but not into the current actor */ |
| 1214 |
if (lst[i] <> actor) |
| 1215 |
ret += visibleList(lst[i], actor); |
| 1216 |
} |
| 1217 |
|
| 1218 |
/* |
| 1219 |
* since the "Me" object never shows up in room.contents, if Me is |
| 1220 |
* located in obj, and actor <> Me, add Me.contents to the list |
| 1221 |
*/ |
| 1222 |
if (actor <> parserGetMe() and parserGetMe().location = obj) |
| 1223 |
ret += visibleList(parserGetMe(), actor); |
| 1224 |
} |
| 1225 |
|
| 1226 |
return ret; |
| 1227 |
} |
| 1228 |
|
| 1229 |
/* |
| 1230 |
* numbered_cleanup: function |
| 1231 |
* |
| 1232 |
* This function is used as a fuse to delete objects created by the |
| 1233 |
* numberedObject class in reponse to calls to its newNumbered |
| 1234 |
* method. Whenever that method creates a new object, it sets up a fuse |
| 1235 |
* call to this function to delete the object at the end of the turn in |
| 1236 |
* which it created the object. |
| 1237 |
*/ |
| 1238 |
numbered_cleanup: function(obj) |
| 1239 |
{ |
| 1240 |
delete obj; |
| 1241 |
} |
| 1242 |
|
| 1243 |
/* |
| 1244 |
* mainRestore: function |
| 1245 |
* |
| 1246 |
* Restore a saved game. Returns true on success, nil on failure. If |
| 1247 |
* the game is restored successfully, we'll update the status line and |
| 1248 |
* show the full description of the current location. The restore command |
| 1249 |
* uses this function; this can also be used by initRestore (which must be |
| 1250 |
* separately defined by the game, since it's not defined in this file). |
| 1251 |
*/ |
| 1252 |
mainRestore: function(fname) |
| 1253 |
{ |
| 1254 |
/* try restoring the game */ |
| 1255 |
switch(restore(fname)) |
| 1256 |
{ |
| 1257 |
case RESTORE_SUCCESS: |
| 1258 |
/* update the status line */ |
| 1259 |
scoreStatus(global.score, global.turnsofar); |
| 1260 |
|
| 1261 |
/* tell the user we succeeded, and show the location */ |
| 1262 |
"Restored.\b"; |
| 1263 |
parserGetMe().location.lookAround(true); |
| 1264 |
|
| 1265 |
/* success */ |
| 1266 |
return true; |
| 1267 |
|
| 1268 |
case RESTORE_FILE_NOT_FOUND: |
| 1269 |
"The saved position file could not be opened. "; |
| 1270 |
return nil; |
| 1271 |
|
| 1272 |
case RESTORE_NOT_SAVE_FILE: |
| 1273 |
"This file does not contain a saved game position. "; |
| 1274 |
return nil; |
| 1275 |
|
| 1276 |
case RESTORE_BAD_FMT_VSN: |
| 1277 |
"This file was saved by another version of TADS that is |
| 1278 |
not compatible with the current version. "; |
| 1279 |
return nil; |
| 1280 |
|
| 1281 |
case RESTORE_BAD_GAME_VSN: |
| 1282 |
"This file was saved by a different game, or a different |
| 1283 |
version of this game, and cannot be restored with this game. "; |
| 1284 |
return nil; |
| 1285 |
|
| 1286 |
case RESTORE_READ_ERROR: |
| 1287 |
"An error occurred reading the saved position file; the file |
| 1288 |
might be corrupted. The game might have been partially restored, |
| 1289 |
which could make it impossible to continue playing; if the game |
| 1290 |
does not seem to be working properly, you should quit the game |
| 1291 |
and start over. "; |
| 1292 |
return nil; |
| 1293 |
|
| 1294 |
case RESTORE_NO_PARAM_FILE: |
| 1295 |
/* |
| 1296 |
* ignore the error, since the caller was only asking, and |
| 1297 |
* return nil |
| 1298 |
*/ |
| 1299 |
return nil; |
| 1300 |
|
| 1301 |
default: |
| 1302 |
"Restore failed. "; |
| 1303 |
return nil; |
| 1304 |
} |
| 1305 |
} |
| 1306 |
|
| 1307 |
/* |
| 1308 |
* switchPlayer: function |
| 1309 |
* |
| 1310 |
* Switch the player character to a new actor. This function uses the |
| 1311 |
* parserSetMe() built-in function to change the parser's internal |
| 1312 |
* record of the player character object, and in addition performs some |
| 1313 |
* necessary modifications to the outgoing and incoming player character |
| 1314 |
* objects. First, because the player character object is by convention |
| 1315 |
* never part of its room's contents list, we add the outgoing actor to |
| 1316 |
* its location's contents list, and remove the incoming actor from its |
| 1317 |
* location's contents list. Second, we remove the vocabulary words |
| 1318 |
* "me" and "myself" from the outgoing object, and add them to the |
| 1319 |
* incoming object. |
| 1320 |
*/ |
| 1321 |
switchPlayer: function(newPlayer) |
| 1322 |
{ |
| 1323 |
/* if this is the same as the current player character, do nothing */ |
| 1324 |
if (parserGetMe() = newPlayer) |
| 1325 |
return; |
| 1326 |
|
| 1327 |
/* |
| 1328 |
* add the outgoing player character to its location's contents -- |
| 1329 |
* it's going to be an ordinary actor from now on, so it should be |
| 1330 |
* in its location's contents list |
| 1331 |
*/ |
| 1332 |
if (parserGetMe() != nil && parserGetMe().location != nil) |
| 1333 |
parserGetMe().location.contents += parserGetMe(); |
| 1334 |
|
| 1335 |
/* |
| 1336 |
* remove the incoming player character from its location's contents |
| 1337 |
* -- by convention, the active player character is never in its |
| 1338 |
* location's contents list |
| 1339 |
*/ |
| 1340 |
if (newPlayer != nil && newPlayer.location != nil) |
| 1341 |
newPlayer.location.contents -= newPlayer; |
| 1342 |
|
| 1343 |
/* |
| 1344 |
* remove "me" and "myself" from the old object's vocabulary -- it's |
| 1345 |
* no longer "me" from the player's perspective |
| 1346 |
*/ |
| 1347 |
delword(parserGetMe(), &noun, 'me'); |
| 1348 |
delword(parserGetMe(), &noun, 'myself'); |
| 1349 |
|
| 1350 |
/* establish the new player character object in the parser */ |
| 1351 |
parserSetMe(newPlayer); |
| 1352 |
|
| 1353 |
/* add "me" and "myself" to the new player character's vocabulary */ |
| 1354 |
addword(newPlayer, &noun, 'me'); |
| 1355 |
addword(newPlayer, &noun, 'myself'); |
| 1356 |
} |
| 1357 |
|
| 1358 |
/* |
| 1359 |
* numberedObject: object |
| 1360 |
* |
| 1361 |
* This class can be added to a class list for an object to allow it to |
| 1362 |
* be used as a generic numbered object. You can create a single object |
| 1363 |
* with this class, and then the player can refer to that object with |
| 1364 |
* any number. For example, you can create a single "button" object |
| 1365 |
* that the player can refer to with "button 100" or "button 1000" |
| 1366 |
* or any other number. If you want to limit the range of acceptable |
| 1367 |
* numbers, override the num_is_valid method so that it displays |
| 1368 |
* an appropriate error message and returns nil for invalid numbers. |
| 1369 |
* If you want to use a separate object to handle references to the object |
| 1370 |
* with a plural ("look at buttons"), override newNumberedPlural to |
| 1371 |
* return the object to handle these references; by default, the original |
| 1372 |
* object is used to handle plurals. |
| 1373 |
*/ |
| 1374 |
|
| 1375 |
class numberedObject: object |
| 1376 |
adjective = '#' |
| 1377 |
anyvalue(n) = { return n; } |
| 1378 |
clean_up = { delete self; } |
| 1379 |
newNumberedPlural(a, v) = { return self; } |
| 1380 |
newNumbered(a, v, n) = |
| 1381 |
{ |
| 1382 |
local obj; |
| 1383 |
|
| 1384 |
if (n = nil) |
| 1385 |
return self.newNumberedPlural(a, v); |
| 1386 |
if (not self.num_is_valid(n)) |
| 1387 |
return nil; |
| 1388 |
obj := new self; |
| 1389 |
obj.value := n; |
| 1390 |
setfuse(numbered_cleanup, 0, obj); |
| 1391 |
return obj; |
| 1392 |
} |
| 1393 |
num_is_valid(n) = { return true; } |
| 1394 |
dobjGen(a, v, i, p) = |
| 1395 |
{ |
| 1396 |
if (self.value = nil) |
| 1397 |
{ |
| 1398 |
"%You%'ll have to be more specific about which one %you% mean."; |
| 1399 |
exit; |
| 1400 |
} |
| 1401 |
} |
| 1402 |
iobjGen(a, v, d, p) = { self.dobjGen(a, v, d, p); } |
| 1403 |
; |
| 1404 |
|
| 1405 |
|
| 1406 |
/* |
| 1407 |
* nestedroom: room |
| 1408 |
* |
| 1409 |
* A special kind of room that is inside another room; chairs and |
| 1410 |
* some types of vehicles, such as inflatable rafts, fall into this |
| 1411 |
* category. Note that a room can be within another room without |
| 1412 |
* being a nestedroom, simply by setting its location property |
| 1413 |
* to another room. The nestedroom is different from an ordinary |
| 1414 |
* room, though, in that it's an "open" room; that is, when inside it, |
| 1415 |
* the actor is still really inside the enclosing room for purposes of |
| 1416 |
* descriptions. Hence, the player sees "Laboratory, in the chair." |
| 1417 |
* In addition, a nestedroom is an object in its own right, |
| 1418 |
* visible to the player; for example, a chair is an object in a |
| 1419 |
* room in addition to being a room itself. The statusPrep |
| 1420 |
* property displays the preposition in the status description; by |
| 1421 |
* default, it will be "in," but some subclasses and instances |
| 1422 |
* will want to change this to a more appropriate preposition. |
| 1423 |
* outOfPrep is used to report what happens when the player |
| 1424 |
* gets out of the object: it should be "out of" or "off of" as |
| 1425 |
* appropriate to this object. |
| 1426 |
*/ |
| 1427 |
class nestedroom: room |
| 1428 |
statusPrep = "in" |
| 1429 |
outOfPrep = "out of" |
| 1430 |
islit = |
| 1431 |
{ |
| 1432 |
if (self.location) |
| 1433 |
return self.location.islit; |
| 1434 |
return nil; |
| 1435 |
} |
| 1436 |
statusRoot = |
| 1437 |
{ |
| 1438 |
"<<self.location.sdesc>>, <<self.statusPrep>> <<self.thedesc>>"; |
| 1439 |
} |
| 1440 |
lookAround(verbosity) = |
| 1441 |
{ |
| 1442 |
self.dispBeginSdesc; |
| 1443 |
self.statusRoot; |
| 1444 |
self.dispEndSdesc; |
| 1445 |
|
| 1446 |
self.location.nrmLkAround(verbosity); |
| 1447 |
} |
| 1448 |
roomDrop(obj) = |
| 1449 |
{ |
| 1450 |
if (self.location = nil or self.isdroploc) |
| 1451 |
pass roomDrop; |
| 1452 |
else |
| 1453 |
self.location.roomDrop(obj); |
| 1454 |
} |
| 1455 |
|
| 1456 |
/* |
| 1457 |
* canReachContents - this flag indicates whether or not the player |
| 1458 |
* can reach the contents of objects in the 'reachable' list from |
| 1459 |
* this nested room. This is true by default, which means that the |
| 1460 |
* player can reach not only the items directly in the 'reachable' |
| 1461 |
* list, but also the objects within those objects. If this is nil, |
| 1462 |
* it means that the player can only reach the objects actually |
| 1463 |
* listed in the 'reachable' list, and not any objects within those |
| 1464 |
* objects. |
| 1465 |
* |
| 1466 |
* Setting canReachContents to nil is probably undesirable in most |
| 1467 |
* cases. This setting is provided mostly for compatibility with |
| 1468 |
* past versions of adv.t, which behaved as though canReachContents |
| 1469 |
* was true for nested rooms *except* for chairItem objects, which |
| 1470 |
* acted as though canReachContents was nil. If you want consistent |
| 1471 |
* behavior in all nested rooms including chairs, simply set |
| 1472 |
* chairItem.canReachContents to true. |
| 1473 |
*/ |
| 1474 |
canReachContents = true |
| 1475 |
|
| 1476 |
/* |
| 1477 |
* If canReachContents is nil, enforce the limitation |
| 1478 |
*/ |
| 1479 |
roomAction(actor, v, dobj, prep, io) = |
| 1480 |
{ |
| 1481 |
/* enforce !canReachContents, except for 'look at' */ |
| 1482 |
if (dobj != nil && !self.canReachContents && v != inspectVerb) |
| 1483 |
checkReach(self, actor, v, dobj); |
| 1484 |
|
| 1485 |
/* enforce !canReachContents, except for 'ask/tell about' */ |
| 1486 |
if (io != nil && !self.canReachContents |
| 1487 |
&& v != askVerb && v != tellVerb) |
| 1488 |
checkReach(self, actor, v, io); |
| 1489 |
|
| 1490 |
/* inherit the default behavior */ |
| 1491 |
inherited.roomAction(actor, v, dobj, prep, io); |
| 1492 |
} |
| 1493 |
|
| 1494 |
/* |
| 1495 |
* This routine is called when the actor is in this nested room, and |
| 1496 |
* tries to manipulate something that is visible but not reachable. |
| 1497 |
* This generally means that the object is in the enclosing room (or |
| 1498 |
* within an object in the enclosing room), but is not in our own |
| 1499 |
* "reachable" list, making the object visible but not touchable. |
| 1500 |
* We'll just say so. |
| 1501 |
*/ |
| 1502 |
cantReachRoom(otherRoom) = |
| 1503 |
{ |
| 1504 |
"%You% can't reach that from <<self.thedesc>>. "; |
| 1505 |
} |
| 1506 |
; |
| 1507 |
|
| 1508 |
/* |
| 1509 |
* chairitem: fixeditem, nestedroom, surface |
| 1510 |
* |
| 1511 |
* Acts like a chair: actors can sit on the object. While sitting |
| 1512 |
* on the object, an actor can't go anywhere until standing up, and |
| 1513 |
* can only reach objects that are on the chair and in the chair's |
| 1514 |
* reachable list. By default, nothing is in the reachable |
| 1515 |
* list. Note that there is no real distinction made between chairs |
| 1516 |
* and beds, so you can sit or lie on either; the only difference is |
| 1517 |
* the message displayed describing the situation. |
| 1518 |
*/ |
| 1519 |
class chairitem: fixeditem, nestedroom, surface |
| 1520 |
reachable = ([] + self) // list of all containers reachable from here; |
| 1521 |
// normally, you can only reach carried items |
| 1522 |
// from a chair, but this makes special allowances |
| 1523 |
ischair = true // it is a chair by default; for beds or other |
| 1524 |
// things you lie down on, make it false |
| 1525 |
|
| 1526 |
/* |
| 1527 |
* For compatibility with past versions of adv.t, we do not allow |
| 1528 |
* the player to reach objects that are inside objects that are in |
| 1529 |
* the reachable list. This behavior probably doesn't make a lot of |
| 1530 |
* sense in most cases, and isn't consistent with other types of |
| 1531 |
* nested rooms, so many games will probably want to modify |
| 1532 |
* chairItem and set canReachContents = true. However, since it |
| 1533 |
* worked this way in the past, the default is still nil, so that |
| 1534 |
* any games that (intentionally or otherwise) depended on this |
| 1535 |
* behavior will continue to work the same way they used to. |
| 1536 |
*/ |
| 1537 |
canReachContents = nil |
| 1538 |
|
| 1539 |
outOfPrep = "out of" |
| 1540 |
enterRoom(actor) = {} |
| 1541 |
noexit = |
| 1542 |
{ |
| 1543 |
"%You're% not going anywhere until %you% |
| 1544 |
get%s% <<outOfPrep>> <<thedesc>>. "; |
| 1545 |
return nil; |
| 1546 |
} |
| 1547 |
verDoBoard(actor) = { self.verDoSiton(actor); } |
| 1548 |
doBoard(actor) = { self.doSiton(actor); } |
| 1549 |
verDoSiton(actor) = |
| 1550 |
{ |
| 1551 |
if (actor.location = self) |
| 1552 |
{ |
| 1553 |
"%You're% already on "; self.thedesc; "! "; |
| 1554 |
} |
| 1555 |
} |
| 1556 |
doSiton(actor) = |
| 1557 |
{ |
| 1558 |
"Okay, %you're% now sitting on "; self.thedesc; ". "; |
| 1559 |
actor.travelTo(self); |
| 1560 |
} |
| 1561 |
verDoLieon(actor) = |
| 1562 |
{ |
| 1563 |
self.verDoSiton(actor); |
| 1564 |
} |
| 1565 |
doLieon(actor) = |
| 1566 |
{ |
| 1567 |
self.doSiton(actor); |
| 1568 |
} |
| 1569 |
; |
| 1570 |
|
| 1571 |
/* |
| 1572 |
* beditem: chairitem |
| 1573 |
* |
| 1574 |
* This object is the same as a chairitem, except that the player |
| 1575 |
* is described as lying on, rather than sitting in, the object. |
| 1576 |
*/ |
| 1577 |
class beditem: chairitem |
| 1578 |
ischair = nil |
| 1579 |
isbed = true |
| 1580 |
sdesc = "bed" |
| 1581 |
statusPrep = "on" |
| 1582 |
outOfPrep = "out of" |
| 1583 |
doLieon(actor) = |
| 1584 |
{ |
| 1585 |
"Okay, %you're% now lying on <<self.thedesc>>."; |
| 1586 |
actor.travelTo(self); |
| 1587 |
} |
| 1588 |
; |
| 1589 |
|
| 1590 |
/* |
| 1591 |
* floatingItem: object |
| 1592 |
* |
| 1593 |
* This class doesn't do anything apart from mark an object as having a |
| 1594 |
* variable location property. It is necessary to mark all such |
| 1595 |
* items by making them a member of this class, so that the objects are |
| 1596 |
* added to global.floatingList, which is necessary so that floating |
| 1597 |
* objects are included in validDoList and validIoList values (see |
| 1598 |
* the deepverb class for a description of these methods). |
| 1599 |
*/ |
| 1600 |
class floatingItem: object |
| 1601 |
; |
| 1602 |
|
| 1603 |
/* |
| 1604 |
* thing: object |
| 1605 |
* |
| 1606 |
* The basic class for objects in a game. The property contents |
| 1607 |
* is a list that specifies what is in the object; this property is |
| 1608 |
* automatically set up by the system after the game is compiled to |
| 1609 |
* contain a list of all objects that have this object as their |
| 1610 |
* location property. The contents property is kept |
| 1611 |
* consistent with the location properties of referenced objects |
| 1612 |
* by the moveInto method; always use moveInto rather than |
| 1613 |
* directly setting a location property for this reason. The |
| 1614 |
* adesc method displays the name of the object with an indefinite |
| 1615 |
* article; the default is to display "a" followed by the sdesc, |
| 1616 |
* but objects that need a different indefinite article (such as "an" |
| 1617 |
* or "some") should override this method. Likewise, thedesc |
| 1618 |
* displays the name with a definite article; by default, thedesc |
| 1619 |
* displays "the" followed by the object's sdesc. The sdesc |
| 1620 |
* simply displays the object's name ("short description") without |
| 1621 |
* any articles. The ldesc is the long description, normally |
| 1622 |
* displayed when the object is examined by the player; by default, |
| 1623 |
* the ldesc displays "It looks like an ordinary sdesc." |
| 1624 |
* The isIn(object) method returns true if the |
| 1625 |
* object's location is the specified object or the object's |
| 1626 |
* location is an object whose contentsVisible property is |
| 1627 |
* true and that object's isIn(object) method is |
| 1628 |
* true. Note that if isIn is true, it doesn't |
| 1629 |
* necessarily mean the object is reachable, because isIn is |
| 1630 |
* true if the object is merely visible within the location. |
| 1631 |
* The moveInto(object) method moves the object to be inside |
| 1632 |
* the specified object. To make an object disappear, move it |
| 1633 |
* into nil. |
| 1634 |
*/ |
| 1635 |
class thing: object |
| 1636 |
weight = 0 |
| 1637 |
statusPrep = "on" // give everything a default status preposition |
| 1638 |
bulk = 1 |
| 1639 |
isListed = true // shows up in room/inventory listings |
| 1640 |
contents = [] // set up automatically by system - do not set |
| 1641 |
verGrab(obj) = {} |
| 1642 |
Grab(obj) = {} |
| 1643 |
adesc = |
| 1644 |
{ |
| 1645 |
"a "; self.sdesc; // default is "a <name>"; "self" is current object |
| 1646 |
} |
| 1647 |
pluraldesc = // default is to add "s" to the sdesc |
| 1648 |
{ |
| 1649 |
self.sdesc; |
| 1650 |
if (not self.isThem) |
| 1651 |
"s"; |
| 1652 |
} |
| 1653 |
thedesc = |
| 1654 |
{ |
| 1655 |
"the "; self.sdesc; // default is "the <name>" |
| 1656 |
} |
| 1657 |
itnomdesc = |
| 1658 |
{ |
| 1659 |
/* |
| 1660 |
* display "it" in the nominative case: "it" if this is a |
| 1661 |
* singular object, "they" otherwise |
| 1662 |
*/ |
| 1663 |
if (self.isThem) |
| 1664 |
"they"; |
| 1665 |
else |
| 1666 |
"it"; |
| 1667 |
} |
| 1668 |
itobjdesc = |
| 1669 |
{ |
| 1670 |
/* |
| 1671 |
* display "it" in the objective case: "it" for singular, "them" |
| 1672 |
* otherwise |
| 1673 |
*/ |
| 1674 |
if (self.isThem) |
| 1675 |
"them"; |
| 1676 |
else |
| 1677 |
"it"; |
| 1678 |
} |
| 1679 |
itisdesc = |
| 1680 |
{ |
| 1681 |
/* display "it's" if this is singular, "they're" otherwise */ |
| 1682 |
if (self.isThem) |
| 1683 |
"they're"; |
| 1684 |
else |
| 1685 |
"it's"; |
| 1686 |
} |
| 1687 |
doesdesc = |
| 1688 |
{ |
| 1689 |
/* display "does" if singular, "do" otherwise (it does, they do) */ |
| 1690 |
if (self.isThem) |
| 1691 |
"do"; |
| 1692 |
else |
| 1693 |
"does"; |
| 1694 |
} |
| 1695 |
isdesc = |
| 1696 |
{ |
| 1697 |
/* display "is" if this is singular, "are" otherwise */ |
| 1698 |
if (self.isThem) |
| 1699 |
"are"; |
| 1700 |
else |
| 1701 |
"is"; |
| 1702 |
} |
| 1703 |
isntdesc = |
| 1704 |
{ |
| 1705 |
/* display "isn't" if this is singular, "aren't" otherwise */ |
| 1706 |
if (self.isThem) |
| 1707 |
"aren't"; |
| 1708 |
else |
| 1709 |
"isn't"; |
| 1710 |
} |
| 1711 |
itselfdesc = |
| 1712 |
{ |
| 1713 |
/* display "itself" if this is singular, "themselves" otherwise */ |
| 1714 |
if (self.isThem) |
| 1715 |
"themselves"; |
| 1716 |
else |
| 1717 |
"itself"; |
| 1718 |
} |
| 1719 |
thatdesc = |
| 1720 |
{ |
| 1721 |
/* display "that" if this is singular, "them" otherwise */ |
| 1722 |
if (self.isThem) |
| 1723 |
"those"; |
| 1724 |
else |
| 1725 |
"that"; |
| 1726 |
} |
| 1727 |
multisdesc = { self.sdesc; } |
| 1728 |
ldesc = |
| 1729 |
{ |
| 1730 |
if (self.isThem) |
| 1731 |
"\^<<self.itnomdesc>> look like ordinary <<self.sdesc>> to %me%."; |
| 1732 |
else |
| 1733 |
"\^<<self.itnomdesc>> looks like an |
| 1734 |
ordinary <<self.sdesc>> to %me%."; |
| 1735 |
} |
| 1736 |
readdesc = { "%You% can't read "; self.adesc; ". "; } |
| 1737 |
actorAction(v, d, p, i) = |
| 1738 |
{ |
| 1739 |
"%You% %have% lost %your% mind. "; |
| 1740 |
exit; |
| 1741 |
} |
| 1742 |
contentsVisible = { return true; } |
| 1743 |
contentsReachable = { return true; } |
| 1744 |
isIn(obj) = |
| 1745 |
{ |
| 1746 |
local myloc; |
| 1747 |
|
| 1748 |
myloc := self.location; |
| 1749 |
if (myloc) |
| 1750 |
{ |
| 1751 |
if (myloc = obj) |
| 1752 |
return true; |
| 1753 |
if (myloc.contentsVisible) |
| 1754 |
return myloc.isIn(obj); |
| 1755 |
} |
| 1756 |
return nil; |
| 1757 |
} |
| 1758 |
moveInto(obj) = |
| 1759 |
{ |
| 1760 |
local loc; |
| 1761 |
|
| 1762 |
/* |
| 1763 |
* For the object containing me, and its container, and so forth, |
| 1764 |
* tell it via a Grab message that I'm going away. |
| 1765 |
*/ |
| 1766 |
loc := self.location; |
| 1767 |
while (loc) |
| 1768 |
{ |
| 1769 |
loc.Grab(self); |
| 1770 |
loc := loc.location; |
| 1771 |
} |
| 1772 |
|
| 1773 |
if (self.location) |
| 1774 |
self.location.contents := self.location.contents - self; |
| 1775 |
self.location := obj; |
| 1776 |
if (obj) |
| 1777 |
obj.contents := obj.contents + self; |
| 1778 |
} |
| 1779 |
verDoSave(actor) = |
| 1780 |
{ |
| 1781 |
"Please specify the name of the game to save in double quotes, |
| 1782 |
for example, SAVE \"GAME1\". "; |
| 1783 |
} |
| 1784 |
verDoRestore(actor) = |
| 1785 |
{ |
| 1786 |
"Please specify the name of the game to restore in double quotes, |
| 1787 |
for example, RESTORE \"GAME1\". "; |
| 1788 |
} |
| 1789 |
verDoScript(actor) = |
| 1790 |
{ |
| 1791 |
"You should type the name of a file to write the transcript to |
| 1792 |
in quotes, for example, SCRIPT \"LOG1\". "; |
| 1793 |
} |
| 1794 |
verDoSay(actor) = |
| 1795 |
{ |
| 1796 |
"You should put what you want said in double quotes; for example, |
| 1797 |
SAY \"HELLO\". "; |
| 1798 |
} |
| 1799 |
verDoPush(actor) = |
| 1800 |
{ |
| 1801 |
"Pushing <<self.thedesc>> doesn't do anything. "; |
| 1802 |
} |
| 1803 |
|
| 1804 |
verDoAttachTo(actor, iobj) = { "There's no obvious way to do that."; } |
| 1805 |
verIoAttachTo(actor) = { "There's no obvious way to do that."; } |
| 1806 |
|
| 1807 |
verDoDetach(actor) = { "There's no obvious way to do that."; } |
| 1808 |
verDoDetachFrom(actor, iobj) = { "There's no obvious way to do that."; } |
| 1809 |
verIoDetachFrom(actor) = { "There's no obvious way to do that."; } |
| 1810 |
|
| 1811 |
verDoWear(actor) = |
| 1812 |
{ |
| 1813 |
"%You% can't wear "; self.thedesc; ". "; |
| 1814 |
} |
| 1815 |
verDoTake(actor) = |
| 1816 |
{ |
| 1817 |
if (self.location = actor) |
| 1818 |
{ |
| 1819 |
"%You% already %have% "; self.thedesc; "! "; |
| 1820 |
} |
| 1821 |
else |
| 1822 |
self.verifyRemove(actor); |
| 1823 |
} |
| 1824 |
verifyRemove(actor) = |
| 1825 |
{ |
| 1826 |
/* |
| 1827 |
* Check with each container to make sure that the container |
| 1828 |
* doesn't object to the object's removal. |
| 1829 |
*/ |
| 1830 |
local loc; |
| 1831 |
|
| 1832 |
loc := self.location; |
| 1833 |
while (loc) |
| 1834 |
{ |
| 1835 |
if (loc <> actor) |
| 1836 |
loc.verGrab(self); |
| 1837 |
loc := loc.location; |
| 1838 |
} |
| 1839 |
} |
| 1840 |
isVisible(vantage) = |
| 1841 |
{ |
| 1842 |
local loc; |
| 1843 |
|
| 1844 |
loc := self.location; |
| 1845 |
if (loc = nil) |
| 1846 |
return nil; |
| 1847 |
|
| 1848 |
/* |
| 1849 |
* if the vantage is inside me, and my contents are visible, |
| 1850 |
* I'm visible |
| 1851 |
*/ |
| 1852 |
if (vantage.location = self and self.contentsVisible) |
| 1853 |
return true; |
| 1854 |
|
| 1855 |
/* if I'm in the vantage, I'm visible */ |
| 1856 |
if (loc = vantage) |
| 1857 |
return true; |
| 1858 |
|
| 1859 |
/* |
| 1860 |
* if its location's contents are visible, and its location is |
| 1861 |
* itself visible, it's visible |
| 1862 |
*/ |
| 1863 |
if (loc.contentsVisible and loc.isVisible(vantage)) |
| 1864 |
return true; |
| 1865 |
|
| 1866 |
/* |
| 1867 |
* If the vantage has a location, and the vantage's location's |
| 1868 |
* contents are visible (if you can see me I can see you), and |
| 1869 |
* the object is visible from the vantage's location, the object |
| 1870 |
* is visible |
| 1871 |
*/ |
| 1872 |
if (vantage.location <> nil and vantage.location.contentsVisible and |
| 1873 |
self.isVisible(vantage.location)) |
| 1874 |
return true; |
| 1875 |
|
| 1876 |
/* all tests failed: it's not visible */ |
| 1877 |
return nil; |
| 1878 |
} |
| 1879 |
|
| 1880 |
/* |
| 1881 |
* This routine is called when the actor tries to manipulate this |
| 1882 |
* object, and the object is visible to the actor but can't be |
| 1883 |
* touched. |
| 1884 |
* |
| 1885 |
* If this object is inside something which doesn't block access to |
| 1886 |
* its contents (such as a closed container), we'll let the |
| 1887 |
* container handle it; this can bubble up to the enclosing room if |
| 1888 |
* all enclosing containers are open. |
| 1889 |
* |
| 1890 |
* If this object is inside a closed container, we'll point out that |
| 1891 |
* the container must be opened before the object can be |
| 1892 |
* manipulated. This usually means that the container is closed but |
| 1893 |
* transparent, so its contents can be seen but not touched. |
| 1894 |
*/ |
| 1895 |
cantReach(actor) = |
| 1896 |
{ |
| 1897 |
if (not actor.isactor) |
| 1898 |
{ |
| 1899 |
"\^<<actor.thedesc>> <<actor.doesdesc>> not respond."; |
| 1900 |
return; |
| 1901 |
} |
| 1902 |
if (not isclass(actor, movableActor)) |
| 1903 |
{ |
| 1904 |
"There's no point in talking to <<actor.sdesc>>."; |
| 1905 |
return; |
| 1906 |
} |
| 1907 |
|
| 1908 |
if (self.location = nil) |
| 1909 |
{ |
| 1910 |
if (actor.location.location) |
| 1911 |
"%You% can't reach <<self.thatdesc>> from << |
| 1912 |
actor.location.thedesc >>. "; |
| 1913 |
else |
| 1914 |
"%You% can't reach <<self.thatdesc>>."; |
| 1915 |
return; |
| 1916 |
} |
| 1917 |
if (not self.location.isopenable or self.location.isopen) |
| 1918 |
self.location.cantReach(actor); |
| 1919 |
else |
| 1920 |
"%You%'ll have to open << self.location.thedesc >> first. "; |
| 1921 |
} |
| 1922 |
|
| 1923 |
/* |
| 1924 |
* This routine is called when the actor is (directly) within this |
| 1925 |
* object, and is trying to reach something in the given room, but |
| 1926 |
* cannot. This should generate an appropriate message explaining |
| 1927 |
* why objects in the given room are visible but not reachable. By |
| 1928 |
* default, we'll just say that the object is not reachable; some |
| 1929 |
* rooms may wish to explain more fully why this is the case. |
| 1930 |
*/ |
| 1931 |
cantReachRoom(otherRoom) = |
| 1932 |
{ |
| 1933 |
"%You% can't reach that from here. "; |
| 1934 |
} |
| 1935 |
|
| 1936 |
isReachable(actor) = |
| 1937 |
{ |
| 1938 |
local loc; |
| 1939 |
|
| 1940 |
/* make sure the actor's location has a reachable list */ |
| 1941 |
if (actor.location = nil or actor.location.reachable = nil) |
| 1942 |
return nil; |
| 1943 |
|
| 1944 |
/* if the object is in the room's 'reachable' list, it's reachable */ |
| 1945 |
if (find(actor.location.reachable, self) <> nil) |
| 1946 |
return true; |
| 1947 |
|
| 1948 |
/* |
| 1949 |
* If the object's container's contents are reachable, and the |
| 1950 |
* container is reachable, the object is reachable. |
| 1951 |
*/ |
| 1952 |
loc := self.location; |
| 1953 |
if (loc = nil) |
| 1954 |
return nil; |
| 1955 |
if (loc = actor or loc = actor.location) |
| 1956 |
return true; |
| 1957 |
if (loc.contentsReachable) |
| 1958 |
return loc.isReachable(actor); |
| 1959 |
return nil; |
| 1960 |
} |
| 1961 |
doTake(actor) = |
| 1962 |
{ |
| 1963 |
local totbulk, totweight; |
| 1964 |
|
| 1965 |
totbulk := addbulk(actor.contents) + self.bulk; |
| 1966 |
totweight := addweight(actor.contents); |
| 1967 |
if (not actor.isCarrying(self)) |
| 1968 |
totweight := totweight + self.weight + addweight(self.contents); |
| 1969 |
|
| 1970 |
if (totweight > actor.maxweight) |
| 1971 |
"%Your% load is too heavy. "; |
| 1972 |
else if (totbulk > actor.maxbulk) |
| 1973 |
"%You've% already got %your% hands full. "; |
| 1974 |
else |
| 1975 |
{ |
| 1976 |
self.moveInto(actor); |
| 1977 |
"Taken. "; |
| 1978 |
} |
| 1979 |
} |
| 1980 |
verDoDrop(actor) = |
| 1981 |
{ |
| 1982 |
if (not actor.isCarrying(self)) |
| 1983 |
{ |
| 1984 |
"%You're% not carrying "; self.thedesc; "! "; |
| 1985 |
} |
| 1986 |
else self.verifyRemove(actor); |
| 1987 |
} |
| 1988 |
doDrop(actor) = |
| 1989 |
{ |
| 1990 |
actor.location.roomDrop(self); |
| 1991 |
} |
| 1992 |
verDoUnwear(actor) = |
| 1993 |
{ |
| 1994 |
"%You're% not wearing "; self.thedesc; "! "; |
| 1995 |
} |
| 1996 |
verIoPutIn(actor) = |
| 1997 |
{ |
| 1998 |
"%You% can't put anything into "; self.thedesc; ". "; |
| 1999 |
} |
| 2000 |
circularMessage(io) = |
| 2001 |
{ |
| 2002 |
local cont, prep; |
| 2003 |
|
| 2004 |
/* set prep to 'on' if io.location is a surface, 'in' otherwise */ |
| 2005 |
prep := (io.location.issurface ? 'on' : 'in'); |
| 2006 |
|
| 2007 |
/* tell them about the problem */ |
| 2008 |
"%You% can't put <<thedesc>> <<prep>> <<io.thedesc>>, because << |
| 2009 |
io.thedesc>> <<io.isdesc>> << |
| 2010 |
io.location = self ? "already" : "">> <<prep>> << |
| 2011 |
io.location.thedesc>>"; |
| 2012 |
for (cont := io.location ; cont <> self ; cont := cont.location) |
| 2013 |
{ |
| 2014 |
", which <<cont.isdesc>> << |
| 2015 |
cont.location = self ? "already" : "">> <<prep>> << |
| 2016 |
cont.location.thedesc>>"; |
| 2017 |
} |
| 2018 |
". "; |
| 2019 |
} |
| 2020 |
verDoPutIn(actor, io) = |
| 2021 |
{ |
| 2022 |
if (io = nil) |
| 2023 |
return; |
| 2024 |
|
| 2025 |
if (self.location = io) |
| 2026 |
{ |
| 2027 |
caps(); self.thedesc; " is already in "; io.thedesc; "! "; |
| 2028 |
} |
| 2029 |
else if (io = self) |
| 2030 |
{ |
| 2031 |
"%You% can't put "; self.thedesc; " in <<self.itselfdesc>>! "; |
| 2032 |
} |
| 2033 |
else if (io.isIn(self)) |
| 2034 |
self.circularMessage(io); |
| 2035 |
else |
| 2036 |
self.verifyRemove(actor); |
| 2037 |
} |
| 2038 |
doPutIn(actor, io) = |
| 2039 |
{ |
| 2040 |
self.moveInto(io); |
| 2041 |
"Done. "; |
| 2042 |
} |
| 2043 |
verIoPutOn(actor) = |
| 2044 |
{ |
| 2045 |
"There's no good surface on "; self.thedesc; ". "; |
| 2046 |
} |
| 2047 |
verDoPutOn(actor, io) = |
| 2048 |
{ |
| 2049 |
if (io = nil) |
| 2050 |
return; |
| 2051 |
|
| 2052 |
if (self.location = io) |
| 2053 |
{ |
| 2054 |
caps(); self.thedesc; " is already on "; io.thedesc; "! "; |
| 2055 |
} |
| 2056 |
else if (io = self) |
| 2057 |
{ |
| 2058 |
"%You% can't put "; self.thedesc; " on <<self.itselfdesc>>! "; |
| 2059 |
} |
| 2060 |
else if (io.isIn(self)) |
| 2061 |
self.circularMessage(io); |
| 2062 |
else |
| 2063 |
self.verifyRemove(actor); |
| 2064 |
} |
| 2065 |
doPutOn(actor, io) = |
| 2066 |
{ |
| 2067 |
self.moveInto(io); |
| 2068 |
"Done. "; |
| 2069 |
} |
| 2070 |
verIoTakeOut(actor) = {} |
| 2071 |
ioTakeOut(actor, dobj) = |
| 2072 |
{ |
| 2073 |
dobj.doTakeOut(actor, self); |
| 2074 |
} |
| 2075 |
verDoTakeOut(actor, io) = |
| 2076 |
{ |
| 2077 |
if (io <> nil and not self.isIn(io)) |
| 2078 |
{ |
| 2079 |
caps(); self.thedesc; " "; self.isntdesc; |
| 2080 |
" in "; io.thedesc; ". "; |
| 2081 |
} |
| 2082 |
else |
| 2083 |
self.verDoTake(actor); /* ensure object can be taken at all */ |
| 2084 |
} |
| 2085 |
doTakeOut(actor, io) = |
| 2086 |
{ |
| 2087 |
self.doTake(actor); |
| 2088 |
} |
| 2089 |
verIoTakeOff(actor) = {} |
| 2090 |
ioTakeOff(actor, dobj) = |
| 2091 |
{ |
| 2092 |
dobj.doTakeOff(actor, self); |
| 2093 |
} |
| 2094 |
verDoTakeOff(actor, io) = |
| 2095 |
{ |
| 2096 |
if (io <> nil and not self.isIn(io)) |
| 2097 |
{ |
| 2098 |
caps(); self.thedesc; " "; self.isntdesc; |
| 2099 |
" on "; io.thedesc; "! "; |
| 2100 |
} |
| 2101 |
self.verDoTake(actor); /* ensure object can be taken at all */ |
| 2102 |
} |
| 2103 |
doTakeOff(actor, io) = |
| 2104 |
{ |
| 2105 |
self.doTake(actor); |
| 2106 |
} |
| 2107 |
verIoPlugIn(actor) = |
| 2108 |
{ |
| 2109 |
"%You% can't plug anything into "; self.thedesc; ". "; |
| 2110 |
} |
| 2111 |
verDoPlugIn(actor, io) = |
| 2112 |
{ |
| 2113 |
"%You% can't plug "; self.thedesc; " into anything. "; |
| 2114 |
} |
| 2115 |
verIoUnplugFrom(actor) = |
| 2116 |
{ |
| 2117 |
"It's not plugged into "; self.thedesc; ". "; |
| 2118 |
} |
| 2119 |
verDoUnplugFrom(actor, io) = |
| 2120 |
{ |
| 2121 |
if (io <> nil) |
| 2122 |
{ "\^<<self.itisdesc>> not plugged into "; io.thedesc; ". "; } |
| 2123 |
} |
| 2124 |
verDoLookin(actor) = |
| 2125 |
{ |
| 2126 |
"There's nothing in "; self.thedesc; ". "; |
| 2127 |
} |
| 2128 |
thrudesc = { "%You% can't see much through << thedesc >>.\n"; } |
| 2129 |
verDoLookthru(actor) = |
| 2130 |
{ |
| 2131 |
"%You% can't see anything through "; self.thedesc; ". "; |
| 2132 |
} |
| 2133 |
verDoLookunder(actor) = |
| 2134 |
{ |
| 2135 |
"There's nothing under "; self.thedesc; ". "; |
| 2136 |
} |
| 2137 |
verDoInspect(actor) = {} |
| 2138 |
doInspect(actor) = |
| 2139 |
{ |
| 2140 |
self.ldesc; |
| 2141 |
} |
| 2142 |
verDoRead(actor) = |
| 2143 |
{ |
| 2144 |
"I don't know how to read "; self.thedesc; ". "; |
| 2145 |
} |
| 2146 |
verDoLookbehind(actor) = |
| 2147 |
{ |
| 2148 |
"There's nothing behind "; self.thedesc; ". "; |
| 2149 |
} |
| 2150 |
verDoTurn(actor) = |
| 2151 |
{ |
| 2152 |
"Turning <<self.thedesc>> doesn't have any effect. "; |
| 2153 |
} |
| 2154 |
verDoTurnWith(actor, io) = |
| 2155 |
{ |
| 2156 |
"Turning <<self.thedesc>> doesn't have any effect. "; |
| 2157 |
} |
| 2158 |
verDoTurnTo(actor, io) = |
| 2159 |
{ |
| 2160 |
"Turning <<self.thedesc>> doesn't have any effect. "; |
| 2161 |
} |
| 2162 |
verIoTurnTo(actor) = |
| 2163 |
{ |
| 2164 |
"I don't know how to do that. "; |
| 2165 |
} |
| 2166 |
verDoTurnon(actor) = |
| 2167 |
{ |
| 2168 |
"I don't know how to turn "; self.thedesc; " on. "; |
| 2169 |
} |
| 2170 |
verDoTurnoff(actor) = |
| 2171 |
{ |
| 2172 |
"I don't know how to turn "; self.thedesc; " off. "; |
| 2173 |
} |
| 2174 |
|
| 2175 |
verDoScrew(actor) = { "%You% see%s% no way to do that."; } |
| 2176 |
verDoScrewWith(actor, iobj) = { "%You% see%s% no way to do that."; } |
| 2177 |
verIoScrewWith(actor) = { "%You% can't use <<self.thedesc>> like that."; } |
| 2178 |
|
| 2179 |
verDoUnscrew(actor) = { "%You% see%s% no way to do that."; } |
| 2180 |
verDoUnscrewWith(actor, iobj) = { "%You% see%s% no way to do that."; } |
| 2181 |
verIoUnscrewWith(actor) = |
| 2182 |
{ "%You% can't use <<self.thedesc>> like that."; } |
| 2183 |
|
| 2184 |
verIoAskAbout(actor) = {} |
| 2185 |
ioAskAbout(actor, dobj) = |
| 2186 |
{ |
| 2187 |
dobj.doAskAbout(actor, self); |
| 2188 |
} |
| 2189 |
verDoAskAbout(actor, io) = |
| 2190 |
{ |
| 2191 |
"Surely, %you% can't think "; self.thedesc; " knows anything |
| 2192 |
about it! "; |
| 2193 |
} |
| 2194 |
verIoTellAbout(actor) = {} |
| 2195 |
ioTellAbout(actor, dobj) = |
| 2196 |
{ |
| 2197 |
dobj.doTellAbout(actor, self); |
| 2198 |
} |
| 2199 |
verDoTellAbout(actor, io) = |
| 2200 |
{ |
| 2201 |
"It doesn't look as though <<self.thedesc>> << |
| 2202 |
self.isdesc>> interested. "; |
| 2203 |
} |
| 2204 |
verDoUnboard(actor) = |
| 2205 |
{ |
| 2206 |
if (actor.location <> self) |
| 2207 |
{ |
| 2208 |
"%You're% not <<self.statusPrep>> <<self.thedesc>>! "; |
| 2209 |
} |
| 2210 |
else if (self.location = nil) |
| 2211 |
{ |
| 2212 |
"%You% can't leave <<self.thedesc>>! "; |
| 2213 |
} |
| 2214 |
} |
| 2215 |
doUnboard(actor) = |
| 2216 |
{ |
| 2217 |
if (self.fastenitem) |
| 2218 |
{ |
| 2219 |
"%You%'ll have to unfasten <<actor.location.fastenitem.thedesc |
| 2220 |
>> first. "; |
| 2221 |
} |
| 2222 |
else |
| 2223 |
{ |
| 2224 |
"Okay, %you're% no longer <<self.statusPrep>> <<self.thedesc>>. "; |
| 2225 |
self.leaveRoom(actor); |
| 2226 |
actor.moveInto(self.location); |
| 2227 |
} |
| 2228 |
} |
| 2229 |
verDoAttackWith(actor, io) = |
| 2230 |
{ |
| 2231 |
"Attacking <<self.thedesc>> doesn't appear productive. "; |
| 2232 |
} |
| 2233 |
verIoAttackWith(actor) = |
| 2234 |
{ |
| 2235 |
"It's not very effective to attack with <<self.thedesc>>. "; |
| 2236 |
} |
| 2237 |
verDoEat(actor) = |
| 2238 |
{ |
| 2239 |
"\^<<self.thedesc>> <<self.doesdesc>>n't appear appetizing. "; |
| 2240 |
} |
| 2241 |
verDoDrink(actor) = |
| 2242 |
{ |
| 2243 |
"\^<<self.thedesc>> <<self.doesdesc>>n't appear appetizing. "; |
| 2244 |
} |
| 2245 |
verDoGiveTo(actor, io) = |
| 2246 |
{ |
| 2247 |
if (not actor.isCarrying(self)) |
| 2248 |
{ |
| 2249 |
"%You're% not carrying "; self.thedesc; ". "; |
| 2250 |
} |
| 2251 |
else self.verifyRemove(actor); |
| 2252 |
} |
| 2253 |
doGiveTo(actor, io) = |
| 2254 |
{ |
| 2255 |
self.moveInto(io); |
| 2256 |
"Done. "; |
| 2257 |
} |
| 2258 |
verDoPull(actor) = |
| 2259 |
{ |
| 2260 |
"Pulling "; self.thedesc; " doesn't have any effect. "; |
| 2261 |
} |
| 2262 |
verDoThrowAt(actor, io) = |
| 2263 |
{ |
| 2264 |
if (not actor.isCarrying(self)) |
| 2265 |
{ |
| 2266 |
"%You're% not carrying "; self.thedesc; ". "; |
| 2267 |
} |
| 2268 |
else self.verifyRemove(actor); |
| 2269 |
} |
| 2270 |
doThrowAt(actor, io) = |
| 2271 |
{ |
| 2272 |
local loc; |
| 2273 |
|
| 2274 |
"%You% miss%es%. "; |
| 2275 |
|
| 2276 |
/* move it to the actor's location's thrown object destination */ |
| 2277 |
loc := actor.location; |
| 2278 |
if (loc != nil) |
| 2279 |
loc := loc.throwHitDest; |
| 2280 |
|
| 2281 |
/* move it to the location we figured out */ |
| 2282 |
self.moveInto(loc); |
| 2283 |
} |
| 2284 |
|
| 2285 |
/* |
| 2286 |
* The destination location of a thrown object when an actor is |
| 2287 |
* inside me. By default, this just returns 'self'. In some cases, |
| 2288 |
* special nested rooms might want to make the thrown object land |
| 2289 |
* somewhere different. |
| 2290 |
*/ |
| 2291 |
throwHitDest = { return self; } |
| 2292 |
|
| 2293 |
verIoThrowAt(actor) = |
| 2294 |
{ |
| 2295 |
if (actor.isCarrying(self)) |
| 2296 |
{ |
| 2297 |
"%You% could at least drop "; self.thedesc; " first. "; |
| 2298 |
} |
| 2299 |
} |
| 2300 |
ioThrowAt(actor, dobj) = |
| 2301 |
{ |
| 2302 |
dobj.doThrowAt(actor, self); |
| 2303 |
} |
| 2304 |
verDoThrowTo(actor, io) = |
| 2305 |
{ |
| 2306 |
if (not actor.isCarrying(self)) |
| 2307 |
{ |
| 2308 |
"%You're% not carrying "; self.thedesc; ". "; |
| 2309 |
} |
| 2310 |
else |
| 2311 |
self.verifyRemove(actor); |
| 2312 |
} |
| 2313 |
doThrowTo(actor, io) = |
| 2314 |
{ |
| 2315 |
"%You% miss%es%. "; |
| 2316 |
self.moveInto(actor.location); |
| 2317 |
} |
| 2318 |
verDoThrow(actor) = |
| 2319 |
{ |
| 2320 |
if (not actor.isCarrying(self)) |
| 2321 |
{ |
| 2322 |
"%You're% not carrying "; self.thedesc; ". "; |
| 2323 |
} |
| 2324 |
else |
| 2325 |
self.verifyRemove(actor); |
| 2326 |
} |
| 2327 |
doThrow(actor) = |
| 2328 |
{ |
| 2329 |
"Thrown. "; |
| 2330 |
self.moveInto(actor.location); |
| 2331 |
} |
| 2332 |
verDoShowTo(actor, io) = |
| 2333 |
{ |
| 2334 |
} |
| 2335 |
doShowTo(actor, io) = |
| 2336 |
{ |
| 2337 |
if (io <> nil) |
| 2338 |
{ |
| 2339 |
caps(); io.thedesc; " "; io.isntdesc; " impressed. "; |
| 2340 |
} |
| 2341 |
} |
| 2342 |
verIoShowTo(actor) = |
| 2343 |
{ |
| 2344 |
caps(); self.thedesc; " "; self.isntdesc; " impressed. "; |
| 2345 |
} |
| 2346 |
verDoClean(actor) = |
| 2347 |
{ |
| 2348 |
caps(); self.thedesc; " looks a bit cleaner now. "; |
| 2349 |
} |
| 2350 |
verDoCleanWith(actor, io) = {} |
| 2351 |
doCleanWith(actor, io) = |
| 2352 |
{ |
| 2353 |
caps(); self.thedesc; " looks a bit cleaner now. "; |
| 2354 |
} |
| 2355 |
verDoMove(actor) = |
| 2356 |
{ |
| 2357 |
"Moving "; self.thedesc; " doesn't reveal anything. "; |
| 2358 |
} |
| 2359 |
verDoMoveTo(actor, io) = |
| 2360 |
{ |
| 2361 |
"Moving "; self.thedesc; " doesn't reveal anything. "; |
| 2362 |
} |
| 2363 |
verIoMoveTo(actor) = |
| 2364 |
{ |
| 2365 |
"That doesn't get us anywhere. "; |
| 2366 |
} |
| 2367 |
verDoMoveWith(actor, io) = |
| 2368 |
{ |
| 2369 |
"Moving "; self.thedesc; " doesn't reveal anything. "; |
| 2370 |
} |
| 2371 |
verIoMoveWith(actor) = |
| 2372 |
{ |
| 2373 |
caps(); self.thedesc; " <<self.doesdesc>>n't seem to help. "; |
| 2374 |
} |
| 2375 |
verDoTypeOn(actor, io) = |
| 2376 |
{ |
| 2377 |
"You should put what you want typed in double quotes, for |
| 2378 |
example, TYPE \"HELLO\" ON KEYBOARD. "; |
| 2379 |
} |
| 2380 |
verDoTouch(actor) = |
| 2381 |
{ |
| 2382 |
"Touching "; self.thedesc; " doesn't seem to have any effect. "; |
| 2383 |
} |
| 2384 |
verDoPoke(actor) = |
| 2385 |
{ |
| 2386 |
"Poking "; self.thedesc; " doesn't seem to have any effect. "; |
| 2387 |
} |
| 2388 |
verDoBreak(actor) = {} |
| 2389 |
doBreak(actor) = |
| 2390 |
{ |
| 2391 |
"You'll have to tell me how to do that."; |
| 2392 |
} |
| 2393 |
genMoveDir = { "%You% can't seem to do that. "; } |
| 2394 |
verDoMoveN(actor) = { self.genMoveDir; } |
| 2395 |
verDoMoveS(actor) = { self.genMoveDir; } |
| 2396 |
verDoMoveE(actor) = { self.genMoveDir; } |
| 2397 |
verDoMoveW(actor) = { self.genMoveDir; } |
| 2398 |
verDoMoveNE(actor) = { self.genMoveDir; } |
| 2399 |
verDoMoveNW(actor) = { self.genMoveDir; } |
| 2400 |
verDoMoveSE(actor) = { self.genMoveDir; } |
| 2401 |
verDoMoveSW(actor) = { self.genMoveDir; } |
| 2402 |
verDoSearch(actor) = |
| 2403 |
{ |
| 2404 |
"%You% find%s% nothing of interest. "; |
| 2405 |
} |
| 2406 |
|
| 2407 |
/* on dynamic construction, move into my contents list */ |
| 2408 |
construct = |
| 2409 |
{ |
| 2410 |
self.moveInto(location); |
| 2411 |
} |
| 2412 |
|
| 2413 |
/* on dynamic destruction, move out of contents list */ |
| 2414 |
destruct = |
| 2415 |
{ |
| 2416 |
self.moveInto(nil); |
| 2417 |
} |
| 2418 |
|
| 2419 |
/* |
| 2420 |
* Make it so that the player can give a command to an actor only |
| 2421 |
* if an actor is reachable in the normal manner. This method |
| 2422 |
* returns true when 'self' can be given a command by the player. |
| 2423 |
*/ |
| 2424 |
validActor = (self.isReachable(parserGetMe())) |
| 2425 |
; |
| 2426 |
|
| 2427 |
/* |
| 2428 |
* item: thing |
| 2429 |
* |
| 2430 |
* A basic item which can be picked up by the player. It has no weight |
| 2431 |
* (0) and minimal bulk (1). The weight property should be set |
| 2432 |
* to a non-zero value for heavy objects. The bulk property |
| 2433 |
* should be set to a value greater than 1 for bulky objects, and to |
| 2434 |
* zero for objects that are very small and take essentially no effort |
| 2435 |
* to hold---or, more precisely, don't detract at all from the player's |
| 2436 |
* ability to hold other objects (for example, a piece of paper). |
| 2437 |
*/ |
| 2438 |
class item: thing |
| 2439 |
weight = 0 |
| 2440 |
bulk = 1 |
| 2441 |
; |
| 2442 |
|
| 2443 |
/* |
| 2444 |
* lightsource: item |
| 2445 |
* |
| 2446 |
* A portable lamp, candle, match, or other source of light. The |
| 2447 |
* light source can be turned on and off with the islit property. |
| 2448 |
* If islit is true, the object provides light, otherwise it's |
| 2449 |
* just an ordinary object. Note that this object provides a doTurnon |
| 2450 |
* method to provide appropriate behavior for a switchable light source, |
| 2451 |
* such as a flashlight or a room's electric lights. However, this object |
| 2452 |
* does not provide a verDoTurnon method, so by default it can't be |
| 2453 |
* switched on and off. To create something like a flashlight that should |
| 2454 |
* be a lightsource that can be switched on and off, simply include both |
| 2455 |
* lightsource and switchItem in the superclass list, and be sure |
| 2456 |
* that lightsource precedes switchItem in the superclass list, |
| 2457 |
* because the doTurnon method provided by lightsource should |
| 2458 |
* override the one provided by switchItem. The doTurnon method |
| 2459 |
* provided here turns on the light source (by setting its isActive |
| 2460 |
* property to true, and then describes the room if it was previously |
| 2461 |
* dark. |
| 2462 |
*/ |
| 2463 |
class lightsource: item |
| 2464 |
islamp = true |
| 2465 |
islit = nil |
| 2466 |
doTurnon(actor) = |
| 2467 |
{ |
| 2468 |
local waslit := actor.location.islit; |
| 2469 |
|
| 2470 |
// turn on the light |
| 2471 |
self.isActive := true; |
| 2472 |
self.islit := true; |
| 2473 |
"%You% switch%es% on <<self.thedesc>>"; |
| 2474 |
|
| 2475 |
// if the room wasn't previously lit, and it is now, describe it |
| 2476 |
if (actor.location.islit and not waslit) |
| 2477 |
{ |
| 2478 |
", lighting the area.\b"; |
| 2479 |
actor.location.enterRoom(actor); |
| 2480 |
} |
| 2481 |
else |
| 2482 |
"."; |
| 2483 |
} |
| 2484 |
; |
| 2485 |
|
| 2486 |
/* |
| 2487 |
* hiddenItem: object |
| 2488 |
* |
| 2489 |
* This is an object that is hidden with one of the hider classes. |
| 2490 |
* A hiddenItem object doesn't have any special properties in its |
| 2491 |
* own right, but all objects hidden with one of the hider classes |
| 2492 |
* must be of class hiddenItem so that initSearch can find |
| 2493 |
* them. |
| 2494 |
*/ |
| 2495 |
class hiddenItem: object |
| 2496 |
; |
| 2497 |
|
| 2498 |
/* |
| 2499 |
* hider: item |
| 2500 |
* |
| 2501 |
* This is a basic class of object that can hide other objects in various |
| 2502 |
* ways. The underHider, behindHider, and searchHider classes |
| 2503 |
* are examples of hider subclasses. The class defines |
| 2504 |
* the method searchObj(actor, list), which is given the list |
| 2505 |
* of hidden items contained in the object (for example, this would be the |
| 2506 |
* underCont property, in the case of an underHider), and "finds" |
| 2507 |
* the object or objects. Its action is dependent upon a couple of other |
| 2508 |
* properties of the hider object. The serialSearch property, |
| 2509 |
* if true, indicates that items in the list are to be found one at |
| 2510 |
* a time; if nil (the default), the entire list is found on the |
| 2511 |
* first try. The autoTake property, if true, indicates that |
| 2512 |
* the actor automatically takes the item or items found; if nil, the |
| 2513 |
* item or items are moved to the actor's location. The searchObj method |
| 2514 |
* returns the list with the found object or objects removed; the |
| 2515 |
* caller should assign this returned value back to the appropriate |
| 2516 |
* property (for example, underHider will assign the return value |
| 2517 |
* to underCont). |
| 2518 |
* |
| 2519 |
* Note that because the hider is hiding something, this class |
| 2520 |
* overrides the normal verDoSearch method to display the |
| 2521 |
* message, "You'll have to be more specific about how you want |
| 2522 |
* to search that." The reason is that the normal verDoSearch |
| 2523 |
* message ("You find nothing of interest") leads players to believe |
| 2524 |
* that the object was exhaustively searched, and we want to avoid |
| 2525 |
* misleading the player. On the other hand, we don't want a general |
| 2526 |
* search to be exhaustive for most hider objects. So, we just |
| 2527 |
* display a message letting the player know that the search was not |
| 2528 |
* enough, but we don't give away what they have to do instead. |
| 2529 |
* |
| 2530 |
* The objects hidden with one of the hider classes must be |
| 2531 |
* of class hiddenItem. |
| 2532 |
*/ |
| 2533 |
class hider: item |
| 2534 |
verDoSearch(actor) = |
| 2535 |
{ |
| 2536 |
"%You%'ll have to be more specific about how %you% want%s% |
| 2537 |
to search <<self.thatdesc>>. "; |
| 2538 |
} |
| 2539 |
searchObj(actor, list) = |
| 2540 |
{ |
| 2541 |
local found, dest, i, tot; |
| 2542 |
|
| 2543 |
/* see how much we get this time */ |
| 2544 |
if (self.serialSearch) |
| 2545 |
{ |
| 2546 |
found := [] + car(list); |
| 2547 |
list := cdr(list); |
| 2548 |
} |
| 2549 |
else |
| 2550 |
{ |
| 2551 |
found := list; |
| 2552 |
list := nil; |
| 2553 |
} |
| 2554 |
|
| 2555 |
/* set it(them) to the found item(s) */ |
| 2556 |
if (length(found) = 1) |
| 2557 |
setit(found[1]); // only one item - set 'it' |
| 2558 |
else |
| 2559 |
setit(found); // multiple items - set 'them' |
| 2560 |
|
| 2561 |
/* figure destination */ |
| 2562 |
dest := actor; |
| 2563 |
if (not self.autoTake) |
| 2564 |
dest := dest.location; |
| 2565 |
|
| 2566 |
/* note what we found, and move it to destination */ |
| 2567 |
"%You% find%s% "; |
| 2568 |
tot := length(found); |
| 2569 |
i := 1; |
| 2570 |
while (i <= tot) |
| 2571 |
{ |
| 2572 |
found[i].adesc; |
| 2573 |
if (i+1 < tot) |
| 2574 |
", "; |
| 2575 |
else if (i = 1 and tot = 2) |
| 2576 |
" and "; |
| 2577 |
else if (i+1 = tot and tot > 2) |
| 2578 |
", and "; |
| 2579 |
|
| 2580 |
found[i].moveInto(dest); |
| 2581 |
i := i + 1; |
| 2582 |
} |
| 2583 |
|
| 2584 |
/* say what happened */ |
| 2585 |
if (self.autoTake) |
| 2586 |
", which %you% take%s%. "; |
| 2587 |
else |
| 2588 |
"! "; |
| 2589 |
|
| 2590 |
if (list<>nil and length(list)=0) |
| 2591 |
list := nil; |
| 2592 |
return list; |
| 2593 |
} |
| 2594 |
serialSearch = nil /* find everything in one try by default */ |
| 2595 |
autoTake = true /* actor takes item when found by default */ |
| 2596 |
; |
| 2597 |
|
| 2598 |
/* |
| 2599 |
* underHider: hider |
| 2600 |
* |
| 2601 |
* This is an object that can have other objects placed under it. The |
| 2602 |
* objects placed under it can only be found by looking under the object; |
| 2603 |
* see the description of hider for more information. You should |
| 2604 |
* set the underLoc property of each hidden object to point to |
| 2605 |
* the underHider. |
| 2606 |
* |
| 2607 |
* Note that an underHider doesn't allow the player to put anything |
| 2608 |
* under the object during the game. Instead, it's to make it easy for the |
| 2609 |
* game writer to set up hidden objects while implementing the game. All you |
| 2610 |
* need to do to place an object under another object is declare the top |
| 2611 |
* object as an underHider, then declare the hidden object normally, |
| 2612 |
* except use underLoc rather than location to specify the |
| 2613 |
* location of the hidden object. The behindHider and searchHider |
| 2614 |
* objects work similarly. |
| 2615 |
* |
| 2616 |
* The objects hidden with underHider must be of class hiddenItem. |
| 2617 |
*/ |
| 2618 |
class underHider: hider |
| 2619 |
underCont = [] /* list of items under me (set up by initSearch) */ |
| 2620 |
verDoLookunder(actor) = { } |
| 2621 |
doLookunder(actor) = |
| 2622 |
{ |
| 2623 |
if (self.underCont = []) |
| 2624 |
"There's nothing under <<self.thedesc>>. "; |
| 2625 |
else if (self.underCont = nil) |
| 2626 |
"There's nothing else under <<self.thedesc>>. "; |
| 2627 |
else |
| 2628 |
self.underCont := self.searchObj(actor, self.underCont); |
| 2629 |
} |
| 2630 |
; |
| 2631 |
|
| 2632 |
/* |
| 2633 |
* behindHider: hider |
| 2634 |
* |
| 2635 |
* This is just like an underHider, except that objects are hidden |
| 2636 |
* behind this object. Objects to be behind this object should have their |
| 2637 |
* behindLoc property set to point to this object. |
| 2638 |
* |
| 2639 |
* The objects hidden with behindHider must be of class hiddenItem. |
| 2640 |
*/ |
| 2641 |
class behindHider: hider |
| 2642 |
behindCont = [] |
| 2643 |
verDoLookbehind(actor) = {} |
| 2644 |
doLookbehind(actor) = |
| 2645 |
{ |
| 2646 |
if (self.behindCont = []) |
| 2647 |
"There's nothing behind <<self.thedesc>>. "; |
| 2648 |
else if (self.behindCont = nil) |
| 2649 |
"There's nothing else behind <<self.thedesc>>. "; |
| 2650 |
else |
| 2651 |
self.behindCont := self.searchObj(actor, self.behindCont); |
| 2652 |
} |
| 2653 |
; |
| 2654 |
|
| 2655 |
/* |
| 2656 |
* searchHider: hider |
| 2657 |
* |
| 2658 |
* This is just like an underHider, except that objects are hidden |
| 2659 |
* within this object in such a way that the object must be looked in |
| 2660 |
* or searched. Objects to be hidden in this object should have their |
| 2661 |
* searchLoc property set to point to this object. Note that this |
| 2662 |
* is different from a normal container, in that the objects hidden within |
| 2663 |
* this object will not show up until the object is explicitly looked in |
| 2664 |
* or searched. |
| 2665 |
* |
| 2666 |
* The items hidden with searchHider must be of class hiddenItem. |
| 2667 |
*/ |
| 2668 |
class searchHider: hider |
| 2669 |
searchCont = [] |
| 2670 |
verDoSearch(actor) = {} |
| 2671 |
doSearch(actor) = |
| 2672 |
{ |
| 2673 |
if (self.searchCont = []) |
| 2674 |
"There's nothing in <<self.thedesc>>. "; |
| 2675 |
else if (self.searchCont = nil) |
| 2676 |
"There's nothing else in <<self.thedesc>>. "; |
| 2677 |
else |
| 2678 |
self.searchCont := self.searchObj(actor, self.searchCont); |
| 2679 |
} |
| 2680 |
verDoLookin(actor) = |
| 2681 |
{ |
| 2682 |
if (self.searchCont = [] || self.searchCont = nil) |
| 2683 |
pass verDoLookin; |
| 2684 |
} |
| 2685 |
doLookin(actor) = |
| 2686 |
{ |
| 2687 |
if (self.searchCont = [] || self.searchCont = nil) |
| 2688 |
pass doLookin; |
| 2689 |
else |
| 2690 |
self.searchCont := self.searchObj(actor, self.searchCont); |
| 2691 |
} |
| 2692 |
; |
| 2693 |
|
| 2694 |
|
| 2695 |
/* |
| 2696 |
* fixeditem: thing |
| 2697 |
* |
| 2698 |
* An object that cannot be taken or otherwise moved from its location. |
| 2699 |
* Note that a fixeditem is sometimes part of a movable object; |
| 2700 |
* this can be done to make one object part of another, ensuring that |
| 2701 |
* they cannot be separated. By default, the functions that list a room's |
| 2702 |
* contents do not automatically describe fixeditem objects (because |
| 2703 |
* the isListed property is set to nil). Instead, the game author |
| 2704 |
* will generally describe the fixeditem objects separately as part of |
| 2705 |
* the room's ldesc. |
| 2706 |
*/ |
| 2707 |
class fixeditem: thing // An immovable object |
| 2708 |
isListed = nil // not listed in room/inventory displays |
| 2709 |
isfixed = true // Item can't be taken |
| 2710 |
weight = 0 // no actual weight |
| 2711 |
bulk = 0 |
| 2712 |
verDoTake(actor) = |
| 2713 |
{ |
| 2714 |
"%You% can't have "; self.thedesc; ". "; |
| 2715 |
} |
| 2716 |
verDoTakeOut(actor, io) = |
| 2717 |
{ |
| 2718 |
self.verDoTake(actor); |
| 2719 |
} |
| 2720 |
verDoDrop(actor) = |
| 2721 |
{ |
| 2722 |
"%You% can't drop "; self.thedesc; ". "; |
| 2723 |
} |
| 2724 |
verDoTakeOff(actor, io) = |
| 2725 |
{ |
| 2726 |
self.verDoTake(actor); |
| 2727 |
} |
| 2728 |
verDoPutIn(actor, io) = |
| 2729 |
{ |
| 2730 |
"%You% can't put "; self.thedesc; " anywhere. "; |
| 2731 |
} |
| 2732 |
verDoPutOn(actor, io) = |
| 2733 |
{ |
| 2734 |
"%You% can't put "; self.thedesc; " anywhere. "; |
| 2735 |
} |
| 2736 |
verDoMove(actor) = |
| 2737 |
{ |
| 2738 |
"%You% can't move "; self.thedesc; ". "; |
| 2739 |
} |
| 2740 |
verDoThrowAt(actor, iobj) = |
| 2741 |
{ |
| 2742 |
"%You% can't throw <<self.thedesc>>."; |
| 2743 |
} |
| 2744 |
; |
| 2745 |
|
| 2746 |
/* |
| 2747 |
* readable: item |
| 2748 |
* |
| 2749 |
* An item that can be read. The readdesc property is displayed |
| 2750 |
* when the item is read. By default, the readdesc is the same |
| 2751 |
* as the ldesc, but the readdesc can be overridden to give |
| 2752 |
* a different message. |
| 2753 |
*/ |
| 2754 |
class readable: item |
| 2755 |
verDoRead(actor) = |
| 2756 |
{ |
| 2757 |
} |
| 2758 |
doRead(actor) = |
| 2759 |
{ |
| 2760 |
self.readdesc; |
| 2761 |
} |
| 2762 |
readdesc = |
| 2763 |
{ |
| 2764 |
self.ldesc; |
| 2765 |
} |
| 2766 |
; |
| 2767 |
|
| 2768 |
/* |
| 2769 |
* fooditem: item |
| 2770 |
* |
| 2771 |
* An object that can be eaten. When eaten, the object is removed from |
| 2772 |
* the game, and global.lastMealTime is decremented by the |
| 2773 |
* foodvalue property. By default, the foodvalue property |
| 2774 |
* is global.eatTime, which is the time between meals. So, the |
| 2775 |
* default fooditem will last for one "nourishment interval." |
| 2776 |
*/ |
| 2777 |
class fooditem: item |
| 2778 |
verDoEat(actor) = |
| 2779 |
{ |
| 2780 |
self.verifyRemove(actor); |
| 2781 |
} |
| 2782 |
doEat(actor) = |
| 2783 |
{ |
| 2784 |
"That was delicious! "; |
| 2785 |
global.lastMealTime := global.lastMealTime - self.foodvalue; |
| 2786 |
self.moveInto(nil); |
| 2787 |
} |
| 2788 |
foodvalue = { return global.eatTime; } |
| 2789 |
; |
| 2790 |
|
| 2791 |
/* |
| 2792 |
* dialItem: fixeditem |
| 2793 |
* |
| 2794 |
* This class is used for making "dials," which are controls in |
| 2795 |
* your game that can be turned to a range of numbers. You can |
| 2796 |
* define the property maxsetting as a number specifying the |
| 2797 |
* highest number to which the dial can be turned; the lowest number |
| 2798 |
* on the dial is minsetting. The setting property is the dial's |
| 2799 |
* current setting, and can be changed by the player by typing the |
| 2800 |
* command "turn dial to number." By default, the ldesc |
| 2801 |
* method displays the current setting. |
| 2802 |
*/ |
| 2803 |
class dialItem: fixeditem |
| 2804 |
minsetting = 1 // it has settings from this value... |
| 2805 |
maxsetting = 10 // ...to this value |
| 2806 |
setting = 1 // the current setting |
| 2807 |
ldesc = |
| 2808 |
{ |
| 2809 |
caps(); self.thedesc; " can be turned to settings |
| 2810 |
numbered from << self.minsetting >> to << self.maxsetting >>. |
| 2811 |
\^<<self.itisdesc>> currently set to << self.setting >>. "; |
| 2812 |
} |
| 2813 |
verDoTurn(actor) = {} |
| 2814 |
doTurn(actor) = |
| 2815 |
{ |
| 2816 |
askio(toPrep); |
| 2817 |
} |
| 2818 |
verDoTurnTo(actor, io) = {} |
| 2819 |
doTurnTo(actor, io) = |
| 2820 |
{ |
| 2821 |
if (io = numObj) |
| 2822 |
{ |
| 2823 |
if (numObj.value < self.minsetting |
| 2824 |
or numObj.value > self.maxsetting) |
| 2825 |
{ |
| 2826 |
"There's no such setting! "; |
| 2827 |
} |
| 2828 |
else if (numObj.value <> self.setting) |
| 2829 |
{ |
| 2830 |
self.setting := numObj.value; |
| 2831 |
"Okay, <<self.itisdesc>> now turned to "; |
| 2832 |
say(self.setting); ". "; |
| 2833 |
} |
| 2834 |
else |
| 2835 |
{ |
| 2836 |
"\^<<self.itisdesc>> already set to "; |
| 2837 |
say(self.setting); "! "; |
| 2838 |
} |
| 2839 |
} |
| 2840 |
else |
| 2841 |
{ |
| 2842 |
"I don't know how to turn "; self.thedesc; |
| 2843 |
" to that. "; |
| 2844 |
} |
| 2845 |
} |
| 2846 |
; |
| 2847 |
|
| 2848 |
/* |
| 2849 |
* switchItem: fixeditem |
| 2850 |
* |
| 2851 |
* This is a class for things that can be turned on and off by the |
| 2852 |
* player. The only special property is isActive, which is nil |
| 2853 |
* if the switch is turned off and true when turned on. The object |
| 2854 |
* accepts the commands "turn it on" and "turn it off," as well as |
| 2855 |
* synonymous constructions, and updates isActive accordingly. |
| 2856 |
*/ |
| 2857 |
class switchItem: fixeditem |
| 2858 |
verDoSwitch(actor) = {} |
| 2859 |
doSwitch(actor) = |
| 2860 |
{ |
| 2861 |
self.isActive := not self.isActive; |
| 2862 |
"Okay, "; self.thedesc; " <<self.isdesc>> now switched "; |
| 2863 |
if (self.isActive) |
| 2864 |
"on"; |
| 2865 |
else |
| 2866 |
"off"; |
| 2867 |
". "; |
| 2868 |
} |
| 2869 |
verDoTurnon(actor) = |
| 2870 |
{ |
| 2871 |
/* |
| 2872 |
* You can't turn on something in the dark unless you're |
| 2873 |
* carrying it. You also can't turn something on if it's |
| 2874 |
* already on. |
| 2875 |
*/ |
| 2876 |
if (not actor.location.islit and not actor.isCarrying(self)) |
| 2877 |
"It's pitch black."; |
| 2878 |
else if (self.isActive) |
| 2879 |
"\^<<self.itisdesc>> already turned on! "; |
| 2880 |
} |
| 2881 |
doTurnon(actor) = |
| 2882 |
{ |
| 2883 |
self.isActive := true; |
| 2884 |
"Okay, <<self.itisdesc>> now turned on. "; |
| 2885 |
} |
| 2886 |
verDoTurnoff(actor) = |
| 2887 |
{ |
| 2888 |
if (not self.isActive) |
| 2889 |
"\^<<self.itisdesc>> already turned off! "; |
| 2890 |
} |
| 2891 |
doTurnoff(actor) = |
| 2892 |
{ |
| 2893 |
self.isActive := nil; |
| 2894 |
"Okay, <<self.itisdesc>> now turned off. "; |
| 2895 |
} |
| 2896 |
; |
| 2897 |
|
| 2898 |
/* |
| 2899 |
* room: thing |
| 2900 |
* |
| 2901 |
* A location in the game. By default, the islit property is |
| 2902 |
* true, which means that the room is lit (no light source is |
| 2903 |
* needed while in the room). You should create a darkroom |
| 2904 |
* object rather than a room with islit set to nil if you |
| 2905 |
* want a dark room, because other methods are affected as well. |
| 2906 |
* The isseen property records whether the player has entered |
| 2907 |
* the room before; initially it's nil, and is set to true |
| 2908 |
* the first time the player enters. The roomAction(actor, |
| 2909 |
* verb, directObject, preposition, indirectObject) method is |
| 2910 |
* activated for each player command; by default, all it does is |
| 2911 |
* call the room's location's roomAction method if the room |
| 2912 |
* is inside another room. The lookAround(verbosity) |
| 2913 |
* method displays the room's description for a given verbosity |
| 2914 |
* level; true means a full description, nil means only |
| 2915 |
* the short description (just the room name plus a list of the |
| 2916 |
* objects present). roomDrop(object) is called when |
| 2917 |
* an object is dropped within the room; normally, it just moves |
| 2918 |
* the object to the room and displays "Dropped." The firstseen |
| 2919 |
* method is called when isseen is about to be set true |
| 2920 |
* for the first time (i.e., when the player first sees the room); |
| 2921 |
* by default, this routine does nothing, but it's a convenient |
| 2922 |
* place to put any special code you want to execute when a room |
| 2923 |
* is first entered. The firstseen method is called after |
| 2924 |
* the room's description is displayed. |
| 2925 |
*/ |
| 2926 |
class room: thing |
| 2927 |
/* |
| 2928 |
* 'reachable' is the list of explicitly reachable objects, over and |
| 2929 |
* above the objects that are here. This is mostly used in nested |
| 2930 |
* rooms to make objects in the containing room accessible. Most |
| 2931 |
* normal rooms will leave this as an empty list. |
| 2932 |
*/ |
| 2933 |
reachable = [] |
| 2934 |
|
| 2935 |
/* |
| 2936 |
* The default message when the actor can't reach something in the |
| 2937 |
* room. If we got here, it means that the object that the actor |
| 2938 |
* was actually trying to reach is within the room, or within |
| 2939 |
* something inside the room whose contents are accessible. |
| 2940 |
*/ |
| 2941 |
cantReach(actor) = |
| 2942 |
{ |
| 2943 |
if (actor.location = self || actor.location = nil) |
| 2944 |
{ |
| 2945 |
/* |
| 2946 |
* The actor is in the room, and not inside any other object |
| 2947 |
* within the room. The object must simply not be |
| 2948 |
* accessible for some reason. |
| 2949 |
*/ |
| 2950 |
"I don't see that here."; |
| 2951 |
} |
| 2952 |
else |
| 2953 |
{ |
| 2954 |
/* |
| 2955 |
* The actor is inside something from which the room is |
| 2956 |
* visible (such as something within the room), but from |
| 2957 |
* which the room's contents are not reachable. Tell the |
| 2958 |
* actor's location to generate an appropriate message. |
| 2959 |
*/ |
| 2960 |
actor.location.cantReachRoom(self); |
| 2961 |
} |
| 2962 |
} |
| 2963 |
|
| 2964 |
/* |
| 2965 |
* This routine is called when the actor is (directly) within this |
| 2966 |
* object, and is trying to reach something in the given room, but |
| 2967 |
* cannot. This should generate an appropriate message explaining |
| 2968 |
* why objects in the given room are visible but not reachable. By |
| 2969 |
* default, we'll just say that the object is not reachable; some |
| 2970 |
* rooms may wish to explain more fully why this is the case. |
| 2971 |
*/ |
| 2972 |
cantReachRoom(otherRoom) = |
| 2973 |
{ |
| 2974 |
"%You% can't reach that from here. "; |
| 2975 |
} |
| 2976 |
|
| 2977 |
/* |
| 2978 |
* roomCheck is true if the verb is valid in the room. This |
| 2979 |
* is a first pass; generally, its only function is to disallow |
| 2980 |
* certain commands in a dark room. |
| 2981 |
*/ |
| 2982 |
roomCheck(v) = { return true; } |
| 2983 |
islit = true // rooms are lit unless otherwise specified |
| 2984 |
isseen = nil // room has not been seen yet |
| 2985 |
enterRoom(actor) = // sent to room as actor is entering it |
| 2986 |
{ |
| 2987 |
self.lookAround((not self.isseen) or global.verbose); |
| 2988 |
if (self.islit) |
| 2989 |
{ |
| 2990 |
if (not self.isseen) |
| 2991 |
self.firstseen; |
| 2992 |
self.isseen := true; |
| 2993 |
} |
| 2994 |
} |
| 2995 |
|
| 2996 |
/* |
| 2997 |
* Notify this object that the current player character ("me") |
| 2998 |
* object is being explicitly moved into this room via the player |
| 2999 |
* character object's moveInto() method. This method is only called |
| 3000 |
* when the player character is explicitly moved into this location. |
| 3001 |
* This method doesn't do anything by default; it is provided for |
| 3002 |
* cases where the room must do something special when the player |
| 3003 |
* character is moved into it. |
| 3004 |
* |
| 3005 |
* Note that this is called BEFORE the player character's new |
| 3006 |
* location is established, so that we still have access to the |
| 3007 |
* player character's old location during this method. (Note that |
| 3008 |
* we do know the new location here - it's always 'self'.) |
| 3009 |
*/ |
| 3010 |
meIsMovingInto(meActor) = |
| 3011 |
{ |
| 3012 |
/* default does nothing */ |
| 3013 |
} |
| 3014 |
|
| 3015 |
roomAction(a, v, d, p, i) = |
| 3016 |
{ |
| 3017 |
if (self.location) |
| 3018 |
self.location.roomAction(a, v, d, p, i); |
| 3019 |
} |
| 3020 |
|
| 3021 |
/* |
| 3022 |
* Whenever a normal object (i.e., one that does not override the |
| 3023 |
* default doDrop provided by 'thing') is dropped, the actor's |
| 3024 |
* location is sent roomDrop(object being dropped). By default, |
| 3025 |
* we move the object into this room. |
| 3026 |
*/ |
| 3027 |
roomDrop(obj) = |
| 3028 |
{ |
| 3029 |
"Dropped. "; |
| 3030 |
obj.moveInto(self); |
| 3031 |
} |
| 3032 |
|
| 3033 |
/* |
| 3034 |
* Whenever an actor leaves this room, we run through the leaveList. |
| 3035 |
* This is a list of objects that have registered themselves with us |
| 3036 |
* via addLeaveList(). For each object in the leaveList, we send |
| 3037 |
* a "leaving" message, with the actor as the parameter. It should |
| 3038 |
* return true if it wants to be removed from the leaveList, nil |
| 3039 |
* if it wants to stay. |
| 3040 |
*/ |
| 3041 |
leaveList = [] |
| 3042 |
addLeaveList(obj) = |
| 3043 |
{ |
| 3044 |
self.leaveList := self.leaveList + obj; |
| 3045 |
} |
| 3046 |
leaveRoom(actor) = |
| 3047 |
{ |
| 3048 |
local tmplist, thisobj, i, tot; |
| 3049 |
|
| 3050 |
tmplist := self.leaveList; |
| 3051 |
tot := length(tmplist); |
| 3052 |
i := 1; |
| 3053 |
while (i <= tot) |
| 3054 |
{ |
| 3055 |
thisobj := tmplist[i]; |
| 3056 |
if (thisobj.leaving(actor)) |
| 3057 |
self.leaveList := self.leaveList - thisobj; |
| 3058 |
i := i + 1; |
| 3059 |
} |
| 3060 |
} |
| 3061 |
|
| 3062 |
/* |
| 3063 |
* dispParagraph - display the paragraph separator. By default we |
| 3064 |
* display a \n\t sequence; games can change this (via 'modify') to |
| 3065 |
* customize the display format |
| 3066 |
*/ |
| 3067 |
dispParagraph = "\n\t" |
| 3068 |
|
| 3069 |
/* |
| 3070 |
* dispBeginSdesc and dispEndSdesc - display begin and end of |
| 3071 |
* location short description sequence. We'll call these just |
| 3072 |
* before and after showing a room's description. By default these |
| 3073 |
* do nothing; games that want to customize the display format can |
| 3074 |
* change these (via 'modify'). |
| 3075 |
*/ |
| 3076 |
dispBeginSdesc = "" |
| 3077 |
dispEndSdesc = "" |
| 3078 |
|
| 3079 |
/* |
| 3080 |
* dispBeginLdesc and dispEndLdesc - display begin and end of |
| 3081 |
* location long description sequence. We'll call these just before |
| 3082 |
* and after showing a room's long description. By default, we |
| 3083 |
* start a new paragraph before the ldesc; games that want to |
| 3084 |
* customize the display format can change these (via 'modify'). |
| 3085 |
*/ |
| 3086 |
dispBeginLdesc = { self.dispParagraph; } |
| 3087 |
dispEndLdesc = "" |
| 3088 |
|
| 3089 |
/* |
| 3090 |
* lookAround describes the room. If verbosity is true, the full |
| 3091 |
* description is given, otherwise an abbreviated description (without |
| 3092 |
* the room's ldesc) is displayed. |
| 3093 |
*/ |
| 3094 |
nrmLkAround(verbosity) = // lookAround without location status |
| 3095 |
{ |
| 3096 |
local l, cur, i, tot; |
| 3097 |
|
| 3098 |
if (verbosity) |
| 3099 |
{ |
| 3100 |
self.dispBeginLdesc; |
| 3101 |
self.ldesc; |
| 3102 |
self.dispEndLdesc; |
| 3103 |
|
| 3104 |
l := self.contents; |
| 3105 |
tot := length(l); |
| 3106 |
i := 1; |
| 3107 |
while (i <= tot) |
| 3108 |
{ |
| 3109 |
cur := l[i]; |
| 3110 |
if (cur.isfixed) |
| 3111 |
cur.heredesc; |
| 3112 |
i := i + 1; |
| 3113 |
} |
| 3114 |
} |
| 3115 |
|
| 3116 |
self.dispParagraph; |
| 3117 |
if (itemcnt(self.contents)) |
| 3118 |
{ |
| 3119 |
"%You% see%s% "; listcont(self); " here. "; |
| 3120 |
} |
| 3121 |
listcontcont(self); "\n"; |
| 3122 |
|
| 3123 |
l := self.contents; |
| 3124 |
tot := length(l); |
| 3125 |
i := 1; |
| 3126 |
while (i <= tot) |
| 3127 |
{ |
| 3128 |
cur := l[i]; |
| 3129 |
if (cur.isactor) |
| 3130 |
{ |
| 3131 |
if (cur <> parserGetMe()) |
| 3132 |
{ |
| 3133 |
self.dispParagraph; |
| 3134 |
cur.actorDesc; |
| 3135 |
} |
| 3136 |
} |
| 3137 |
i := i + 1; |
| 3138 |
} |
| 3139 |
"\n"; |
| 3140 |
} |
| 3141 |
#ifdef USE_HTML_STATUS |
| 3142 |
|
| 3143 |
/* |
| 3144 |
* Generate HTML formatting that provides the traditional status |
| 3145 |
* line appearance, using the traditional status line computation |
| 3146 |
* mechanism. |
| 3147 |
*/ |
| 3148 |
statusLine = |
| 3149 |
{ |
| 3150 |
/* |
| 3151 |
* Check the system to see if this is an HTML-enabled run-time. |
| 3152 |
* If so, generate an HTML-style banner; otherwise, generate an |
| 3153 |
* old-style banner. |
| 3154 |
*/ |
| 3155 |
if (systemInfo(__SYSINFO_SYSINFO) = true |
| 3156 |
and systemInfo(__SYSINFO_HTML) = 1) |
| 3157 |
{ |
| 3158 |
"<banner id=StatusLine height=previous border> |
| 3159 |
<body bgcolor=statusbg text=statustext><b>"; |
| 3160 |
|
| 3161 |
self.statusRoot; |
| 3162 |
|
| 3163 |
"</b><tab align=right><i>"; |
| 3164 |
|
| 3165 |
say(scoreFormat(global.score, global.turnsofar)); |
| 3166 |
" "; |
| 3167 |
|
| 3168 |
"</i></banner>"; |
| 3169 |
} |
| 3170 |
else |
| 3171 |
{ |
| 3172 |
self.statusRoot; |
| 3173 |
self.dispParagraph; |
| 3174 |
} |
| 3175 |
} |
| 3176 |
|
| 3177 |
#else /* USE_HTML_STATUS */ |
| 3178 |
|
| 3179 |
/* use the standard HTML status line system */ |
| 3180 |
statusLine = |
| 3181 |
{ |
| 3182 |
self.statusRoot; |
| 3183 |
self.dispParagraph; |
| 3184 |
} |
| 3185 |
|
| 3186 |
#endif /* USE_HTML_STATUS */ |
| 3187 |
|
| 3188 |
statusRoot = |
| 3189 |
{ |
| 3190 |
self.sdesc; |
| 3191 |
} |
| 3192 |
lookAround(verbosity) = |
| 3193 |
{ |
| 3194 |
self.dispBeginSdesc; |
| 3195 |
self.statusRoot; |
| 3196 |
self.dispEndSdesc; |
| 3197 |
|
| 3198 |
self.nrmLkAround(verbosity); |
| 3199 |
} |
| 3200 |
|
| 3201 |
/* |
| 3202 |
* Direction handlers for the player character. The directions are |
| 3203 |
* all set up to the default, which is no travel allowed. To make |
| 3204 |
* travel possible in a direction, just assign a room to the |
| 3205 |
* direction property. |
| 3206 |
*/ |
| 3207 |
north = { return self.noexit; } |
| 3208 |
south = { return self.noexit; } |
| 3209 |
east = { return self.noexit; } |
| 3210 |
west = { return self.noexit; } |
| 3211 |
up = { return self.noexit; } |
| 3212 |
down = { return self.noexit; } |
| 3213 |
ne = { return self.noexit; } |
| 3214 |
nw = { return self.noexit; } |
| 3215 |
se = { return self.noexit; } |
| 3216 |
sw = { return self.noexit; } |
| 3217 |
in = { return self.noexit; } |
| 3218 |
out = { return self.noexit; } |
| 3219 |
|
| 3220 |
/* |
| 3221 |
* Direction handlers for non-player characters. By default, we |
| 3222 |
* handle each direction for an NPC the same way we handle the |
| 3223 |
* corresponding direction for the player character. A room can |
| 3224 |
* override any of these it wants to differentiate between PC travel |
| 3225 |
* and NPC travel. |
| 3226 |
*/ |
| 3227 |
actorNorth = { return self.north; } |
| 3228 |
actorSouth = { return self.south; } |
| 3229 |
actorEast = { return self.east; } |
| 3230 |
actorWest = { return self.west; } |
| 3231 |
actorUp = { return self.up; } |
| 3232 |
actorDown = { return self.down; } |
| 3233 |
actorNE = { return self.ne; } |
| 3234 |
actorNW = { return self.nw; } |
| 3235 |
actorSE = { return self.se; } |
| 3236 |
actorSW = { return self.sw; } |
| 3237 |
actorIn = { return self.in; } |
| 3238 |
actorOut = { return self.out; } |
| 3239 |
|
| 3240 |
/* |
| 3241 |
* noexit displays a message when the player attempts to travel |
| 3242 |
* in a direction in which travel is not possible. |
| 3243 |
*/ |
| 3244 |
noexit = { "%You% can't go that way. "; return nil; } |
| 3245 |
; |
| 3246 |
|
| 3247 |
/* |
| 3248 |
* darkroom: room |
| 3249 |
* |
| 3250 |
* A dark room. The player must have some object that can act as a |
| 3251 |
* light source in order to move about and perform most operations |
| 3252 |
* while in this room. Note that the room's lights can be turned |
| 3253 |
* on by setting the room's lightsOn property to true; |
| 3254 |
* do this instead of setting islit, because islit is |
| 3255 |
* a method which checks for the presence of a light source. |
| 3256 |
*/ |
| 3257 |
class darkroom: room // An enterable area which might be dark |
| 3258 |
islit = // true ONLY if something is lighting the room |
| 3259 |
{ |
| 3260 |
local rem, cur, tot, i; |
| 3261 |
|
| 3262 |
if (self.lightsOn) |
| 3263 |
return true; |
| 3264 |
|
| 3265 |
rem := global.lamplist; |
| 3266 |
tot := length(rem); |
| 3267 |
i := 1; |
| 3268 |
while (i <= tot) |
| 3269 |
{ |
| 3270 |
cur := rem[i]; |
| 3271 |
if (cur.isIn(self) and cur.islit) |
| 3272 |
return true; |
| 3273 |
i := i + 1; |
| 3274 |
} |
| 3275 |
return nil; |
| 3276 |
} |
| 3277 |
roomAction(actor, v, dobj, prep, io) = |
| 3278 |
{ |
| 3279 |
if (not self.islit and not v.isDarkVerb) |
| 3280 |
{ |
| 3281 |
"%You% can't see a thing. "; |
| 3282 |
exit; |
| 3283 |
} |
| 3284 |
else |
| 3285 |
pass roomAction; |
| 3286 |
} |
| 3287 |
statusRoot = |
| 3288 |
{ |
| 3289 |
if (self.islit) |
| 3290 |
pass statusRoot; |
| 3291 |
else |
| 3292 |
"In the dark."; |
| 3293 |
} |
| 3294 |
lookAround(verbosity) = |
| 3295 |
{ |
| 3296 |
if (self.islit) |
| 3297 |
pass lookAround; |
| 3298 |
else |
| 3299 |
"It's pitch black. "; |
| 3300 |
} |
| 3301 |
noexit = |
| 3302 |
{ |
| 3303 |
if (self.islit) |
| 3304 |
pass noexit; |
| 3305 |
else |
| 3306 |
{ |
| 3307 |
darkTravel(); |
| 3308 |
return nil; |
| 3309 |
} |
| 3310 |
} |
| 3311 |
roomCheck(v) = |
| 3312 |
{ |
| 3313 |
if (self.islit or v.isDarkVerb) |
| 3314 |
return true; |
| 3315 |
else |
| 3316 |
{ |
| 3317 |
"It's pitch black.\n"; |
| 3318 |
return nil; |
| 3319 |
} |
| 3320 |
} |
| 3321 |
; |
| 3322 |
|
| 3323 |
/* |
| 3324 |
* theFloor is a special item that appears in every room (hence |
| 3325 |
* the non-standard location property). This object is included |
| 3326 |
* mostly for completeness, so that the player can refer to the |
| 3327 |
* floor; otherwise, it doesn't do much. Dropping an item on the |
| 3328 |
* floor, for example, moves it to the current room. |
| 3329 |
*/ |
| 3330 |
theFloor: beditem, floatingItem |
| 3331 |
noun = 'floor' 'ground' |
| 3332 |
sdesc = "ground" |
| 3333 |
ldesc = "It lies beneath %youm%. " |
| 3334 |
adesc = "the ground" |
| 3335 |
statusPrep = "on" |
| 3336 |
outOfPrep = "off of" |
| 3337 |
location = |
| 3338 |
{ |
| 3339 |
if (parserGetMe().location = self) |
| 3340 |
return self.sitloc; |
| 3341 |
else |
| 3342 |
return parserGetMe().location; |
| 3343 |
} |
| 3344 |
locationOK = true // suppress warning about location being a method |
| 3345 |
doSiton(actor) = |
| 3346 |
{ |
| 3347 |
"Okay, %you're% now sitting on "; self.thedesc; ". "; |
| 3348 |
self.sitloc := actor.location; |
| 3349 |
actor.moveInto(self); |
| 3350 |
} |
| 3351 |
meIsMovingInto(meActor) = |
| 3352 |
{ |
| 3353 |
/* |
| 3354 |
* When the player character object is explicitly moved into |
| 3355 |
* theFloor, we must set our sitloc property to the player |
| 3356 |
* character's old location. Since we're floating, we don't |
| 3357 |
* have a location ourselves, so we use sitloc to keep track of |
| 3358 |
* the effective container that the player should see when |
| 3359 |
* moving back out of the floor. |
| 3360 |
*/ |
| 3361 |
self.sitloc := meActor.location; |
| 3362 |
} |
| 3363 |
|
| 3364 |
doLieon(actor) = |
| 3365 |
{ |
| 3366 |
self.doSiton(actor); |
| 3367 |
} |
| 3368 |
ioPutOn(actor, dobj) = |
| 3369 |
{ |
| 3370 |
dobj.doDrop(actor); |
| 3371 |
} |
| 3372 |
ioPutIn(actor, dobj) = |
| 3373 |
{ |
| 3374 |
dobj.doDrop(actor); |
| 3375 |
} |
| 3376 |
ioThrowAt(actor, dobj) = |
| 3377 |
{ |
| 3378 |
"Thrown. "; |
| 3379 |
dobj.moveInto(actor.location); |
| 3380 |
} |
| 3381 |
|
| 3382 |
/* |
| 3383 |
* when the actor is on the floor, throwing an object makes the |
| 3384 |
* object land in the current floating location |
| 3385 |
*/ |
| 3386 |
throwHitDest = { return self.location; } |
| 3387 |
; |
| 3388 |
|
| 3389 |
/* |
| 3390 |
* Actor: fixeditem, movableActor |
| 3391 |
* |
| 3392 |
* A character in the game. The maxweight property specifies |
| 3393 |
* the maximum weight that the character can carry, and the maxbulk |
| 3394 |
* property specifies the maximum bulk the character can carry. The |
| 3395 |
* actorAction(verb, directObject, preposition, indirectObject) |
| 3396 |
* method specifies what happens when the actor is given a command by |
| 3397 |
* the player; by default, the actor ignores the command and displays |
| 3398 |
* a message to this effect. The isCarrying(object) |
| 3399 |
* method returns true if the object is being carried by |
| 3400 |
* the actor. The actorDesc method displays a message when the |
| 3401 |
* actor is in the current room; this message is displayed along with |
| 3402 |
* a room's description when the room is entered or examined. The |
| 3403 |
* verGrab(object) method is called when someone tries to |
| 3404 |
* take an object the actor is carrying; by default, an actor won't |
| 3405 |
* let other characters take its possessions. |
| 3406 |
* |
| 3407 |
* If you want the player to be able to follow the actor when it |
| 3408 |
* leaves the room, you should define a follower object to shadow |
| 3409 |
* the character, and set the actor's myfollower property to |
| 3410 |
* the follower object. The follower is then automatically |
| 3411 |
* moved around just behind the actor by the actor's moveInto |
| 3412 |
* method. |
| 3413 |
* |
| 3414 |
* The isHim property should return true if the actor can |
| 3415 |
* be referred to by the player as "him," and likewise isHer |
| 3416 |
* should be set to true if the actor can be referred to as "her." |
| 3417 |
* Note that both or neither can be set; if neither is set, the actor |
| 3418 |
* can only be referred to as "it," and if both are set, any of "him," |
| 3419 |
* "her," or "it" will be accepted. |
| 3420 |
*/ |
| 3421 |
class Actor: fixeditem, movableActor |
| 3422 |
; |
| 3423 |
|
| 3424 |
/* |
| 3425 |
* movableActor: qcontainer |
| 3426 |
* |
| 3427 |
* Just like an Actor object, except that the player can |
| 3428 |
* manipulate the actor like an ordinary item. Useful for certain |
| 3429 |
* types of actors, such as small animals. |
| 3430 |
*/ |
| 3431 |
class movableActor: qcontainer // A character in the game |
| 3432 |
isListed = nil // described separately from room's contents |
| 3433 |
weight = 10 // actors are pretty heavy |
| 3434 |
bulk = 10 // and pretty bulky |
| 3435 |
maxweight = 50 // Weight that can be carried at once |
| 3436 |
maxbulk = 20 // Number of objects that can be carried at once |
| 3437 |
isactor = true // flag that this is an actor |
| 3438 |
reachable = [] |
| 3439 |
roomCheck(v) = |
| 3440 |
{ |
| 3441 |
/* |
| 3442 |
* if the actor has a location, return its roomCheck, otherwise |
| 3443 |
* simply allow the command |
| 3444 |
*/ |
| 3445 |
if (self.location) |
| 3446 |
return self.location.roomCheck(v); |
| 3447 |
else |
| 3448 |
return true; |
| 3449 |
} |
| 3450 |
actorAction(v, d, p, i) = |
| 3451 |
{ |
| 3452 |
"\^<<self.thedesc>> <<self.doesdesc>>n't appear interested. "; |
| 3453 |
exit; |
| 3454 |
} |
| 3455 |
isCarrying(obj) = { return obj.isIn(self); } |
| 3456 |
actorDesc = |
| 3457 |
{ |
| 3458 |
"\^<<self.adesc>> is here. "; |
| 3459 |
} |
| 3460 |
verGrab(item) = |
| 3461 |
{ |
| 3462 |
"\^<<self.thedesc>> <<self.isdesc>> carrying <<item.thedesc>> and |
| 3463 |
won't let %youm% have <<item.itobjdesc>>. "; |
| 3464 |
} |
| 3465 |
verDoFollow(actor) = |
| 3466 |
{ |
| 3467 |
"But <<self.thedesc>> is right here! "; |
| 3468 |
} |
| 3469 |
moveInto(obj) = |
| 3470 |
{ |
| 3471 |
if (self.myfollower) |
| 3472 |
self.myfollower.moveInto(self.location); |
| 3473 |
pass moveInto; |
| 3474 |
} |
| 3475 |
// these properties are for the format strings |
| 3476 |
fmtYou = { self.isHim ? "he" : self.isHer ? "she" : "it"; } |
| 3477 |
fmtYour = { self.isHim ? "his" : self.isHer ? "her" : "its"; } |
| 3478 |
fmtYoure = { self.isHim ? "he's" : self.isHer ? "she's" : "it's"; } |
| 3479 |
fmtYoum = { self.isHim ? "him" : self.isHer ? "her" : "it"; } |
| 3480 |
fmtYouve = { self.isHim ? "he's" : self.isHer ? "she's" : "it's"; } |
| 3481 |
fmtS = "s" |
| 3482 |
fmtEs = "es" |
| 3483 |
fmtHave = "has" |
| 3484 |
fmtDo = "does" |
| 3485 |
fmtAre = "is" |
| 3486 |
fmtMe = { self.thedesc; } |
| 3487 |
askWord(word, lst) = { return nil; } |
| 3488 |
verDoAskAbout(actor, iobj) = {} |
| 3489 |
doAskAbout(actor, iobj) = |
| 3490 |
{ |
| 3491 |
local lst, i, tot; |
| 3492 |
|
| 3493 |
lst := objwords(2); // get actual words asked about |
| 3494 |
tot := length(lst); |
| 3495 |
if ((tot = 1 and (find(['it' 'them' 'him' 'her'], lst[1]) <> nil)) |
| 3496 |
or tot = 0) |
| 3497 |
{ |
| 3498 |
"\"Could you be more specific?\""; |
| 3499 |
return; |
| 3500 |
} |
| 3501 |
|
| 3502 |
// try to find a response for each word |
| 3503 |
for (i := 1 ; i <= tot ; ++i) |
| 3504 |
{ |
| 3505 |
if (self.askWord(lst[i], lst)) |
| 3506 |
return; |
| 3507 |
} |
| 3508 |
|
| 3509 |
// didn't find anything to talk about |
| 3510 |
self.disavow; |
| 3511 |
} |
| 3512 |
disavow = "\"I don't know much about that.\"" |
| 3513 |
verIoPutIn(actor) = |
| 3514 |
{ |
| 3515 |
"If you want something given to << thedesc >>, just say so."; |
| 3516 |
} |
| 3517 |
verIoGiveTo(actor) = |
| 3518 |
{ |
| 3519 |
if (actor = self) |
| 3520 |
"That wouldn't accomplish anything!"; |
| 3521 |
} |
| 3522 |
ioGiveTo(actor, dobj) = |
| 3523 |
{ |
| 3524 |
"\^<<self.thedesc>> rejects the offer."; |
| 3525 |
} |
| 3526 |
|
| 3527 |
// move to a new location, notifying player of coming and going |
| 3528 |
travelTo(room) = |
| 3529 |
{ |
| 3530 |
local old_loc_visible; |
| 3531 |
local new_loc_visible; |
| 3532 |
|
| 3533 |
/* if it's an obstacle, travel to the obstacle instead */ |
| 3534 |
while (room != nil && room.isobstacle) |
| 3535 |
room := room.destination; |
| 3536 |
|
| 3537 |
/* do nothing if going nowhere */ |
| 3538 |
if (room = nil) |
| 3539 |
return; |
| 3540 |
|
| 3541 |
/* note whether the actor was previously visible */ |
| 3542 |
old_loc_visible := (self.location != nil |
| 3543 |
&& parserGetMe().isVisible(self.location)); |
| 3544 |
|
| 3545 |
/* note whether the actor will be visible in the new location */ |
| 3546 |
new_loc_visible := parserGetMe().isVisible(room); |
| 3547 |
|
| 3548 |
/* |
| 3549 |
* if I'm leaving the player's location, and I was previously |
| 3550 |
* visible, and I'm not going to be visible after the move, and |
| 3551 |
* the player's location isn't dark, show the "leaving" message |
| 3552 |
*/ |
| 3553 |
if (parserGetMe().location != nil |
| 3554 |
&& parserGetMe().location.islit |
| 3555 |
&& old_loc_visible |
| 3556 |
&& !new_loc_visible) |
| 3557 |
self.sayLeaving; |
| 3558 |
|
| 3559 |
/* move to my new location */ |
| 3560 |
self.moveInto(room); |
| 3561 |
|
| 3562 |
/* |
| 3563 |
* if I'm visible to the player at the new location, and I |
| 3564 |
* wasn't previously visible, and it's not dark, show the |
| 3565 |
* "arriving" message |
| 3566 |
*/ |
| 3567 |
if (parserGetMe().location != nil |
| 3568 |
&& parserGetMe().location.islit |
| 3569 |
&& new_loc_visible |
| 3570 |
&& !old_loc_visible) |
| 3571 |
self.sayArriving; |
| 3572 |
} |
| 3573 |
|
| 3574 |
// sayLeaving and sayArriving announce the actor's departure and arrival |
| 3575 |
// in the same room as the player. |
| 3576 |
sayLeaving = |
| 3577 |
{ |
| 3578 |
self.location.dispParagraph; |
| 3579 |
"\^<<self.thedesc>> leaves the area."; |
| 3580 |
} |
| 3581 |
sayArriving = |
| 3582 |
{ |
| 3583 |
self.location.dispParagraph; |
| 3584 |
"\^<<self.thedesc>> enters the area."; |
| 3585 |
} |
| 3586 |
|
| 3587 |
// this should be used as an actor when ambiguous |
| 3588 |
preferredActor = true |
| 3589 |
|
| 3590 |
/* |
| 3591 |
* Mappings to room properties that we use when this actor travels |
| 3592 |
* via a directional command (NORTH, SOUTH, etc). When we process an |
| 3593 |
* actor travel command, we'll look in these properties of the actor |
| 3594 |
* first. Each of these will in turn give us another property, which |
| 3595 |
* we'll invoke on the actor's current location. |
| 3596 |
* |
| 3597 |
* Note that by default, the basic "Me" actor uses the basic |
| 3598 |
* directional properties (&north, &south, and so on), whereas |
| 3599 |
* non-player characters use the actor-specific directional |
| 3600 |
* properties (&actorNorth, &actorSouth, etc). This means that when |
| 3601 |
* the player character travels, we'll find out the destination of |
| 3602 |
* the travel by calling |
| 3603 |
* |
| 3604 |
* Me.location.north |
| 3605 |
* |
| 3606 |
*. ..and when a non-player character travels, we'll instead call |
| 3607 |
* |
| 3608 |
* Me.location.actorNorth |
| 3609 |
* |
| 3610 |
* By default, room simply maps actorNorth to north, which means that |
| 3611 |
* the player character and the NPC's all end up acting the same way, |
| 3612 |
* so this distinction ends up making no difference. However, the |
| 3613 |
* distinction makes it possible to make traveling act one way for |
| 3614 |
* the player character and another way for NPC's simply by |
| 3615 |
* overriding actorNorth (etc) in a room definition. |
| 3616 |
*/ |
| 3617 |
northProp = &actorNorth |
| 3618 |
southProp = &actorSouth |
| 3619 |
eastProp = &actorEast |
| 3620 |
westProp = &actorWest |
| 3621 |
neProp = &actorNE |
| 3622 |
nwProp = &actorNW |
| 3623 |
seProp = &actorSE |
| 3624 |
swProp = &actorSW |
| 3625 |
inProp = &actorIn |
| 3626 |
outProp = &actorOut |
| 3627 |
upProp = &actorUp |
| 3628 |
downProp = &actorDown |
| 3629 |
; |
| 3630 |
|
| 3631 |
/* |
| 3632 |
* follower: Actor |
| 3633 |
* |
| 3634 |
* This is a special object that can "shadow" the movements of a |
| 3635 |
* character as it moves from room to room. The purpose of a follower |
| 3636 |
* is to allow the player to follow an actor as it leaves a room by |
| 3637 |
* typing a "follow" command. Each actor that is to be followed must |
| 3638 |
* have its own follower object. The follower object should |
| 3639 |
* define all of the same vocabulary words (nouns and adjectives) as the |
| 3640 |
* actual actor to which it refers. The follower must also |
| 3641 |
* define the myactor property to be the Actor object that |
| 3642 |
* the follower follows. The follower will always stay |
| 3643 |
* one room behind the character it follows; no commands are effective |
| 3644 |
* with a follower except for "follow." |
| 3645 |
*/ |
| 3646 |
class follower: Actor |
| 3647 |
sdesc = { self.myactor.sdesc; } |
| 3648 |
isfollower = true |
| 3649 |
ldesc = { caps(); self.myactor.thedesc; " <<self.myactor.isdesc>> no |
| 3650 |
longer here. "; } |
| 3651 |
actorAction(v, d, p, i) = { self.ldesc; exit; } |
| 3652 |
actorDesc = {} |
| 3653 |
myactor = nil // set to the Actor to be followed |
| 3654 |
verDoFollow(actor) = {} |
| 3655 |
doFollow(actor) = |
| 3656 |
{ |
| 3657 |
actor.travelTo(self.myactor.location); |
| 3658 |
} |
| 3659 |
dobjGen(a, v, i, p) = |
| 3660 |
{ |
| 3661 |
if (v <> followVerb) |
| 3662 |
{ |
| 3663 |
"\^<< self.myactor.thedesc >> <<self.myactor.isdesc>> no |
| 3664 |
longer here."; |
| 3665 |
exit; |
| 3666 |
} |
| 3667 |
} |
| 3668 |
iobjGen(a, v, d, p) = |
| 3669 |
{ |
| 3670 |
"\^<< self.myactor.thedesc >> <<self.myactor.isdesc>> no |
| 3671 |
longer here."; |
| 3672 |
exit; |
| 3673 |
} |
| 3674 |
; |
| 3675 |
|
| 3676 |
/* |
| 3677 |
* basicMe: Actor |
| 3678 |
* |
| 3679 |
* A default implementation of the Me object, which is the |
| 3680 |
* player character. adv.t defines basicMe instead of |
| 3681 |
* Me to allow your game to override parts of the default |
| 3682 |
* implementation while still using the rest, and without changing |
| 3683 |
* adv.t itself. To use basicMe unchanged as your player |
| 3684 |
* character, include this in your game: "Me: basicMe;". |
| 3685 |
* |
| 3686 |
* The basicMe object defines all of the methods and properties |
| 3687 |
* required for an actor, with appropriate values for the player |
| 3688 |
* character. The nouns "me" and "myself" are defined ("I" |
| 3689 |
* is not defined, because it conflicts with the "inventory" |
| 3690 |
* command's minimal abbreviation of "i" in certain circumstances, |
| 3691 |
* and is generally not compatible with the syntax of most player |
| 3692 |
* commands anyway). The sdesc is "you"; the thedesc |
| 3693 |
* and adesc are "yourself," which is appropriate for most |
| 3694 |
* contexts. The maxbulk and maxweight properties are |
| 3695 |
* set to 10 each; a more sophisticated Me might include the |
| 3696 |
* player's state of health in determining the maxweight and |
| 3697 |
* maxbulk properties. |
| 3698 |
*/ |
| 3699 |
class basicMe: Actor, floatingItem |
| 3700 |
roomCheck(v) = { return self.location.roomCheck(v); } |
| 3701 |
noun = 'me' 'myself' |
| 3702 |
sdesc = "you" |
| 3703 |
thedesc = "yourself" |
| 3704 |
adesc = "yourself" |
| 3705 |
ldesc = "You look about the same as always. " |
| 3706 |
maxweight = 10 |
| 3707 |
maxbulk = 10 |
| 3708 |
verDoFollow(actor) = |
| 3709 |
{ |
| 3710 |
if (actor = self) |
| 3711 |
"You can't follow yourself! "; |
| 3712 |
} |
| 3713 |
actorAction(verb, dobj, prep, iobj) = |
| 3714 |
{ |
| 3715 |
} |
| 3716 |
travelTo(room) = |
| 3717 |
{ |
| 3718 |
/* |
| 3719 |
* if I'm not the current player character, inherit the default |
| 3720 |
* handling |
| 3721 |
*/ |
| 3722 |
if (parserGetMe() != self) |
| 3723 |
{ |
| 3724 |
/* |
| 3725 |
* I'm not the current player character, so I'm just an |
| 3726 |
* ordinary actor - use the inherited version that ordinary |
| 3727 |
* actors use |
| 3728 |
*/ |
| 3729 |
inherited.travelTo(room); |
| 3730 |
return; |
| 3731 |
} |
| 3732 |
|
| 3733 |
/* |
| 3734 |
* if the room is not nil, travel to the new location; ignore |
| 3735 |
* attempts to travel to "nil", because direction properties and |
| 3736 |
* obstacles return nil after displaying a message explaining |
| 3737 |
* why the travel is impossible, hence we need do nothing more |
| 3738 |
* in these cases |
| 3739 |
*/ |
| 3740 |
if (room != nil) |
| 3741 |
{ |
| 3742 |
if (room.isobstacle) |
| 3743 |
{ |
| 3744 |
/* it's an obstacle - travel to the obstacle's destination */ |
| 3745 |
self.travelTo(room.destination); |
| 3746 |
} |
| 3747 |
else if (!(self.location.islit || room.islit)) |
| 3748 |
{ |
| 3749 |
/* neither location is lit - travel in the dark */ |
| 3750 |
darkTravel(); |
| 3751 |
} |
| 3752 |
else |
| 3753 |
{ |
| 3754 |
/* notify the old location that we're leaving */ |
| 3755 |
if (self.location != nil) |
| 3756 |
self.location.leaveRoom(self); |
| 3757 |
|
| 3758 |
/* move to the new location */ |
| 3759 |
self.location := room; |
| 3760 |
|
| 3761 |
/* notify the new location that we're entering */ |
| 3762 |
room.enterRoom(self); |
| 3763 |
} |
| 3764 |
} |
| 3765 |
} |
| 3766 |
moveInto(room) = |
| 3767 |
{ |
| 3768 |
/* |
| 3769 |
* If I"m not the current player character, inherit the default |
| 3770 |
* handling; otherwise, we must use special handling, because |
| 3771 |
* the current player character never appears in its location's |
| 3772 |
* contents list. |
| 3773 |
*/ |
| 3774 |
if (parserGetMe() = self) |
| 3775 |
{ |
| 3776 |
/* |
| 3777 |
* Notify the new container that the player character is |
| 3778 |
* being explicitly moved into it. |
| 3779 |
*/ |
| 3780 |
if (room != nil) |
| 3781 |
room.meIsMovingInto(self); |
| 3782 |
|
| 3783 |
/* |
| 3784 |
* we're the player character - move directly to the new |
| 3785 |
* room; do not update the contents lists for my old or new |
| 3786 |
* containers, because we do not appear in the old list and |
| 3787 |
* do not want to appear in the new list |
| 3788 |
*/ |
| 3789 |
self.location := room; |
| 3790 |
} |
| 3791 |
else |
| 3792 |
{ |
| 3793 |
/* |
| 3794 |
* we're an ordinary actor at the moment - inherit the |
| 3795 |
* default handling |
| 3796 |
*/ |
| 3797 |
inherited.moveInto(room); |
| 3798 |
} |
| 3799 |
} |
| 3800 |
ioGiveTo(actor, dobj) = |
| 3801 |
{ |
| 3802 |
"\^<<self.fmtYou>> accept<<self.fmtS>> <<dobj.thedesc |
| 3803 |
>> from %youm%."; |
| 3804 |
dobj.moveInto(parserGetMe()); |
| 3805 |
} |
| 3806 |
|
| 3807 |
// these properties are for the format strings |
| 3808 |
fmtYou = "you" |
| 3809 |
fmtYour = "your" |
| 3810 |
fmtYoure = "you're" |
| 3811 |
fmtYoum = "you" |
| 3812 |
fmtYouve = "you've" |
| 3813 |
fmtS = "" |
| 3814 |
fmtEs = "" |
| 3815 |
fmtHave = "have" |
| 3816 |
fmtDo = "do" |
| 3817 |
fmtAre = "are" |
| 3818 |
fmtMe = "me" |
| 3819 |
|
| 3820 |
/* for travel, use the basic direction proeprties */ |
| 3821 |
northProp = &north |
| 3822 |
southProp = &south |
| 3823 |
eastProp = &east |
| 3824 |
westProp = &west |
| 3825 |
neProp = &ne |
| 3826 |
nwProp = &nw |
| 3827 |
seProp = &se |
| 3828 |
swProp = &sw |
| 3829 |
inProp = &in |
| 3830 |
outProp = &out |
| 3831 |
upProp = &up |
| 3832 |
downProp = &down |
| 3833 |
; |
| 3834 |
|
| 3835 |
/* |
| 3836 |
* decoration: fixeditem |
| 3837 |
* |
| 3838 |
* An item that doesn't have any function in the game, apart from |
| 3839 |
* having been mentioned in the room description. These items |
| 3840 |
* are immovable and can't be manipulated in any way, but can be |
| 3841 |
* referred to and inspected. Liberal use of decoration items |
| 3842 |
* can improve a game's playability by helping the parser recognize |
| 3843 |
* all the words the game uses in its descriptions of rooms. |
| 3844 |
*/ |
| 3845 |
class decoration: fixeditem |
| 3846 |
ldesc = "\^<<self.thatdesc>> <<self.isntdesc>> important." |
| 3847 |
dobjGen(a, v, i, p) = |
| 3848 |
{ |
| 3849 |
if (v <> inspectVerb) |
| 3850 |
{ |
| 3851 |
"\^<<self.thedesc>> <<self.isntdesc>> important."; |
| 3852 |
exit; |
| 3853 |
} |
| 3854 |
} |
| 3855 |
iobjGen(a, v, d, p) = |
| 3856 |
{ |
| 3857 |
"\^<<self.thedesc>> <<self.isntdesc>> important."; |
| 3858 |
exit; |
| 3859 |
} |
| 3860 |
; |
| 3861 |
|
| 3862 |
/* |
| 3863 |
* distantItem: fixeditem |
| 3864 |
* |
| 3865 |
* This is an item that is too far away to manipulate, but can be seen. |
| 3866 |
* The class uses dobjGen and iobjGen to prevent any verbs from being |
| 3867 |
* used on the object apart from inspectVerb; using any other verb results |
| 3868 |
* in the message "It's too far away." Instances of this class should |
| 3869 |
* provide the normal item properties: sdesc, ldesc, location, |
| 3870 |
* and vocabulary. |
| 3871 |
*/ |
| 3872 |
class distantItem: fixeditem |
| 3873 |
dobjGen(a, v, i, p) = |
| 3874 |
{ |
| 3875 |
if (v <> askVerb and v <> tellVerb and v <> inspectVerb) |
| 3876 |
{ |
| 3877 |
"\^<<self.itisdesc>> too far away."; |
| 3878 |
exit; |
| 3879 |
} |
| 3880 |
} |
| 3881 |
iobjGen(a, v, d, p) = { self.dobjGen(a, v, d, p); } |
| 3882 |
; |
| 3883 |
|
| 3884 |
/* |
| 3885 |
* buttonitem: fixeditem |
| 3886 |
* |
| 3887 |
* A button (the type you push). The individual button's action method |
| 3888 |
* doPush(actor), which must be specified in |
| 3889 |
* the button, carries out the function of the button. Note that |
| 3890 |
* all buttons have the noun "button" defined. |
| 3891 |
*/ |
| 3892 |
class buttonitem: fixeditem |
| 3893 |
noun = 'button' |
| 3894 |
plural = 'buttons' |
| 3895 |
verDoPush(actor) = {} |
| 3896 |
; |
| 3897 |
|
| 3898 |
/* |
| 3899 |
* clothingItem: item |
| 3900 |
* |
| 3901 |
* Something that can be worn. By default, the only thing that |
| 3902 |
* happens when the item is worn is that its isworn property |
| 3903 |
* is set to true. If you want more to happen, override the |
| 3904 |
* doWear(actor) property. Note that, when a clothingItem |
| 3905 |
* is being worn, certain operations will cause it to be removed (for |
| 3906 |
* example, dropping it causes it to be removed). If you want |
| 3907 |
* something else to happen, override the checkDrop method; |
| 3908 |
* if you want to disallow such actions while the object is worn, |
| 3909 |
* use an exit statement in the checkDrop method. |
| 3910 |
*/ |
| 3911 |
class clothingItem: item |
| 3912 |
checkDrop = |
| 3913 |
{ |
| 3914 |
if (self.isworn) |
| 3915 |
{ |
| 3916 |
"(Taking off "; self.thedesc; " first)\n"; |
| 3917 |
self.isworn := nil; |
| 3918 |
} |
| 3919 |
} |
| 3920 |
doDrop(actor) = |
| 3921 |
{ |
| 3922 |
self.checkDrop; |
| 3923 |
pass doDrop; |
| 3924 |
} |
| 3925 |
doPutIn(actor, io) = |
| 3926 |
{ |
| 3927 |
self.checkDrop; |
| 3928 |
pass doPutIn; |
| 3929 |
} |
| 3930 |
doPutOn(actor, io) = |
| 3931 |
{ |
| 3932 |
self.checkDrop; |
| 3933 |
pass doPutOn; |
| 3934 |
} |
| 3935 |
doGiveTo(actor, io) = |
| 3936 |
{ |
| 3937 |
self.checkDrop; |
| 3938 |
pass doGiveTo; |
| 3939 |
} |
| 3940 |
doThrowAt(actor, io) = |
| 3941 |
{ |
| 3942 |
self.checkDrop; |
| 3943 |
pass doThrowAt; |
| 3944 |
} |
| 3945 |
doThrowTo(actor, io) = |
| 3946 |
{ |
| 3947 |
self.checkDrop; |
| 3948 |
pass doThrowTo; |
| 3949 |
} |
| 3950 |
doThrow(actor) = |
| 3951 |
{ |
| 3952 |
self.checkDrop; |
| 3953 |
pass doThrow; |
| 3954 |
} |
| 3955 |
moveInto(obj) = |
| 3956 |
{ |
| 3957 |
/* |
| 3958 |
* Catch any other movements with moveInto; this won't stop the |
| 3959 |
* movement from happening, but it will prevent any anamolous |
| 3960 |
* consequences caused by the object moving but still being worn. |
| 3961 |
*/ |
| 3962 |
self.isworn := nil; |
| 3963 |
pass moveInto; |
| 3964 |
} |
| 3965 |
verDoWear(actor) = |
| 3966 |
{ |
| 3967 |
if (self.isworn && self.isIn(actor)) |
| 3968 |
{ |
| 3969 |
"%You're% already wearing "; self.thedesc; "! "; |
| 3970 |
} |
| 3971 |
} |
| 3972 |
doWear(actor) = |
| 3973 |
{ |
| 3974 |
/* |
| 3975 |
* if the actor is not directly carrying it (in other words, |
| 3976 |
* it's either not in the player's inventory at all, or it's |
| 3977 |
* within a container within the actor's inventory), take it -- |
| 3978 |
* the actor must be directly holding the object for this to |
| 3979 |
* succeed |
| 3980 |
*/ |
| 3981 |
if (self.location != actor) |
| 3982 |
{ |
| 3983 |
/* try taking it */ |
| 3984 |
"(First taking <<self.thedesc>>)\n"; |
| 3985 |
if (execCommand(actor, takeVerb, self) != 0) |
| 3986 |
exit; |
| 3987 |
|
| 3988 |
/* |
| 3989 |
* make certain it ended up where we want it - the command |
| 3990 |
* might have failed without actually indicating failure |
| 3991 |
*/ |
| 3992 |
if (self.location != actor) |
| 3993 |
exit; |
| 3994 |
} |
| 3995 |
|
| 3996 |
/* wear it */ |
| 3997 |
"Okay, %you're% now wearing "; self.thedesc; ". "; |
| 3998 |
self.isworn := true; |
| 3999 |
} |
| 4000 |
verDoUnwear(actor) = |
| 4001 |
{ |
| 4002 |
if (not self.isworn or not self.isIn(actor)) |
| 4003 |
{ |
| 4004 |
"%You're% not wearing "; self.thedesc; ". "; |
| 4005 |
} |
| 4006 |
} |
| 4007 |
doUnwear(actor) = |
| 4008 |
{ |
| 4009 |
/* ensure that maximum bulk is not exceeded */ |
| 4010 |
if (addbulk(actor.contents) + self.bulk > actor.maxbulk) |
| 4011 |
{ |
| 4012 |
"%You% could drop <<self.thedesc>>, but %your% hands are |
| 4013 |
too full to carry <<self.itobjdesc>>. "; |
| 4014 |
} |
| 4015 |
else |
| 4016 |
{ |
| 4017 |
/* doff the item */ |
| 4018 |
"Okay, %you're% no longer wearing "; self.thedesc; ". "; |
| 4019 |
self.isworn := nil; |
| 4020 |
} |
| 4021 |
} |
| 4022 |
verDoTake(actor) = |
| 4023 |
{ |
| 4024 |
if (self.isworn) |
| 4025 |
self.verDoUnwear(actor); |
| 4026 |
else |
| 4027 |
pass verDoTake; |
| 4028 |
} |
| 4029 |
doTake(actor) = |
| 4030 |
{ |
| 4031 |
if (self.isworn) |
| 4032 |
self.doUnwear(actor); |
| 4033 |
else |
| 4034 |
pass doTake; |
| 4035 |
} |
| 4036 |
doSynonym('Unwear') = 'Unboard' |
| 4037 |
; |
| 4038 |
|
| 4039 |
/* |
| 4040 |
* obstacle: object |
| 4041 |
* |
| 4042 |
* An obstacle is used in place of a room for a direction |
| 4043 |
* property. The destination property specifies the room that |
| 4044 |
* is reached if the obstacle is successfully negotiated; when the |
| 4045 |
* obstacle is not successfully negotiated, destination should |
| 4046 |
* display an appropriate message and return nil. |
| 4047 |
*/ |
| 4048 |
class obstacle: object |
| 4049 |
isobstacle = true |
| 4050 |
; |
| 4051 |
|
| 4052 |
/* |
| 4053 |
* doorway: fixeditem, obstacle |
| 4054 |
* |
| 4055 |
* A doorway is an obstacle that impedes progress when it is closed. |
| 4056 |
* When the door is open (isopen is true), the user ends up in |
| 4057 |
* the room specified in the doordest property upon going through |
| 4058 |
* the door. Since a doorway is an obstacle, use the door object for |
| 4059 |
* a direction property of the room containing the door. |
| 4060 |
* |
| 4061 |
* If noAutoOpen is not set to true, the door will automatically |
| 4062 |
* be opened when the player tries to walk through the door, unless the |
| 4063 |
* door is locked (islocked = true). If the door is locked, |
| 4064 |
* it can be unlocked simply by typing "unlock door", unless the |
| 4065 |
* mykey property is set, in which case the object specified in |
| 4066 |
* mykey must be used to unlock the door. Note that the door can |
| 4067 |
* only be relocked by the player under the circumstances that allow |
| 4068 |
* unlocking, plus the property islockable must be set to true. |
| 4069 |
* By default, the door is closed; set isopen to true if the door |
| 4070 |
* is to start out open (and be sure to open the other side as well). |
| 4071 |
* |
| 4072 |
* otherside specifies the corresponding doorway object in the |
| 4073 |
* destination room (doordest), if any. If otherside is |
| 4074 |
* specified, its isopen and islocked properties will be |
| 4075 |
* kept in sync automatically. |
| 4076 |
*/ |
| 4077 |
class doorway: fixeditem, obstacle |
| 4078 |
isdoor = true // Item can be opened and closed |
| 4079 |
destination = |
| 4080 |
{ |
| 4081 |
if (self.isopen) |
| 4082 |
return self.doordest; |
| 4083 |
else if (not self.islocked and not self.noAutoOpen) |
| 4084 |
{ |
| 4085 |
self.setIsopen(true); |
| 4086 |
"(Opening << self.thedesc >>)\n"; |
| 4087 |
return self.doordest; |
| 4088 |
} |
| 4089 |
else |
| 4090 |
{ |
| 4091 |
"%You%'ll have to open << self.thedesc >> first. "; |
| 4092 |
setit(self); |
| 4093 |
return nil; |
| 4094 |
} |
| 4095 |
} |
| 4096 |
verDoOpen(actor) = |
| 4097 |
{ |
| 4098 |
if (self.isopen) |
| 4099 |
"\^<<self.itisdesc>> already open. "; |
| 4100 |
else if (self.islocked) |
| 4101 |
"\^<<self.itisdesc>> locked. "; |
| 4102 |
} |
| 4103 |
setIsopen(setting) = |
| 4104 |
{ |
| 4105 |
/* update my status */ |
| 4106 |
self.isopen := setting; |
| 4107 |
|
| 4108 |
/* |
| 4109 |
* if there's another side to this door, and its status is not |
| 4110 |
* already set to the new setting, update it as well (we don't |
| 4111 |
* update it if it's already been updated, since otherwise we'd |
| 4112 |
* recurse forever calling back and forth between the two sides) |
| 4113 |
*/ |
| 4114 |
if (self.otherside != nil && self.otherside.isopen != setting) |
| 4115 |
self.otherside.setIsopen(setting); |
| 4116 |
} |
| 4117 |
setIslocked(setting) = |
| 4118 |
{ |
| 4119 |
/* update my status */ |
| 4120 |
self.islocked := setting; |
| 4121 |
|
| 4122 |
/* if there's another side, update it as well */ |
| 4123 |
if (self.otherside != nil && self.otherside.islocked != setting) |
| 4124 |
self.otherside.setIslocked(setting); |
| 4125 |
} |
| 4126 |
doOpen(actor) = |
| 4127 |
{ |
| 4128 |
"Opened. "; |
| 4129 |
self.setIsopen(true); |
| 4130 |
} |
| 4131 |
verDoClose(actor) = |
| 4132 |
{ |
| 4133 |
if (not self.isopen) |
| 4134 |
"\^<<self.itisdesc>> already closed. "; |
| 4135 |
} |
| 4136 |
doClose(actor) = |
| 4137 |
{ |
| 4138 |
"Closed. "; |
| 4139 |
self.setIsopen(nil); |
| 4140 |
} |
| 4141 |
verDoLock(actor) = |
| 4142 |
{ |
| 4143 |
if (self.islocked) |
| 4144 |
"\^<<self.itisdesc>> already locked! "; |
| 4145 |
else if (not self.islockable) |
| 4146 |
"\^<<self.itnomdesc>> can't be locked. "; |
| 4147 |
else if (self.isopen) |
| 4148 |
"%You%'ll have to close <<self.itobjdesc>> first. "; |
| 4149 |
} |
| 4150 |
doLock(actor) = |
| 4151 |
{ |
| 4152 |
if (self.mykey = nil) |
| 4153 |
{ |
| 4154 |
"Locked. "; |
| 4155 |
self.setIslocked(true); |
| 4156 |
} |
| 4157 |
else |
| 4158 |
askio(withPrep); |
| 4159 |
} |
| 4160 |
verDoUnlock(actor) = |
| 4161 |
{ |
| 4162 |
if (not self.islocked) |
| 4163 |
"\^<<self.itisdesc>> not locked! "; |
| 4164 |
} |
| 4165 |
doUnlock(actor) = |
| 4166 |
{ |
| 4167 |
if (self.mykey = nil) |
| 4168 |
{ |
| 4169 |
"Unlocked. "; |
| 4170 |
self.setIslocked(nil); |
| 4171 |
} |
| 4172 |
else |
| 4173 |
askio(withPrep); |
| 4174 |
} |
| 4175 |
verDoLockWith(actor, io) = |
| 4176 |
{ |
| 4177 |
if (self.islocked) |
| 4178 |
"\^<<self.itisdesc>> already locked. "; |
| 4179 |
else if (not self.islockable) |
| 4180 |
"\^<<self.itnomdesc>> can't be locked. "; |
| 4181 |
else if (self.mykey = nil) |
| 4182 |
"%You% %do%n't need anything to lock <<self.itobjdesc>>. "; |
| 4183 |
else if (self.isopen) |
| 4184 |
"%You%'ll have to close <<self.itobjdesc>> first. "; |
| 4185 |
} |
| 4186 |
doLockWith(actor, io) = |
| 4187 |
{ |
| 4188 |
if (io = self.mykey) |
| 4189 |
{ |
| 4190 |
"Locked. "; |
| 4191 |
self.setIslocked(true); |
| 4192 |
} |
| 4193 |
else |
| 4194 |
"\^<<io.itnomdesc>> <<io.doesdesc>>n't fit the lock. "; |
| 4195 |
} |
| 4196 |
verDoUnlockWith(actor, io) = |
| 4197 |
{ |
| 4198 |
if (not self.islocked) |
| 4199 |
"\^<<self.itisdesc>> not locked! "; |
| 4200 |
else if (self.mykey = nil) |
| 4201 |
"%You% %do%n't need anything to unlock <<self.itobjdesc>>. "; |
| 4202 |
} |
| 4203 |
doUnlockWith(actor, io) = |
| 4204 |
{ |
| 4205 |
if (io = self.mykey) |
| 4206 |
{ |
| 4207 |
"Unlocked. "; |
| 4208 |
self.setIslocked(nil); |
| 4209 |
} |
| 4210 |
else |
| 4211 |
"\^<<io.itnomdesc>> <<io.doesdesc>>n't fit the lock. "; |
| 4212 |
} |
| 4213 |
ldesc = |
| 4214 |
{ |
| 4215 |
if (self.isopen) |
| 4216 |
"\^<<self.itisdesc>> open. "; |
| 4217 |
else |
| 4218 |
{ |
| 4219 |
if (self.islocked) |
| 4220 |
"\^<<self.itisdesc>> closed and locked. "; |
| 4221 |
else |
| 4222 |
"\^<<self.itisdesc>> closed. "; |
| 4223 |
} |
| 4224 |
} |
| 4225 |
verDoKnock(actor) = { } |
| 4226 |
doKnock(actor) = { "There is no answer. "; } |
| 4227 |
verDoEnter(actor) = { } |
| 4228 |
doEnter(actor) = |
| 4229 |
{ |
| 4230 |
actor.travelTo(self.destination); |
| 4231 |
} |
| 4232 |
doSynonym('Enter') = 'Gothrough' |
| 4233 |
; |
| 4234 |
|
| 4235 |
/* |
| 4236 |
* lockableDoorway: doorway |
| 4237 |
* |
| 4238 |
* This is just a normal doorway with the islockable and |
| 4239 |
* islocked properties set to true. Fill in the other |
| 4240 |
* properties (otherside and doordest) as usual. If |
| 4241 |
* the door has a key, set property mykey to the key object. |
| 4242 |
*/ |
| 4243 |
class lockableDoorway: doorway |
| 4244 |
islockable = true |
| 4245 |
islocked = true |
| 4246 |
; |
| 4247 |
|
| 4248 |
/* |
| 4249 |
* vehicle: item, nestedroom |
| 4250 |
* |
| 4251 |
* This is an object that an actor can board. An actor cannot go |
| 4252 |
* anywhere while on board a vehicle (except where the vehicle goes); |
| 4253 |
* the actor must get out first. |
| 4254 |
*/ |
| 4255 |
class vehicle: item, nestedroom |
| 4256 |
reachable = ([] + self) |
| 4257 |
isvehicle = true |
| 4258 |
verDoEnter(actor) = { self.verDoBoard(actor); } |
| 4259 |
doEnter(actor) = { self.doBoard(actor); } |
| 4260 |
verDoBoard(actor) = |
| 4261 |
{ |
| 4262 |
if (actor.location = self) |
| 4263 |
{ |
| 4264 |
"%You're% already <<self.statusPrep>> <<self.thedesc>>! "; |
| 4265 |
} |
| 4266 |
else if (actor.isCarrying(self)) |
| 4267 |
{ |
| 4268 |
"%You%'ll have to drop <<self.thedesc>> first!"; |
| 4269 |
} |
| 4270 |
} |
| 4271 |
doBoard(actor) = |
| 4272 |
{ |
| 4273 |
"Okay, %you're% now <<self.statusPrep>> <<self.thedesc>>. "; |
| 4274 |
actor.moveInto(self); |
| 4275 |
} |
| 4276 |
noexit = |
| 4277 |
{ |
| 4278 |
"%You're% not going anywhere until %you% get%s% <<self.outOfPrep>> << |
| 4279 |
self.thedesc>>. "; |
| 4280 |
return nil; |
| 4281 |
} |
| 4282 |
out = (self.location) |
| 4283 |
verDoTake(actor) = |
| 4284 |
{ |
| 4285 |
if (actor.isIn(self)) |
| 4286 |
"%You%'ll have to get <<self.outOfPrep>> <<self.thedesc>> first."; |
| 4287 |
else |
| 4288 |
pass verDoTake; |
| 4289 |
} |
| 4290 |
dobjGen(a, v, i, p) = |
| 4291 |
{ |
| 4292 |
if (a.isIn(self) and v <> inspectVerb and v <> getOutVerb |
| 4293 |
and v <> outVerb) |
| 4294 |
{ |
| 4295 |
"%You%'ll have to get <<self.outOfPrep>> << |
| 4296 |
self.thedesc>> first. "; |
| 4297 |
exit; |
| 4298 |
} |
| 4299 |
} |
| 4300 |
iobjGen(a, v, d, p) = |
| 4301 |
{ |
| 4302 |
if (a.isIn(self) and v <> putVerb) |
| 4303 |
{ |
| 4304 |
"%You%'ll have to get <<self.outOfPrep>> << |
| 4305 |
self.thedesc>> first. "; |
| 4306 |
exit; |
| 4307 |
} |
| 4308 |
} |
| 4309 |
; |
| 4310 |
|
| 4311 |
/* |
| 4312 |
* surface: item |
| 4313 |
* |
| 4314 |
* Objects can be placed on a surface. Apart from using the |
| 4315 |
* preposition "on" rather than "in" to refer to objects |
| 4316 |
* contained by the object, a surface is identical to a |
| 4317 |
* container. Note: an object cannot be both a |
| 4318 |
* surface and a container, because there is no |
| 4319 |
* distinction between the two internally. |
| 4320 |
*/ |
| 4321 |
class surface: item |
| 4322 |
issurface = true // Item can hold objects on its surface |
| 4323 |
ldesc = |
| 4324 |
{ |
| 4325 |
if (itemcnt(self.contents)) |
| 4326 |
{ |
| 4327 |
"On "; self.thedesc; " %you% see%s% "; listcont(self); ". "; |
| 4328 |
} |
| 4329 |
else |
| 4330 |
{ |
| 4331 |
"There's nothing on "; self.thedesc; ". "; |
| 4332 |
} |
| 4333 |
} |
| 4334 |
verIoPutOn(actor) = {} |
| 4335 |
ioPutOn(actor, dobj) = |
| 4336 |
{ |
| 4337 |
dobj.doPutOn(actor, self); |
| 4338 |
} |
| 4339 |
verDoSearch(actor) = {} |
| 4340 |
doSearch(actor) = |
| 4341 |
{ |
| 4342 |
if (itemcnt(self.contents) <> 0) |
| 4343 |
"On <<self.thedesc>> %you% see%s% <<listcont(self)>>. "; |
| 4344 |
else |
| 4345 |
"There's nothing on <<self.thedesc>>. "; |
| 4346 |
} |
| 4347 |
; |
| 4348 |
|
| 4349 |
|
| 4350 |
/* |
| 4351 |
* qsurface: surface |
| 4352 |
* |
| 4353 |
* This is a minor variation of the standard surface that doesn't list |
| 4354 |
* its contents by default when the surface itself is described. |
| 4355 |
*/ |
| 4356 |
class qsurface: surface |
| 4357 |
isqsurface = true |
| 4358 |
; |
| 4359 |
|
| 4360 |
|
| 4361 |
/* |
| 4362 |
* container: item |
| 4363 |
* |
| 4364 |
* This object can contain other objects. The iscontainer property |
| 4365 |
* is set to true. The default ldesc displays a list of the |
| 4366 |
* objects inside the container, if any. The maxbulk property |
| 4367 |
* specifies the maximum amount of bulk the container can contain. |
| 4368 |
*/ |
| 4369 |
class container: item |
| 4370 |
maxbulk = 10 // maximum bulk the container can contain |
| 4371 |
isopen = true // in fact, it can't be closed at all |
| 4372 |
iscontainer = true // Item can contain other items |
| 4373 |
ldesc = |
| 4374 |
{ |
| 4375 |
if (self.contentsVisible and itemcnt(self.contents) <> 0) |
| 4376 |
{ |
| 4377 |
"In "; self.thedesc; " %you% see%s% "; listcont(self); ". "; |
| 4378 |
} |
| 4379 |
else |
| 4380 |
{ |
| 4381 |
"There's nothing in "; self.thedesc; ". "; |
| 4382 |
} |
| 4383 |
} |
| 4384 |
verIoPutIn(actor) = |
| 4385 |
{ |
| 4386 |
} |
| 4387 |
ioPutIn(actor, dobj) = |
| 4388 |
{ |
| 4389 |
if (addbulk(self.contents) + dobj.bulk > self.maxbulk) |
| 4390 |
{ |
| 4391 |
"%You% can't fit <<dobj.thatdesc>> in "; self.thedesc; ". "; |
| 4392 |
} |
| 4393 |
else |
| 4394 |
{ |
| 4395 |
dobj.doPutIn(actor, self); |
| 4396 |
} |
| 4397 |
} |
| 4398 |
verDoLookin(actor) = {} |
| 4399 |
doLookin(actor) = |
| 4400 |
{ |
| 4401 |
self.doSearch(actor); |
| 4402 |
} |
| 4403 |
verDoSearch(actor) = {} |
| 4404 |
doSearch(actor) = |
| 4405 |
{ |
| 4406 |
if (self.contentsVisible and itemcnt(self.contents) <> 0) |
| 4407 |
"In <<self.thedesc>> %you% see%s% <<listcont(self)>>. "; |
| 4408 |
else |
| 4409 |
"There's nothing in <<self.thedesc>>. "; |
| 4410 |
} |
| 4411 |
; |
| 4412 |
|
| 4413 |
/* |
| 4414 |
* openable: container |
| 4415 |
* |
| 4416 |
* A container that can be opened and closed. The isopenable |
| 4417 |
* property is set to true. The default ldesc displays |
| 4418 |
* the contents of the container if the container is open, otherwise |
| 4419 |
* a message saying that the object is closed. |
| 4420 |
*/ |
| 4421 |
class openable: container |
| 4422 |
contentsReachable = { return self.isopen; } |
| 4423 |
contentsVisible = { return self.isopen; } |
| 4424 |
isopenable = true |
| 4425 |
ldesc = |
| 4426 |
{ |
| 4427 |
caps(); self.thedesc; " "; self.isdesc; |
| 4428 |
if (self.isopen) |
| 4429 |
{ |
| 4430 |
" open. "; |
| 4431 |
pass ldesc; |
| 4432 |
} |
| 4433 |
else |
| 4434 |
{ |
| 4435 |
" closed. "; |
| 4436 |
|
| 4437 |
/* if it's transparent, list its contents anyway */ |
| 4438 |
if (isclass(self, transparentItem)) |
| 4439 |
pass ldesc; |
| 4440 |
} |
| 4441 |
} |
| 4442 |
isopen = true |
| 4443 |
verDoOpen(actor) = |
| 4444 |
{ |
| 4445 |
if (self.isopen) |
| 4446 |
{ |
| 4447 |
caps(); self.thedesc; " <<self.isdesc>> already open! "; |
| 4448 |
} |
| 4449 |
} |
| 4450 |
doOpen(actor) = |
| 4451 |
{ |
| 4452 |
if (itemcnt(self.contents)) |
| 4453 |
{ |
| 4454 |
"Opening "; self.thedesc; " reveals "; listcont(self); ". "; |
| 4455 |
} |
| 4456 |
else |
| 4457 |
"Opened. "; |
| 4458 |
self.isopen := true; |
| 4459 |
} |
| 4460 |
verDoClose(actor) = |
| 4461 |
{ |
| 4462 |
if (not self.isopen) |
| 4463 |
{ |
| 4464 |
caps(); self.thedesc; " <<self.isdesc>> already closed! "; |
| 4465 |
} |
| 4466 |
} |
| 4467 |
doClose(actor) = |
| 4468 |
{ |
| 4469 |
"Closed. "; |
| 4470 |
self.isopen := nil; |
| 4471 |
} |
| 4472 |
verIoPutIn(actor) = |
| 4473 |
{ |
| 4474 |
if (not self.isopen) |
| 4475 |
{ |
| 4476 |
caps(); self.thedesc; " <<self.isdesc>> closed. "; |
| 4477 |
} |
| 4478 |
} |
| 4479 |
verDoLookin(actor) = |
| 4480 |
{ |
| 4481 |
/* we can look in it if either it's open or it's transparent */ |
| 4482 |
if (not self.isopen and not isclass(self, transparentItem)) |
| 4483 |
"\^<<self.itisdesc>> closed. "; |
| 4484 |
} |
| 4485 |
verDoSearch(actor) = { self.verDoLookin(actor); } |
| 4486 |
; |
| 4487 |
|
| 4488 |
/* |
| 4489 |
* qcontainer: container |
| 4490 |
* |
| 4491 |
* A "quiet" container: its contents are not listed when it shows |
| 4492 |
* up in a room description or inventory list. The isqcontainer |
| 4493 |
* property is set to true. |
| 4494 |
*/ |
| 4495 |
class qcontainer: container |
| 4496 |
isqcontainer = true |
| 4497 |
; |
| 4498 |
|
| 4499 |
/* |
| 4500 |
* lockable: openable |
| 4501 |
* |
| 4502 |
* A container that can be locked and unlocked. The islocked |
| 4503 |
* property specifies whether the object can be opened or not. The |
| 4504 |
* object can be locked and unlocked without the need for any other |
| 4505 |
* object; if you want a key to be involved, use a keyedLockable. |
| 4506 |
*/ |
| 4507 |
class lockable: openable |
| 4508 |
verDoOpen(actor) = |
| 4509 |
{ |
| 4510 |
if (self.islocked) |
| 4511 |
{ |
| 4512 |
"\^<<self.itisdesc>> locked. "; |
| 4513 |
} |
| 4514 |
else |
| 4515 |
pass verDoOpen; |
| 4516 |
} |
| 4517 |
verDoLock(actor) = |
| 4518 |
{ |
| 4519 |
if (self.islocked) |
| 4520 |
{ |
| 4521 |
"\^<<self.itisdesc>> already locked! "; |
| 4522 |
} |
| 4523 |
} |
| 4524 |
doLock(actor) = |
| 4525 |
{ |
| 4526 |
if (self.isopen) |
| 4527 |
{ |
| 4528 |
"%You%'ll have to close "; self.thedesc; " first. "; |
| 4529 |
} |
| 4530 |
else |
| 4531 |
{ |
| 4532 |
"Locked. "; |
| 4533 |
self.islocked := true; |
| 4534 |
} |
| 4535 |
} |
| 4536 |
verDoUnlock(actor) = |
| 4537 |
{ |
| 4538 |
if (not self.islocked) |
| 4539 |
"\^<<self.itisdesc>> not locked! "; |
| 4540 |
} |
| 4541 |
doUnlock(actor) = |
| 4542 |
{ |
| 4543 |
"Unlocked. "; |
| 4544 |
self.islocked := nil; |
| 4545 |
} |
| 4546 |
verDoLockWith(actor, io) = |
| 4547 |
{ |
| 4548 |
if (self.islocked) |
| 4549 |
"\^<<self.itisdesc>> already locked. "; |
| 4550 |
} |
| 4551 |
verDoUnlockWith(actor, io) = |
| 4552 |
{ |
| 4553 |
if (not self.islocked) |
| 4554 |
"\^<<self.itisdesc>> not locked! "; |
| 4555 |
else if (self.mykey = nil) |
| 4556 |
"%You% %do%n't need anything to unlock << self.itobjdesc >>."; |
| 4557 |
} |
| 4558 |
; |
| 4559 |
|
| 4560 |
/* |
| 4561 |
* keyedLockable: lockable |
| 4562 |
* |
| 4563 |
* This subclass of lockable allows you to create an object |
| 4564 |
* that can only be locked and unlocked with a corresponding key. |
| 4565 |
* Set the property mykey to the keyItem object that can |
| 4566 |
* lock and unlock the object. |
| 4567 |
*/ |
| 4568 |
class keyedLockable: lockable |
| 4569 |
mykey = nil // set 'mykey' to the key which locks/unlocks me |
| 4570 |
doLock(actor) = |
| 4571 |
{ |
| 4572 |
askio(withPrep); |
| 4573 |
} |
| 4574 |
doUnlock(actor) = |
| 4575 |
{ |
| 4576 |
askio(withPrep); |
| 4577 |
} |
| 4578 |
doLockWith(actor, io) = |
| 4579 |
{ |
| 4580 |
if (self.isopen) |
| 4581 |
{ |
| 4582 |
"%You% can't lock << self.thedesc >> when << |
| 4583 |
self.itisdesc>> open. "; |
| 4584 |
} |
| 4585 |
else if (io = self.mykey) |
| 4586 |
{ |
| 4587 |
"Locked. "; |
| 4588 |
self.islocked := true; |
| 4589 |
} |
| 4590 |
else |
| 4591 |
"\^<<io.itnomdesc>> <<io.doesdesc>>n't fit the lock. "; |
| 4592 |
} |
| 4593 |
doUnlockWith(actor, io) = |
| 4594 |
{ |
| 4595 |
if (io = self.mykey) |
| 4596 |
{ |
| 4597 |
"Unlocked. "; |
| 4598 |
self.islocked := nil; |
| 4599 |
} |
| 4600 |
else |
| 4601 |
"\^<<io.itnomdesc>> <<io.doesdesc>>n't fit the lock. "; |
| 4602 |
} |
| 4603 |
; |
| 4604 |
|
| 4605 |
/* |
| 4606 |
* keyItem: item |
| 4607 |
* |
| 4608 |
* This is an object that can be used as a key for a keyedLockable |
| 4609 |
* or lockableDoorway object. It otherwise behaves as an ordinary item. |
| 4610 |
*/ |
| 4611 |
class keyItem: item |
| 4612 |
verIoUnlockWith(actor) = {} |
| 4613 |
ioUnlockWith(actor, dobj) = |
| 4614 |
{ |
| 4615 |
dobj.doUnlockWith(actor, self); |
| 4616 |
} |
| 4617 |
verIoLockWith(actor) = {} |
| 4618 |
ioLockWith(actor, dobj) = |
| 4619 |
{ |
| 4620 |
dobj.doLockWith(actor, self); |
| 4621 |
} |
| 4622 |
; |
| 4623 |
|
| 4624 |
/* |
| 4625 |
* seethruItem: item |
| 4626 |
* |
| 4627 |
* This is an object that the player can look through, such as a window. |
| 4628 |
* The thrudesc method displays a message for when the player looks |
| 4629 |
* through the object (with a command such as "look through window"). |
| 4630 |
* Note this is not the same as a transparentItem, whose contents |
| 4631 |
* are visible from outside the object. |
| 4632 |
*/ |
| 4633 |
class seethruItem: item |
| 4634 |
verDoLookthru(actor) = {} |
| 4635 |
doLookthru(actor) = { self.thrudesc; } |
| 4636 |
; |
| 4637 |
|
| 4638 |
|
| 4639 |
/* |
| 4640 |
* transparentItem: item |
| 4641 |
* |
| 4642 |
* An object whose contents are visible, even when the object is |
| 4643 |
* closed. Whether the contents are reachable is decided in the |
| 4644 |
* normal fashion. This class is useful for items such as glass |
| 4645 |
* bottles, whose contents can be seen when the bottle is closed |
| 4646 |
* but cannot be reached. |
| 4647 |
*/ |
| 4648 |
class transparentItem: item |
| 4649 |
contentsVisible = { return true; } |
| 4650 |
ldesc = |
| 4651 |
{ |
| 4652 |
if (self.contentsVisible and itemcnt(self.contents) <> 0) |
| 4653 |
{ |
| 4654 |
"In "; self.thedesc; " %you% see%s% "; listcont(self); ". "; |
| 4655 |
} |
| 4656 |
else |
| 4657 |
{ |
| 4658 |
"There's nothing in "; self.thedesc; ". "; |
| 4659 |
} |
| 4660 |
} |
| 4661 |
verGrab(obj) = |
| 4662 |
{ |
| 4663 |
if (self.isopenable and not self.isopen) |
| 4664 |
"%You% will have to open << self.thedesc >> first. "; |
| 4665 |
} |
| 4666 |
doOpen(actor) = |
| 4667 |
{ |
| 4668 |
self.isopen := true; |
| 4669 |
"Opened. "; |
| 4670 |
} |
| 4671 |
verDoLookin(actor) = {} |
| 4672 |
doLookin(actor) = { self.doSearch(actor); } |
| 4673 |
verDoSearch(actor) = {} |
| 4674 |
doSearch(actor) = |
| 4675 |
{ |
| 4676 |
if (self.contentsVisible and itemcnt(self.contents) <> 0) |
| 4677 |
"In <<self.thedesc>> %you% see%s% <<listcont(self)>>. "; |
| 4678 |
else |
| 4679 |
"There's nothing in <<self.thedesc>>. "; |
| 4680 |
} |
| 4681 |
; |
| 4682 |
|
| 4683 |
/* |
| 4684 |
* basicNumObj: object |
| 4685 |
* |
| 4686 |
* This object provides a default implementation for numObj. |
| 4687 |
* To use this default unchanged in your game, include in your |
| 4688 |
* game this line: "numObj: basicNumObj". |
| 4689 |
*/ |
| 4690 |
class basicNumObj: object // when a number is used in a player command, |
| 4691 |
value = 0 // this is set to its value |
| 4692 |
sdesc = "<<value>>" |
| 4693 |
adesc = "a number" |
| 4694 |
thedesc = "the number <<value>>" |
| 4695 |
verDoTypeOn(actor, io) = {} |
| 4696 |
doTypeOn(actor, io) = { "\"Tap, tap, tap, tap...\" "; } |
| 4697 |
verIoTurnTo(actor) = {} |
| 4698 |
ioTurnTo(actor, dobj) = { dobj.doTurnTo(actor, self); } |
| 4699 |
; |
| 4700 |
|
| 4701 |
/* |
| 4702 |
* basicStrObj: object |
| 4703 |
* |
| 4704 |
* This object provides a default implementation for strObj. |
| 4705 |
* To use this default unchanged in your game, include in your |
| 4706 |
* game this line: "strObj: basicStrObj". |
| 4707 |
*/ |
| 4708 |
class basicStrObj: object // when a string is used in a player command, |
| 4709 |
value = '' // this is set to its value |
| 4710 |
sdesc = "\"<<value>>\"" |
| 4711 |
adesc = "\"<<value>>\"" |
| 4712 |
thedesc = "\"<<value>>\"" |
| 4713 |
verDoTypeOn(actor, io) = {} |
| 4714 |
doTypeOn(actor, io) = { "\"Tap, tap, tap, tap...\" "; } |
| 4715 |
doSynonym('TypeOn') = 'EnterOn' 'EnterIn' 'EnterWith' |
| 4716 |
verDoSave(actor) = {} |
| 4717 |
saveGame(actor) = |
| 4718 |
{ |
| 4719 |
if (save(self.value)) |
| 4720 |
{ |
| 4721 |
"Save failed. "; |
| 4722 |
return nil; |
| 4723 |
} |
| 4724 |
else |
| 4725 |
{ |
| 4726 |
"Saved. "; |
| 4727 |
return true; |
| 4728 |
} |
| 4729 |
} |
| 4730 |
doSave(actor) = |
| 4731 |
{ |
| 4732 |
self.saveGame(actor); |
| 4733 |
abort; |
| 4734 |
} |
| 4735 |
verDoRestore(actor) = {} |
| 4736 |
restoreGame(actor) = |
| 4737 |
{ |
| 4738 |
return mainRestore(self.value); |
| 4739 |
} |
| 4740 |
doRestore(actor) = |
| 4741 |
{ |
| 4742 |
self.restoreGame(actor); |
| 4743 |
abort; |
| 4744 |
} |
| 4745 |
verDoScript(actor) = {} |
| 4746 |
startScripting(actor) = |
| 4747 |
{ |
| 4748 |
logging(self.value); |
| 4749 |
"Writing script file. "; |
| 4750 |
} |
| 4751 |
doScript(actor) = |
| 4752 |
{ |
| 4753 |
self.startScripting(actor); |
| 4754 |
abort; |
| 4755 |
} |
| 4756 |
verDoSay(actor) = {} |
| 4757 |
doSay(actor) = |
| 4758 |
{ |
| 4759 |
"Okay, \""; say(self.value); "\"."; |
| 4760 |
} |
| 4761 |
; |
| 4762 |
|
| 4763 |
/* |
| 4764 |
* deepverb: object |
| 4765 |
* |
| 4766 |
* A "verb object" that is referenced by the parser when the player |
| 4767 |
* uses an associated vocabulary word. A deepverb contains both |
| 4768 |
* the vocabulary of the verb and a description of available syntax. |
| 4769 |
* The verb property lists the verb vocabulary words; |
| 4770 |
* one word (such as 'take') or a pair (such as 'pick up') |
| 4771 |
* can be used. In the latter case, the second word must be a |
| 4772 |
* preposition, and may move to the end of the sentence in a player's |
| 4773 |
* command, as in "pick it up." The action(actor) |
| 4774 |
* method specifies what happens when the verb is used without any |
| 4775 |
* objects; its absence specifies that the verb cannot be used without |
| 4776 |
* an object. The doAction specifies the root of the message |
| 4777 |
* names (in single quotes) sent to the direct object when the verb |
| 4778 |
* is used with a direct object; its absence means that a single object |
| 4779 |
* is not allowed. Likewise, the ioAction(preposition) |
| 4780 |
* specifies the root of the message name sent to the direct and |
| 4781 |
* indirect objects when the verb is used with both a direct and |
| 4782 |
* indirect object; its absence means that this syntax is illegal. |
| 4783 |
* Several ioAction properties may be present: one for each |
| 4784 |
* preposition that can be used with an indirect object with the verb. |
| 4785 |
* |
| 4786 |
* The validDo(actor, object, seqno) method returns true |
| 4787 |
* if the indicated object is valid as a direct object for this actor. |
| 4788 |
* The validIo(actor, object, seqno) method does likewise |
| 4789 |
* for indirect objects. The seqno parameter is a "sequence |
| 4790 |
* number," starting with 1 for the first object tried for a given |
| 4791 |
* verb, 2 for the second, and so forth; this parameter is normally |
| 4792 |
* ignored, but can be used for some special purposes. For example, |
| 4793 |
* askVerb does not distinguish between objects matching vocabulary |
| 4794 |
* words, and therefore accepts only the first from a set of ambiguous |
| 4795 |
* objects. These methods do not normally need to be changed; by |
| 4796 |
* default, they return true if the object is accessible to the |
| 4797 |
* actor. |
| 4798 |
* |
| 4799 |
* The doDefault(actor, prep, indirectObject) and |
| 4800 |
* ioDefault(actor, prep) methods return a list of the |
| 4801 |
* default direct and indirect objects, respectively. These lists |
| 4802 |
* are used for determining which objects are meant by "all" and which |
| 4803 |
* should be used when the player command is missing an object. These |
| 4804 |
* normally return a list of all objects that are applicable to the |
| 4805 |
* current command. |
| 4806 |
* |
| 4807 |
* The validDoList(actor, prep, indirectObject) and |
| 4808 |
* validIoList(actor, prep, directObject) methods return |
| 4809 |
* a list of all of the objects for which validDo would be true. |
| 4810 |
* Remember to include floating objects, which are generally |
| 4811 |
* accessible. Note that the objects returned by this list will |
| 4812 |
* still be submitted by the parser to validDo, so it's okay for |
| 4813 |
* this routine to return too many objects. In fact, this |
| 4814 |
* routine is entirely unnecessary; if you omit it altogether, or |
| 4815 |
* make it return nil, the parser will simply submit every |
| 4816 |
* object matching the player's vocabulary words to validDo. |
| 4817 |
* The reason to provide this method is that it can significantly |
| 4818 |
* improve parsing speed when the game has lots of objects that |
| 4819 |
* all have the same vocabulary word, because it cuts down on the |
| 4820 |
* number of times that validDo has to be called (each call |
| 4821 |
* to validDo is fairly time-consuming). |
| 4822 |
*/ |
| 4823 |
class deepverb: object // A deep-structure verb. |
| 4824 |
validDo(actor, obj, seqno) = |
| 4825 |
{ |
| 4826 |
return obj.isReachable(actor); |
| 4827 |
} |
| 4828 |
validDoList(actor, prep, iobj) = |
| 4829 |
{ |
| 4830 |
local ret; |
| 4831 |
local loc; |
| 4832 |
|
| 4833 |
loc := actor.location; |
| 4834 |
while (loc.location) |
| 4835 |
loc := loc.location; |
| 4836 |
ret := visibleList(actor, actor) + visibleList(loc, actor) |
| 4837 |
+ global.floatingList; |
| 4838 |
return ret; |
| 4839 |
} |
| 4840 |
validIo(actor, obj, seqno) = |
| 4841 |
{ |
| 4842 |
return obj.isReachable(actor); |
| 4843 |
} |
| 4844 |
validIoList(actor, prep, dobj) = (self.validDoList(actor, prep, dobj)) |
| 4845 |
doDefault(actor, prep, io) = |
| 4846 |
{ |
| 4847 |
return actor.contents + actor.location.contents; |
| 4848 |
} |
| 4849 |
ioDefault(actor, prep) = |
| 4850 |
{ |
| 4851 |
return actor.contents + actor.location.contents; |
| 4852 |
} |
| 4853 |
; |
| 4854 |
|
| 4855 |
/* |
| 4856 |
Dark verb - a verb that can be used in the dark. Travel verbs |
| 4857 |
are all dark verbs, as are system verbs (quit, save, etc.). |
| 4858 |
In addition, certain special verbs are usable in the dark: for |
| 4859 |
example, you can drop objects you are carrying, and you can turn |
| 4860 |
on light sources you are carrying. |
| 4861 |
*/ |
| 4862 |
|
| 4863 |
class darkVerb: deepverb |
| 4864 |
isDarkVerb = true |
| 4865 |
; |
| 4866 |
|
| 4867 |
/* |
| 4868 |
* Various verbs. |
| 4869 |
*/ |
| 4870 |
inspectVerb: deepverb |
| 4871 |
verb = 'inspect' 'examine' 'look at' 'l at' 'x' |
| 4872 |
sdesc = "inspect" |
| 4873 |
doAction = 'Inspect' |
| 4874 |
validDo(actor, obj, seqno) = |
| 4875 |
{ |
| 4876 |
return obj.isVisible(actor); |
| 4877 |
} |
| 4878 |
; |
| 4879 |
askVerb: deepverb |
| 4880 |
verb = 'ask' |
| 4881 |
sdesc = "ask" |
| 4882 |
prepDefault = aboutPrep |
| 4883 |
ioAction(aboutPrep) = 'AskAbout' |
| 4884 |
validIo(actor, obj, seqno) = { return (seqno = 1); } |
| 4885 |
validIoList(actor, prep, dobj) = (nil) |
| 4886 |
; |
| 4887 |
tellVerb: deepverb |
| 4888 |
verb = 'tell' |
| 4889 |
sdesc = "tell" |
| 4890 |
prepDefault = aboutPrep |
| 4891 |
ioAction(aboutPrep) = 'TellAbout' |
| 4892 |
validIo(actor, obj, seqno) = { return (seqno = 1); } |
| 4893 |
validIoList(actor, prep, dobj) = (nil) |
| 4894 |
ioDefault(actor, prep) = |
| 4895 |
{ |
| 4896 |
if (prep = aboutPrep) |
| 4897 |
return []; |
| 4898 |
else |
| 4899 |
return (actor.contents + actor.location.contents); |
| 4900 |
} |
| 4901 |
; |
| 4902 |
followVerb: deepverb |
| 4903 |
sdesc = "follow" |
| 4904 |
verb = 'follow' |
| 4905 |
doAction = 'Follow' |
| 4906 |
; |
| 4907 |
digVerb: deepverb |
| 4908 |
verb = 'dig' 'dig in' |
| 4909 |
sdesc = "dig in" |
| 4910 |
prepDefault = withPrep |
| 4911 |
ioAction(withPrep) = 'DigWith' |
| 4912 |
; |
| 4913 |
jumpVerb: deepverb |
| 4914 |
verb = 'jump' 'jump over' 'jump off' |
| 4915 |
sdesc = "jump" |
| 4916 |
doAction = 'Jump' |
| 4917 |
action(actor) = { "Wheeee!"; } |
| 4918 |
; |
| 4919 |
pushVerb: deepverb |
| 4920 |
verb = 'push' 'press' |
| 4921 |
sdesc = "push" |
| 4922 |
doAction = 'Push' |
| 4923 |
; |
| 4924 |
attachVerb: deepverb |
| 4925 |
verb = 'attach' 'connect' |
| 4926 |
sdesc = "attach" |
| 4927 |
prepDefault = toPrep |
| 4928 |
ioAction(toPrep) = 'AttachTo' |
| 4929 |
; |
| 4930 |
wearVerb: deepverb |
| 4931 |
verb = 'wear' 'put on' 'don' |
| 4932 |
sdesc = "wear" |
| 4933 |
doAction = 'Wear' |
| 4934 |
; |
| 4935 |
dropVerb: deepverb, darkVerb |
| 4936 |
verb = 'drop' 'put down' |
| 4937 |
sdesc = "drop" |
| 4938 |
ioAction(onPrep) = 'PutOn' |
| 4939 |
doAction = 'Drop' |
| 4940 |
doDefault(actor, prep, io) = |
| 4941 |
{ |
| 4942 |
return actor.contents; |
| 4943 |
} |
| 4944 |
; |
| 4945 |
removeVerb: deepverb |
| 4946 |
verb = 'take off' 'doff' |
| 4947 |
sdesc = "take off" |
| 4948 |
doAction = 'Unwear' |
| 4949 |
ioAction(fromPrep) = 'RemoveFrom' |
| 4950 |
; |
| 4951 |
openVerb: deepverb |
| 4952 |
verb = 'open' |
| 4953 |
sdesc = "open" |
| 4954 |
doAction = 'Open' |
| 4955 |
; |
| 4956 |
closeVerb: deepverb |
| 4957 |
verb = 'close' |
| 4958 |
sdesc = "close" |
| 4959 |
doAction = 'Close' |
| 4960 |
; |
| 4961 |
putVerb: deepverb |
| 4962 |
verb = 'put' 'place' |
| 4963 |
sdesc = "put" |
| 4964 |
prepDefault = inPrep |
| 4965 |
ioAction(inPrep) = 'PutIn' |
| 4966 |
ioAction(onPrep) = 'PutOn' |
| 4967 |
doDefault(actor, prep, io) = |
| 4968 |
{ |
| 4969 |
return (takeVerb.doDefault(actor, prep, io) + actor.contents); |
| 4970 |
} |
| 4971 |
; |
| 4972 |
takeVerb: deepverb // This object defines how to take things |
| 4973 |
verb = 'take' 'pick up' 'get' 'remove' |
| 4974 |
sdesc = "take" |
| 4975 |
ioAction(offPrep) = 'TakeOff' |
| 4976 |
ioAction(outPrep) = 'TakeOut' |
| 4977 |
ioAction(fromPrep) = 'TakeOut' |
| 4978 |
ioAction(inPrep) = 'TakeOut' |
| 4979 |
ioAction(onPrep) = 'TakeOff' |
| 4980 |
doAction = 'Take' |
| 4981 |
doDefault(actor, prep, io) = |
| 4982 |
{ |
| 4983 |
local ret, rem, cur, rem2, cur2, tot, i, tot2, j; |
| 4984 |
|
| 4985 |
ret := []; |
| 4986 |
|
| 4987 |
/* |
| 4988 |
* For "take all out/off of <iobj>", return the (non-fixed) |
| 4989 |
* contents of the indirect object. Same goes for "take all in |
| 4990 |
* <iobj>", "take all on <iobj>", and "take all from <iobj>". |
| 4991 |
*/ |
| 4992 |
if ((prep = outPrep or prep = offPrep or prep = inPrep |
| 4993 |
or prep = onPrep or prep = fromPrep) |
| 4994 |
and io <> nil) |
| 4995 |
{ |
| 4996 |
rem := io.contents; |
| 4997 |
i := 1; |
| 4998 |
tot := length(rem); |
| 4999 |
while (i <= tot) |
| 5000 |
{ |
| 5001 |
cur := rem[i]; |
| 5002 |
if (not cur.isfixed and self.validDo(actor, cur, i)) |
| 5003 |
ret += cur; |
| 5004 |
++i; |
| 5005 |
} |
| 5006 |
return ret; |
| 5007 |
} |
| 5008 |
|
| 5009 |
/* |
| 5010 |
* In the general case, return everything that's not fixed |
| 5011 |
* in the actor's location, or everything inside fixed containers |
| 5012 |
* that isn't itself fixed. |
| 5013 |
*/ |
| 5014 |
rem := actor.location.contents; |
| 5015 |
tot := length(rem); |
| 5016 |
i := 1; |
| 5017 |
while (i <= tot) |
| 5018 |
{ |
| 5019 |
cur := rem[i]; |
| 5020 |
if (cur.isfixed) |
| 5021 |
{ |
| 5022 |
if (((cur.isopenable and cur.isopen) or (not cur.isopenable)) |
| 5023 |
and (not cur.isactor)) |
| 5024 |
{ |
| 5025 |
rem2 := cur.contents; |
| 5026 |
tot2 := length(rem2); |
| 5027 |
j := 1; |
| 5028 |
while (j <= tot2) |
| 5029 |
{ |
| 5030 |
cur2 := rem2[j]; |
| 5031 |
if (not cur2.isfixed and not cur2.notakeall) |
| 5032 |
{ |
| 5033 |
ret := ret + cur2; |
| 5034 |
} |
| 5035 |
j := j + 1; |
| 5036 |
} |
| 5037 |
} |
| 5038 |
} |
| 5039 |
else if (not cur.notakeall) |
| 5040 |
{ |
| 5041 |
ret := ret + cur; |
| 5042 |
} |
| 5043 |
|
| 5044 |
i := i + 1; |
| 5045 |
} |
| 5046 |
return ret; |
| 5047 |
} |
| 5048 |
; |
| 5049 |
plugVerb: deepverb |
| 5050 |
verb = 'plug' |
| 5051 |
sdesc = "plug" |
| 5052 |
prepDefault = inPrep |
| 5053 |
ioAction(inPrep) = 'PlugIn' |
| 5054 |
; |
| 5055 |
lookInVerb: deepverb |
| 5056 |
verb = 'look in' 'look on' 'l in' 'l on' |
| 5057 |
sdesc = "look in" |
| 5058 |
doAction = 'Lookin' |
| 5059 |
; |
| 5060 |
screwVerb: deepverb |
| 5061 |
verb = 'screw' |
| 5062 |
sdesc = "screw" |
| 5063 |
ioAction(withPrep) = 'ScrewWith' |
| 5064 |
doAction = 'Screw' |
| 5065 |
; |
| 5066 |
unscrewVerb: deepverb |
| 5067 |
verb = 'unscrew' |
| 5068 |
sdesc = "unscrew" |
| 5069 |
ioAction(withPrep) = 'UnscrewWith' |
| 5070 |
doAction = 'Unscrew' |
| 5071 |
; |
| 5072 |
turnVerb: deepverb |
| 5073 |
verb = 'turn' 'rotate' 'twist' |
| 5074 |
sdesc = "turn" |
| 5075 |
ioAction(toPrep) = 'TurnTo' |
| 5076 |
ioAction(withPrep) = 'TurnWith' |
| 5077 |
doAction = 'Turn' |
| 5078 |
; |
| 5079 |
switchVerb: deepverb |
| 5080 |
verb = 'switch' |
| 5081 |
sdesc = "switch" |
| 5082 |
doAction = 'Switch' |
| 5083 |
; |
| 5084 |
flipVerb: deepverb |
| 5085 |
verb = 'flip' |
| 5086 |
sdesc = "flip" |
| 5087 |
doAction = 'Flip' |
| 5088 |
; |
| 5089 |
turnOnVerb: deepverb, darkVerb |
| 5090 |
verb = 'activate' 'turn on' 'switch on' |
| 5091 |
sdesc = "turn on" |
| 5092 |
doAction = 'Turnon' |
| 5093 |
; |
| 5094 |
turnOffVerb: deepverb |
| 5095 |
verb = 'turn off' 'deactiv' 'switch off' |
| 5096 |
sdesc = "turn off" |
| 5097 |
doAction = 'Turnoff' |
| 5098 |
; |
| 5099 |
lookVerb: deepverb |
| 5100 |
verb = 'look' 'l' 'look around' 'l around' |
| 5101 |
sdesc = "look" |
| 5102 |
action(actor) = |
| 5103 |
{ |
| 5104 |
actor.location.lookAround(true); |
| 5105 |
} |
| 5106 |
; |
| 5107 |
sitVerb: deepverb |
| 5108 |
verb = 'sit on' 'sit in' 'sit' 'sit down' 'sit downin' 'sit downon' |
| 5109 |
sdesc = "sit on" |
| 5110 |
doAction = 'Siton' |
| 5111 |
; |
| 5112 |
lieVerb: deepverb |
| 5113 |
verb = 'lie' 'lie on' 'lie in' 'lie down' 'lie downon' 'lie downin' |
| 5114 |
sdesc = "lie on" |
| 5115 |
doAction = 'Lieon' |
| 5116 |
; |
| 5117 |
getOutVerb: deepverb |
| 5118 |
verb = 'get out' 'get outof' 'get off' 'get offof' |
| 5119 |
sdesc = "get out of" |
| 5120 |
doAction = 'Unboard' |
| 5121 |
action(actor) = { askdo; } |
| 5122 |
doDefault(actor, prep, io) = |
| 5123 |
{ |
| 5124 |
if (actor.location and actor.location.location) |
| 5125 |
return ([] + actor.location); |
| 5126 |
else |
| 5127 |
return []; |
| 5128 |
} |
| 5129 |
; |
| 5130 |
boardVerb: deepverb |
| 5131 |
verb = 'get in' 'get into' 'board' 'get on' |
| 5132 |
sdesc = "get on" |
| 5133 |
doAction = 'Board' |
| 5134 |
; |
| 5135 |
againVerb: darkVerb // Required verb: repeats last command. No |
| 5136 |
// action routines are necessary; this one's |
| 5137 |
// handled internally by the parser. |
| 5138 |
verb = 'again' 'g' |
| 5139 |
sdesc = "again" |
| 5140 |
; |
| 5141 |
waitVerb: darkVerb |
| 5142 |
verb = 'wait' 'z' |
| 5143 |
sdesc = "wait" |
| 5144 |
action(actor) = |
| 5145 |
{ |
| 5146 |
"Time passes...\n"; |
| 5147 |
} |
| 5148 |
; |
| 5149 |
iVerb: deepverb |
| 5150 |
verb = 'inventory' 'i' |
| 5151 |
sdesc = "inventory" |
| 5152 |
useInventoryTall = nil |
| 5153 |
action(actor) = |
| 5154 |
{ |
| 5155 |
if (itemcnt(actor.contents)) |
| 5156 |
{ |
| 5157 |
/* use tall or wide mode, as appropriate */ |
| 5158 |
if (self.useInventoryTall) |
| 5159 |
{ |
| 5160 |
/* use "tall" mode */ |
| 5161 |
"%You% %are% carrying:\n"; |
| 5162 |
nestlistcont(actor, 1); |
| 5163 |
} |
| 5164 |
else |
| 5165 |
{ |
| 5166 |
/* use wide mode */ |
| 5167 |
"%You% %have% "; listcont(actor); ". "; |
| 5168 |
listcontcont(actor); |
| 5169 |
} |
| 5170 |
} |
| 5171 |
else |
| 5172 |
"%You% %are% empty-handed.\n"; |
| 5173 |
} |
| 5174 |
; |
| 5175 |
iwideVerb: deepverb |
| 5176 |
verb = 'i_wide' |
| 5177 |
sdesc = "inventory" |
| 5178 |
action(actor) = |
| 5179 |
{ |
| 5180 |
iVerb.useInventoryTall := nil; |
| 5181 |
iVerb.action(actor); |
| 5182 |
} |
| 5183 |
; |
| 5184 |
itallVerb: deepverb |
| 5185 |
verb = 'i_tall' |
| 5186 |
sdesc = "inventory" |
| 5187 |
action(actor) = |
| 5188 |
{ |
| 5189 |
iVerb.useInventoryTall := true; |
| 5190 |
iVerb.action(actor); |
| 5191 |
} |
| 5192 |
; |
| 5193 |
lookThruVerb: deepverb |
| 5194 |
verb = 'look through' 'look thru' 'l through' 'l thru' |
| 5195 |
sdesc = "look through" |
| 5196 |
doAction = 'Lookthru' |
| 5197 |
; |
| 5198 |
breakVerb: deepverb |
| 5199 |
verb = 'break' 'ruin' 'destroy' |
| 5200 |
sdesc = "break" |
| 5201 |
doAction = 'Break' |
| 5202 |
; |
| 5203 |
attackVerb: deepverb |
| 5204 |
verb = 'attack' 'kill' 'hit' |
| 5205 |
sdesc = "attack" |
| 5206 |
prepDefault = withPrep |
| 5207 |
ioAction(withPrep) = 'AttackWith' |
| 5208 |
; |
| 5209 |
climbVerb: deepverb |
| 5210 |
verb = 'climb' |
| 5211 |
sdesc = "climb" |
| 5212 |
doAction = 'Climb' |
| 5213 |
; |
| 5214 |
eatVerb: deepverb |
| 5215 |
verb = 'eat' 'consume' |
| 5216 |
sdesc = "eat" |
| 5217 |
doAction = 'Eat' |
| 5218 |
; |
| 5219 |
drinkVerb: deepverb |
| 5220 |
verb = 'drink' |
| 5221 |
sdesc = "drink" |
| 5222 |
doAction = 'Drink' |
| 5223 |
; |
| 5224 |
giveVerb: deepverb |
| 5225 |
verb = 'give' 'offer' |
| 5226 |
sdesc = "give" |
| 5227 |
prepDefault = toPrep |
| 5228 |
ioAction(toPrep) = 'GiveTo' |
| 5229 |
doDefault(actor, prep, io) = |
| 5230 |
{ |
| 5231 |
return actor.contents; |
| 5232 |
} |
| 5233 |
; |
| 5234 |
pullVerb: deepverb |
| 5235 |
verb = 'pull' |
| 5236 |
sdesc = "pull" |
| 5237 |
doAction = 'Pull' |
| 5238 |
; |
| 5239 |
readVerb: deepverb |
| 5240 |
verb = 'read' |
| 5241 |
sdesc = "read" |
| 5242 |
doAction = 'Read' |
| 5243 |
; |
| 5244 |
throwVerb: deepverb |
| 5245 |
verb = 'throw' 'toss' |
| 5246 |
sdesc = "throw" |
| 5247 |
prepDefault = atPrep |
| 5248 |
ioAction(atPrep) = 'ThrowAt' |
| 5249 |
ioAction(toPrep) = 'ThrowTo' |
| 5250 |
; |
| 5251 |
standOnVerb: deepverb |
| 5252 |
verb = 'stand on' |
| 5253 |
sdesc = "stand on" |
| 5254 |
doAction = 'Standon' |
| 5255 |
; |
| 5256 |
standVerb: deepverb |
| 5257 |
verb = 'stand' 'stand up' 'get up' |
| 5258 |
sdesc = "stand" |
| 5259 |
outhideStatus = 0 |
| 5260 |
action(actor) = |
| 5261 |
{ |
| 5262 |
if (actor.location = nil or actor.location.location = nil) |
| 5263 |
"%You're% already standing! "; |
| 5264 |
else |
| 5265 |
{ |
| 5266 |
/* |
| 5267 |
* silently check verDoUnboard, to see if we can get out of |
| 5268 |
* whatever object we're in |
| 5269 |
*/ |
| 5270 |
self.outhideStatus := outhide(true); |
| 5271 |
actor.location.verDoUnboard(actor); |
| 5272 |
if (outhide(self.outhideStatus)) |
| 5273 |
{ |
| 5274 |
/* |
| 5275 |
* verification failed - run again, showing the message |
| 5276 |
* this time |
| 5277 |
*/ |
| 5278 |
actor.location.verDoUnboard(actor); |
| 5279 |
} |
| 5280 |
else |
| 5281 |
{ |
| 5282 |
/* verification succeeded - unboard */ |
| 5283 |
actor.location.doUnboard(actor); |
| 5284 |
} |
| 5285 |
} |
| 5286 |
} |
| 5287 |
; |
| 5288 |
helloVerb: deepverb |
| 5289 |
verb = 'hello' 'hi' 'greetings' |
| 5290 |
sdesc = "hello" |
| 5291 |
action(actor) = |
| 5292 |
{ |
| 5293 |
"Nice weather we've been having.\n"; |
| 5294 |
} |
| 5295 |
; |
| 5296 |
showVerb: deepverb |
| 5297 |
verb = 'show' |
| 5298 |
sdesc = "show" |
| 5299 |
prepDefault = toPrep |
| 5300 |
ioAction(toPrep) = 'ShowTo' |
| 5301 |
doDefault(actor, prep, io) = |
| 5302 |
{ |
| 5303 |
return actor.contents; |
| 5304 |
} |
| 5305 |
; |
| 5306 |
cleanVerb: deepverb |
| 5307 |
verb = 'clean' |
| 5308 |
sdesc = "clean" |
| 5309 |
ioAction(withPrep) = 'CleanWith' |
| 5310 |
doAction = 'Clean' |
| 5311 |
; |
| 5312 |
sayVerb: deepverb |
| 5313 |
verb = 'say' |
| 5314 |
sdesc = "say" |
| 5315 |
doAction = 'Say' |
| 5316 |
; |
| 5317 |
yellVerb: deepverb |
| 5318 |
verb = 'yell' 'shout' 'yell at' 'shout at' |
| 5319 |
sdesc = "yell" |
| 5320 |
action(actor) = |
| 5321 |
{ |
| 5322 |
"%Your% throat is a bit sore now. "; |
| 5323 |
} |
| 5324 |
; |
| 5325 |
moveVerb: deepverb |
| 5326 |
verb = 'move' |
| 5327 |
sdesc = "move" |
| 5328 |
ioAction(withPrep) = 'MoveWith' |
| 5329 |
ioAction(toPrep) = 'MoveTo' |
| 5330 |
doAction = 'Move' |
| 5331 |
; |
| 5332 |
fastenVerb: deepverb |
| 5333 |
verb = 'fasten' 'buckle' 'buckle up' |
| 5334 |
sdesc = "fasten" |
| 5335 |
doAction = 'Fasten' |
| 5336 |
; |
| 5337 |
unfastenVerb: deepverb |
| 5338 |
verb = 'unfasten' 'unbuckle' |
| 5339 |
sdesc = "unfasten" |
| 5340 |
doAction = 'Unfasten' |
| 5341 |
; |
| 5342 |
unplugVerb: deepverb |
| 5343 |
verb = 'unplug' |
| 5344 |
sdesc = "unplug" |
| 5345 |
ioAction(fromPrep) = 'UnplugFrom' |
| 5346 |
doAction = 'Unplug' |
| 5347 |
; |
| 5348 |
lookUnderVerb: deepverb |
| 5349 |
verb = 'look under' 'look beneath' 'l under' 'l beneath' |
| 5350 |
sdesc = "look under" |
| 5351 |
doAction = 'Lookunder' |
| 5352 |
; |
| 5353 |
lookBehindVerb: deepverb |
| 5354 |
verb = 'look behind' 'l behind' |
| 5355 |
sdesc = "look behind" |
| 5356 |
doAction = 'Lookbehind' |
| 5357 |
; |
| 5358 |
typeVerb: deepverb |
| 5359 |
verb = 'type' |
| 5360 |
sdesc = "type" |
| 5361 |
prepDefault = onPrep |
| 5362 |
ioAction(onPrep) = 'TypeOn' |
| 5363 |
; |
| 5364 |
lockVerb: deepverb |
| 5365 |
verb = 'lock' |
| 5366 |
sdesc = "lock" |
| 5367 |
ioAction(withPrep) = 'LockWith' |
| 5368 |
doAction = 'Lock' |
| 5369 |
prepDefault = withPrep |
| 5370 |
; |
| 5371 |
unlockVerb: deepverb |
| 5372 |
verb = 'unlock' |
| 5373 |
sdesc = "unlock" |
| 5374 |
ioAction(withPrep) = 'UnlockWith' |
| 5375 |
doAction = 'Unlock' |
| 5376 |
prepDefault = withPrep |
| 5377 |
; |
| 5378 |
detachVerb: deepverb |
| 5379 |
verb = 'detach' 'disconnect' |
| 5380 |
prepDefault = fromPrep |
| 5381 |
ioAction(fromPrep) = 'DetachFrom' |
| 5382 |
doAction = 'Detach' |
| 5383 |
sdesc = "detach" |
| 5384 |
; |
| 5385 |
sleepVerb: darkVerb |
| 5386 |
action(actor) = |
| 5387 |
{ |
| 5388 |
if (actor.cantSleep) |
| 5389 |
"%You% %are% much too anxious worrying about %your% continued |
| 5390 |
survival to fall asleep now. "; |
| 5391 |
else if (global.awakeTime+1 < global.sleepTime) |
| 5392 |
"%You're% not tired. "; |
| 5393 |
else if (not (actor.location.isbed or actor.location.ischair)) |
| 5394 |
"I don't know about you, but I can never sleep |
| 5395 |
standing up. %You% should find a nice comfortable |
| 5396 |
bed somewhere. "; |
| 5397 |
else |
| 5398 |
{ |
| 5399 |
"%You% quickly drift%s% off into dreamland...\b"; |
| 5400 |
goToSleep(); |
| 5401 |
} |
| 5402 |
} |
| 5403 |
verb = 'sleep' |
| 5404 |
sdesc = "sleep" |
| 5405 |
; |
| 5406 |
pokeVerb: deepverb |
| 5407 |
verb = 'poke' 'jab' |
| 5408 |
sdesc = "poke" |
| 5409 |
doAction = 'Poke' |
| 5410 |
; |
| 5411 |
touchVerb: deepverb |
| 5412 |
verb = 'touch' |
| 5413 |
sdesc = "touch" |
| 5414 |
doAction = 'Touch' |
| 5415 |
; |
| 5416 |
moveNVerb: deepverb |
| 5417 |
verb = 'move north' 'move n' 'push north' 'push n' |
| 5418 |
sdesc = "move north" |
| 5419 |
doAction = 'MoveN' |
| 5420 |
; |
| 5421 |
moveSVerb: deepverb |
| 5422 |
verb = 'move south' 'move s' 'push south' 'push s' |
| 5423 |
sdesc = "move south" |
| 5424 |
doAction = 'MoveS' |
| 5425 |
; |
| 5426 |
moveEVerb: deepverb |
| 5427 |
verb = 'move east' 'move e' 'push east' 'push e' |
| 5428 |
sdesc = "move east" |
| 5429 |
doAction = 'MoveE' |
| 5430 |
; |
| 5431 |
moveWVerb: deepverb |
| 5432 |
verb = 'move west' 'move w' 'push west' 'push w' |
| 5433 |
sdesc = "move west" |
| 5434 |
doAction = 'MoveW' |
| 5435 |
; |
| 5436 |
moveNEVerb: deepverb |
| 5437 |
verb = 'move northeast' 'move ne' 'push northeast' 'push ne' |
| 5438 |
sdesc = "move northeast" |
| 5439 |
doAction = 'MoveNE' |
| 5440 |
; |
| 5441 |
moveNWVerb: deepverb |
| 5442 |
verb = 'move northwest' 'move nw' 'push northwest' 'push nw' |
| 5443 |
sdesc = "move northwest" |
| 5444 |
doAction = 'MoveNW' |
| 5445 |
; |
| 5446 |
moveSEVerb: deepverb |
| 5447 |
verb = 'move southeast' 'move se' 'push southeast' 'push se' |
| 5448 |
sdesc = "move southeast" |
| 5449 |
doAction = 'MoveSE' |
| 5450 |
; |
| 5451 |
moveSWVerb: deepverb |
| 5452 |
verb = 'move southwest' 'move sw' 'push southwest' 'push sw' |
| 5453 |
sdesc = "move southwest" |
| 5454 |
doAction = 'MoveSW' |
| 5455 |
; |
| 5456 |
centerVerb: deepverb |
| 5457 |
verb = 'center' |
| 5458 |
sdesc = "center" |
| 5459 |
doAction = 'Center' |
| 5460 |
; |
| 5461 |
searchVerb: deepverb |
| 5462 |
verb = 'search' |
| 5463 |
sdesc = "search" |
| 5464 |
doAction = 'Search' |
| 5465 |
; |
| 5466 |
knockVerb: deepverb |
| 5467 |
verb = 'knock' 'knock on' 'knock at' |
| 5468 |
sdesc = "knock" |
| 5469 |
doAction = 'Knock' |
| 5470 |
; |
| 5471 |
|
| 5472 |
/* |
| 5473 |
* Travel verbs - these verbs allow the player to move about. |
| 5474 |
* All travel verbs have the property isTravelVerb set true. |
| 5475 |
*/ |
| 5476 |
class travelVerb: deepverb, darkVerb |
| 5477 |
isTravelVerb = true |
| 5478 |
; |
| 5479 |
|
| 5480 |
eVerb: travelVerb |
| 5481 |
action(actor) = { actor.travelTo(self.travelDir(actor)); } |
| 5482 |
verb = 'e' 'east' 'go east' |
| 5483 |
sdesc = "go east" |
| 5484 |
travelDir(actor) = { return actor.location.(actor.eastProp); } |
| 5485 |
; |
| 5486 |
sVerb: travelVerb |
| 5487 |
action(actor) = { actor.travelTo(self.travelDir(actor)); } |
| 5488 |
verb = 's' 'south' 'go south' |
| 5489 |
sdesc = "go south" |
| 5490 |
travelDir(actor) = { return actor.location.(actor.southProp); } |
| 5491 |
; |
| 5492 |
nVerb: travelVerb |
| 5493 |
action(actor) = { actor.travelTo(self.travelDir(actor)); } |
| 5494 |
verb = 'n' 'north' 'go north' |
| 5495 |
sdesc = "go north" |
| 5496 |
travelDir(actor) = { return actor.location.(actor.northProp); } |
| 5497 |
; |
| 5498 |
wVerb: travelVerb |
| 5499 |
action(actor) = { actor.travelTo(self.travelDir(actor)); } |
| 5500 |
verb = 'w' 'west' 'go west' |
| 5501 |
sdesc = "go west" |
| 5502 |
travelDir(actor) = { return actor.location.(actor.westProp); } |
| 5503 |
; |
| 5504 |
neVerb: travelVerb |
| 5505 |
action(actor) = { actor.travelTo(self.travelDir(actor)); } |
| 5506 |
verb = 'ne' 'northeast' 'go ne' 'go northeast' |
| 5507 |
sdesc = "go northeast" |
| 5508 |
travelDir(actor) = { return actor.location.(actor.neProp); } |
| 5509 |
; |
| 5510 |
nwVerb: travelVerb |
| 5511 |
action(actor) = { actor.travelTo(self.travelDir(actor)); } |
| 5512 |
verb = 'nw' 'northwest' 'go nw' 'go northwest' |
| 5513 |
sdesc = "go northwest" |
| 5514 |
travelDir(actor) = { return actor.location.(actor.nwProp); } |
| 5515 |
; |
| 5516 |
seVerb: travelVerb |
| 5517 |
action(actor) = { actor.travelTo(self.travelDir(actor)); } |
| 5518 |
verb = 'se' 'southeast' 'go se' 'go southeast' |
| 5519 |
sdesc = "go southeast" |
| 5520 |
travelDir(actor) = { return actor.location.(actor.seProp); } |
| 5521 |
; |
| 5522 |
swVerb: travelVerb |
| 5523 |
action(actor) = { actor.travelTo(self.travelDir(actor)); } |
| 5524 |
verb = 'sw' 'southwest' 'go sw' 'go southwest' |
| 5525 |
sdesc = "go southwest" |
| 5526 |
travelDir(actor) = { return actor.location.(actor.swProp); } |
| 5527 |
; |
| 5528 |
inVerb: travelVerb |
| 5529 |
action(actor) = { actor.travelTo(self.travelDir(actor)); } |
| 5530 |
verb = 'in' 'go in' 'enter' 'go to' 'go into' |
| 5531 |
sdesc = "enter" |
| 5532 |
doAction = 'Enter' |
| 5533 |
travelDir(actor) = { return actor.location.(actor.inProp); } |
| 5534 |
ioAction(onPrep) = 'EnterOn' |
| 5535 |
ioAction(inPrep) = 'EnterIn' |
| 5536 |
ioAction(withPrep) = 'EnterWith' |
| 5537 |
; |
| 5538 |
outVerb: travelVerb |
| 5539 |
sdesc = "go out" |
| 5540 |
action(actor) = { actor.travelTo(self.travelDir(actor)); } |
| 5541 |
verb = 'out' 'go out' 'exit' 'leave' |
| 5542 |
travelDir(actor) = { return actor.location.(actor.outProp); } |
| 5543 |
; |
| 5544 |
dVerb: travelVerb |
| 5545 |
action(actor) = { actor.travelTo(self.travelDir(actor)); } |
| 5546 |
verb = 'd' 'down' 'go down' |
| 5547 |
sdesc = "go down" |
| 5548 |
travelDir(actor) = { return actor.location.(actor.downProp); } |
| 5549 |
; |
| 5550 |
uVerb: travelVerb |
| 5551 |
action(actor) = { actor.travelTo(self.travelDir(actor)); } |
| 5552 |
verb = 'u' 'up' 'go up' |
| 5553 |
sdesc = "go up" |
| 5554 |
travelDir(actor) = { return actor.location.(actor.upProp); } |
| 5555 |
; |
| 5556 |
|
| 5557 |
gothroughVerb: deepverb |
| 5558 |
verb = 'go through' 'go thru' |
| 5559 |
sdesc = "go through" |
| 5560 |
doAction = 'Gothrough' |
| 5561 |
; |
| 5562 |
|
| 5563 |
/* |
| 5564 |
* sysverb: A system verb. Verbs of this class are special verbs that |
| 5565 |
* can be executed without certain normal validations. For example, |
| 5566 |
* a system verb can be executed in a dark room. System verbs are |
| 5567 |
* for operations such as saving, restoring, and quitting, which are |
| 5568 |
* not really part of the game. |
| 5569 |
*/ |
| 5570 |
class sysverb: deepverb, darkVerb |
| 5571 |
issysverb = true |
| 5572 |
; |
| 5573 |
|
| 5574 |
quitVerb: sysverb |
| 5575 |
verb = 'quit' 'q' |
| 5576 |
sdesc = "quit" |
| 5577 |
quitGame(actor) = |
| 5578 |
{ |
| 5579 |
local yesno; |
| 5580 |
|
| 5581 |
scoreRank(); |
| 5582 |
"\bDo you really want to quit? (YES or NO) > "; |
| 5583 |
yesno := yorn(); |
| 5584 |
"\b"; |
| 5585 |
if (yesno = 1) |
| 5586 |
{ |
| 5587 |
terminate(); // allow user good-bye message |
| 5588 |
quit(); |
| 5589 |
} |
| 5590 |
else |
| 5591 |
{ |
| 5592 |
"Okay. "; |
| 5593 |
} |
| 5594 |
} |
| 5595 |
action(actor) = |
| 5596 |
{ |
| 5597 |
self.quitGame(actor); |
| 5598 |
abort; |
| 5599 |
} |
| 5600 |
; |
| 5601 |
verboseVerb: sysverb |
| 5602 |
verb = 'verbose' |
| 5603 |
sdesc = "verbose" |
| 5604 |
verboseMode(actor) = |
| 5605 |
{ |
| 5606 |
"Okay, now in VERBOSE mode.\n"; |
| 5607 |
global.verbose := true; |
| 5608 |
parserGetMe().location.lookAround(true); |
| 5609 |
} |
| 5610 |
action(actor) = |
| 5611 |
{ |
| 5612 |
self.verboseMode(actor); |
| 5613 |
abort; |
| 5614 |
} |
| 5615 |
; |
| 5616 |
terseVerb: sysverb |
| 5617 |
verb = 'brief' 'terse' |
| 5618 |
sdesc = "terse" |
| 5619 |
terseMode(actor) = |
| 5620 |
{ |
| 5621 |
"Okay, now in TERSE mode.\n"; |
| 5622 |
global.verbose := nil; |
| 5623 |
} |
| 5624 |
action(actor) = |
| 5625 |
{ |
| 5626 |
self.terseMode(actor); |
| 5627 |
abort; |
| 5628 |
} |
| 5629 |
; |
| 5630 |
scoreVerb: sysverb |
| 5631 |
verb = 'score' 'status' |
| 5632 |
sdesc = "score" |
| 5633 |
showScore(actor) = |
| 5634 |
{ |
| 5635 |
scoreRank(); |
| 5636 |
} |
| 5637 |
action(actor) = |
| 5638 |
{ |
| 5639 |
self.showScore(actor); |
| 5640 |
abort; |
| 5641 |
} |
| 5642 |
; |
| 5643 |
saveVerb: sysverb |
| 5644 |
verb = 'save' |
| 5645 |
sdesc = "save" |
| 5646 |
doAction = 'Save' |
| 5647 |
saveGame(actor) = |
| 5648 |
{ |
| 5649 |
local savefile; |
| 5650 |
|
| 5651 |
savefile := askfile('File to save game in', |
| 5652 |
ASKFILE_PROMPT_SAVE, FILE_TYPE_SAVE, |
| 5653 |
ASKFILE_EXT_RESULT); |
| 5654 |
switch(savefile[1]) |
| 5655 |
{ |
| 5656 |
case ASKFILE_SUCCESS: |
| 5657 |
if (save(savefile[2])) |
| 5658 |
{ |
| 5659 |
"An error occurred saving the game position to the file. "; |
| 5660 |
return nil; |
| 5661 |
} |
| 5662 |
else |
| 5663 |
{ |
| 5664 |
"Saved. "; |
| 5665 |
return true; |
| 5666 |
} |
| 5667 |
|
| 5668 |
case ASKFILE_CANCEL: |
| 5669 |
"Canceled. "; |
| 5670 |
return nil; |
| 5671 |
|
| 5672 |
case ASKFILE_FAILURE: |
| 5673 |
default: |
| 5674 |
"Failed. "; |
| 5675 |
return nil; |
| 5676 |
} |
| 5677 |
} |
| 5678 |
action(actor) = |
| 5679 |
{ |
| 5680 |
self.saveGame(actor); |
| 5681 |
abort; |
| 5682 |
} |
| 5683 |
; |
| 5684 |
restoreVerb: sysverb |
| 5685 |
verb = 'restore' |
| 5686 |
sdesc = "restore" |
| 5687 |
doAction = 'Restore' |
| 5688 |
restoreGame(actor) = |
| 5689 |
{ |
| 5690 |
local savefile; |
| 5691 |
|
| 5692 |
savefile := askfile('File to restore game from', |
| 5693 |
ASKFILE_PROMPT_OPEN, FILE_TYPE_SAVE, |
| 5694 |
ASKFILE_EXT_RESULT); |
| 5695 |
switch(savefile[1]) |
| 5696 |
{ |
| 5697 |
case ASKFILE_SUCCESS: |
| 5698 |
return mainRestore(savefile[2]); |
| 5699 |
|
| 5700 |
case ASKFILE_CANCEL: |
| 5701 |
"Canceled. "; |
| 5702 |
return nil; |
| 5703 |
|
| 5704 |
case ASKFILE_FAILURE: |
| 5705 |
default: |
| 5706 |
"Failed. "; |
| 5707 |
return nil; |
| 5708 |
} |
| 5709 |
} |
| 5710 |
action(actor) = |
| 5711 |
{ |
| 5712 |
self.restoreGame(actor); |
| 5713 |
abort; |
| 5714 |
} |
| 5715 |
; |
| 5716 |
|
| 5717 |
scriptVerb: sysverb |
| 5718 |
verb = 'script' |
| 5719 |
sdesc = "script" |
| 5720 |
doAction = 'Script' |
| 5721 |
startScripting(actor) = |
| 5722 |
{ |
| 5723 |
local scriptfile; |
| 5724 |
|
| 5725 |
scriptfile := askfile('File to write transcript to', |
| 5726 |
ASKFILE_PROMPT_SAVE, FILE_TYPE_LOG, |
| 5727 |
ASKFILE_EXT_RESULT); |
| 5728 |
|
| 5729 |
switch(scriptfile[1]) |
| 5730 |
{ |
| 5731 |
case ASKFILE_SUCCESS: |
| 5732 |
logging(scriptfile[2]); |
| 5733 |
"All text will now be saved to the script file. |
| 5734 |
Type UNSCRIPT at any time to discontinue scripting."; |
| 5735 |
break; |
| 5736 |
|
| 5737 |
case ASKFILE_CANCEL: |
| 5738 |
"Canceled. "; |
| 5739 |
break; |
| 5740 |
|
| 5741 |
case ASKFILE_FAILURE: |
| 5742 |
"Failed. "; |
| 5743 |
break; |
| 5744 |
} |
| 5745 |
} |
| 5746 |
action(actor) = |
| 5747 |
{ |
| 5748 |
self.startScripting(actor); |
| 5749 |
abort; |
| 5750 |
} |
| 5751 |
; |
| 5752 |
unscriptVerb: sysverb |
| 5753 |
verb = 'unscript' |
| 5754 |
sdesc = "unscript" |
| 5755 |
stopScripting(actor) = |
| 5756 |
{ |
| 5757 |
logging(nil); |
| 5758 |
"Script closed.\n"; |
| 5759 |
} |
| 5760 |
action(actor) = |
| 5761 |
{ |
| 5762 |
self.stopScripting(actor); |
| 5763 |
abort; |
| 5764 |
} |
| 5765 |
; |
| 5766 |
restartVerb: sysverb |
| 5767 |
verb = 'restart' |
| 5768 |
sdesc = "restart" |
| 5769 |
restartGame(actor) = |
| 5770 |
{ |
| 5771 |
local yesno; |
| 5772 |
while (true) |
| 5773 |
{ |
| 5774 |
"Are you sure you want to start over? (YES or NO) > "; |
| 5775 |
yesno := yorn(); |
| 5776 |
if (yesno = 1) |
| 5777 |
{ |
| 5778 |
"\n"; |
| 5779 |
scoreStatus(0, 0); |
| 5780 |
restart(initRestart, global.initRestartParam); |
| 5781 |
break; |
| 5782 |
} |
| 5783 |
else if (yesno = 0) |
| 5784 |
{ |
| 5785 |
"\nOkay.\n"; |
| 5786 |
break; |
| 5787 |
} |
| 5788 |
} |
| 5789 |
} |
| 5790 |
action(actor) = |
| 5791 |
{ |
| 5792 |
self.restartGame(actor); |
| 5793 |
abort; |
| 5794 |
} |
| 5795 |
; |
| 5796 |
versionVerb: sysverb |
| 5797 |
verb = 'version' |
| 5798 |
sdesc = "version" |
| 5799 |
showVersion(actor) = |
| 5800 |
{ |
| 5801 |
version.sdesc; |
| 5802 |
} |
| 5803 |
action(actor) = |
| 5804 |
{ |
| 5805 |
self.showVersion(actor); |
| 5806 |
abort; |
| 5807 |
} |
| 5808 |
; |
| 5809 |
debugVerb: sysverb |
| 5810 |
verb = 'debug' |
| 5811 |
sdesc = "debug" |
| 5812 |
enterDebugger(actor) = |
| 5813 |
{ |
| 5814 |
if (debugTrace()) |
| 5815 |
"You can't think this game has any bugs left in it... "; |
| 5816 |
} |
| 5817 |
action(actor) = |
| 5818 |
{ |
| 5819 |
self.enterDebugger(actor); |
| 5820 |
abort; |
| 5821 |
} |
| 5822 |
; |
| 5823 |
|
| 5824 |
undoVerb: sysverb |
| 5825 |
verb = 'undo' |
| 5826 |
sdesc = "undo" |
| 5827 |
undoMove(actor) = |
| 5828 |
{ |
| 5829 |
/* do TWO undo's - one for this 'undo', one for previous command */ |
| 5830 |
if (undo() and undo()) |
| 5831 |
{ |
| 5832 |
"(Undoing one command)\b"; |
| 5833 |
parserGetMe().location.lookAround(true); |
| 5834 |
scoreStatus(global.score, global.turnsofar); |
| 5835 |
} |
| 5836 |
else |
| 5837 |
"No more undo information is available. "; |
| 5838 |
} |
| 5839 |
action(actor) = |
| 5840 |
{ |
| 5841 |
self.undoMove(actor); |
| 5842 |
abort; |
| 5843 |
} |
| 5844 |
; |
| 5845 |
|
| 5846 |
/* |
| 5847 |
* Prep: object |
| 5848 |
* |
| 5849 |
* A preposition. The preposition property specifies the |
| 5850 |
* vocabulary word. |
| 5851 |
*/ |
| 5852 |
class Prep: object |
| 5853 |
; |
| 5854 |
|
| 5855 |
/* |
| 5856 |
* Various prepositions |
| 5857 |
*/ |
| 5858 |
ofPrep: Prep |
| 5859 |
preposition = 'of' |
| 5860 |
sdesc = "of" |
| 5861 |
; |
| 5862 |
aboutPrep: Prep |
| 5863 |
preposition = 'about' |
| 5864 |
sdesc = "about" |
| 5865 |
; |
| 5866 |
withPrep: Prep |
| 5867 |
preposition = 'with' |
| 5868 |
sdesc = "with" |
| 5869 |
; |
| 5870 |
toPrep: Prep |
| 5871 |
preposition = 'to' |
| 5872 |
sdesc = "to" |
| 5873 |
; |
| 5874 |
onPrep: Prep |
| 5875 |
preposition = 'on' 'onto' 'downon' 'upon' |
| 5876 |
sdesc = "on" |
| 5877 |
; |
| 5878 |
inPrep: Prep |
| 5879 |
preposition = 'in' 'into' 'downin' |
| 5880 |
sdesc = "in" |
| 5881 |
; |
| 5882 |
offPrep: Prep |
| 5883 |
preposition = 'off' 'offof' |
| 5884 |
sdesc = "off" |
| 5885 |
; |
| 5886 |
outPrep: Prep |
| 5887 |
preposition = 'out' 'outof' |
| 5888 |
sdesc = "out" |
| 5889 |
; |
| 5890 |
fromPrep: Prep |
| 5891 |
preposition = 'from' |
| 5892 |
sdesc = "from" |
| 5893 |
; |
| 5894 |
betweenPrep: Prep |
| 5895 |
preposition = 'between' 'inbetween' |
| 5896 |
sdesc = "between" |
| 5897 |
; |
| 5898 |
overPrep: Prep |
| 5899 |
preposition = 'over' |
| 5900 |
sdesc = "over" |
| 5901 |
; |
| 5902 |
atPrep: Prep |
| 5903 |
preposition = 'at' |
| 5904 |
sdesc = "at" |
| 5905 |
; |
| 5906 |
aroundPrep: Prep |
| 5907 |
preposition = 'around' |
| 5908 |
sdesc = "around" |
| 5909 |
; |
| 5910 |
thruPrep: Prep |
| 5911 |
preposition = 'through' 'thru' |
| 5912 |
sdesc = "through" |
| 5913 |
; |
| 5914 |
dirPrep: Prep |
| 5915 |
preposition = 'north' 'south' 'east' 'west' 'up' 'down' 'northeast' 'ne' |
| 5916 |
'northwest' 'nw' 'southeast' 'se' 'southwest' 'sw' |
| 5917 |
'n' 's' 'e' 'w' 'u' 'd' |
| 5918 |
sdesc = "north" // Shouldn't ever need this, but just in case |
| 5919 |
; |
| 5920 |
underPrep: Prep |
| 5921 |
preposition = 'under' 'beneath' |
| 5922 |
sdesc = "under" |
| 5923 |
; |
| 5924 |
behindPrep: Prep |
| 5925 |
preposition = 'behind' |
| 5926 |
sdesc = "behind" |
| 5927 |
; |
| 5928 |
|
| 5929 |
/* |
| 5930 |
* articles: the "built-in" articles. "The," "a," and "an" are |
| 5931 |
* defined. |
| 5932 |
*/ |
| 5933 |
articles: object |
| 5934 |
article = 'the' 'a' 'an' |
| 5935 |
; |
| 5936 |
|