comparison arogue5/daemons.c @ 63:0ed67132cf10

Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
author elwin
date Thu, 09 Aug 2012 22:58:48 +0000
parents
children f2951c4e28d9
comparison
equal deleted inserted replaced
62:0ef99244acb8 63:0ed67132cf10
1 /*
2 * All the daemon and fuse functions are in here
3 *
4 * Advanced Rogue
5 * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
6 * All rights reserved.
7 *
8 * Based on "Rogue: Exploring the Dungeons of Doom"
9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
10 * All rights reserved.
11 *
12 * See the file LICENSE.TXT for full copyright and licensing information.
13 */
14
15 #include "curses.h"
16 #include "rogue.h"
17
18 int between = 0;
19
20 /*
21 * doctor:
22 * A healing daemon that restors hit points after rest
23 */
24
25 doctor(tp)
26 register struct thing *tp;
27 {
28 register int ohp;
29 register int limit, new_points;
30 register struct stats *curp; /* current stats pointer */
31 register struct stats *maxp; /* max stats pointer */
32
33 curp = &(tp->t_stats);
34 maxp = &(tp->maxstats);
35 if (curp->s_hpt == maxp->s_hpt) {
36 tp->t_quiet = 0;
37 return;
38 }
39 tp->t_quiet++;
40 switch (tp->t_ctype) {
41 case C_MAGICIAN:
42 limit = 8 - curp->s_lvl;
43 new_points = curp->s_lvl - 3;
44 when C_THIEF:
45 limit = 8 - curp->s_lvl;
46 new_points = curp->s_lvl - 2;
47 when C_CLERIC:
48 limit = 8 - curp->s_lvl;
49 new_points = curp->s_lvl - 3;
50 when C_FIGHTER:
51 limit = 16 - curp->s_lvl*2;
52 new_points = curp->s_lvl - 5;
53 when C_MONSTER:
54 limit = 16 - curp->s_lvl;
55 new_points = curp->s_lvl - 6;
56 otherwise:
57 debug("what a strange character you are!");
58 return;
59 }
60 ohp = curp->s_hpt;
61 if (off(*tp, HASDISEASE) && off(*tp, DOROT)) {
62 if (curp->s_lvl < 8) {
63 if (tp->t_quiet > limit) {
64 curp->s_hpt++;
65 tp->t_quiet = 0;
66 }
67 }
68 else {
69 if (tp->t_quiet >= 3) {
70 curp->s_hpt += rnd(new_points)+1;
71 tp->t_quiet = 0;
72 }
73 }
74 }
75 if (tp == &player) {
76 if (ISRING(LEFT_1, R_REGEN)) curp->s_hpt++;
77 if (ISRING(LEFT_2, R_REGEN)) curp->s_hpt++;
78 if (ISRING(LEFT_3, R_REGEN)) curp->s_hpt++;
79 if (ISRING(LEFT_4, R_REGEN)) curp->s_hpt++;
80 if (ISRING(RIGHT_1, R_REGEN)) curp->s_hpt++;
81 if (ISRING(RIGHT_2, R_REGEN)) curp->s_hpt++;
82 if (ISRING(RIGHT_3, R_REGEN)) curp->s_hpt++;
83 if (ISRING(RIGHT_4, R_REGEN)) curp->s_hpt++;
84 }
85 if (on(*tp, ISREGEN))
86 curp->s_hpt += curp->s_lvl/10 + 1;
87 if (ohp != curp->s_hpt) {
88 if (curp->s_hpt >= maxp->s_hpt) {
89 curp->s_hpt = maxp->s_hpt;
90 if (off(*tp, WASTURNED) && on(*tp, ISFLEE) && tp != &player) {
91 turn_off(*tp, ISFLEE);
92 tp->t_oldpos = tp->t_pos; /* Start our trek over */
93 }
94 }
95 }
96 }
97
98 /*
99 * Swander:
100 * Called when it is time to start rolling for wandering monsters
101 */
102
103 swander()
104 {
105 daemon(rollwand, 0, BEFORE);
106 }
107
108 /*
109 * rollwand:
110 * Called to roll to see if a wandering monster starts up
111 */
112
113 rollwand()
114 {
115 if (++between >= 4)
116 {
117 /* Theives may not awaken a monster */
118 if ((roll(1, 6) == 4) &&
119 ((player.t_ctype != C_THIEF) || (rnd(30) >= dex_compute()))) {
120 if (levtype != POSTLEV)
121 wanderer();
122 kill_daemon(rollwand);
123 fuse(swander, 0, WANDERTIME, BEFORE);
124 }
125 between = 0;
126 }
127 }
128 /*
129 * this function is a daemon called each turn when the character is a thief
130 */
131 trap_look()
132 {
133 if (rnd(100) < (2*dex_compute() + 5*pstats.s_lvl))
134 search(TRUE, FALSE);
135 }
136
137 /*
138 * unconfuse:
139 * Release the poor player from his confusion
140 */
141
142 unconfuse()
143 {
144 turn_off(player, ISHUH);
145 msg("You feel less confused now");
146 }
147
148
149 /*
150 * unsee:
151 * He lost his see invisible power
152 */
153
154 unsee()
155 {
156 if (!ISWEARING(R_SEEINVIS)) {
157 turn_off(player, CANSEE);
158 msg("The tingling feeling leaves your eyes");
159 }
160 }
161
162 /*
163 * unstink:
164 * Remove to-hit handicap from player
165 */
166
167 unstink()
168 {
169 turn_off(player, HASSTINK);
170 }
171
172 /*
173 * unclrhead:
174 * Player is no longer immune to confusion
175 */
176
177 unclrhead()
178 {
179 turn_off(player, ISCLEAR);
180 msg("The blue aura about your head fades away.");