Example #1
0
void
freeze(object *monster)
{
    short freeze_percent = 99;
    short i, n;

    if (rand_percent(12)) {
	return;
    }
    freeze_percent -= (rogue.str_current + (rogue.str_current / 2));
    freeze_percent -= ((rogue.exp + ring_exp) * 4);
    freeze_percent -= (get_armor_class(rogue.armor) * 5);
    freeze_percent -= (rogue.hp_max / 3);

    if (freeze_percent > 10) {
	monster->m_flags |= FREEZING_ROGUE;
	message(mesg[203], 1);
	n = get_rand(4, 8);
	for (i = 0; i < n; i++) {
	    mv_mons();
	}
	if (rand_percent(freeze_percent)) {
	    for (i = 0; i < 50; i++) {
		mv_mons();
	    }
	    killed_by((object *) 0, HYPOTHERMIA);
	}
	message(you_can_move_again, 1);
	monster->m_flags &= (~FREEZING_ROGUE);
    }
}
Example #2
0
File: main.c Project: albfan/rlwrap
void
cleanup_rlwrap_and_exit(int status)
{
  unblock_all_signals();
  DPRINTF0(DEBUG_TERMIO, "Cleaning up");

  if (write_histfile && (histsize==0 ||  history_total_bytes() > 0)) /* avoid creating empty .speling_eror_history file after typo */
    write_history(history_filename);	/* ignore errors */

  close_logfile();

  DPRINTF4(DEBUG_SIGNALS, "command_pid: %d, commands_exit_status: %x, filter_pid: %d, filters_exit_status: %x",
           command_pid, commands_exit_status, filter_pid, filters_exit_status);
  mymicrosleep(10); /* we may have got an EOF or EPIPE because the filter or command died, but this doesn't mean that
                       SIGCHLD has been caught already. Taking a little nap now improves the chance that we will catch it
                       (no grave problem if we miss it, but diagnostics, exit status and transparent signal handling depend on it) */
  if (filter_pid) 
    kill_filter();
  else if (filter_is_dead) {
    int filters_killer = killed_by(filters_exit_status);
    errno = 0;
    mywarn((filters_killer ? "filter was killed by signal %d (%s)": WEXITSTATUS(filters_exit_status) ? "filter died" : "filter exited"), filters_killer, signal_name(filters_killer));
  }     
  if (debug) 
    debug_postmortem();
  
  if (terminal_settings_saved)
    if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &saved_terminal_settings) < 0)  /* ignore errors (almost dead anyway) */ 
      ; /* fprintf(stderr, "Arggh\n"); don't use myerror!!*/

  if (!newline_came_last) /* print concluding newline, if necessary */
    my_putstr("\n");
     

  if (status != EXIT_SUCCESS)  /* rlwrap itself has failed, rather than the wrapped command */
    exit(status);              
  else {                      
    int commands_killer = killed_by(commands_exit_status);
    if (commands_killer)
      suicide_by(commands_killer, commands_exit_status); /* command terminated by signal, make rlwrap's
                                                            parent believe rlwrap was killed by it */ 
    else
      exit(WEXITSTATUS(commands_exit_status));           /* propagate command's exit status */
  }
}
Example #3
0
void
rogue_damage(short d, object *monster, short other)
{
	if (d >= rogue.hp_current) {
		rogue.hp_current = 0;
		print_stats(STAT_HP);
		killed_by(monster, other);
	}
	if (d > 0) {
		rogue.hp_current -= d;
		print_stats(STAT_HP);
	}
}
Example #4
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;
    }
}