BOOLEAN check_ibm_stop(void) { int key; int __ss *p; /* if (kbhit()) getch(); */ /* allow DOS to test for control-C */ p = &key; if ((int)p < 500) { err_logo(STACK_OVERFLOW, NIL); return(1); } if (((key = bioskey(1)) == (4113)) || ctrl_c_count > 0) { /* control-q */ if (ctrl_c_count == 0) getch(); ctrl_c_count = 0; err_logo(STOP_ERROR,NIL); return(1); } if (key == (4375)) { /* control-w */ getch(); to_pending = 0; lpause(NIL); } return (0); }
void portal_travel() { int start_y; int start_x; int y; int x; // int target_x; // int target_y; start_y = player->y / FLOOR_H; start_x = player->x / CELL_TO_TILES; player->y--; draw_board(); lpause(); player->y--; draw_board(); lpause(); for (y = 0; y < MAX_FLOORS; y++) { for (x = 0; x < CELLS_W; x++) { if (get_cell(y, x) == CELL_PORTAL && x != start_x && y != start_y) { player->x = x * CELL_TO_TILES + 4; player->y = y * FLOOR_H + FLOOR_Y - 3; view_y = y * FLOOR_H; recenter(false); } } } draw_board(); lpause(); player->y++; draw_board(); lpause(); player->y++; draw_board(); return; }
RETSIGTYPE logo_pause(int sig) { if (inside_gc || in_eval_save) { int_during_gc = 2; } else { charmode_off(); to_pending = 0; signal(SIGQUIT, logo_pause); lpause(NIL); } SIGRET}
void logo_pause() #endif { to_pending = 0; #ifdef bsd sigsetmask(0); #else signal(SIGQUIT, logo_pause); #endif #if 1 /* was #ifndef unix */ lpause(); #else if (ufun != NIL) { lpause(); } else { new_line(stdout); unblock_input(); } #endif }
RETSIGTYPE logo_pause() #endif { if (inside_gc || in_eval_save) { int_during_gc = 2; } else { charmode_off(); to_pending = 0; #ifdef bsd sigsetmask(0); #else #if !defined(mac) && !defined(_MSC_VER) signal(SIGQUIT, logo_pause); #endif #endif lpause(NIL); } SIGRET }
void disco() { bool old_flip; mob_t * m; int i; pwait("THIS LOOKS LIKE A DANCE FLOOR!"); stile(player->y, player->x, TL_VOID); m = player; old_flip = m->flip; m->flip = true; m->type = MOB_DANCER; draw_board(); opause(); for (i = 0; i < 9; i++) { stile(m->y - 5 + i % 2, m->x - 4 + i, TL_DISCOLIGHT1 + i); draw_board(); lpause(); } NOW_DANCE(0); NOW_DANCE(1); NOW_DANCE(0); NOW_DANCE(1); DANCE_FLIP(); NOW_DANCE(0); NOW_DANCE(1); NOW_DANCE(0); NOW_DANCE(1); NOW_DANCE(0); NOW_DANCE(10); NOW_DANCE(11); NOW_DANCE(12); DANCE_FLIP(); NOW_DANCE(11); NOW_DANCE(10); NOW_DANCE(11); NOW_DANCE(12); DANCE_FLIP(); NOW_DANCE(11); DANCE_FLIP(); NOW_DANCE(20); NOW_DANCE(21); NOW_DANCE(20); NOW_DANCE(22); DANCE_FLIP(); NOW_DANCE(20); NOW_DANCE(21); NOW_DANCE(20); NOW_DANCE(22); // DANCE_FLIP(); m->x -= 1; NOW_DANCE(30); DANCE_FLIP(); m->x += 1; NOW_DANCE(30); DANCE_FLIP(); m->x += 1; NOW_DANCE(30); DANCE_FLIP(); m->x -= 1; NOW_DANCE(30); DANCE_FLIP(); m->x -= 1; NOW_DANCE(30); DANCE_FLIP(); m->x += 1; NOW_DANCE(30); DANCE_FLIP(); m->x += 1; NOW_DANCE(30); DANCE_FLIP(); m->x -= 1; NOW_DANCE(30); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); m->x += 1; DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); m->x += 1; DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); //DANCE_FLIP(); m->x -= 1; m->y -= 1; NOW_DANCE(40); m->x -= 1; NOW_DANCE(40); m->x -= 1; m->y += 1; NOW_DANCE(40); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); m->x += 1; m->y -= 1; NOW_DANCE(40); m->x += 1; NOW_DANCE(40); m->x += 1; m->y += 1; NOW_DANCE(40); NOW_DANCE(50); m->x -= 1; NOW_DANCE(51); NOW_DANCE(50); m->x -= 1; NOW_DANCE(51); NOW_DANCE(50); m->x -= 1; NOW_DANCE(51); NOW_DANCE(50); m->x -= 1; NOW_DANCE(51); NOW_DANCE(50); // NOW_DANCE(51); DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); m->x += 1; DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); m->x += 1; DANCE_FLIP(); Q_DANCE(31); DANCE_FLIP(); Q_DANCE(31); NOW_DANCE(60); DANCE_FLIP(); NOW_DANCE(60); m->y += 1; NOW_DANCE(60); DANCE_FLIP(); m->y -= 1; NOW_DANCE(70); lpause(); NOW_DANCE(71); lpause(); NOW_DANCE(70); lpause(); NOW_DANCE(71); opause(); for (i = 0; i < 9; i++) { stile(m->y - 5, m->x - 4 + i, TL_VOID); stile(m->y - 4, m->x - 4 + i, TL_VOID); } m->type = MOB_PLAYER; m->flags = 0; m->flip = old_flip; draw_board(); lpause(); char line[DEFLEN]; snprintf(line, DEFLEN, "YOU GET %d EXPERIENCE", DISCO_EXP); pwait(line); draw_board(); give_exp(DISCO_EXP); draw_stats(); return; }
void fountain() { char line[DEFLEN]; char liquid[DEFLEN]; char * insert; int temp; int blood; int rlen; blood = (gtile(player->y, player->x) == TL_P_BLOOD_FOUNTAIN); snprintf(liquid, DEFLEN, "%s", blood ? "BLOOD" : "WATER"); stile(player->y, player->x, TL_FOUNT_BASE); stile(player->y - 1, player->x, TL_VOID); stile(player->y - 2, player->x, TL_VOID); stile(player->y - 2, player->x - 1, TL_VOID); stile(player->y - 2, player->x + 1, TL_VOID); snprintf(line, DEFLEN, "YOU DRINK FROM THE %sFOUNTAIN\n\n", (blood ? "BLOOD " : "")); rlen = strlen(line); insert = &line[rlen]; rlen = DEFLEN - rlen; draw_board(); switch (rand() % 10) { case 0: snprintf(insert, rlen, "THE %s TASTES FOUL!!", liquid); pwait(line); player->flags = GFX_HURT; draw_board(); lpause(); player->flags = 0; player->hp -= 1 + rand() % 10; draw_bars(); if (player->hp <= 0) { draw_board(); game_over("YOU DIED FROM A\n" "POISONED FOUNTAIN", false); } break; case 1: snprintf(insert, rlen, "THE %s TASTES BITTER!\n\nYOU FEEL SLOWER!", liquid); pwait(line); change_pl_sp(-1); draw_stats(); break; case 2: case 3: temp = 100 + (rand() % 5) * 100; temp += MAX(0, game->current_floor - 7) * 100; snprintf(insert, rlen, "THIS IS A FOUNTAIN OF WISDOM!\n\n" "YOU GET %d EXP", temp); pwait(line); draw_board(); give_exp(temp); break; case 4: case 5: snprintf(insert, rlen, "THE %s IS INVIGORATING!\n\nYOU FEEL STRONGER!", liquid); pwait(line); change_pl_st(+1); draw_stats(); break; default: snprintf(insert, rlen, "THE %s IS REFRESHING!", liquid); pwait(line); refill_hp(FOUNTAIN_HEAL); break; } return; }
void stone_tablet() { char line[DEFLEN]; int seq[15]; int inp_seq[15]; int i; int states = 7; int exp; pwait("YOU FIND A MYSTERIOUS STONE TABLET"); stile(player->y, player->x, TL_VOID); stile(player->y - 1, player->x, TL_VOID); states = game->tablet_diff; draw_tablet(-1); pwait("REPEAT THE SEQUENCE\n" "USING THE DIRECTIONAL KEYS"); draw_tablet(-1); for (i = 0; i < states; i++) { opause(); seq[i] = rand() % 4; draw_tablet(seq[i]); opause(); draw_tablet(-1); } for (i = 0; i < states; i++) { int gk; gk = getch(); if (gk == KEY_UP) inp_seq[i] = 0; else if (gk == KEY_RIGHT) inp_seq[i] = 1; else if (gk == KEY_DOWN) inp_seq[i] = 2; else if (gk == KEY_LEFT) inp_seq[i] = 3; else { snprintf(lowmsg, DEFLEN, "INVALID INPUT"); draw_lowmsg(); continue; } if (inp_seq[i] != seq[i]) { lpause(); board_attr(A_REVERSE | A_BOLD, PAIR_RED); wrefresh(board); pwait("SHIT"); draw_board(); return; } else { draw_tablet(seq[i]); opause(); draw_tablet(-1); flush_input(); } } draw_board(); switch (states) { case 7: exp = 1000; break; case 8: exp = 2000; break; case 9: exp = 3000; break; default: exp = 1000; break; } snprintf(line, DEFLEN, "YOU HAVE DECODED THE MYSTIC RUNES\n" "\nYOU GET %d EXP", exp); pwait(line); draw_board(); give_exp(exp); draw_stats(); // Make it harder next time game->tablet_diff += 1; draw_stats(); return; }
bool melee(mob_t * attacker, int speed) { char line[DEFLEN]; mob_t * target; int att_x; int range; int i; range = attacker->range; att_x = attacker->x; if (speed > 0) att_x++; for (i = 0; i < range; i++) { att_x += speed; target = find_enemy(attacker, player->y, att_x); if (target == NULL) continue; if (target->type == MOB_MIMIC && target->attack_phase == 0) { pwait("WAIT! THAT IS A SMALL MIMIC!"); target->attack_phase = 1; target->flags = 0; return true; } else if (target->type == MOB_BLURK && target->attack_phase == 0) { draw_board_norefresh(); pwait("OH NO! AN INSIDIOUS BLURK BARS YOUR WAY!"); target->attack_phase = 1; target->flags = 0; return true; } // Attack! // The attacker must always lower their shield attacker->shd_up = 0; if (attacker == player && game->weapon > WPN_UNARMED) { damage_weapon(1); } // If the target has their shield up and they are facing each other if (target->shd_up && target->flip != attacker->flip) { if (shield_block(target)) { mob_text(target, "BLOCK"); damage_shield(target); if (target->type == MOB_KNAVE) { if (target->attack_phase == 0) target->attack_phase = 1; else if (target->attack_phase == 1 || target->attack_phase == 2) { move_towards_player(target); } } return true; } } damage(attacker, target); if (attacker->attack_frames == 2) { attacker->flags = GFX_ATTACK2; draw_board(); lpause(); attacker->flags = 0; } attacker->flags = GFX_ATTACK; draw_board(); lpause(); attacker->flags = 0; damage_armor(target); // Draining dagger restores attacker HP if (attacker == player && game->weapon == WPN_DRAIN) { attacker->hp += 1; } if (target->hp > 0) { // Keep track of who we are fighting if (attacker == player) { enemy_bar = target->index; enemy_bar_time = BAR_TIMEOUT; draw_bars(); } else if (target == player) { enemy_bar = attacker->index; enemy_bar_time = BAR_TIMEOUT; draw_bars(); } } target->flags = GFX_HURT; draw_board(); lpause(); target->flags = 0; if (target->hp <= 0) { if (target == player) { snprintf(line, DEFLEN, "YOU WERE %s\n" "BY %s%s", attacker->killverb, article[attacker->article], mob_name[attacker->type]); draw_bars(); game_over(line, false); } else { kill_enemy(target); } } if (attacker->type == MOB_ROGUE && game->player_gold > ROGUE_STEAL_GOLD && rand() % 100 < ROGUE_STEAL_CHANCE) { rogue_escape(attacker); } return true; } return false; }
int shoot_missile(mob_t * attacker, int dir) { char line[DEFLEN]; mob_t * target; int m_y; int m_x; int sc_y; int sc_x; int count; int m_type; int adjust_y; int passes; int pass; int xbow; chtype color; chtype missile; // attacker = &game->mob[mi]; xbow = false; passes = 1; adjust_y = water_offset(attacker); m_y = attacker->y; sc_y = m_y - view_y - 1; m_x = attacker->x + (attacker->flip ? -attacker->pack_w + 2 : attacker->pack_w - 2) + dir * 2; if (attacker->type == MOB_EYE) { m_type = MIS_DISINT; sc_y -= 1; m_x = attacker->x; } else if (attacker->type == MOB_LICH) { m_type = MIS_FIREBALL; sc_y -= 1; } else if (attacker == player) { if (game->weapon == WPN_BOW) m_type = MIS_ARROW; else if (game->weapon == WPN_3XBOW) { xbow = true; m_type = MIS_ARROW; if (water_offset(attacker)) passes = 2; else passes = 3; } else if (game->weapon == WPN_BLASTER) { m_type = MIS_BLASTER; adjust_y -= 1; } } else { m_type = MIS_ARROW; } draw_board(); for (pass = 0; pass < passes; pass++) { count = 0; if (xbow) { m_x = attacker->x + (attacker->flip ? -attacker->pack_w + 2 : attacker->pack_w - 2) + dir * 2; if (pass == 0) adjust_y = water_offset(attacker) - 1; else if (pass == 1) adjust_y = water_offset(attacker); else if (pass == 2) adjust_y = water_offset(attacker) + 1; } while (1) { m_x += dir; sc_x = m_x - view_x; count++; if (sc_x < 0 || sc_x >= BOARD_W) goto end_pass;//break;//return 0; target = find_enemy(attacker, m_y, m_x + dir); if (target == NULL) { if (game->blinded) continue; if (m_type != MIS_BLASTER && count % 2 == 1) continue; // Skip the length of the barrel if (m_type == MIS_BLASTER && count < 4) continue; missile = '?'; color = COLOR_PAIR(PAIR_GREEN); if (m_type == MIS_ARROW) { missile = '-'; color = COLOR_PAIR(PAIR_MAGENTA); } if (m_type == MIS_BLASTER) { missile = '='; color = COLOR_PAIR(PAIR_MAGENTA); } else if (m_type == MIS_FIREBALL) { missile = '*'; color = COLOR_PAIR(PAIR_RED); } else if (m_type == MIS_DISINT) { missile = (dir > 0 ? '>' : '<'); color = COLOR_PAIR(PAIR_RED); } if (water_join(gtile(m_y - 1, m_x))) { color = COLOR_PAIR(PAIR_BLACK_ON_CYAN); } if (m_type == MIS_BLASTER) { mvwaddch(board, sc_y + adjust_y, sc_x, '_' | color); /* if (count % 2) mvwaddch(board, sc_y, sc_x, (dir > 0 ? ')' : '(') | color); else mvwaddch(board, sc_y - 1, sc_x, (dir > 0 ? ')' : '(') | color);*/ } else mvwaddch(board, sc_y + adjust_y, sc_x, missile | color); wrefresh(board); spause(); continue; } if (target->shd_up && ((!target->flip && dir < 0) || (target->flip && dir > 0)) ) { if (target == player && m_type == MIS_DISINT && target->shd_type != SHD_NONE && target->shd_type != SHD_MAGIC) { flush_input(); snprintf(line, DEFLEN, "DISINTEGRATION BEAM!!\n\nYOUR %s\nCRUMBLES TO DUST!", armor_name[target->shd_type]); pwait(line); target->shd_type = SHD_NONE; target->shd_up = false; goto end_pass;//return true; } if (m_type != MIS_BLASTER && shield_block(target)) { mob_text(target, "BLOCK"); damage_shield(target); goto end_pass; //return true; } } if (target == player && m_type == MIS_DISINT) { if (target->armor_type != ARMOR_NONE && target->armor_type != ARMOR_MAGIC) { flush_input(); snprintf(line, DEFLEN, "DISINTEGRATION BEAM!!\n\nYOUR %s\nCRUMBLES TO DUST!", armor_name[target->armor_type]); pwait(line); target->armor_type = ARMOR_NONE; goto end_pass;// return true; } if (game->weapon != WPN_UNARMED) { flush_input(); snprintf(line, DEFLEN, "DISINTEGRATION BEAM!!\n\nYOUR %s\nCRUMBLES TO DUST!", weapon_name[game->weapon]); pwait(line); give_weapon(WPN_UNARMED); goto end_pass; //return true; } } damage(attacker, target); if (m_type == MIS_ARROW) { target->flags = GFX_HURT; draw_board(); lpause(); target->flags = 0; } else if (m_type == MIS_BLASTER) { target->flags = GFX_HURT; draw_board(); lpause(); target->flags = 0; } else if (m_type == MIS_FIREBALL) { explosion(sc_y, sc_x + dir); } if (target == player) { draw_bars(); } if (target->hp <= 0) { if (target == player) { snprintf(line, DEFLEN, "YOU WERE %s\n" "BY %s%s", (m_type == MIS_FIREBALL ? "FRIED" : (m_type == MIS_DISINT ? "DISINTEGRATED" : "SHOT")), article[attacker->article], mob_name[attacker->type]); draw_board(); game_over(line, false); } else { if (!xbow || pass == passes - 1) kill_enemy(target); goto end_pass; } } else if (target != player) { enemy_bar = target->index; enemy_bar_time = BAR_TIMEOUT; draw_bars(); // update the number of eyes it has if (target->type == MOB_BIGSPIDER) draw_board();// draw_board(); } damage_armor(target); goto end_pass; } end_pass: continue; } // return 1; // } return 1; }