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