2 * File with various monster functions in it
4 * @(#)monsters.c 3.18 (Berkeley) 6/15/81
6 * Rogue: Exploring the Dungeons of Doom
7 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
10 * See the file LICENSE.TXT for full copyright and licensing information.
19 * List of monsters in rough order of vorpalness
21 char lvl_mons
[27] = "KJBSHEAOZGLCRQNYTWFIXUMVDP";
22 char wand_mons
[27] = "KJBSH AOZG CRQ Y W IXU V ";
26 * Pick a monster to show up. The lower the level,
27 * the meaner the monster.
36 mons
= wander
? wand_mons
: lvl_mons
;
39 d
= level
+ (rnd(10) - 5);
44 } while (mons
[--d
] == ' ');
50 * Pick a new monster and add it to the list
53 new_monster(item
, type
, cp
)
54 struct linked_list
*item
;
58 register struct thing
*tp
;
59 register struct monster
*mp
;
62 tp
= (struct thing
*) ldata(item
);
65 tp
->t_oldch
= mvwinch(cw
, cp
->y
, cp
->x
);
66 mvwaddch(mw
, cp
->y
, cp
->x
, tp
->t_type
);
67 mp
= &monsters
[tp
->t_type
-'A'];
68 tp
->t_stats
.s_hpt
= roll(mp
->m_stats
.s_lvl
, 8);
69 tp
->t_stats
.s_lvl
= mp
->m_stats
.s_lvl
;
70 tp
->t_stats
.s_arm
= mp
->m_stats
.s_arm
;
71 strcpy(tp
->t_stats
.s_dmg
,mp
->m_stats
.s_dmg
);
72 tp
->t_stats
.s_exp
= mp
->m_stats
.s_exp
;
73 tp
->t_stats
.s_str
.st_str
= 10;
74 tp
->t_flags
= mp
->m_flags
;
77 if (ISWEARING(R_AGGR
))
83 if (tp
->t_pack
!= NULL
)
84 mch
= ((struct object
*) ldata(tp
->t_pack
))->o_type
;
86 switch (rnd(level
> 25 ? 9 : 8))
104 * A wandering monster has awakened and is headed for the player
110 register struct room
*rp
, *hr
= roomin(&hero
);
111 register struct linked_list
*item
;
112 register struct thing
*tp
;
115 item
= new_item(sizeof *tp
);
119 if ((rp
= &rooms
[i
]) == hr
)
122 if ((ch
= mvwinch(stdscr
, cp
.y
, cp
.x
)) == ERR
)
124 debug("Routine wanderer: mvwinch failed to %d,%d", cp
.y
, cp
.x
);
129 } until(hr
!= rp
&& step_ok(ch
));
130 new_monster(item
, randmonster(TRUE
), &cp
);
131 tp
= (struct thing
*) ldata(item
);
132 tp
->t_flags
|= ISRUN
;
136 msg("Started a wandering %s", monsters
[tp
->t_type
-'A'].m_name
);
140 * what to do when the hero steps next to a monster
146 register struct thing
*tp
;
147 register struct linked_list
*it
;
148 register struct room
*rp
;
151 if ((it
= find_mons(y
, x
)) == NULL
)
152 fatal("Can't find monster in wake");
153 tp
= (struct thing
*) ldata(it
);
156 * Every time he sees mean monster, it might start chasing him
158 if (rnd(100) > 33 && on(*tp
, ISMEAN
) && off(*tp
, ISHELD
)
159 && !ISWEARING(R_STEALTH
))
162 tp
->t_flags
|= ISRUN
;
164 if (ch
== 'U' && off(player
, ISBLIND
))
167 if ((rp
!= NULL
&& !(rp
->r_flags
&ISDARK
))
168 || DISTANCE(y
, x
, hero
.y
, hero
.x
) < 3)
170 if (off(*tp
, ISFOUND
) && !save(VS_MAGIC
))
172 msg("The umber hulk's gaze has confused you.");
173 if (on(player
, ISHUH
))
174 lengthen(unconfuse
, rnd(20)+HUHDURATION
);
176 fuse(unconfuse
, 0, rnd(20)+HUHDURATION
, AFTER
);
177 player
.t_flags
|= ISHUH
;
179 tp
->t_flags
|= ISFOUND
;
183 * Hide invisible monsters
185 if (on(*tp
, ISINVIS
) && off(player
, CANSEE
))
186 ch
= mvwinch(stdscr
, y
, x
);
188 * Let greedy ones guard gold
190 if (on(*tp
, ISGREED
) && off(*tp
, ISRUN
))
194 if (rp
!= NULL
&& rp
->r_goldval
)
196 tp
->t_dest
= &rp
->r_gold
;
197 tp
->t_flags
|= ISRUN
;
206 register struct linked_list
*ip
;
207 register struct thing
*mp
;
210 register struct linked_list
*nip
;
212 addmsg("Which monster");
214 addmsg(" do you wish to wipe out");
216 while (!isalpha(c
= readchar(cw
)))
222 msg("Please specify a letter between 'A' and 'Z'");
226 for (ip
= mlist
; ip
; ip
= nip
)
228 mp
= (struct thing
*) ldata(ip
);
231 remove_monster(&mp
->t_pos
, ip
);
233 for (i
= 0; i
< 26; i
++)
234 if (lvl_mons
[i
] == c
)