Mercurial > hg > early-roguelike
comparison rogue5/daemons.c @ 33:f502bf60e6e4
Import Rogue 5.4 from the Roguelike Restoration Project (r1490)
| author | elwin | 
|---|---|
| date | Mon, 24 May 2010 20:10:59 +0000 | 
| parents | |
| children | 
   comparison
  equal
  deleted
  inserted
  replaced
| 32:2dcd75e6a736 | 33:f502bf60e6e4 | 
|---|---|
| 1 /* | |
| 2 * All the daemon and fuse functions are in here | |
| 3 * | |
| 4 * @(#)daemons.c 4.24 (Berkeley) 02/05/99 | |
| 5 * | |
| 6 * Rogue: Exploring the Dungeons of Doom | |
| 7 * Copyright (C) 1980-1983, 1985, 1999 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 /* | |
| 17 * doctor: | |
| 18 * A healing daemon that restors hit points after rest | |
| 19 */ | |
| 20 void | |
| 21 doctor(void) | |
| 22 { | |
| 23 int lv, ohp; | |
| 24 | |
| 25 lv = pstats.s_lvl; | |
| 26 ohp = pstats.s_hpt; | |
| 27 quiet++; | |
| 28 if (lv < 8) | |
| 29 { | |
| 30 if (quiet + (lv << 1) > 20) | |
| 31 pstats.s_hpt++; | |
| 32 } | |
| 33 else | |
| 34 if (quiet >= 3) | |
| 35 pstats.s_hpt += rnd(lv - 7) + 1; | |
| 36 if (ISRING(LEFT, R_REGEN)) | |
| 37 pstats.s_hpt++; | |
| 38 if (ISRING(RIGHT, R_REGEN)) | |
| 39 pstats.s_hpt++; | |
| 40 if (ohp != pstats.s_hpt) | |
| 41 { | |
| 42 if (pstats.s_hpt > max_hp) | |
| 43 pstats.s_hpt = max_hp; | |
| 44 quiet = 0; | |
| 45 } | |
| 46 } | |
| 47 | |
| 48 /* | |
| 49 * Swander: | |
| 50 * Called when it is time to start rolling for wandering monsters | |
| 51 */ | |
| 52 void | |
| 53 swander(void) | |
| 54 { | |
| 55 start_daemon(rollwand, 0, BEFORE); | |
| 56 } | |
| 57 | |
| 58 /* | |
| 59 * rollwand: | |
| 60 * Called to roll to see if a wandering monster starts up | |
| 61 */ | |
| 62 | |
| 63 void | |
| 64 rollwand(void) | |
| 65 { | |
| 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 %s now", choose_str("trippy", "confused")); | |
| 88 } | |
| 89 | |
| 90 /* | |
| 91 * unsee: | |
| 92 * Turn off the ability to see invisible | |
| 93 */ | |
| 94 void | |
| 95 unsee(void) | |
| 96 { | |
| 97 THING *th; | |
| 98 | |
| 99 for (th = mlist; th != NULL; th = next(th)) | |
| 100 if (on(*th, ISINVIS) && see_monst(th)) | |
| 101 mvaddch(th->t_pos.y, th->t_pos.x, th->t_oldch); | |
| 102 player.t_flags &= ~CANSEE; | |
| 103 } | |
| 104 | |
| 105 /* | |
| 106 * sight: | |
| 107 * He gets his sight back | |
| 108 */ | |
| 109 void | |
| 110 sight(void) | |
| 111 { | |
| 112 if (on(player, ISBLIND)) | |
| 113 { | |
| 114 extinguish(sight); | |
| 115 player.t_flags &= ~ISBLIND; | |
| 116 if (!(proom->r_flags & ISGONE)) | |
| 117 enter_room(&hero); | |
| 118 msg(choose_str("far out! Everything is all cosmic again", | |
| 119 "the veil of darkness lifts")); | |
| 120 } | |
| 121 } | |
| 122 | |
| 123 /* | |
| 124 * nohaste: | |
| 125 * End the hasting | |
| 126 */ | |
| 127 void | |
| 128 nohaste(void) | |
| 129 { | |
| 130 player.t_flags &= ~ISHASTE; | |
| 131 msg("you feel yourself slowing down"); | |
| 132 } | |
| 133 | |
| 134 /* | |
| 135 * stomach: | |
| 136 * Digest the hero's food | |
| 137 */ | |
| 138 void | |
| 139 stomach(void) | |
| 140 { | |
| 141 int oldfood; | |
| 142 int orig_hungry = hungry_state; | |
| 143 | |
| 144 if (food_left <= 0) | |
| 145 { | |
| 146 if (food_left-- < -STARVETIME) | |
| 147 death('s'); | |
| 148 /* | |
| 149 * the hero is fainting | |
| 150 */ | |
| 151 if (no_command || rnd(5) != 0) | |
| 152 return; | |
| 153 no_command += rnd(8) + 4; | |
| 154 hungry_state = 3; | |
| 155 if (!terse) | |
| 156 addmsg(choose_str("the munchies overpower your motor capabilities. ", | |
| 157 "you feel too weak from lack of food. ")); | |
| 158 msg(choose_str("You freak out", "You faint")); | |
| 159 } | |
| 160 else | |
| 161 { | |
| 162 oldfood = food_left; | |
| 163 food_left -= ring_eat(LEFT) + ring_eat(RIGHT) + 1 - amulet; | |
| 164 | |
| 165 if (food_left < MORETIME && oldfood >= MORETIME) | |
| 166 { | |
| 167 hungry_state = 2; | |
| 168 msg(choose_str("the munchies are interfering with your motor capabilites", | |
| 169 "you are starting to feel weak")); | |
| 170 } | |
| 171 else if (food_left < 2 * MORETIME && oldfood >= 2 * MORETIME) | |
| 172 { | |
| 173 hungry_state = 1; | |
| 174 if (terse) | |
| 175 msg(choose_str("getting the munchies", "getting hungry")); | |
| 176 else | |
| 177 msg(choose_str("you are getting the munchies", | |
| 178 "you are starting to get hungry")); | |
| 179 } | |
| 180 } | |
| 181 if (hungry_state != orig_hungry) { | |
| 182 player.t_flags &= ~ISRUN; | |
| 183 running = FALSE; | |
| 184 to_death = FALSE; | |
| 185 count = 0; | |
| 186 } | |
| 187 } | |
| 188 | |
| 189 /* | |
| 190 * come_down: | |
| 191 * Take the hero down off her acid trip. | |
| 192 */ | |
| 193 void | |
| 194 come_down(void) | |
| 195 { | |
| 196 THING *tp; | |
| 197 int seemonst; | |
| 198 | |
| 199 if (!on(player, ISHALU)) | |
| 200 return; | |
| 201 | |
| 202 kill_daemon(visuals); | |
| 203 player.t_flags &= ~ISHALU; | |
| 204 | |
| 205 if (on(player, ISBLIND)) | |
| 206 return; | |
| 207 | |
| 208 /* | |
| 209 * undo the things | |
| 210 */ | |
| 211 for (tp = lvl_obj; tp != NULL; tp = next(tp)) | |
| 212 if (cansee(tp->o_pos.y, tp->o_pos.x)) | |
| 213 mvaddch(tp->o_pos.y, tp->o_pos.x, tp->o_type); | |
| 214 | |
| 215 /* | |
| 216 * undo the monsters | |
| 217 */ | |
| 218 seemonst = on(player, SEEMONST); | |
| 219 for (tp = mlist; tp != NULL; tp = next(tp)) | |
| 220 { | |
| 221 move(tp->t_pos.y, tp->t_pos.x); | |
| 222 if (cansee(tp->t_pos.y, tp->t_pos.x)) | |
| 223 if (!on(*tp, ISINVIS) || on(player, CANSEE)) | |
| 224 addch(tp->t_disguise); | |
| 225 else | |
| 226 addch(chat(tp->t_pos.y, tp->t_pos.x)); | |
| 227 else if (seemonst) | |
| 228 { | |
| 229 standout(); | |
| 230 addch(tp->t_type); | |
| 231 standend(); | |
| 232 } | |
| 233 } | |
| 234 msg("Everything looks SO boring now."); | |
| 235 } | |
| 236 | |
| 237 /* | |
| 238 * visuals: | |
| 239 * change the characters for the player | |
| 240 */ | |
| 241 void | |
| 242 visuals(void) | |
| 243 { | |
| 244 THING *tp; | |
| 245 int seemonst; | |
| 246 | |
| 247 if (!after || (running && jump)) | |
| 248 return; | |
| 249 /* | |
| 250 * change the things | |
| 251 */ | |
| 252 for (tp = lvl_obj; tp != NULL; tp = next(tp)) | |
| 253 if (cansee(tp->o_pos.y, tp->o_pos.x)) | |
| 254 mvaddch(tp->o_pos.y, tp->o_pos.x, rnd_thing()); | |
| 255 | |
| 256 /* | |
| 257 * change the stairs | |
| 258 */ | |
| 259 if (!seenstairs && cansee(stairs.y, stairs.x)) | |
| 260 mvaddch(stairs.y, stairs.x, rnd_thing()); | |
| 261 | |
| 262 /* | |
| 263 * change the monsters | |
| 264 */ | |
| 265 seemonst = on(player, SEEMONST); | |
| 266 for (tp = mlist; tp != NULL; tp = next(tp)) | |
| 267 { | |
| 268 move(tp->t_pos.y, tp->t_pos.x); | |
| 269 if (see_monst(tp)) | |
| 270 { | |
| 271 if (tp->t_type == 'X' && tp->t_disguise != 'X') | |
| 272 addch(rnd_thing()); | |
| 273 else | |
| 274 addch(rnd(26) + 'A'); | |
| 275 } | |
| 276 else if (seemonst) | |
| 277 { | |
| 278 standout(); | |
| 279 addch(rnd(26) + 'A'); | |
| 280 standend(); | |
| 281 } | |
| 282 } | |
| 283 } | |
| 284 | |
| 285 /* | |
| 286 * land: | |
| 287 * Land from a levitation potion | |
| 288 */ | |
| 289 void | |
| 290 land(void) | |
| 291 { | |
| 292 player.t_flags &= ~ISLEVIT; | |
| 293 msg(choose_str("bummer! You've hit the ground", | |
| 294 "you float gently to the ground")); | |
| 295 } | 
