void id_trap(void) { short dir, row, col, d, t; messagef(0, "direction? "); while (!is_direction(dir = rgetchar(), &d)) { beep(); } check_message(); if (dir == CANCEL) { return; } row = rogue.row; col = rogue.col; get_dir_rc(d, &row, &col, 0); if ((dungeon[row][col] & TRAP) && (!(dungeon[row][col] & HIDDEN))) { t = trap_at(row, col); messagef(0, "%s", trap_strings[t*2]); } else { messagef(0, "no trap there"); } }
static Boolean teleok(Short x, Short y) { /* might throw him into a POOL */ return( !OUT_OF_BOUNDS(x,y) && !IS_ROCK(get_cell_type(floor_info[x][y])) && !mon_at(x,y) && !sobj_at(ENORMOUS_ROCK,x,y) && !trap_at(x,y) ); /* Note: gold is permitted (because of vaults) */ }
void search(short n, boolean is_auto) { 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++) { row = rogue.row + i; col = rogue.col + j; if ((row < MIN_ROW) || (row >= (ROGUE_LINES - 1)) || (col < 0) || (col >= ROGUE_COLUMNS)) { continue; } if (dungeon[row][col] & HIDDEN) { found++; } } } for (s = 0; s < n; s++) { for (i = -1; i <= 1; i++) { for (j = -1; j <= 1; j++) { row = rogue.row + i; col = rogue.col + j; if ((row < MIN_ROW) || (row >= (ROGUE_LINES - 1)) || (col < 0) || (col >= ROGUE_COLUMNS)) { continue; } if (dungeon[row][col] & HIDDEN) { if (rand_percent(17 + (rogue.exp + ring_exp))) { dungeon[row][col] &= (~HIDDEN); if ((!blind) && ((row != rogue.row) || (col != rogue.col))) { mvaddch_rogue(row, col, get_dungeon_char(row, col)); } shown++; if (dungeon[row][col] & TRAP) { t = trap_at(row, col); message(trap_strings[t * 2], 1); } } } if (((shown == found) && (found > 0)) || interrupted) { return; } } } if ((!is_auto) && (reg_search = !reg_search)) { (void) reg_move(); } } }
void trap_player(short row, short col) { short t; if ((t = trap_at(row, col)) == NO_TRAP) { return; } dungeon[row][col] &= (~HIDDEN); if (rand_percent(rogue.exp + ring_exp)) { message(mesg[228], 1); return; } switch (t) { case TRAP_DOOR: trap_door = 1; new_level_message = trap_strings[(t * 2) + 1]; break; case BEAR_TRAP: message(trap_strings[(t * 2) + 1], 1); bear_trap = get_rand(4, 7); break; case TELE_TRAP: mvaddch_rogue(rogue.row, rogue.col, '^'); tele(); break; case DART_TRAP: message(trap_strings[(t * 2) + 1], 1); rogue.hp_current -= get_damage("1d6", 1); if (rogue.hp_current <= 0) { rogue.hp_current = 0; } if ((!sustain_strength) && rand_percent(40) && (rogue.str_current >= 3)) { rogue.str_current--; } print_stats(STAT_HP | STAT_STRENGTH); if (rogue.hp_current <= 0) { killed_by((object *) 0, POISON_DART); } break; case SLEEPING_GAS_TRAP: message(trap_strings[(t * 2) + 1], 1); take_a_nap(); break; case RUST_TRAP: message(trap_strings[(t * 2) + 1], 1); rust((object *) 0); break; } }
Short findit() /* returns number of things found */ { Short num; UChar zx,zy; trap_t *ttmp; monst_t *mtmp; UChar lx,hx,ly,hy; if (you.uswallow) return false; for (lx = you.ux; (num = get_cell_type(floor_info[lx-1][you.uy])) && num != CORR; lx--) ; for (hx = you.ux; (num = get_cell_type(floor_info[hx+1][you.uy])) && num != CORR; hx++) ; for (ly = you.uy; (num = get_cell_type(floor_info[you.ux][ly-1])) && num != CORR; ly--) ; for (hy = you.uy; (num = get_cell_type(floor_info[you.ux][hy+1])) && num != CORR; hy++) ; num = 0; for (zy = ly; zy <= hy; zy++) { for (zx = lx; zx <= hx; zx++) { if (get_cell_type(floor_info[zx][zy]) == SDOOR) { set_cell_type(floor_info[zx][zy], DOOR); print(zx, zy, DOOR_SYM); num++; } else if (get_cell_type(floor_info[zx][zy]) == SCORR) { set_cell_type(floor_info[zx][zy], CORR); print(zx, zy, CORR_SYM); num++; } else if ((ttmp = trap_at(zx, zy))) { if (get_trap_type(ttmp->trap_info) == PIERC) { makemon(PM_PIERCER, zx, zy); num++; deltrap(ttmp); } else if (!get_trap_seen(ttmp->trap_info)) { ttmp->trap_info |= SEEN_TRAP; if (!vism_at(zx, zy)) print(zx,zy,'^'); num++; } } else if ((mtmp = mon_at(zx,zy)) && (mtmp->bitflags & M_IS_MIMIC)) { see_mimic(mtmp); num++; } } } return num; }
void float_down() { trap_t *trap; message("You float gently to the ground."); trap = trap_at(you.ux, you.uy); if (trap) switch(get_trap_type(trap->trap_info)) { case PIERC: break; case TRAPDOOR: if (!xdnstair || you.ustuck) break; /* fall into next case */ default: do_trap(trap); } pickup(true); }
Char loc_symbol(Short x, Short y) // Equivalent of "news0" { obj_t *otmp; trap_t *ttmp; UChar cell_type; Char c; Boolean blind = Blind; if (OUT_OF_BOUNDS(x,y)) return ' '; cell_type = get_cell_type(floor_info[x][y]); if (!get_cell_seen(floor_info[x][y])) c = ' '; else if (cell_type == POOL) c = POOL_SYM; else if (!blind && (otmp = obj_at(x,y))) c = otmp->olet; else if (!blind && gold_at(x,y)) c = GOLD_SYM; else if (x == xupstair && y == yupstair) c = UPSTAIR_SYM; else if (x == xdnstair && y == ydnstair) c = DOWNSTAIR_SYM; else if ((ttmp = trap_at(x,y)) && get_trap_seen(ttmp->trap_info)) c = TRAP_SYM; else switch(cell_type) { case HWALL: c = HWALL_SYM; break; case VWALL: c = VWALL_SYM; break; case CORR: c = CORR_SYM; break; case SCORR: case SDOOR: c = floor_symbol[x][y]; /* %% wrong after killing mimic ! */ break; case LDOOR: case DOOR: c = DOOR_SYM; break; case ROOM: // the 'blind' here seems strange to me: if (get_cell_lit(floor_info[x][y]) || cansee(x,y) || blind) c = ROOM_SYM; else c = ' '; break; default: c = ERRCHAR; } return c; }
void id_trap(void) { short dir, row, col; short t; dir = get_direction(); if (dir == CANCEL) { return; } row = rogue.row; col = rogue.col; get_dir_rc(dir, &row, &col, 0); if ((dungeon[row][col] & TRAP) && (!(dungeon[row][col] & HIDDEN))) { t = trap_at(row, col); message(trap_strings[t * 2], 0); } else { message(mesg[229], 0); } }
void look(int wakeup) { int x, y; char ch, och; int oldx, oldy; int inpass, horizontal, vertical, do_light = FALSE, do_blank = FALSE; int passcount = 0; struct room *rp; int ey, ex; /* Are we moving vertically or horizontally? */ if (runch == 'h' || runch == 'l') horizontal = TRUE; else horizontal = FALSE; if (runch == 'j' || runch == 'k') vertical = TRUE; else vertical = FALSE; getyx(cw, oldy, oldx); /* Save current position */ /* * Blank out the floor around our last position and check for moving * out of a corridor in a maze. */ if (oldrp != NULL && (oldrp->r_flags & ISDARK) && !(oldrp->r_flags & HASFIRE) && off(player, ISBLIND)) do_blank = TRUE; for (x = player.t_oldpos.x - 1; x <= player.t_oldpos.x + 1; x++) for (y = player.t_oldpos.y - 1; y <= player.t_oldpos.y + 1; y++) { ch = show(y, x); if (do_blank && (y != hero.y || x != hero.x) && ch == FLOOR) mvwaddch(cw, y, x, ' '); /* Moving out of a corridor? */ if (levtype == MAZELEV && (ch != '|' && ch != '-') && /* Not a wall */ ((vertical && x != player.t_oldpos.x && y == player.t_oldpos.y) || (horizontal && y != player.t_oldpos.y && x == player.t_oldpos.x))) do_light = TRUE; /* Just came to a turn */ } inpass = ((rp = roomin(hero)) == NULL); /* Are we in a passage? */ /* Are we coming out of a wall into a corridor in a maze? */ och = show(player.t_oldpos.y, player.t_oldpos.x); ch = show(hero.y, hero.x); if (levtype == MAZELEV && (och == '|' || och == '-' || och == SECRETDOOR) && (ch != '|' && ch != '-' && ch != SECRETDOOR)) { do_light = off(player, ISBLIND); /* Light it up if not blind */ } /* Look around the player */ ey = hero.y + 1; ex = hero.x + 1; for (x = hero.x - 1; x <= ex; x++) if (x >= 0 && x < COLS) for (y = hero.y - 1; y <= ey; y++) { if (y <= 0 || y >= LINES - 2) continue; if (isalpha(mvwinch(mw, y, x))) { struct linked_list *it; struct thing *tp; if (wakeup) it = wake_monster(y, x); else it = find_mons(y, x); if (it == NULL) continue; tp = THINGPTR(it); tp->t_oldch = CCHAR( mvinch(y, x) ); if (isatrap(tp->t_oldch)) { struct trap *trp = trap_at(y, x); tp->t_oldch = (trp->tr_flags & ISFOUND) ? tp->t_oldch : trp->tr_show; } if (tp->t_oldch == FLOOR && (rp->r_flags & ISDARK) && !(rp->r_flags & HASFIRE) && off(player, ISBLIND)) tp->t_oldch = ' '; } /* Secret doors show as walls */ if ((ch = show(y, x)) == SECRETDOOR) ch = secretdoor(y, x); /* * Don't show room walls if he is in a * passage and check for maze turns */ if (off(player, ISBLIND)) { if (y == hero.y && x == hero.x || (inpass && (ch == '-' || ch == '|'))) continue; /* Are we at a crossroads in a maze? */ if (levtype == MAZELEV && (ch != '|' && ch != '-') && /* Not a wall */ ((vertical && x != hero.x && y == hero.y) || (horizontal && y != hero.y && x == hero.x))) do_light = TRUE; /* Just came to a turn */ } else if (y != hero.y || x != hero.x) continue; wmove(cw, y, x); waddch(cw, ch); if (door_stop && !firstmove && running) { switch (runch) { case 'h': if (x == ex) continue; break; case 'j': if (y == hero.y - 1) continue; break; case 'k': if (y == ey) continue; break; case 'l': if (x == hero.x - 1) continue; break; case 'y': if ((x + y) - (hero.x + hero.y) >= 1) continue; break; case 'u': if ((y - x) - (hero.y - hero.x) >= 1) continue; break; case 'n': if ((x + y) - (hero.x + hero.y) <= -1) continue; break; case 'b': if ((y - x) - (hero.y - hero.x) <= -1) continue; break; } switch (ch) { case DOOR: if (x == hero.x || y == hero.y) running = FALSE; break; case PASSAGE: if (x == hero.x || y == hero.y) passcount++; break; case FLOOR: /* * Stop by new passages in a * maze (floor next to us) */ if ((levtype == MAZELEV) && ((horizontal && x == hero.x && y != hero.y) || (vertical && y == hero.y && x != hero.x))) running = FALSE; case '|': case '-': case ' ': break; default: running = FALSE; break; } } } if (door_stop && !firstmove && passcount > 1) running = FALSE; /* * Do we have to light up the area (just stepped into a new * corridor)? */ if (do_light && wakeup && /* wakeup will be true on a normal move */ !(rp->r_flags & ISDARK) && /* We have some light */ !ce(hero, player.t_oldpos)) /* Don't do anything if we didn't move */ light(&hero); mvwaddch(cw, hero.y, hero.x, PLAYER); wmove(cw, oldy, oldx); if (wakeup) { player.t_oldpos = hero; /* Don't change if we didn't move */ oldrp = rp; } }
Short mon_in_trap(monst_t *mtmp) // was mintrap { trap_t *trap = trap_at(mtmp->mx, mtmp->my); Boolean wasintrap = (mtmp->bitflags & M_IS_TRAPPED); if (!trap) { mtmp->bitflags &= ~M_IS_TRAPPED; /* perhaps teleported? */ } else if (wasintrap) { if (!rund(40)) mtmp->bitflags &= ~M_IS_TRAPPED; } else { Short tt = get_trap_type(trap->trap_info); Short in_sight = cansee(mtmp->mx, mtmp->my); if (mtmp->mtraps_seen & (1 << tt)) { /* he has been in such a trap - perhaps he escapes */ if (rund(4)) return 0; } mtmp->mtraps_seen |= (1 << tt); switch (tt) { case BEAR_TRAP: if (StrChr(mlarge, mtmp->data->mlet)) { if (in_sight) { StrPrintF(ScratchBuffer,"%s is caught in a bear trap!",Monnam(mtmp)); message(ScratchBuffer); } else if (mtmp->data->mlet == 'o') message("You hear the roaring of an angry bear!"); mtmp->bitflags |= M_IS_TRAPPED; } break; case PIT: /* there should be a mtmp/data -> floating */ if (!StrChr("EywBfk'& ", mtmp->data->mlet)) { /* ab */ mtmp->bitflags |= M_IS_TRAPPED; if (in_sight) { StrPrintF(ScratchBuffer, "%s falls in a pit!", Monnam(mtmp)); message(ScratchBuffer); } } break; case SLP_GAS_TRAP: if (!(mtmp->bitflags & (M_IS_ASLEEP | M_IS_FROZEN))) { mtmp->bitflags |= M_IS_ASLEEP; if (in_sight) { StrPrintF(ScratchBuffer, "%s suddenly falls asleep!", Monnam(mtmp)); message(ScratchBuffer); } } break; case TELEP_TRAP: rloc(mtmp); if (in_sight && !cansee(mtmp->mx,mtmp->my)) { StrPrintF(ScratchBuffer, "%s suddenly disappears!", Monnam(mtmp)); message(ScratchBuffer); } break; case ARROW_TRAP: if (in_sight) { StrPrintF(ScratchBuffer, "%s is hit by an arrow!", Monnam(mtmp)); message(ScratchBuffer); } mtmp->mhp -= 3; break; case DART_TRAP: if (in_sight) { StrPrintF(ScratchBuffer, "%s is hit by a dart!", Monnam(mtmp)); message(ScratchBuffer); } mtmp->mhp -= 2; /* not mondied here !! */ break; case TRAPDOOR: if (!xdnstair) { mtmp->mhp -= 10; if (in_sight) { StrPrintF(ScratchBuffer, "A trap door in the ceiling opens and a rock hits %s!", monnam(mtmp)); message(ScratchBuffer); } break; } if (mtmp->data->mlet != 'w') { fall_down(mtmp); if (in_sight) { StrPrintF(ScratchBuffer, "Suddenly, %s disappears out of sight.", monnam(mtmp)); message(ScratchBuffer); } return 2; /* no longer on this level */ } break; case PIERC: break; default: message("BUG: Some monster encountered a strange trap."); } } return ((mtmp->bitflags & M_IS_TRAPPED) != 0); }