-
Notifications
You must be signed in to change notification settings - Fork 1
/
melee.zil
347 lines (305 loc) · 9.41 KB
/
melee.zil
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
"SUBTITLE MELEE"
"melee actions (object functions for villains called with these"
<CONSTANT F-DEAD 2> ;"mistah kurtz, he dead."
<CONSTANT F-FIRST? 5> ;"strike first?"
\
"blow results"
<CONSTANT MISSED 1> ;"attacker misses"
<CONSTANT KILLED 3> ;"defender dead"
<CONSTANT LIGHT-WOUND 4> ;"defender lightly wounded"
<CONSTANT SERIOUS-WOUND 5> ;"defender seriously wounded"
<CONSTANT STAGGER 6> ;"defender staggered (miss turn)"
"tables of melee results"
<GLOBAL DEF1
<TABLE
MISSED MISSED MISSED MISSED
STAGGER STAGGER
STAGGER STAGGER
KILLED KILLED KILLED KILLED KILLED>>
<GLOBAL DEF2A
<TABLE
MISSED MISSED MISSED MISSED MISSED
STAGGER STAGGER
LIGHT-WOUND LIGHT-WOUND
KILLED>>
<GLOBAL DEF2B
<TABLE
MISSED MISSED MISSED
STAGGER STAGGER
LIGHT-WOUND LIGHT-WOUND LIGHT-WOUND
KILLED
KILLED KILLED KILLED>>
<GLOBAL DEF3A
<TABLE
MISSED MISSED MISSED MISSED MISSED
STAGGER STAGGER
LIGHT-WOUND LIGHT-WOUND
SERIOUS-WOUND SERIOUS-WOUND>>
<GLOBAL DEF3B
<TABLE
MISSED MISSED MISSED
STAGGER STAGGER
LIGHT-WOUND LIGHT-WOUND LIGHT-WOUND
SERIOUS-WOUND SERIOUS-WOUND SERIOUS-WOUND>>
<GLOBAL DEF3C
<TABLE
MISSED
STAGGER STAGGER
LIGHT-WOUND LIGHT-WOUND LIGHT-WOUND LIGHT-WOUND
SERIOUS-WOUND SERIOUS-WOUND SERIOUS-WOUND>>
<GLOBAL DEF1-RES
<TABLE DEF1
0 ;<REST ,DEF1 2>
0 ;<REST ,DEF1 4>>>
<GLOBAL DEF2-RES
<TABLE DEF2A
DEF2B
0; <REST ,DEF2B 2>
0; <REST ,DEF2B 4>>>
<GLOBAL DEF3-RES
<TABLE DEF3A
0 ;<REST ,DEF3A 2>
DEF3B
0 ;<REST ,DEF3B 2>
DEF3C>>
\
"useful constants"
<CONSTANT STRENGTH-MAX 7>
<CONSTANT STRENGTH-MIN 2>
<CONSTANT CURE-WAIT 30>
"each table entry is:"
<CONSTANT V-VILLAIN 0> ;"villain"
<CONSTANT V-BEST 1> ;"best weapon"
<CONSTANT V-BEST-ADV 2> ;"advantage it confers"
<CONSTANT V-MSGS 3> ;"messages for that villain"
<GLOBAL VILLAINS
<LTABLE <TABLE TROLL SWORD 1 TROLL-MELEE>
<TABLE THIEF KNIFE 1 THIEF-MELEE>>>
\
"I-FIGHT moved to DEMONS"
<ROUTINE DO-FIGHT (LEN "AUX" CNT O OO (OUT <>))
<SET CNT 0>
<REPEAT ()
<SET CNT <+ .CNT 1>>
<COND (<G? .CNT .LEN>
<RETURN T>)>
<SET OO <GET ,VILLAINS .CNT>>
<SET O <GET .OO ,V-VILLAIN>>
<COND (<NOT <FSET? .O ,FIGHTBIT>>)
(<NOT <VILLAIN-BLOW .OO>>
<RETURN>)>>>
\
"takes a remark, defender, and good-guy's weapon"
<ROUTINE REMARK (REMARK D W "AUX" (LEN <GET .REMARK 0>) (CNT 0) STR)
#DECL ((A D) OBJECT (W) <OR OBJECT FALSE> (LEN CNT) FIX
(STR) <OR FIX STRING>)
<REPEAT ()
<COND (<G? <SET CNT <+ .CNT 1>> .LEN> <RETURN>)>
<SET STR <GET .REMARK .CNT>>
<COND (<==? .STR ,F-WEP> <PRINTD .W>)
(<==? .STR ,F-DEF> <PRINTD .D>)
(ELSE <PRINT .STR>)>>
<CRLF>>
"Strength of the player is a basic value (S) adjusted by his P?STRENGTH
property, which is normally 0"
<ROUTINE FIGHT-STRENGTH ("OPTIONAL" (ADJUST? T) "AUX" S)
#DECL ((HERO) ADV (S SMAX SMIN VALUE) FIX (ADJUST?) <OR ATOM FALSE>)
<SET S
<+ ,STRENGTH-MIN
</ ,SCORE
</ ,SCORE-MAX
<- ,STRENGTH-MAX ,STRENGTH-MIN>>>>>
<COND (.ADJUST? <+ .S <GETP ,WINNER ,P?STRENGTH>>)(ELSE .S)>>
<ROUTINE VILLAIN-STRENGTH (OO
"AUX" (VILLAIN <GET .OO ,V-VILLAIN>)
OD TMP)
#DECL ((VILLAIN) OBJECT (WV) <OR FALSE VECTOR>
(OD VALUE) FIX)
<SET OD <GETP .VILLAIN ,P?STRENGTH>>
<COND (<NOT <L? .OD 0>>
<COND (<AND <==? .VILLAIN ,THIEF> ,THIEF-ENGROSSED>
<COND (<G? .OD 2> <SET OD 2>)>
<SETG THIEF-ENGROSSED <>>)>
<COND (<AND ,PRSI
<FSET? ,PRSI ,WEAPONBIT>
<==? <GET .OO ,V-BEST> ,PRSI>>
<SET TMP <- .OD <GET .OO ,V-BEST-ADV>>>
<COND (<L? .TMP 1> <SET TMP 1>)>
<SET OD .TMP>)>)>
.OD>
"find a weapon (if any) in possession of argument"
<ROUTINE FIND-WEAPON (O "AUX" W)
<SET W <FIRST? .O>>
<COND (<NOT .W>
<RFALSE>)>
<REPEAT ()
<COND (<FSET? .W ,WEAPONBIT> <RETURN .W>)
(<NOT <SET W <NEXT? .W>>> <RETURN <>>)>>>
\
<ROUTINE VILLAIN-BLOW (OO
"AUX" (VILLAIN <GET .OO ,V-VILLAIN>)
(REMARKS <GET .OO ,V-MSGS>)
DWEAPON ATT DEF OA OD TBL RES)
<FCLEAR ,WINNER ,STAGGERED>
<COND (<FSET? .VILLAIN ,STAGGERED>
<TELL "The " D .VILLAIN
" slowly regains his feet." CR>
<FCLEAR .VILLAIN ,STAGGERED>
<RTRUE>)>
<SET OA <SET ATT <VILLAIN-STRENGTH .OO>>>
<COND (<NOT <G? <SET DEF <FIGHT-STRENGTH>> 0>> <RTRUE>)>
<SET OD <FIGHT-STRENGTH <>>>
<SET DWEAPON <FIND-WEAPON ,WINNER>>
<COND (<L? .DEF 0> <SET RES ,KILLED>)
(ELSE
<COND (<1? .DEF>
<COND (<G? .ATT 2> <SET ATT 3>)>
<SET TBL <GET ,DEF1-RES <- .ATT 1>>>)
(<==? .DEF 2>
<COND (<G? .ATT 3> <SET ATT 4>)>
<SET TBL <GET ,DEF2-RES <- .ATT 1>>>)
(<G? .DEF 2>
<SET ATT <- .ATT .DEF>>
<COND (<L? .ATT -1> <SET ATT -2>)
(<G? .ATT 1> <SET ATT 2>)>
<SET TBL <GET ,DEF3-RES <+ .ATT 2>>>)>
<SET RES <GET .TBL <- <RANDOM 9> 1>>>
<REMARK
<PICK-ONE <GET .REMARKS <- .RES 1>>>
,WINNER
.DWEAPON>)>
<COND (<==? .RES ,MISSED>)
(<==? .RES ,KILLED> <SET DEF 0>)
(<==? .RES ,LIGHT-WOUND>
<SET DEF <- .DEF 1>>
<COND (<L? .DEF 0> <SET DEF 0>)>
<COND (<G? ,LOAD-ALLOWED 50>
<SETG LOAD-ALLOWED <- ,LOAD-ALLOWED 10>>)>)
(<==? .RES ,SERIOUS-WOUND>
<SET DEF <- .DEF 2>>
<COND (<L? .DEF 0> <SET DEF 0>)>
<COND (<G? ,LOAD-ALLOWED 50>
<SETG LOAD-ALLOWED <- ,LOAD-ALLOWED 20>>)>)
(<==? .RES ,STAGGER> <FSET ,WINNER ,STAGGERED>)>
<WINNER-RESULT .DEF .RES .OD>>
<ROUTINE HERO-BLOW ("AUX" OO VILLAIN DWEAPON ATT DEF (CNT 0)
OA OD TBL RES (LEN <GET ,VILLAINS 0>))
#DECL ((VILLAIN) OBJECT
(RES OA OD ATT DEF FIX) FIX (HERO?) <OR ATOM FALSE>)
<REPEAT ()
<SET CNT <+ .CNT 1>>
<COND (<G? .CNT .LEN> <RETURN>)>
<SET OO <GET ,VILLAINS .CNT>>
<COND (<==? <GET .OO ,V-VILLAIN> ,PRSO>
<RETURN>)>>
<FSET ,PRSO ,FIGHTBIT>
<COND (<FSET? ,WINNER ,STAGGERED>
<TELL
"You are still recovering from that last blow, so your attack is
ineffective." CR>
<FCLEAR ,WINNER ,STAGGERED>
<RTRUE>)>
<SET ATT <FIGHT-STRENGTH>>
<COND (<L? .ATT 1> <SET ATT 1>)>
<SET OA .ATT>
<SET VILLAIN <GET .OO ,V-VILLAIN>>
<COND (<0? <SET OD <SET DEF <VILLAIN-STRENGTH .OO>>>>
<COND (<==? ,PRSO ,WINNER>
<RETURN <JIGS-UP
"Well, you really did it that time. Is suicide painless?">>)>
<TELL "Attacking the " D .VILLAIN " is pointless." CR>
<RTRUE>)>
<SET DWEAPON <FIND-WEAPON .VILLAIN>>
<COND (<1? .DEF>
<COND (<G? .ATT 2> <SET ATT 3>)>
<SET TBL <GET ,DEF1-RES <- .ATT 1>>>)
(<==? .DEF 2>
<COND (<G? .ATT 3> <SET ATT 4>)>
<SET TBL <GET ,DEF2-RES <- .ATT 1>>>)
(<G? .DEF 2>
<SET ATT <- .ATT .DEF>>
<COND (<L? .ATT -1> <SET ATT -2>)
(<G? .ATT 1> <SET ATT 2>)>
<SET TBL <GET ,DEF3-RES <+ .ATT 2>>>)>
<SET RES <GET .TBL <- <RANDOM 9> 1>>>
<COND (<==? .RES 2> <SET RES 1>)>
<REMARK
<PICK-ONE <GET ,HERO-MELEE <- .RES 1>>>
,PRSO
,PRSI>
<COND (<EQUAL? .RES ,MISSED>)
(<EQUAL? .RES ,KILLED> <SET DEF 0>)
(<==? .RES ,LIGHT-WOUND>
<SET DEF <- .DEF 1>>
<COND (<L? .DEF 0> <SET DEF 0>)>)
(<==? .RES ,SERIOUS-WOUND>
<SET DEF <- .DEF 2>>
<COND (<L? .DEF 0> <SET DEF 0>)>)
(<==? .RES ,STAGGER> <FSET ,PRSO ,STAGGERED>)>
<VILLAIN-RESULT ,PRSO .DEF .RES>>
\
<ROUTINE WINNER-RESULT (DEF RES OD)
<PUTP ,WINNER
,P?STRENGTH
<COND (<0? .DEF> -10000)(ELSE <- .DEF .OD>)>>
<COND (<L? <- .DEF .OD> 0>
<ENABLE <QUEUE I-CURE ,CURE-WAIT>>)>
<COND (<NOT <G? <FIGHT-STRENGTH> 0>>
<PUTP ,WINNER ,P?STRENGTH <+ 1 <- <FIGHT-STRENGTH <>>>>>
<JIGS-UP
"It appears that that last blow was too much for you. I'm afraid you
are dead.">
<>)
(ELSE .RES)>>
<ROUTINE VILLAIN-RESULT (VILLAIN DEF RES)
<PUTP .VILLAIN ,P?STRENGTH .DEF>
<COND (<0? .DEF>
<FCLEAR .VILLAIN ,FIGHTBIT>
<TELL
"Almost as soon as the " D .VILLAIN " breathes his last breath, a cloud
of sinister black fog envelops him, and when the fog lifts, his carcass
and weapon have disappeared." CR>
<REMOVE .VILLAIN>
<APPLY <GETP .VILLAIN ,P?ACTION> ,F-DEAD>
.RES)
(ELSE .RES)>>
\
<ROUTINE WINNING? (V "AUX" VS PS)
#DECL ((V) OBJECT (VS PS) FIX)
<SET VS <GETP .V ,P?STRENGTH>>
<SET PS <- .VS <FIGHT-STRENGTH>>>
<COND (<G? .PS 3> <PROB 90>)
(<G? .PS 0> <PROB 75>)
(<0? .PS> <PROB 50>)
(<G? .VS 1> <PROB 25>)
(ELSE <PROB 10>)>>
<ROUTINE I-CURE ("AUX" (S <GETP ,WINNER ,P?STRENGTH>))
#DECL ((S) FIX)
<COND (<G? .S 0> <SET S 0> <PUTP ,WINNER ,P?STRENGTH .S>)
(<L? .S 0> <SET S <+ .S 1>> <PUTP ,WINNER ,P?STRENGTH .S>)>
<COND (<L? .S 0>
<COND (<L? ,LOAD-ALLOWED ,LOAD-MAX>
<SETG LOAD-ALLOWED <+ ,LOAD-ALLOWED 10>>)>
<ENABLE <QUEUE I-CURE ,CURE-WAIT>>)
(ELSE
<SETG LOAD-ALLOWED ,LOAD-MAX>
<DISABLE <INT I-CURE>>)>>
<ROUTINE V-DIAGNOSE ("AUX" (MS <FIGHT-STRENGTH <>>)
(WD <GETP ,WINNER ,P?STRENGTH>) (RS <+ .MS .WD>))
#DECL ((MS WD RS) FIX)
<COND (<0? <GET <INT I-CURE> ,C-ENABLED?>> <SET WD 0>)
(ELSE <SET WD <- .WD>>)>
<COND (<0? .WD> <TELL "You are in perfect health.">)
(T
<TELL "You have wounds which will be cured in ">
<PRINTN
<+ <* ,CURE-WAIT <- .WD 1>>
<GET <INT I-CURE> ,C-TICK>>>
<TELL " moves.">)>
<CRLF>
<COND (<0? .RS> <TELL "You are at death's door.">)
(<1? .RS> <TELL "You can be killed by one more wound.">)
(<==? .RS 2> <TELL "You can be killed by a serious wound.">)
(<==? .RS 3> <TELL "You can survive one serious wound.">)
(<G? .RS 3> <TELL "You are still strong.">)>
<CRLF>>