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