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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
|
/* $OpenBSD: moreobj.c,v 1.4 2002/02/16 21:27:10 millert Exp $ */
/* $NetBSD: moreobj.c,v 1.4 1997/10/18 20:03:32 christos Exp $ */
/*
* moreobj.c Larn is copyrighted 1986 by Noah Morgan.
*
* Routines in this file:
*
* oaltar() othrone() ochest() ofountain()
*/
#ifndef lint
static char rcsid[] = "$OpenBSD: moreobj.c,v 1.4 2002/02/16 21:27:10 millert Exp $";
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "header.h"
#include "extern.h"
static void ohear(int);
static void fch(int, long *);
/*
* ******
* OALTAR
* ******
*
* subroutine to process an altar object
*/
void
oaltar()
{
unsigned long k;
lprcat("\nDo you (p) pray (d) desecrate");
iopts();
while (1) {
while (1)
switch (lgetchar()) {
case 'p':
lprcat(" pray\nDo you (m) give money or (j) just pray? ");
while (1)
switch (lgetchar()) {
case 'j':
if (rnd(100) < 75)
lprcat("\nnothing happens");
else if (rnd(13) < 4)
ohear(1);
else if (rnd(43) == 10) {
if (c[WEAR])
lprcat("\nYou feel your armor vibrate for a moment");
enchantarmor();
return;
} else if (rnd(43) == 10) {
if (c[WIELD])
lprcat("\nYou feel your weapon vibrate for a moment");
enchweapon();
return;
} else
createmonster(makemonst(level + 1));
return;
case 'm':
lprcat("\n\n");
cursor(1, 24);
cltoeoln();
cursor(1, 23);
cltoeoln();
lprcat("how much do you donate? ");
k = readnum((long) c[GOLD]);
if (c[GOLD] < k) {
lprcat("You don't have that much!");
return;
}
c[GOLD] -= k;
if (k < c[GOLD] / 10 || k < rnd(50)) {
createmonster(makemonst(level + 1));
c[AGGRAVATE] += 200;
} else if (rnd(101) > 50) {
ohear(0);
return;
} else if (rnd(43) == 5) {
if (c[WEAR])
lprcat("You feel your armor vibrate for a moment");
enchantarmor();
return;
} else if (rnd(43) == 8) {
if (c[WIELD])
lprcat("You feel your weapon vibrate for a moment");
enchweapon();
return;
} else
lprcat("Thank You.");
bottomline();
return;
case '\33':
return;
};
case 'd':
lprcat(" desecrate");
if (rnd(100) < 60) {
createmonster(makemonst(level + 2) + 8);
c[AGGRAVATE] += 2500;
} else if (rnd(101) < 30) {
lprcat("\nThe altar crumbles into a pile of dust before your eyes");
forget(); /* remember to destroy
* the altar */
} else
lprcat("\nnothing happens");
return;
case 'i':
case '\33':
ignore();
if (rnd(100) < 30) {
createmonster(makemonst(level + 1));
c[AGGRAVATE] += rnd(450);
} else
lprcat("\nnothing happens");
return;
};
}
}
/*
* function to cast a +3 protection on the player
*/
static void
ohear(do_newline)
int do_newline;
{
if (do_newline)
lprcat("\nYou have been heard!");
else
lprcat("You have been heard!");
if (c[ALTPRO] == 0)
c[MOREDEFENSES] += 3;
c[ALTPRO] += 500; /* protection field */
bottomline();
}
/*
* *******
* OTHRONE
* *******
*
* subroutine to process a throne object
*/
void
othrone(arg)
int arg;
{
int i, k;
lprcat("\nDo you (p) pry off jewels, (s) sit down");
iopts();
while (1) {
while (1)
switch (lgetchar()) {
case 'p':
lprcat(" pry off");
k = rnd(101);
if (k < 25) {
for (i = 0; i < rnd(4); i++)
creategem(); /* gems pop off the
* throne */
item[playerx][playery] = ODEADTHRONE;
know[playerx][playery] = 0;
} else if (k < 40 && arg == 0) {
createmonster(GNOMEKING);
item[playerx][playery] = OTHRONE2;
know[playerx][playery] = 0;
} else
lprcat("\nnothing happens");
return;
case 's':
lprcat(" sit down");
k = rnd(101);
if (k < 30 && arg == 0) {
createmonster(GNOMEKING);
item[playerx][playery] = OTHRONE2;
know[playerx][playery] = 0;
} else if (k < 35) {
lprcat("\nZaaaappp! You've been teleported!\n");
lbeep();
oteleport(0);
} else
lprcat("\nnothing happens");
return;
case 'i':
case '\33':
ignore();
return;
};
}
}
void
odeadthrone()
{
int k;
lprcat("\nDo you (s) sit down");
iopts();
while (1) {
while (1)
switch (lgetchar()) {
case 's':
lprcat(" sit down");
k = rnd(101);
if (k < 35) {
lprcat("\nZaaaappp! You've been teleported!\n");
lbeep();
oteleport(0);
} else
lprcat("\nnothing happens");
return;
case 'i':
case '\33':
ignore();
return;
};
}
}
/*
* ******
* OCHEST
* ******
*
* subroutine to process a throne object
*/
void
ochest()
{
int i, k;
lprcat("\nDo you (t) take it, (o) try to open it");
iopts();
while (1) {
while (1)
switch (lgetchar()) {
case 'o':
lprcat(" open it");
k = rnd(101);
if (k < 40) {
lprcat("\nThe chest explodes as you open it");
lbeep();
i = rnd(10);
lastnum = 281; /* in case he dies */
lprintf("\nYou suffer %d hit points damage!", (long) i);
checkloss(i);
switch (rnd(10)) { /* see if he gets a
* curse */
case 1:
c[ITCHING] += rnd(1000) + 100;
lprcat("\nYou feel an irritation spread over your skin!");
lbeep();
break;
case 2:
c[CLUMSINESS] += rnd(1600) + 200;
lprcat("\nYou begin to lose hand to eye coordination!");
lbeep();
break;
case 3:
c[HALFDAM] += rnd(1600) + 200;
lbeep();
lprcat("\nA sickness engulfs you!");
break;
};
item[playerx][playery] = know[playerx][playery] = 0;
if (rnd(100) < 69)
creategem(); /* gems from the chest */
dropgold(rnd(110 * iarg[playerx][playery] + 200));
for (i = 0; i < rnd(4); i++)
something(iarg[playerx][playery] + 2);
} else
lprcat("\nnothing happens");
return;
case 't':
lprcat(" take");
if (take(OCHEST, iarg[playerx][playery]) == 0)
item[playerx][playery] = know[playerx][playery] = 0;
return;
case 'i':
case '\33':
ignore();
return;
};
}
}
/*
* *********
* OFOUNTAIN
* *********
*/
void
ofountain()
{
int x;
cursors();
lprcat("\nDo you (d) drink, (w) wash yourself");
iopts();
while (1)
switch (lgetchar()) {
case 'd':
lprcat("drink");
if (rnd(1501) < 2) {
lprcat("\nOops! You seem to have caught the dreadful sleep!");
lbeep();
lflush();
sleep(3);
died(280);
return;
}
x = rnd(100);
if (x < 7) {
c[HALFDAM] += 200 + rnd(200);
lprcat("\nYou feel a sickness coming on");
} else if (x < 13)
quaffpotion(23); /* see invisible */
else if (x < 45)
lprcat("\nnothing seems to have happened");
else if (rnd(3) != 2)
fntchange(1); /* change char levels upward */
else
fntchange(-1); /* change char levels
* downward */
if (rnd(12) < 3) {
lprcat("\nThe fountains bubbling slowly quiets");
item[playerx][playery] = ODEADFOUNTAIN; /* dead fountain */
know[playerx][playery] = 0;
}
return;
case '\33':
case 'i':
ignore();
return;
case 'w':
lprcat("wash yourself");
if (rnd(100) < 11) {
x = rnd((level << 2) + 2);
lprintf("\nOh no! The water was foul! You suffer %d hit points!", (long) x);
lastnum = 273;
losehp(x);
bottomline();
cursors();
} else if (rnd(100) < 29)
lprcat("\nYou got the dirt off!");
else if (rnd(100) < 31)
lprcat("\nThis water seems to be hard water! The dirt didn't come off!");
else if (rnd(100) < 34)
createmonster(WATERLORD); /* make water lord */
else
lprcat("\nnothing seems to have happened");
return;
}
}
/*
* ***
* FCH
* ***
*
* subroutine to process an up/down of a character attribute for ofountain
*/
static void
fch(how, x)
int how;
long *x;
{
if (how < 0) {
lprcat(" went down by one!");
--(*x);
} else {
lprcat(" went up by one!");
(*x)++;
}
bottomline();
}
/*
* a subroutine to raise or lower character levels
* if x > 0 they are raised if x < 0 they are lowered
*/
void
fntchange(how)
int how;
{
long j;
lprc('\n');
switch (rnd(9)) {
case 1:
lprcat("Your strength");
fch(how, &c[0]);
break;
case 2:
lprcat("Your intelligence");
fch(how, &c[1]);
break;
case 3:
lprcat("Your wisdom");
fch(how, &c[2]);
break;
case 4:
lprcat("Your constitution");
fch(how, &c[3]);
break;
case 5:
lprcat("Your dexterity");
fch(how, &c[4]);
break;
case 6:
lprcat("Your charm");
fch(how, &c[5]);
break;
case 7:
j = rnd(level + 1);
if (how < 0) {
lprintf("You lose %d hit point", (long) j);
if (j > 1)
lprcat("s!");
else
lprc('!');
losemhp((int) j);
} else {
lprintf("You gain %d hit point", (long) j);
if (j > 1)
lprcat("s!");
else
lprc('!');
raisemhp((int) j);
}
bottomline();
break;
case 8:
j = rnd(level + 1);
if (how > 0) {
lprintf("You just gained %d spell", (long) j);
raisemspells((int) j);
if (j > 1)
lprcat("s!");
else
lprc('!');
} else {
lprintf("You just lost %d spell", (long) j);
losemspells((int) j);
if (j > 1)
lprcat("s!");
else
lprc('!');
}
bottomline();
break;
case 9:
j = 5 * rnd((level + 1) * (level + 1));
if (how < 0) {
lprintf("You just lost %d experience point", (long) j);
if (j > 1)
lprcat("s!");
else
lprc('!');
loseexperience((long) j);
} else {
lprintf("You just gained %d experience point", (long) j);
if (j > 1)
lprcat("s!");
else
lprc('!');
raiseexperience((long) j);
}
break;
}
cursors();
}
|