-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSLIME.C
94 lines (85 loc) · 1.85 KB
/
SLIME.C
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
/*
* Code for handling the various special properties of the slime
*
* slime.c 1.0 (A.I. Design 1.42) 1/17/85
*/
#include "rogue.h"
#include "curses.h"
/*
* Slime_split:
* Called when it has been decided that A slime should divide itself
*/
static coord slimy;
slime_split(tp)
THING *tp;
{
register THING *nslime;
if (new_slime(tp) == 0 || (nslime = new_item()) == NULL)
return;
msg("The slime divides. Ick!");
new_monster(nslime, 'S', &slimy);
if (cansee(slimy.y, slimy.x)) {
nslime->t_oldch = chat(slimy.y, slimy.x);
mvaddch(slimy.y, slimy.x, 'S');
}
start_run(&slimy);
}
new_slime(tp)
THING *tp;
{
register int y, x, ty, tx, ret;
THING *ntp;
coord sp;
ret = 0;
tp->t_flags |= ISFLY;
if (plop_monster((ty = tp->t_pos.y), (tx = tp->t_pos.x), &sp) == 0) {
/*
* There were no open spaces next to this slime, look for other
* slimes that might have open spaces next to them.
*/
for (y = ty -1; y <= ty+1; y++)
for (x = tx-1; x <= tx+1; x++)
if (winat(y, x) == 'S' && (ntp = moat(y, x))) {
if (ntp->t_flags & ISFLY)
continue; /* Already done this one */
if (new_slime(ntp)) {
y = ty+2;
x = tx +2;
}
}
} else {
ret = 1;
slimy = sp;
}
tp->t_flags &= ~ISFLY;
return ret;
}
plop_monster(r, c, cp)
int r, c;
coord *cp;
{
register int y, x;
bool appear = 0;
byte ch;
for (y = r-1; y <= r+1; y++)
for (x = c-1; x <= c+1; x++) {
/*
* Don't put a monster in top of the player.
*/
if ((y == hero.y && x == hero.x) || offmap(y,x))
continue;
/*
* Or anything else nasty
*/
if (step_ok(ch = winat(y, x))) {
if (ch == SCROLL && find_obj(y, x)->o_which == S_SCARE)
continue;
if (rnd(++appear) == 0) {
cp->y = y;
cp->x = x;
}
}
}
return appear;
}