Mercurial > hg > early-roguelike
comparison rogue4/daemons.c @ 12:9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
| author | edwarj4 |
|---|---|
| date | Sat, 24 Oct 2009 16:52:52 +0000 |
| parents | |
| children | f2951c4e28d9 |
comparison
equal
deleted
inserted
replaced
| 11:949d558c2162 | 12:9535a08ddc39 |
|---|---|
| 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 doctor() | |
| 23 { | |
| 24 register int lv, ohp; | |
| 25 | |
| 26 lv = pstats.s_lvl; | |
| 27 ohp = pstats.s_hpt; | |
| 28 quiet++; | |
| 29 if (lv < 8) | |
| 30 { | |
| 31 if (quiet + (lv << 1) > 20) | |
| 32 pstats.s_hpt++; | |
| 33 } | |
| 34 else | |
| 35 if (quiet >= 3) | |
| 36 pstats.s_hpt += rnd(lv - 7) + 1; | |
| 37 if (ISRING(LEFT, R_REGEN)) | |
| 38 pstats.s_hpt++; | |
| 39 if (ISRING(RIGHT, R_REGEN)) | |
| 40 pstats.s_hpt++; | |
| 41 if (ohp != pstats.s_hpt) | |
| 42 { | |
| 43 if (pstats.s_hpt > max_hp) | |
| 44 pstats.s_hpt = max_hp; | |
| 45 quiet = 0; | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 /* | |
| 50 * Swander: | |
| 51 * Called when it is time to start rolling for wandering monsters | |
| 52 */ | |
| 53 swander() | |
| 54 { | |
| 55 daemon(rollwand, 0, BEFORE); | |
| 56 } | |
| 57 | |
| 58 /* | |
| 59 * rollwand: | |
| 60 * Called to roll to see if a wandering monster starts up | |
| 61 */ | |
| 62 rollwand() | |
| 63 { | |
| 64 if (++between >= 4) | |
| 65 { | |
| 66 if (roll(1, 6) == 4) | |
| 67 { | |
| 68 wanderer(); | |
| 69 kill_daemon(rollwand); | |
| 70 fuse(swander, 0, WANDERTIME, BEFORE); | |
| 71 } | |
| 72 between = 0; | |
| 73 } | |
| 74 } | |
| 75 | |
| 76 /* | |
| 77 * unconfuse: | |
| 78 * Release the poor player from his confusion | |
| 79 */ | |
| 80 unconfuse() | |
| 81 { | |
| 82 player.t_flags &= ~ISHUH; | |
| 83 msg("you feel less confused now"); | |
| 84 } | |
| 85 | |
| 86 /* | |
| 87 * unsee: | |
| 88 * Turn off the ability to see invisible | |
| 89 */ | |
| 90 unsee() | |
| 91 { | |
| 92 register THING *th; | |
| 93 | |
| 94 for (th = mlist; th != NULL; th = next(th)) | |
| 95 if (on(*th, ISINVIS) && see_monst(th)) | |
| 96 { | |
| 97 move(th->t_pos.y, th->t_pos.x); | |
| 98 addch(th->t_oldch); | |
| 99 } | |
| 100 player.t_flags &= ~CANSEE; | |
| 101 } | |
| 102 | |
| 103 /* | |
| 104 * sight: | |
| 105 * He gets his sight back | |
| 106 */ | |
| 107 sight() | |
| 108 { | |
| 109 if (on(player, ISBLIND)) | |
| 110 { | |
| 111 extinguish(sight); | |
| 112 player.t_flags &= ~ISBLIND; | |
| 113 if (!(proom->r_flags & ISGONE)) | |
| 114 enter_room(&hero); | |
| 115 msg("the veil of darkness lifts"); | |
| 116 } | |
| 117 } | |
| 118 | |
| 119 /* | |
| 120 * nohaste: | |
| 121 * End the hasting | |
| 122 */ | |
| 123 nohaste() | |
| 124 { | |
| 125 player.t_flags &= ~ISHASTE; | |
| 126 msg("you feel yourself slowing down"); | |
| 127 } | |
| 128 | |
| 129 /* | |
| 130 * stomach: | |
| 131 * Digest the hero's food | |
| 132 */ | |
| 133 stomach() | |
| 134 { | |
| 135 register int oldfood; | |
| 136 | |
| 137 if (food_left <= 0) | |
| 138 { | |
| 139 if (food_left-- < -STARVETIME) | |
| 140 death('s'); | |
| 141 /* | |
| 142 * the hero is fainting | |
| 143 */ | |
| 144 if (no_command || rnd(5) != 0) | |
| 145 return; | |
| 146 no_command += rnd(8) + 4; | |
| 147 player.t_flags &= ~ISRUN; | |
| 148 running = FALSE; | |
| 149 count = 0; | |
| 150 hungry_state = 3; | |
| 151 if (!terse) | |
| 152 addmsg("you feel too weak from lack of food. "); | |
| 153 msg("You faint"); | |
| 154 } | |
| 155 else | |
| 156 { | |
| 157 oldfood = food_left; | |
| 158 food_left -= ring_eat(LEFT) + ring_eat(RIGHT) + 1 - amulet; | |
| 159 | |
| 160 if (food_left < MORETIME && oldfood >= MORETIME) | |
| 161 { | |
| 162 hungry_state = 2; | |
| 163 msg("you are starting to feel weak"); | |
| 164 } | |
| 165 else if (food_left < 2 * MORETIME && oldfood >= 2 * MORETIME) | |
| 166 { | |
| 167 hungry_state = 1; | |
| 168 if (!terse) | |
| 169 msg("you are starting to get hungry"); | |
| 170 else | |
| 171 msg("getting hungry"); | |
| 172 } | |
| 173 } | |
| 174 } |
