-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMUD1.BCL
469 lines (464 loc) · 13 KB
/
MUD1.BCL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
/*
Copyright (C) 1980 by
Roy Trubshaw & Richard Bartle,
Essex University, Colchester. CO4 3SQ.
This software is furnished on the understanding that
it may be used and/or copied only with the inclusion of this
notice. No title or ownership of this software is hereby
transferred. The information in this software is subject to
change without notice. No responsibility is assumed for the
use or reliability of this software.
Released by Richard Bartle exclusively for not for profit use
18 May 2020
*/
get "mudlib"
get "dungen"
let start() be
$( input,output_tty,tty //Initialise things.
mainloop_label(l1) //Ditto.
initialise() //More of above.
$( l1: at_false
justforced_false
check.stuff() //Game in full swing, check
parse.command() //various things and says
instate()
execute.command() //anything try and understand
$) repeat //it. Again and again.
$)
and check.stuff() be
$( let present,change,bit,nm=?,?,?,?
while magic
$( $[ $setzm JBINT $]
outz(strtab!8)
Outs("Everything in the game has been reset to its original starting state!*C*L")
stop.fighting()
$[ $clrbfi $]
quit()
$)
ran() //Bump random (ha!) number generator.
jar(@deldr)
check.gone()
active!player.no_valof
$[ $mstime 1, 0 $]
unjar(@deldr)
unless maint
test lastmoments then
$( lastmoments+_1
if lastmoments ge TIMEOUT*60 test timeok(low2) then
$( out("*C*L:6 will not be closing after all - carry on playing...*C*L", MUD6)
lastmoments_0
$) or
$( out("*C*L:6 is now closed!*C*L", MUD6)
stop.fighting() //ought to have a proc for these 2 - happen together often
quit()
$)
$) or unless timeok()
$( out("*C*L:6 will be closing shortly - you have about :N minutes left!*C*L", MUD6, TIMEOUT)
lastmoments_1
$)
present_WHO!room //See who is in room.
unless who.copy=present then //If changed since last time report on it.
$( change_present neqv who.copy //Get changes.
unless ASLEEP of profile if visible() for i=0 to 35 do unless i=player.no then
$( bit_1<<i //See who it was and tell everyone!
if bit bitand change then unless invisible(i)
$( nm_player.names!i
if nm out(":p has just :s.*C*L",nm,
(WIZARD of LH from player.names!i)=1->(bit bitand present -> "appeared with a crash of thunder", "disappeared in a puff of smoke"),
(bit bitand present -> "arrived", "left"))
$)
$) //If can't find name then someone "died".
who.copy_present //Keep copy up to date.
$) //Continue as nothing had happened
if queue!player.no interact() //If received message process it (them).
if pain STAMINA of profile-_pain<>pain_0
if chcnt>0 test can.wake() then wake.up()<>return or error("You can't wake yourself up yet!")
if ASLEEP of profile /\ can.wake() /\ new.stamina() ge STAMINAMAX of profile
$( outs("You are too alert to sleep any more! ")
wake.up()
$)
test somethingarrived then somethingarrived_false or unless lineflg
unless random(player+1) if melted do
$( let tracer=movers
while tracer do
$( let obj, mobile = LH of tracer, MOTN of obj
if (CURROOM of mobile)/\(FIGHTS of mobile=0)/\(DESTROYED of obj ge 0)/\(P4 of obj=0) then
$( MOVECOUNT of mobile+_1
if MOVECOUNT of mobile gr MOTION of mobile then moveobject(obj)<>MOVECOUNT of mobile_0
$)
tracer of_RH
$)
$)
if ~autowho
$( autowho-_1
unless autowho
$( autowho_autoint
unless ASLEEP of profile
$( Outz($az"*C*LAuto-who:*C*L")
Special(SF.WHO)
$)
$)
$)
if events handledemons(@events)
if gdemons/\random(player+1)=0 handledemons(@gdemons)
if player unless random(player+1)
$( jar(@deldr)
for i=0 to 35 unless i=player.no if player.names!i
$( let act=active!i
if act ls 0 loop
if (((valof
$[ $mstime 1, 0 $])-act+WHOLEDAY) rem WHOLEDAY gr DELAY)\/
(valof
$( let jb=jobnos!i
$[ $setz 1, 0
$move 2, jb
$trmno. 2, 0
$seto 1, 0
$]
$)) then exorcise(i)
$)
unjar(@deldr)
$)
unless prompted \/ pretend
$( unless snooping ge 0 \/ snobj
$( outz($az"*S*C*L")
ccnt_0
if INVIS of profile writech(tty,'(')
if WIZARD of profile writes(tty,"----")
writech(tty,conversing->'"',(BZK/\BERSERK of profile) -> '>', '**')
if INVIS of profile writech(tty,')')
unless valof
$[ $setz 1, 0
$skpinc
$seto 1, 0
$] do
$[ $movei 1, 2
$hrli 1, 2
$movei 2, #2
$move 3, ttyno
retry: $trmop. 1, 0
$jrst okthen
$movei 4, 1
$hiber 4, 0
$trn
$jrst retry
okthen:
$] <> forcetty($az "*^R")
$)
prompted_true
$)
lineflg_hibernate() //Sleep for a sec. or until line ready.
if ctcflg quit()
if lineflg read.line() //Read the line if there.
$) repeat //Otherwise do it again.
and parse.command() be
$( let token=?
switchon scanner() into //See what was typed.
$( case S.MOTION ... S.LEVEL:
verb_scan.info //Remember verb.
token_nvscanner() //Next token.
if token=S.CONT return //Only said verb.
if token=S.WITH\/token=S.AT token_nvscanner() //ignore superfluous WITHs
if token=S.MOTION nvscanner()
//Frig participles to verbs!
try.it(@objct,token) //Remember object.
unless token=S.WITH\/token=S.AT token_nvscanner() //Anything more?
if token=S.AT at_true
unless token=S.WITH\/token=S.AT\/token=S.CONT
$( let what=scan.info
token_nvscanner()
test S.IT le token le S.THEM then try.it(@objct,token) or
test token=S.CONT\/token=S.WITH\/token=S.AT then scan.info_what<>try.it(@objct,S.OBJECT)
or try.it(@instrmnt,token)<>endcase
$)
if token=S.CONT instrmnt_0<>return //No.
if token=S.AT at_true
token_nvscanner()
try.it(@instrmnt,token)
endcase
CASE S.SPECIAL:
verb_scan.info
nvscanner() //take off the s.cont
return
case S.UNCONVERSE:
verb_0
return
case S.AT:
at_true
case S.WITH:
token_nvscanner()
if token=S.CONT error("The first word I understood was a preposition, so it should be*C*L*
*followed by an object, but I don't recognise it.") //Must be followed by something.
try.it(@instrmnt,token) //Remember it.
if scanner()=S.CONT test verb then return or
error("I got the first word as WITH-like and I think I got an instrument, but*C*LI can't find an action.")
//May have specified a verb.
verb_scan.info //Store verb.
token_nvscanner() //Next token.
if token=S.CONT return //Finished so return.
if token=S.MOTION token_nvscanner()
//Frig participles.
try.it(@objct,token) //Store object.
endcase
case S.CONT:
if chcnt>0 endcase //Allow stuff like 'and then'.
return //Or return.
case S.PLAYER:
objct_scan.info //remember player number
while valof switchon scanch into
$(
case '*S':
case '*T':
case ',':
case '.':
case ':':
case '-':
resultis true
default '*0' ... '*D':
resultis false
$) scanch_getch()
if dumb error("You can't speak to :U, you're dumb.",player.names!(P1 of objct)) //can find out hidden people this way
interact(I.TELL)
jump(mainloop)
default:
objct_scan.info //Might be an 'object'
unless verb error("You'll have to try something else, I don't understand the first word*C*L(which should be an action).") //If not said verb report error.
$)
unless scanner()=S.CONT error("I think I can guess what some of that meant, try saying it again a*C*Ldifferent way.") //Phrase must end with a conjunction.
if at swap(@objct, @instrmnt)
unless objct objct_fake.node("that")
$)
and execute.command() be if verb then switchon PTYPE of verb into
$( case S.SPECIAL: //A special verb.
special(P1 of verb) //quoted or shouted
endcase
case S.LEVEL:
special(SF.DBUG)
endcase
case S.MOTION: //Execute a direction.
objct_verb
objname_verbname
verb_tverb
verbname_PNAME of verb
case S.ACTION: case S.FASTATN: //An action verb.
action()
$)
and try.it(lvword,token) be switchon token into
$( case S.OBJECT:
setit(scan.info) //inefficient
default:
!lvword_scan.info
endcase
case S.PLAYER:
$( let nam,prof=player.names!(P1 of scan.info),LH from nam
unless hidden(P1 of scan.info)
$( ((SEX of prof)->her, him)_nam
them_nam
$)
!lvword_scan.info
endcase
$)
case S.HIM:
unless him error("I don't know to whom ':s' refers.",PNAME of scan.info)
pronoun(him,lvword)
endcase
case S.HER:
unless her error("I don't know to whom ':s' refers.",PNAME of scan.info)
pronoun(her,lvword)
endcase
case S.THEM:
unless them error("I don't know to whom ':s' refers.",PNAME of scan.info)
pronoun(them,lvword)
endcase
case S.ME:
pronoun(me, lvword)
endcase
case S.THERE:
unless WIZARD of profile error()
unless there error("I don't know where you mean by 'there'.")
$( let s=selector 7:29:bcplrm
and b=selector 6:30:1
and c=0
$[ $move 1, there
come: $ldb 2, b
$jumpe 2, gone
$aos c
$addi 2, '*S'
$idpb 2, s
$lsh 1, 6
$jrst come
gone:
$]
LENGTH of bcplrm_c
$)
!lvword_fake.node(bcplrm) //hope only have 1 room per sentence!
endcase
case S.IT:
unless it error("I don't know what you mean by 'it'.")
case S.WITH:
!lvword_find.word(it)
endcase
$)
and setit(nd) be unless NOIT of nd it_PNAME of nd
and pronoun(pn,lvword) be
$( let word=find.player(pn)
!lvword_fake.node(pn)
if \word unless hidden(word)
$( PTYPE of fake_S.PLAYER
P1 of fake_word
them_PNAME of LH from player.names!word
$)
$)
and nvscanner()=valof
$( let token=scanner()
while token=S.ACTION \/ token=S.FASTATN do token_scanner()
resultis token
$)
and scanner()=valof
$( let word=?
switchon scanch into
$( case 'A' ... 'Z':
case 'a' ... 'z':
case '0' ... '9':
if conversing
$( get.text()
resultis S.SPECIAL
$)
word_read.name()
scan.info_find.word(word)
if scan.info then
$( if PTYPE of scan.info=S.NOISE then loop
if PTYPE of scan.info=S.SPECIAL
$( get.text()
switchon FIRSTCH of mbuffer into
$(
case ',':
case '.':
case ':':
case '-':
FIRSTCH of mbuffer_'*0'
default '*0' ... '*D':
$)
P1 of scan.info_SF.SHOUT
$)
resultis PTYPE of scan.info
$)
scan.info_fake.node(word)
word_find.player(word)
if word\=-1 then
$( if hidden(word) resultis false
PTYPE of scan.info_S.PLAYER
P1 of scan.info_word
resultis S.PLAYER
$)
resultis false
case ',':
case '.':
case ':':
case '-':
if conversing
$( get.text()
resultis S.SPECIAL
$)
scanch_getch()
resultis S.CONT
case '*"':
scanch_getch()
get.text()
resultis S.SPECIAL
case ';':
chcnt_0
verb_0
case '*L' ... '*P':
case '*$':
case '*^G':
case '*E':
scanch_-1
resultis S.CONT
case ')':
conversing_true
endcase
case '(':
conversing_false
endcase
case '**':
case '>':
if conversing
$( conversing_false
out("*C*LLeaving converse mode.*C*L")
resultis S.UNCONVERSE
$)
default '*0' ... '*D':
$)
scanch_getch()
$) repeat
and read.name()=valof
$( let linev,n=vec 127,0
while 'a'<=scanch<='z'\/'0'<=scanch<='9'\/'A'<=scanch<='Z' do //use a case?
$( n+:1
unless n>127 n!linev_'A'<=scanch<='Z'->scanch+#40,scanch
scanch_getch()
$)
!linev_n>127->127,n
resultis packstring(linev,name.string)
$)
and find.word(word,type,cont)=valof
$( let node=dictionary!((!word>>1) rem HASHSIZE)
switchon numbargs() into
$( case 1:
type_0
case 2:
cont_0
$)
if cont then node_LINK of cont
while node do test seq(word,PNAME of node)/\(type=0\/PTYPE of node=type)/\
(PTYPE of node ne S.OBJECT \/ DREC of node ge #400000) then resultis node
or node of_LINK
resultis false
$)
and find.room(name)=valof
$( let node=?
name_sixbit(name)
node_index!((name>>1) rem HASHSIZE)
while node do test name=RNAME of node then resultis node
or node of_LINK
resultis false
$)
and fake.node(wd)=valof
$( let t=fake.string
fake.string_name.string
name.string_t
PNAME of fake_wd
P1 of fake_0
PTYPE of fake_0
resultis fake
$)
and find.player(name)=valof
$( /*
This procedure searches down the list of player names, and returns the player
number if found, otherwise -1.
*/
for i=0 to 35 do if player.names!i if seq(name,player.names!i) resultis i
resultis -1 //otherwise
$)
and get.text() be
$( read.message(mbuffer)
scan.info_fake.node(mbuffer)
PTYPE of scan.info_S.SPECIAL
P1 of scan.info_SF.QOTE
unless deaf\/us(PNAME of profile) if censor("richard") \/ censor(" roy")
out("*C*LIn the distance you hear a deep rumble of thunder.*C*L")
$)
and censor(password)=valof
$( let pw, txt=vec 127, vec 127
unpackstring(password, pw)
unpackstring(mbuffer,txt)
for i=1 to !pw pw!i bitor_#40
for i=1 to !txt txt!i bitor_#40
for i=1 to !txt-!pw+1 do if valof
$( for j=1 to !pw
unless pw!j=txt!(i+j-1) resultis false
resultis true
$) resultis true
resultis false
$)