2 * all sorts of miscellaneous routines
4 * @(#)misc.c 3.13 (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 * print the name of a trap
31 s
= terse
? "A trapdoor." : "You found a trapdoor.";
33 s
= terse
? "A beartrap." : "You found a beartrap.";
35 s
= terse
? "A sleeping gas trap.":"You found a sleeping gas trap.";
37 s
= terse
? "An arrow trap." : "You found an arrow trap.";
39 s
= terse
? "A teleport trap." : "You found a teleport trap.";
41 s
= terse
? "A dart trap." : "You found a poison dart trap.";
48 * A quick glance all around the player
56 register int oldx
, oldy
;
58 register int passcount
= 0;
59 register struct room
*rp
;
62 getyx(cw
, oldy
, oldx
);
63 if (oldrp
!= NULL
&& (oldrp
->r_flags
& ISDARK
) && off(player
, ISBLIND
))
65 for (x
= oldpos
.x
- 1; x
<= oldpos
.x
+ 1; x
++)
66 for (y
= oldpos
.y
- 1; y
<= oldpos
.y
+ 1; y
++)
67 if ((y
!= hero
.y
|| x
!= hero
.x
) && show(y
, x
) == FLOOR
)
68 mvwaddch(cw
, y
, x
, ' ');
70 inpass
= ((rp
= roomin(&hero
)) == NULL
);
73 for (x
= hero
.x
- 1; x
<= ex
; x
++)
74 if (x
>= 0 && x
< COLS
) for (y
= hero
.y
- 1; y
<= ey
; y
++)
76 if (y
<= 0 || y
>= LINES
- 1)
78 if (isupper(mvwinch(mw
, y
, x
)))
80 register struct linked_list
*it
;
81 register struct thing
*tp
;
84 it
= wake_monster(y
, x
);
87 tp
= (struct thing
*) ldata(it
);
88 if ((tp
->t_oldch
= mvinch(y
, x
)) == TRAP
)
90 (trap_at(y
,x
)->tr_flags
&ISFOUND
) ? TRAP
: FLOOR
;
91 if (tp
->t_oldch
== FLOOR
&& (rp
->r_flags
& ISDARK
)
92 && off(player
, ISBLIND
))
96 * Secret doors show as walls
98 if ((ch
= show(y
, x
)) == SECRETDOOR
)
99 ch
= secretdoor(y
, x
);
101 * Don't show room walls if he is in a passage
103 if (off(player
, ISBLIND
))
105 if (y
== hero
.y
&& x
== hero
.x
106 || (inpass
&& (ch
== '-' || ch
== '|')))
109 else if (y
!= hero
.y
|| x
!= hero
.x
)
113 if (door_stop
&& !firstmove
&& running
)
130 if ((x
+ y
) - (hero
.x
+ hero
.y
) >= 1)
133 if ((y
- x
) - (hero
.y
- hero
.x
) >= 1)
136 if ((x
+ y
) - (hero
.x
+ hero
.y
) <= -1)
139 if ((y
- x
) - (hero
.y
- hero
.x
) <= -1)
145 if (x
== hero
.x
|| y
== hero
.y
)
149 if (x
== hero
.x
|| y
== hero
.y
)
163 if (door_stop
&& !firstmove
&& passcount
> 1)
165 mvwaddch(cw
, hero
.y
, hero
.x
, PLAYER
);
166 wmove(cw
, oldy
, oldx
);
173 * Figure out what a secret door looks like.
180 register struct room
*rp
;
187 for (rp
= rooms
, i
= 0; i
< MAXROOMS
; rp
++, i
++)
189 if (y
== rp
->r_pos
.y
|| y
== rp
->r_pos
.y
+ rp
->r_max
.y
- 1)
199 * find the unclaimed object at y, x
207 register struct linked_list
*obj
;
208 register struct object
*op
;
210 for (obj
= lvl_obj
; obj
!= NULL
; obj
= next(obj
))
212 op
= (struct object
*) ldata(obj
);
213 if (op
->o_pos
.y
== y
&& op
->o_pos
.x
== x
)
216 sprintf(prbuf
, "Non-object %d,%d", y
, x
);
223 * She wants to eat something, so let her try
228 register struct linked_list
*item
;
229 register struct object
*obj
;
231 if ((item
= get_item("eat", FOOD
)) == NULL
)
233 obj
= (struct object
*) ldata(item
);
234 if (obj
->o_type
!= FOOD
)
237 msg("Ugh, you would get ill if you ate that.");
239 msg("That's Inedible!");
243 if (obj
->o_which
== 1)
244 msg("My, that was a yummy %s", fruit
);
248 msg("Yuk, this food tastes awful");
253 msg("Yum, that tasted good");
254 if ((food_left
+= HUNGERTIME
+ rnd(400) - 200) > STOMACHSIZE
)
255 food_left
= STOMACHSIZE
;
257 if (obj
== cur_weapon
)
259 if (--obj
->o_count
< 1)
267 * Used to modify the playes strength
268 * it keeps track of the highest it has been, just in case
280 if (pstats
.s_str
.st_str
< 18)
281 pstats
.s_str
.st_str
++;
282 else if (pstats
.s_str
.st_add
== 0)
283 pstats
.s_str
.st_add
= rnd(50) + 1;
284 else if (pstats
.s_str
.st_add
<= 50)
285 pstats
.s_str
.st_add
= 51 + rnd(24);
286 else if (pstats
.s_str
.st_add
<= 75)
287 pstats
.s_str
.st_add
= 76 + rnd(14);
288 else if (pstats
.s_str
.st_add
<= 90)
289 pstats
.s_str
.st_add
= 91;
290 else if (pstats
.s_str
.st_add
< 100)
291 pstats
.s_str
.st_add
++;
293 if (pstats
.s_str
.st_str
> max_stats
.s_str
.st_str
||
294 (pstats
.s_str
.st_str
== 18 &&
295 pstats
.s_str
.st_add
> max_stats
.s_str
.st_add
))
296 max_stats
.s_str
= pstats
.s_str
;
302 if (pstats
.s_str
.st_str
< 18 || pstats
.s_str
.st_add
== 0)
303 pstats
.s_str
.st_str
--;
304 else if (pstats
.s_str
.st_add
< 51)
305 pstats
.s_str
.st_add
= 0;
306 else if (pstats
.s_str
.st_add
< 76)
307 pstats
.s_str
.st_add
= 1 + rnd(50);
308 else if (pstats
.s_str
.st_add
< 91)
309 pstats
.s_str
.st_add
= 51 + rnd(25);
310 else if (pstats
.s_str
.st_add
< 100)
311 pstats
.s_str
.st_add
= 76 + rnd(14);
313 pstats
.s_str
.st_add
= 91 + rnd(8);
315 if (pstats
.s_str
.st_str
< 3)
316 pstats
.s_str
.st_str
= 3;
322 * add a haste to the player
328 if (on(player
, ISHASTE
))
330 msg("You faint from exhaustion.");
331 no_command
+= rnd(8);
336 player
.t_flags
|= ISHASTE
;
338 fuse(nohaste
, 0, rnd(4)+4, AFTER
);
344 * aggravate all the monsters on this level
349 register struct linked_list
*mi
;
351 for (mi
= mlist
; mi
!= NULL
; mi
= next(mi
))
352 runto(&((struct thing
*) ldata(mi
))->t_pos
, &hero
);
356 * for printfs: if string starts with a vowel, return "n" for an "an"
376 * see if the object is one of the currently used items
379 register struct object
*obj
;
383 if (obj
== cur_armor
|| obj
== cur_weapon
|| obj
== cur_ring
[LEFT
]
384 || obj
== cur_ring
[RIGHT
])
386 msg(terse
? "In use." : "That's already in use.");
393 * set up the direction co_ordinate for use in varios "prefix" commands
397 register char *prompt
;
401 msg(prompt
= "Which direction? ");
403 prompt
= "Direction: ";
407 switch (readchar(cw
))
409 case 'h': case'H': delta
.y
= 0; delta
.x
= -1;
410 when
'j': case'J': delta
.y
= 1; delta
.x
= 0;
411 when
'k': case'K': delta
.y
= -1; delta
.x
= 0;
412 when
'l': case'L': delta
.y
= 0; delta
.x
= 1;
413 when
'y': case'Y': delta
.y
= -1; delta
.x
= -1;
414 when
'u': case'U': delta
.y
= -1; delta
.x
= 1;
415 when
'b': case'B': delta
.y
= 1; delta
.x
= -1;
416 when
'n': case'N': delta
.y
= 1; delta
.x
= 1;
417 when ESCAPE
: return FALSE
;
424 if (on(player
, ISHUH
) && rnd(100) > 80)
427 delta
.y
= rnd(3) - 1;
428 delta
.x
= rnd(3) - 1;
429 } while (delta
.y
== 0 && delta
.x
== 0);