Clean up:
[dragonfly.git] / games / larn / regen.c
CommitLineData
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 $ */
1de703da 3/* $DragonFly: src/games/larn/regen.c,v 1.2 2003/06/17 04:25:24 dillon Exp $ */
984263bc
MD
4#include "header.h"
5/*
6 *******
7 REGEN()
8 *******
9 regen()
10
11 subroutine to regenerate player hp and spells
12 */
13regen()
14 {
15 int i,flag;
16 long *d;
17 d = c;
18#ifdef EXTRA
19 d[MOVESMADE]++;
20#endif
21 if (d[TIMESTOP]) { if(--d[TIMESTOP]<=0) bottomline(); return; } /* for stop time spell */
22 flag=0;
23
24 if (d[STRENGTH]<3) { d[STRENGTH]=3; flag=1; }
25 if ((d[HASTESELF]==0) || ((d[HASTESELF] & 1) == 0))
26 gtime++;
27
28 if (d[HP] != d[HPMAX])
29 if (d[REGENCOUNTER]-- <= 0) /* regenerate hit points */
30 {
31 d[REGENCOUNTER] = 22 + (d[HARDGAME]<<1) - d[LEVEL];
32 if ((d[HP] += d[REGEN]) > d[HPMAX]) d[HP] = d[HPMAX];
33 bottomhp();
34 }
35
36 if (d[SPELLS] < d[SPELLMAX]) /* regenerate spells */
37 if (d[ECOUNTER]-- <= 0)
38 {
39 d[ECOUNTER] = 100+4*(d[HARDGAME]-d[LEVEL]-d[ENERGY]);
40 d[SPELLS]++; bottomspell();
41 }
42
43 if (d[HERO]) if (--d[HERO]<=0) { for (i=0; i<6; i++) d[i] -= 10; flag=1; }
44 if (d[ALTPRO]) if (--d[ALTPRO]<=0) { d[MOREDEFENSES]-=3; flag=1; }
45 if (d[PROTECTIONTIME]) if (--d[PROTECTIONTIME]<=0) { d[MOREDEFENSES]-=2; flag=1; }
46 if (d[DEXCOUNT]) if (--d[DEXCOUNT]<=0) { d[DEXTERITY]-=3; flag=1; }
47 if (d[STRCOUNT]) if (--d[STRCOUNT]<=0) { d[STREXTRA]-=3; flag=1; }
48 if (d[BLINDCOUNT]) if (--d[BLINDCOUNT]<=0) { cursors(); lprcat("\nThe blindness lifts "); beep(); }
49 if (d[CONFUSE]) if (--d[CONFUSE]<=0) { cursors(); lprcat("\nYou regain your senses"); beep(); }
50 if (d[GIANTSTR]) if (--d[GIANTSTR]<=0) { d[STREXTRA] -= 20; flag=1; }
51 if (d[CHARMCOUNT]) if ((--d[CHARMCOUNT]) <= 0) flag=1;
52 if (d[INVISIBILITY]) if ((--d[INVISIBILITY]) <= 0) flag=1;
53 if (d[CANCELLATION]) if ((--d[CANCELLATION]) <= 0) flag=1;
54 if (d[WTW]) if ((--d[WTW]) <= 0) flag=1;
55 if (d[HASTESELF]) if ((--d[HASTESELF]) <= 0) flag=1;
56 if (d[AGGRAVATE]) --d[AGGRAVATE];
57 if (d[SCAREMONST]) if ((--d[SCAREMONST]) <= 0) flag=1;
58 if (d[STEALTH]) if ((--d[STEALTH]) <= 0) flag=1;
59 if (d[AWARENESS]) --d[AWARENESS];
60 if (d[HOLDMONST]) if ((--d[HOLDMONST]) <= 0) flag=1;
61 if (d[HASTEMONST]) --d[HASTEMONST];
62 if (d[FIRERESISTANCE]) if ((--d[FIRERESISTANCE]) <= 0) flag=1;
63 if (d[GLOBE]) if (--d[GLOBE]<=0) { d[MOREDEFENSES]-=10; flag=1; }
64 if (d[SPIRITPRO]) if (--d[SPIRITPRO] <= 0) flag=1;
65 if (d[UNDEADPRO]) if (--d[UNDEADPRO] <= 0) flag=1;
66 if (d[HALFDAM]) if (--d[HALFDAM]<=0) { cursors(); lprcat("\nYou now feel better "); beep(); }
67 if (d[SEEINVISIBLE])
68 if (--d[SEEINVISIBLE]<=0)
69 { monstnamelist[INVISIBLESTALKER] = ' ';
70 cursors(); lprcat("\nYou feel your vision return to normal"); beep(); }
71 if (d[ITCHING])
72 {
73 if (d[ITCHING]>1)
74 if ((d[WEAR]!= -1) || (d[SHIELD]!= -1))
75 if (rnd(100)<50)
76 {
77 d[WEAR]=d[SHIELD]= -1; cursors();
78 lprcat("\nThe hysteria of itching forces you to remove your armor!");
79 beep(); recalc(); bottomline();
80 }
81 if (--d[ITCHING]<=0) { cursors(); lprcat("\nYou now feel the irritation subside!"); beep(); }
82 }
83 if (d[CLUMSINESS])
84 {
85 if (d[WIELD] != -1)
86 if (d[CLUMSINESS]>1)
87 if (item[playerx][playery]==0) /* only if nothing there */
88 if (rnd(100)<33) /* drop your weapon due to clumsiness */
89 drop_object((int)d[WIELD]);
90 if (--d[CLUMSINESS]<=0) { cursors(); lprcat("\nYou now feel less awkward!"); beep(); }
91 }
92 if (flag) bottomline();
93 }
94