Commit | Line | Data |
---|---|---|
984263bc MD |
1 | /* regen.c Larn is copyrighted 1986 by Noah Morgan. */ |
2 | /* $FreeBSD: src/games/larn/regen.c,v 1.4 1999/11/16 02:57:24 billf Exp $ */ | |
88fe92e6 | 3 | /* $DragonFly: src/games/larn/regen.c,v 1.3 2006/08/26 17:05:05 pavalos Exp $ */ |
984263bc MD |
4 | #include "header.h" |
5 | /* | |
6 | ******* | |
7 | REGEN() | |
8 | ******* | |
9 | regen() | |
10 | ||
11 | subroutine to regenerate player hp and spells | |
12 | */ | |
88fe92e6 PA |
13 | void |
14 | regen(void) | |
6693db17 SW |
15 | { |
16 | int i, flag; | |
984263bc MD |
17 | long *d; |
18 | d = c; | |
19 | #ifdef EXTRA | |
20 | d[MOVESMADE]++; | |
21 | #endif | |
6693db17 SW |
22 | if (d[TIMESTOP]) { |
23 | if (--d[TIMESTOP] <= 0) | |
24 | bottomline(); | |
25 | return; | |
26 | } /* for stop time spell */ | |
27 | flag = 0; | |
984263bc | 28 | |
6693db17 SW |
29 | if (d[STRENGTH] < 3) { |
30 | d[STRENGTH] = 3; | |
31 | flag = 1; | |
32 | } | |
33 | if ((d[HASTESELF] == 0) || ((d[HASTESELF] & 1) == 0)) | |
984263bc MD |
34 | gtime++; |
35 | ||
36 | if (d[HP] != d[HPMAX]) | |
6693db17 SW |
37 | if (d[REGENCOUNTER]-- <= 0) { /* regenerate hit points */ |
38 | d[REGENCOUNTER] = 22 + (d[HARDGAME] << 1) - d[LEVEL]; | |
39 | if ((d[HP] += d[REGEN]) > d[HPMAX]) | |
40 | d[HP] = d[HPMAX]; | |
984263bc | 41 | bottomhp(); |
6693db17 | 42 | } |
984263bc | 43 | |
6693db17 SW |
44 | if (d[SPELLS] < d[SPELLMAX]) /* regenerate spells */ |
45 | if (d[ECOUNTER]-- <= 0) { | |
46 | d[ECOUNTER] = 100 + 4 * (d[HARDGAME] - d[LEVEL] - d[ENERGY]); | |
47 | d[SPELLS]++; | |
48 | bottomspell(); | |
49 | } | |
984263bc | 50 | |
6693db17 SW |
51 | if (d[HERO]) |
52 | if (--d[HERO] <= 0) { | |
53 | for (i = 0; i < 6; i++) | |
54 | d[i] -= 10; | |
55 | flag = 1; | |
56 | } | |
57 | if (d[ALTPRO]) | |
58 | if (--d[ALTPRO] <= 0) { | |
59 | d[MOREDEFENSES] -= 3; | |
60 | flag = 1; | |
61 | } | |
62 | if (d[PROTECTIONTIME]) | |
63 | if (--d[PROTECTIONTIME] <= 0) { | |
64 | d[MOREDEFENSES] -= 2; | |
65 | flag = 1; | |
66 | } | |
67 | if (d[DEXCOUNT]) | |
68 | if (--d[DEXCOUNT] <= 0) { | |
69 | d[DEXTERITY] -= 3; | |
70 | flag = 1; | |
71 | } | |
72 | if (d[STRCOUNT]) | |
73 | if (--d[STRCOUNT] <= 0) { | |
74 | d[STREXTRA] -= 3; | |
75 | flag = 1; | |
76 | } | |
77 | if (d[BLINDCOUNT]) | |
78 | if (--d[BLINDCOUNT] <= 0) { | |
79 | cursors(); | |
80 | lprcat("\nThe blindness lifts "); | |
81 | beep(); | |
82 | } | |
83 | if (d[CONFUSE]) | |
84 | if (--d[CONFUSE] <= 0) { | |
85 | cursors(); | |
86 | lprcat("\nYou regain your senses"); | |
87 | beep(); | |
88 | } | |
89 | if (d[GIANTSTR]) | |
90 | if (--d[GIANTSTR] <= 0) { | |
91 | d[STREXTRA] -= 20; | |
92 | flag = 1; | |
93 | } | |
94 | if (d[CHARMCOUNT]) | |
95 | if ((--d[CHARMCOUNT]) <= 0) | |
96 | flag = 1; | |
97 | if (d[INVISIBILITY]) | |
98 | if ((--d[INVISIBILITY]) <= 0) | |
99 | flag = 1; | |
100 | if (d[CANCELLATION]) | |
101 | if ((--d[CANCELLATION]) <= 0) | |
102 | flag = 1; | |
103 | if (d[WTW]) | |
104 | if ((--d[WTW]) <= 0) | |
105 | flag = 1; | |
106 | if (d[HASTESELF]) | |
107 | if ((--d[HASTESELF]) <= 0) | |
108 | flag = 1; | |
109 | if (d[AGGRAVATE]) | |
110 | --d[AGGRAVATE]; | |
111 | if (d[SCAREMONST]) | |
112 | if ((--d[SCAREMONST]) <= 0) | |
113 | flag = 1; | |
114 | if (d[STEALTH]) | |
115 | if ((--d[STEALTH]) <= 0) | |
116 | flag = 1; | |
117 | if (d[AWARENESS]) | |
118 | --d[AWARENESS]; | |
119 | if (d[HOLDMONST]) | |
120 | if ((--d[HOLDMONST]) <= 0) | |
121 | flag = 1; | |
122 | if (d[HASTEMONST]) | |
123 | --d[HASTEMONST]; | |
124 | if (d[FIRERESISTANCE]) | |
125 | if ((--d[FIRERESISTANCE]) <= 0) | |
126 | flag = 1; | |
127 | if (d[GLOBE]) | |
128 | if (--d[GLOBE] <= 0) { | |
129 | d[MOREDEFENSES] -= 10; | |
130 | flag = 1; | |
131 | } | |
132 | if (d[SPIRITPRO]) | |
133 | if (--d[SPIRITPRO] <= 0) | |
134 | flag = 1; | |
135 | if (d[UNDEADPRO]) | |
136 | if (--d[UNDEADPRO] <= 0) | |
137 | flag = 1; | |
138 | if (d[HALFDAM]) | |
139 | if (--d[HALFDAM] <= 0) { | |
140 | cursors(); | |
141 | lprcat("\nYou now feel better "); | |
142 | beep(); | |
143 | } | |
984263bc | 144 | if (d[SEEINVISIBLE]) |
6693db17 SW |
145 | if (--d[SEEINVISIBLE] <= 0) { |
146 | monstnamelist[INVISIBLESTALKER] = ' '; | |
147 | cursors(); | |
148 | lprcat("\nYou feel your vision return to normal"); | |
149 | beep(); | |
150 | } | |
151 | if (d[ITCHING]) { | |
152 | if (d[ITCHING] > 1) | |
153 | if ((d[WEAR] != -1) || (d[SHIELD] != -1)) | |
154 | if (rnd(100) < 50) { | |
155 | d[WEAR] = d[SHIELD] = -1; | |
156 | cursors(); | |
984263bc | 157 | lprcat("\nThe hysteria of itching forces you to remove your armor!"); |
6693db17 SW |
158 | beep(); |
159 | recalc(); | |
160 | bottomline(); | |
161 | } | |
162 | if (--d[ITCHING] <= 0) { | |
163 | cursors(); | |
164 | lprcat("\nYou now feel the irritation subside!"); | |
165 | beep(); | |
984263bc | 166 | } |
6693db17 SW |
167 | } |
168 | if (d[CLUMSINESS]) { | |
984263bc | 169 | if (d[WIELD] != -1) |
6693db17 SW |
170 | if (d[CLUMSINESS] > 1) |
171 | if (item[playerx][playery] == 0) /* only if nothing there */ | |
172 | if (rnd(100) < 33) /* drop your weapon due to clumsiness */ | |
173 | drop_object((int)d[WIELD]); | |
174 | if (--d[CLUMSINESS] <= 0) { | |
175 | cursors(); | |
176 | lprcat("\nYou now feel less awkward!"); | |
177 | beep(); | |
984263bc | 178 | } |
984263bc | 179 | } |
6693db17 SW |
180 | if (flag) |
181 | bottomline(); | |
182 | } |