* Copyright (c) 1988 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)trap.c 5.3 (Berkeley) %G%";
* This source herein may be modified and/or distributed by anybody who
* so desires, with the following restrictions:
* 1.) No portion of this notice shall be removed.
* 2.) Credit shall not be taken for the creation of this source.
* 3.) This code is not to be traded, sold, or used for personal
char *trap_strings
[TRAPS
* 2] = {
"you are caught in a bear trap",
"a small dart just hit you in the shoulder",
"a strange white mist envelops you and you fall asleep",
"a gush of water hits you on the head"
extern short cur_level
, party_room
;
extern char *new_level_message
;
extern boolean interrupted
;
extern boolean sustain_strength
;
for (i
= 0; ((i
< MAX_TRAPS
) && (traps
[i
].trap_type
!= NO_TRAP
)); i
++) {
if ((traps
[i
].trap_row
== row
) && (traps
[i
].trap_col
== col
)) {
return(traps
[i
].trap_type
);
if ((t
= trap_at(row
, col
)) == NO_TRAP
) {
dungeon
[row
][col
] &= (~HIDDEN
);
if (rand_percent(rogue
.exp
+ ring_exp
)) {
message("the trap failed", 1);
new_level_message
= trap_strings
[(t
*2)+1];
message(trap_strings
[(t
*2)+1], 1);
bear_trap
= get_rand(4, 7);
mvaddch(rogue
.row
, rogue
.col
, '^');
message(trap_strings
[(t
*2)+1], 1);
rogue
.hp_current
-= get_damage("1d6", 1);
if (rogue
.hp_current
<= 0) {
if ((!sustain_strength
) && rand_percent(40) &&
(rogue
.str_current
>= 3)) {
print_stats(STAT_HP
| STAT_STRENGTH
);
if (rogue
.hp_current
<= 0) {
killed_by((object
*) 0, POISON_DART
);
message(trap_strings
[(t
*2)+1], 1);
message(trap_strings
[(t
*2)+1], 1);
} else if (cur_level
<= 7) {
} else if (cur_level
<= 11) {
} else if (cur_level
<= 16) {
} else if (cur_level
<= 21) {
} else if (cur_level
<= (AMULET_LEVEL
+ 2)) {
n
= get_rand(5, MAX_TRAPS
);
for (i
= 0; i
< n
; i
++) {
traps
[i
].trap_type
= get_rand(0, (TRAPS
- 1));
if ((i
== 0) && (party_room
!= NO_ROOM
)) {
row
= get_rand((rooms
[party_room
].top_row
+1),
(rooms
[party_room
].bottom_row
-1));
col
= get_rand((rooms
[party_room
].left_col
+1),
(rooms
[party_room
].right_col
-1));
} while (((dungeon
[row
][col
] & (OBJECT
|STAIRS
|TRAP
|TUNNEL
)) ||
(dungeon
[row
][col
] == NOTHING
)) && (tries
< 15));
gr_row_col(&row
, &col
, (FLOOR
| MONSTER
));
gr_row_col(&row
, &col
, (FLOOR
| MONSTER
));
dungeon
[row
][col
] |= (TRAP
| HIDDEN
);
short dir
, row
, col
, d
, t
;
message("direction? ", 0);
while (!is_direction(dir
= rgetchar(), &d
)) {
get_dir_rc(d
, &row
, &col
, 0);
if ((dungeon
[row
][col
] & TRAP
) && (!(dungeon
[row
][col
] & HIDDEN
))) {
message(trap_strings
[t
*2], 0);
message("no trap there", 0);
for (i
= 0; i
< DROWS
; i
++) {
for (j
= 0; j
< DCOLS
; j
++) {
if (dungeon
[i
][j
] & TRAP
) {
short s
, i
, j
, row
, col
, t
;
short shown
= 0, found
= 0;
static boolean reg_search
;
for (i
= -1; i
<= 1; i
++) {
for (j
= -1; j
<= 1; j
++) {
if ((row
< MIN_ROW
) || (row
>= (DROWS
-1)) ||
(col
< 0) || (col
>= DCOLS
)) {
if (dungeon
[row
][col
] & HIDDEN
) {
for (s
= 0; s
< n
; s
++) {
for (i
= -1; i
<= 1; i
++) {
for (j
= -1; j
<= 1; j
++) {
if ((row
< MIN_ROW
) || (row
>= (DROWS
-1)) ||
(col
< 0) || (col
>= DCOLS
)) {
if (dungeon
[row
][col
] & HIDDEN
) {
if (rand_percent(17 + (rogue
.exp
+ ring_exp
))) {
dungeon
[row
][col
] &= (~HIDDEN
);
if ((!blind
) && ((row
!= rogue
.row
) ||
mvaddch(row
, col
, get_dungeon_char(row
, col
));
if (dungeon
[row
][col
] & TRAP
) {
message(trap_strings
[t
*2], 1);
if (((shown
== found
) && (found
> 0)) || interrupted
) {
if ((!is_auto
) && (reg_search
= !reg_search
)) {