Annotation of early-roguelike/srogue/daemons.c, Revision 1.1
1.1 ! rubenllo 1: /*
! 2: * All the daemon and fuse functions are in here
! 3: *
! 4: * @(#)daemons.c 9.0 (rdk) 7/17/84
! 5: *
! 6: * Super-Rogue
! 7: * Copyright (C) 1984 Robert D. Kindelberger
! 8: * All rights reserved.
! 9: *
! 10: * Based on "Rogue: Exploring the Dungeons of Doom"
! 11: * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
! 12: * All rights reserved.
! 13: *
! 14: * See the file LICENSE.TXT for full copyright and licensing information.
! 15: */
! 16:
! 17: #include "rogue.h"
! 18: #include "rogue.ext"
! 19:
! 20: int between = 0;
! 21:
! 22: /*
! 23: * doctor:
! 24: * A healing daemon that restores hit points after rest
! 25: */
! 26: void
! 27: doctor(int fromfuse)
! 28: {
! 29: reg int *thp, lv, ohp, ccon;
! 30:
! 31: lv = him->s_lvl;
! 32: thp = &him->s_hpt;
! 33: ohp = *thp;
! 34: quiet += 1;
! 35:
! 36: ccon = him->s_ef.a_con;
! 37: if (ccon > 16 && !isfight)
! 38: *thp += rnd(ccon - 15);
! 39: if (lv < 8) {
! 40: if (quiet > 20 - lv * 2)
! 41: *thp += 1;
! 42: }
! 43: else {
! 44: if (quiet >= 3)
! 45: *thp += rnd(lv - 7) + 1;
! 46: }
! 47: if (isring(LEFT, R_REGEN))
! 48: *thp += 1;
! 49: if (isring(RIGHT, R_REGEN))
! 50: *thp += 1;
! 51: if (pl_on(ISREGEN))
! 52: *thp += 1;
! 53: if (ohp != *thp) {
! 54: nochange = FALSE;
! 55: if (*thp > him->s_maxhp)
! 56: *thp = him->s_maxhp;
! 57: quiet = 0;
! 58: }
! 59: }
! 60:
! 61:
! 62: /*
! 63: * Swander:
! 64: * Called when it is time to start rolling for wandering monsters
! 65: */
! 66: void
! 67: swander(int fromfuse)
! 68: {
! 69: start_daemon(rollwand, TRUE, AFTER);
! 70: }
! 71:
! 72:
! 73: /*
! 74: * rollwand:
! 75: * Called to roll to see if a wandering monster starts up
! 76: */
! 77: void
! 78: rollwand(int fromfuse)
! 79: {
! 80:
! 81: if (++between >= 4) {
! 82: if (roll(1, 6) == 4) {
! 83: if (levtype != POSTLEV) /* no monsters for posts */
! 84: wanderer();
! 85: extinguish(rollwand);
! 86: fuse(swander, TRUE, WANDERTIME);
! 87: }
! 88: between = 0;
! 89: }
! 90: }
! 91:
! 92:
! 93: /*
! 94: * unconfuse:
! 95: * Release the poor player from his confusion
! 96: */
! 97: void
! 98: unconfuse(int fromfuse)
! 99: {
! 100: if (pl_on(ISHUH))
! 101: msg("You feel less confused now.");
! 102: player.t_flags &= ~ISHUH;
! 103: }
! 104:
! 105: /*
! 106: * unsee:
! 107: * He lost his see invisible power
! 108: */
! 109: void
! 110: unsee(int fromfuse)
! 111: {
! 112: player.t_flags &= ~CANSEE;
! 113: }
! 114:
! 115: /*
! 116: * sight:
! 117: * He gets his sight back
! 118: */
! 119: void
! 120: sight(int fromfuse)
! 121: {
! 122: if (pl_on(ISBLIND))
! 123: msg("The veil of darkness lifts.");
! 124: player.t_flags &= ~ISBLIND;
! 125: light(&hero);
! 126: }
! 127:
! 128: /*
! 129: * nohaste:
! 130: * End the hasting
! 131: */
! 132: void
! 133: nohaste(int fromfuse)
! 134: {
! 135: if (pl_on(ISHASTE))
! 136: msg("You feel yourself slowing down.");
! 137: player.t_flags &= ~ISHASTE;
! 138: }
! 139:
! 140:
! 141: /*
! 142: * stomach:
! 143: * Digest the hero's food
! 144: */
! 145: void
! 146: stomach(int fromfuse)
! 147: {
! 148: reg int oldfood, old_hunger;
! 149:
! 150: old_hunger = hungry_state;
! 151: if (food_left <= 0) { /* the hero is fainting */
! 152: if (--food_left == -150) {
! 153: msg("Your stomach writhes with hunger pains.");
! 154: }
! 155: else if (food_left < -350) {
! 156: msg("You starve to death !!");
! 157: msg(" ");
! 158: death(K_STARVE);
! 159: }
! 160: if (player.t_nocmd > 0 || rnd(100) > 20)
! 161: return;
! 162: player.t_nocmd = rnd(8)+4;
! 163: msg("You faint.");
! 164: running = FALSE;
! 165: count = 0;
! 166: hungry_state = F_FAINT;
! 167: }
! 168: else {
! 169: oldfood = food_left;
! 170: food_left -= ringfood + foodlev - amulet;
! 171: if (player.t_nocmd > 0) /* wait till he can move */
! 172: return;
! 173: if (food_left < WEAKTIME && oldfood >= WEAKTIME) {
! 174: msg("You are starting to feel weak.");
! 175: hungry_state = F_WEAK;
! 176: }
! 177: else if(food_left < HUNGTIME && oldfood >= HUNGTIME) {
! 178: msg("Getting hungry.");
! 179: hungry_state = F_HUNGRY;
! 180: }
! 181: }
! 182: if (old_hunger != hungry_state)
! 183: updpack(); /* new pack weight */
! 184: wghtchk(FALSE);
! 185: }
! 186:
! 187: /*
! 188: * noteth:
! 189: * Hero is no longer etherereal
! 190: */
! 191: void
! 192: noteth(int fromfuse)
! 193: {
! 194: int ch;
! 195:
! 196: if (pl_on(ISETHER)) {
! 197: msg("You begin to feel more corporeal.");
! 198: ch = player.t_oldch;
! 199: if (dead_end(ch)) {
! 200: msg("You materialize in %s.",identify(ch));
! 201: msg(" ");
! 202: death(K_STONE); /* can't materialize in walls */
! 203: }
! 204: }
! 205: player.t_flags &= ~ISETHER;
! 206: }
! 207:
! 208: /*
! 209: * sapem:
! 210: * Sap the hero's life away
! 211: */
! 212: void
! 213: sapem(int fromfuse)
! 214: {
! 215: chg_abil(rnd(4) + 1, -1, TRUE);
! 216: fuse(sapem, TRUE, 150);
! 217: nochange = FALSE;
! 218: }
! 219:
! 220: /*
! 221: * notslow:
! 222: * Restore the hero's normal speed
! 223: */
! 224: void
! 225: notslow(int fromfuse)
! 226: {
! 227: if (pl_on(ISSLOW))
! 228: msg("You no longer feel hindered.");
! 229: player.t_flags &= ~ISSLOW;
! 230: }
! 231:
! 232: /*
! 233: * notregen:
! 234: * Hero is no longer regenerative
! 235: */
! 236: void
! 237: notregen(int fromfuse)
! 238: {
! 239: if (pl_on(ISREGEN))
! 240: msg("You no longer feel bolstered.");
! 241: player.t_flags &= ~ISREGEN;
! 242: }
! 243:
! 244: /*
! 245: * notinvinc:
! 246: * Hero not invincible any more
! 247: */
! 248: void
! 249: notinvinc(int fromfuse)
! 250: {
! 251: if (pl_on(ISINVINC))
! 252: msg("You no longer feel invincible.");
! 253: player.t_flags &= ~ISINVINC;
! 254: }
CVSweb