Annotation of early-roguelike/rogue4/daemons.c, Revision 1.1
1.1 ! rubenllo 1: /*
! 2: * All the daemon and fuse functions are in here
! 3: *
! 4: * @(#)daemons.c 4.10 (Berkeley) 4/6/82
! 5: *
! 6: * Rogue: Exploring the Dungeons of Doom
! 7: * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman
! 8: * All rights reserved.
! 9: *
! 10: * See the file LICENSE.TXT for full copyright and licensing information.
! 11: */
! 12:
! 13: #include <curses.h>
! 14: #include "rogue.h"
! 15:
! 16: int between = 0;
! 17:
! 18: /*
! 19: * doctor:
! 20: * A healing daemon that restors hit points after rest
! 21: */
! 22: void
! 23: doctor(void)
! 24: {
! 25: register int lv, ohp;
! 26:
! 27: lv = pstats.s_lvl;
! 28: ohp = pstats.s_hpt;
! 29: quiet++;
! 30: if (lv < 8)
! 31: {
! 32: if (quiet + (lv << 1) > 20)
! 33: pstats.s_hpt++;
! 34: }
! 35: else
! 36: if (quiet >= 3)
! 37: pstats.s_hpt += rnd(lv - 7) + 1;
! 38: if (ISRING(LEFT, R_REGEN))
! 39: pstats.s_hpt++;
! 40: if (ISRING(RIGHT, R_REGEN))
! 41: pstats.s_hpt++;
! 42: if (ohp != pstats.s_hpt)
! 43: {
! 44: if (pstats.s_hpt > max_hp)
! 45: pstats.s_hpt = max_hp;
! 46: quiet = 0;
! 47: }
! 48: }
! 49:
! 50: /*
! 51: * Swander:
! 52: * Called when it is time to start rolling for wandering monsters
! 53: */
! 54: void
! 55: swander(void)
! 56: {
! 57: start_daemon(rollwand, 0, BEFORE);
! 58: }
! 59:
! 60: /*
! 61: * rollwand:
! 62: * Called to roll to see if a wandering monster starts up
! 63: */
! 64: void
! 65: rollwand(void)
! 66: {
! 67: if (++between >= 4)
! 68: {
! 69: if (roll(1, 6) == 4)
! 70: {
! 71: wanderer();
! 72: kill_daemon(rollwand);
! 73: fuse(swander, 0, WANDERTIME, BEFORE);
! 74: }
! 75: between = 0;
! 76: }
! 77: }
! 78:
! 79: /*
! 80: * unconfuse:
! 81: * Release the poor player from his confusion
! 82: */
! 83: void
! 84: unconfuse(void)
! 85: {
! 86: player.t_flags &= ~ISHUH;
! 87: msg("you feel less confused now");
! 88: }
! 89:
! 90: /*
! 91: * unsee:
! 92: * Turn off the ability to see invisible
! 93: */
! 94: void
! 95: unsee(void)
! 96: {
! 97: register THING *th;
! 98:
! 99: for (th = mlist; th != NULL; th = next(th))
! 100: if (on(*th, ISINVIS) && see_monst(th))
! 101: {
! 102: move(th->t_pos.y, th->t_pos.x);
! 103: addch(th->t_oldch);
! 104: }
! 105: player.t_flags &= ~CANSEE;
! 106: }
! 107:
! 108: /*
! 109: * sight:
! 110: * He gets his sight back
! 111: */
! 112: void
! 113: sight(void)
! 114: {
! 115: if (on(player, ISBLIND))
! 116: {
! 117: extinguish(sight);
! 118: player.t_flags &= ~ISBLIND;
! 119: if (!(proom->r_flags & ISGONE))
! 120: enter_room(&hero);
! 121: msg("the veil of darkness lifts");
! 122: }
! 123: }
! 124:
! 125: /*
! 126: * nohaste:
! 127: * End the hasting
! 128: */
! 129: void
! 130: nohaste(void)
! 131: {
! 132: player.t_flags &= ~ISHASTE;
! 133: msg("you feel yourself slowing down");
! 134: }
! 135:
! 136: /*
! 137: * stomach:
! 138: * Digest the hero's food
! 139: */
! 140: void
! 141: stomach(void)
! 142: {
! 143: register int oldfood;
! 144:
! 145: if (food_left <= 0)
! 146: {
! 147: if (food_left-- < -STARVETIME)
! 148: death('s');
! 149: /*
! 150: * the hero is fainting
! 151: */
! 152: if (no_command || rnd(5) != 0)
! 153: return;
! 154: no_command += rnd(8) + 4;
! 155: player.t_flags &= ~ISRUN;
! 156: running = FALSE;
! 157: count = 0;
! 158: hungry_state = 3;
! 159: if (!terse)
! 160: addmsg("you feel too weak from lack of food. ");
! 161: msg("You faint");
! 162: }
! 163: else
! 164: {
! 165: oldfood = food_left;
! 166: food_left -= ring_eat(LEFT) + ring_eat(RIGHT) + 1 - amulet;
! 167:
! 168: if (food_left < MORETIME && oldfood >= MORETIME)
! 169: {
! 170: hungry_state = 2;
! 171: msg("you are starting to feel weak");
! 172: }
! 173: else if (food_left < 2 * MORETIME && oldfood >= 2 * MORETIME)
! 174: {
! 175: hungry_state = 1;
! 176: if (!terse)
! 177: msg("you are starting to get hungry");
! 178: else
! 179: msg("getting hungry");
! 180: }
! 181: }
! 182: }
CVSweb