void go_blind(void) { short i, j; if (!blind) { message(mesg[274], 0); } blind += get_rand(500, 800); if (detect_monster) { object *monster; monster = level_monsters.next_monster; while (monster) { mvaddch_rogue(monster->row, monster->col, monster->trail_char); monster = monster->next_monster; } } if (cur_room >= 0) { for (i = rooms[cur_room].top_row + 1; i < rooms[cur_room].bottom_row; i++) { for (j = rooms[cur_room].left_col + 1; j < rooms[cur_room].right_col; j++) { mvaddch_rogue(i, j, ' '); } } } mvaddch_rogue(rogue.row, rogue.col, rogue.fchar); }
/* * rw_dungeon * セーブデータからのダンジョン情報の保存と復元 */ void rw_dungeon(FILE *fp, boolean rw) { short i, j; char buf[ROGUE_COLUMNS]; if (rw) { // 書き込み時実行 for (i = 0; i < ROGUE_LINES; i++) { r_write(fp, (char *) dungeon[i], (ROGUE_COLUMNS * sizeof(dungeon[0][0]))); for (j = 0; j < ROGUE_COLUMNS; j++) { buf[j] = mvinch_rogue(i, j); } r_write(fp, buf, ROGUE_COLUMNS); } return; } else { // 読み込み時実行 for (i = 0; i < ROGUE_LINES; i++) { r_read(fp, (char *) dungeon[i], (ROGUE_COLUMNS * sizeof(dungeon[0][0]))); r_read(fp, buf, ROGUE_COLUMNS); if ( i < ROGUE_LINES - 1 ) { for (j = 0; j < ROGUE_COLUMNS; j++) { mvaddch_rogue(i, j, (unsigned char) buf[j]); } } else { print_stats(STAT_ALL); } } return; } }
void relight(void) { if (cur_room == PASSAGE) { light_passage(rogue.row, rogue.col); } else { light_up_room(cur_room); } mvaddch_rogue(rogue.row, rogue.col, rogue.fchar); }
int flame_broil(object *monster) { short row, col; if ((!mon_sees(monster, rogue.row, rogue.col)) || coin_toss()) { return 0; } row = rogue.row - monster->row; col = rogue.col - monster->col; if (row < 0) { row = -row; } if (col < 0) { col = -col; } if (((row != 0) && (col != 0) && (row != col)) || ((row > 7) || (col > 7))) { return 0; } if ((!blind) && (!rogue_is_around(monster->row, monster->col))) { row = monster->row; col = monster->col; get_closer(&row, &col, rogue.row, rogue.col); standout(); do { mvaddch_rogue(row, col, '~'); refresh(); get_closer(&row, &col, rogue.row, rogue.col); } while ((row != rogue.row) || (col != rogue.col)); standend(); row = monster->row; col = monster->col; get_closer(&row, &col, rogue.row, rogue.col); do { mvaddch_rogue(row, col, get_dungeon_char(row, col)); refresh(); get_closer(&row, &col, rogue.row, rogue.col); } while ((row != rogue.row) || (col != rogue.col)); } mon_hit(monster, flame_name, 1); return 1; }
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 show_traps(void) { short i, j; for (i = 0; i < ROGUE_LINES; i++) { for (j = 0; j < ROGUE_COLUMNS; j++) { if (dungeon[i][j] & TRAP) { mvaddch_rogue(i, j, '^'); } } } }
void tele(void) { mvaddch_rogue(rogue.row, rogue.col, get_dungeon_char(rogue.row, rogue.col)); if (cur_room >= 0) { darken_room(cur_room); } put_player(get_room_number(rogue.row, rogue.col)); being_held = false; bear_trap = 0; }
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; } }
void disappear(object *monster) { short row, col; row = monster->row; col = monster->col; dungeon[row][col] &= ~MONSTER; if (rogue_can_see(row, col)) { mvaddch_rogue(row, col, get_dungeon_char(row, col)); } take_from_pack(monster, &level_monsters); free_object(monster); mon_disappeared = 1; }
int check_imitator(object *monster) { char msg[80]; if (monster->m_flags & IMITATES) { wake_up(monster); if (!blind) { mvaddch_rogue(monster->row, monster->col, get_dungeon_char(monster->row, monster->col)); check_message(); sprintf(msg, mesg[206], mon_name(monster)); message(msg, 1); } return 1; } return 0; }
int try_to_cough(short row, short col, object *obj) { if ((row < MIN_ROW) || (row > (ROGUE_LINES - 2)) || (col < 0) || (col > (ROGUE_COLUMNS - 1))) { return 0; } if ((!(dungeon[row][col] & (OBJECT | STAIRS | TRAP))) && (dungeon[row][col] & (TUNNEL | FLOOR | DOOR))) { place_at(obj, row, col); if (((row != rogue.row) || (col != rogue.col)) && (!(dungeon[row][col] & MONSTER))) { mvaddch_rogue(row, col, get_dungeon_char(row, col)); } return 1; } return 0; }
int do_input_line(boolean is_msg, int row, int col, char *prompt, char *insert, char *buf, char *if_cancelled, boolean add_blank, boolean do_echo, int first_ch) { short ch; short i = 0, n = 0; #if defined( JAPAN ) short k; char kanji[MAX_TITLE_LENGTH]; #endif /* JAPAN */ if (is_msg) { message(prompt, 0); n = strlen(prompt) + 1; } else { mvaddstr_rogue(row, col, prompt); } if (insert[0]) { mvaddstr_rogue(row, col + n, insert); (void) strcpy(buf, insert); i = strlen(insert); #if defined( JAPAN ) k = 0; while (k < i) { ch = insert[k]; #if defined( EUC ) if (ch & 0x80) { /* for EUC code by Yasha */ kanji[k] = kanji[k + 1] = 1; k += 2; } else { kanji[k] = 0; k++; } #else /* not EUC */ if (ch >= 0x81 && ch <= 0x9f || ch >= 0xe0 && ch <= 0xfc) { kanji[k] = kanji[k + 1] = 1; k += 2; } else { kanji[k] = 0; k++; } #endif /* not EUC */ } #endif /* JAPAN */ move(row, col + n + i); refresh(); } #if defined( JAPAN ) for (;;) { if (first_ch) { ch = first_ch; first_ch = 0; } else { ch = rgetchar(); } if (ch == '\r' || ch == '\n' || ch == CANCEL) { break; } if ((ch == '\b') && (i > 0)) { i -= kanji[i - 1] ? 2 : 1; if (do_echo) { mvaddstr_rogue(row, col + n + i, " "); move(row, col + n + i); } } else if ( #if defined( EUC ) (ch >= ' ' && !(ch & 0x80)) && (i < MAX_TITLE_LENGTH - 2) #else /* Shift JIS */ (ch >= ' ' && ch <= '~' || ch >= 0xa0 && ch <= 0xde) && (i < MAX_TITLE_LENGTH - 2) #endif /* not EUC */ ) { if ((ch != ' ') || (i > 0)) { buf[i] = ch; kanji[i] = 0; if (do_echo) { addch(ch); } i++; } } else if ( #if defined( EUC ) (ch & 0x80) && (i < MAX_TITLE_LENGTH - 3) #else /* Shift JIS */ (ch >= 0x81 && ch <= 0x9f || ch >= 0xe0 && ch <= 0xfc) && (i < MAX_TITLE_LENGTH - 3) #endif /* not EUC */ ) { buf[i] = ch; buf[i + 1] = rgetchar(); kanji[i] = kanji[i + 1] = 1; if (do_echo) { addch_rogue(buf[i]); addch_rogue(buf[i + 1]); } i += 2; } refresh(); } if (is_msg) { check_message(); } while ((i > 0) && (buf[i - 1] == ' ') && (kanji[i - 1] == 0)) { i--; } if (add_blank) { buf[i++] = ' '; } #else /* not JAPAN */ while (((ch = rgetchar()) != '\r') && (ch != '\n') && (ch != CANCEL)) { if ((ch >= ' ') && (ch <= '~') && (i < MAX_TITLE_LENGTH - 2)) { if ((ch != ' ') || (i > 0)) { buf[i++] = ch; if (do_echo) { addch_rogue(ch); } } } if ((ch == '\b') && (i > 0)) { i--; if (do_echo) { mvaddch_rogue(row, col + n + i, ' '); move(row, col + n + i); } } refresh(); } if (is_msg) { check_message(); } if (add_blank) { buf[i++] = ' '; } else { while ((i > 0) && (buf[i - 1] == ' ')) { i--; } } #endif /* not JAPAN */ buf[i] = 0; if ((ch == CANCEL) || (i == 0) || ((i == 1) && add_blank)) { if (is_msg && if_cancelled) { message(if_cancelled, 0); } return ((ch == CANCEL) ? -1 : 0); } return i; }