2 * File with various monster functions in it
4 * @(#)monsters.c 3.18 (Berkeley) 6/15/81
6 * Rogue: Exploring the Cavern of Cuties
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_stats
.s_ont
= rnd(1 << NUM_FEATURES
);
75 tp
->t_flags
= mp
->m_flags
;
78 if (ISWEARING(R_AGGR
))
84 if (tp
->t_pack
!= NULL
)
85 mch
= ((struct object
*) ldata(tp
->t_pack
))->o_type
;
87 switch (rnd(level
> 25 ? 9 : 8))
105 * A wandering monster has awakened and is headed for the player
111 register struct room
*rp
, *hr
= roomin(&hero
);
112 register struct linked_list
*item
;
113 register struct thing
*tp
;
116 item
= new_item(sizeof *tp
);
120 if ((rp
= &rooms
[i
]) == hr
)
123 if ((ch
= mvwinch(stdscr
, cp
.y
, cp
.x
)) == ERR
)
125 debug("Routine wanderer: mvwinch failed to %d,%d", cp
.y
, cp
.x
);
130 } until(hr
!= rp
&& step_ok(ch
));
131 new_monster(item
, randmonster(TRUE
), &cp
);
132 tp
= (struct thing
*) ldata(item
);
133 tp
->t_flags
|= ISRUN
;
137 msg("Started a wandering %s", monsters
[tp
->t_type
-'A'].m_name
);
141 * what to do when the hero steps next to a monster
147 register struct thing
*tp
;
148 register struct linked_list
*it
;
149 register struct room
*rp
;
152 if ((it
= find_mons(y
, x
)) == NULL
)
153 fatal("Can't find monster in wake");
154 tp
= (struct thing
*) ldata(it
);
157 * Every time he sees mean monster, it might start chasing him
159 if (rnd(100) > 33 && on(*tp
, ISMEAN
) && off(*tp
, ISHELD
)
160 && !ISWEARING(R_STEALTH
))
163 tp
->t_flags
|= ISRUN
;
165 if (ch
== 'U' && off(player
, ISBLIND
))
168 if ((rp
!= NULL
&& !(rp
->r_flags
&ISDARK
))
169 || DISTANCE(y
, x
, hero
.y
, hero
.x
) < 3)
171 if (off(*tp
, ISFOUND
) && !save(VS_MAGIC
))
173 msg("The umber hulk's gaze has confused you.");
174 if (on(player
, ISHUH
))
175 lengthen(unconfuse
, rnd(20)+HUHDURATION
);
177 fuse(unconfuse
, 0, rnd(20)+HUHDURATION
, AFTER
);
178 player
.t_flags
|= ISHUH
;
180 tp
->t_flags
|= ISFOUND
;
184 * Hide invisible monsters
186 if (on(*tp
, ISINVIS
) && off(player
, CANSEE
))
187 ch
= mvwinch(stdscr
, y
, x
);
189 * Let greedy ones guard gold
191 if (on(*tp
, ISGREED
) && off(*tp
, ISRUN
))
195 if (rp
!= NULL
&& rp
->r_goldval
)
197 tp
->t_dest
= &rp
->r_gold
;
198 tp
->t_flags
|= ISRUN
;
207 register struct linked_list
*ip
;
208 register struct thing
*mp
;
211 register struct linked_list
*nip
;
213 addmsg("Which monster");
215 addmsg(" do you wish to wipe out");
217 while (!isalpha(c
= readchar(cw
)))
223 msg("Please specify a letter between 'A' and 'Z'");
227 for (ip
= mlist
; ip
; ip
= nip
)
229 mp
= (struct thing
*) ldata(ip
);
232 remove_monster(&mp
->t_pos
, ip
);
234 for (i
= 0; i
< 26; i
++)
235 if (lvl_mons
[i
] == c
)