summaryrefslogtreecommitdiffstats
path: root/larn/regen.c
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>1997-10-18 20:03:05 +0000
committerchristos <christos@NetBSD.org>1997-10-18 20:03:05 +0000
commitf73f1009084e75624e3bc00fef9cf4749de80dcc (patch)
tree10cc39737f667f056c5537c3fba7cf4d2a832c9d /larn/regen.c
parent39d5db4411fe42946cd3d94eb7d275f3f453d6aa (diff)
downloadbsdgames-darwin-f73f1009084e75624e3bc00fef9cf4749de80dcc.tar.gz
bsdgames-darwin-f73f1009084e75624e3bc00fef9cf4749de80dcc.tar.zst
bsdgames-darwin-f73f1009084e75624e3bc00fef9cf4749de80dcc.zip
Tons of changes; re-indent, use termios, fix warnings, add prototypes...
Games is almost clean; only hack is left...
Diffstat (limited to 'larn/regen.c')
-rw-r--r--larn/regen.c231
1 files changed, 161 insertions, 70 deletions
diff --git a/larn/regen.c b/larn/regen.c
index 1bfe7b6b..efeefca5 100644
--- a/larn/regen.c
+++ b/larn/regen.c
@@ -1,9 +1,13 @@
-#ifndef lint
-static char rcsid[] = "$NetBSD: regen.c,v 1.4 1997/07/13 20:21:39 christos Exp $";
-#endif /* not lint */
+/* $NetBSD: regen.c,v 1.5 1997/10/18 20:03:43 christos Exp $ */
/* regen.c Larn is copyrighted 1986 by Noah Morgan. */
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: regen.c,v 1.5 1997/10/18 20:03:43 christos Exp $");
+#endif /* not lint */
+
#include "header.h"
+#include "extern.h"
/*
*******
REGEN()
@@ -12,85 +16,172 @@ static char rcsid[] = "$NetBSD: regen.c,v 1.4 1997/07/13 20:21:39 christos Exp $
subroutine to regenerate player hp and spells
*/
+void
regen()
- {
- register int i,flag;
- register long *d;
+{
+ int i, flag;
+ long *d;
d = c;
#ifdef EXTRA
d[MOVESMADE]++;
#endif
- if (d[TIMESTOP]) { if(--d[TIMESTOP]<=0) bottomline(); return; } /* for stop time spell */
- flag=0;
+ if (d[TIMESTOP]) {
+ if (--d[TIMESTOP] <= 0)
+ bottomline();
+ return;
+ } /* for stop time spell */
+ flag = 0;
- if (d[STRENGTH]<3) { d[STRENGTH]=3; flag=1; }
- if ((d[HASTESELF]==0) || ((d[HASTESELF] & 1) == 0))
+ if (d[STRENGTH] < 3) {
+ d[STRENGTH] = 3;
+ flag = 1;
+ }
+ if ((d[HASTESELF] == 0) || ((d[HASTESELF] & 1) == 0))
gltime++;
if (d[HP] != d[HPMAX])
- if (d[REGENCOUNTER]-- <= 0) /* regenerate hit points */
- {
- d[REGENCOUNTER] = 22 + (d[HARDGAME]<<1) - d[LEVEL];
- if ((d[HP] += d[REGEN]) > d[HPMAX]) d[HP] = d[HPMAX];
+ if (d[REGENCOUNTER]-- <= 0) { /* regenerate hit points */
+ d[REGENCOUNTER] = 22 + (d[HARDGAME] << 1) - d[LEVEL];
+ if ((d[HP] += d[REGEN]) > d[HPMAX])
+ d[HP] = d[HPMAX];
bottomhp();
- }
-
- if (d[SPELLS] < d[SPELLMAX]) /* regenerate spells */
- if (d[ECOUNTER]-- <= 0)
- {
- d[ECOUNTER] = 100+4*(d[HARDGAME]-d[LEVEL]-d[ENERGY]);
- d[SPELLS]++; bottomspell();
- }
-
- if (d[HERO]) if (--d[HERO]<=0) { for (i=0; i<6; i++) d[i] -= 10; flag=1; }
- if (d[ALTPRO]) if (--d[ALTPRO]<=0) { d[MOREDEFENSES]-=3; flag=1; }
- if (d[PROTECTIONTIME]) if (--d[PROTECTIONTIME]<=0) { d[MOREDEFENSES]-=2; flag=1; }
- if (d[DEXCOUNT]) if (--d[DEXCOUNT]<=0) { d[DEXTERITY]-=3; flag=1; }
- if (d[STRCOUNT]) if (--d[STRCOUNT]<=0) { d[STREXTRA]-=3; flag=1; }
- if (d[BLINDCOUNT]) if (--d[BLINDCOUNT]<=0) { cursors(); lprcat("\nThe blindness lifts "); beep(); }
- if (d[CONFUSE]) if (--d[CONFUSE]<=0) { cursors(); lprcat("\nYou regain your senses"); beep(); }
- if (d[GIANTSTR]) if (--d[GIANTSTR]<=0) { d[STREXTRA] -= 20; flag=1; }
- if (d[CHARMCOUNT]) if ((--d[CHARMCOUNT]) <= 0) flag=1;
- if (d[INVISIBILITY]) if ((--d[INVISIBILITY]) <= 0) flag=1;
- if (d[CANCELLATION]) if ((--d[CANCELLATION]) <= 0) flag=1;
- if (d[WTW]) if ((--d[WTW]) <= 0) flag=1;
- if (d[HASTESELF]) if ((--d[HASTESELF]) <= 0) flag=1;
- if (d[AGGRAVATE]) --d[AGGRAVATE];
- if (d[SCAREMONST]) if ((--d[SCAREMONST]) <= 0) flag=1;
- if (d[STEALTH]) if ((--d[STEALTH]) <= 0) flag=1;
- if (d[AWARENESS]) --d[AWARENESS];
- if (d[HOLDMONST]) if ((--d[HOLDMONST]) <= 0) flag=1;
- if (d[HASTEMONST]) --d[HASTEMONST];
- if (d[FIRERESISTANCE]) if ((--d[FIRERESISTANCE]) <= 0) flag=1;
- if (d[GLOBE]) if (--d[GLOBE]<=0) { d[MOREDEFENSES]-=10; flag=1; }
- if (d[SPIRITPRO]) if (--d[SPIRITPRO] <= 0) flag=1;
- if (d[UNDEADPRO]) if (--d[UNDEADPRO] <= 0) flag=1;
- if (d[HALFDAM]) if (--d[HALFDAM]<=0) { cursors(); lprcat("\nYou now feel better "); beep(); }
+ }
+ if (d[SPELLS] < d[SPELLMAX]) /* regenerate spells */
+ if (d[ECOUNTER]-- <= 0) {
+ d[ECOUNTER] = 100 + 4 * (d[HARDGAME] - d[LEVEL] - d[ENERGY]);
+ d[SPELLS]++;
+ bottomspell();
+ }
+ if (d[HERO])
+ if (--d[HERO] <= 0) {
+ for (i = 0; i < 6; i++)
+ d[i] -= 10;
+ flag = 1;
+ }
+ if (d[ALTPRO])
+ if (--d[ALTPRO] <= 0) {
+ d[MOREDEFENSES] -= 3;
+ flag = 1;
+ }
+ if (d[PROTECTIONTIME])
+ if (--d[PROTECTIONTIME] <= 0) {
+ d[MOREDEFENSES] -= 2;
+ flag = 1;
+ }
+ if (d[DEXCOUNT])
+ if (--d[DEXCOUNT] <= 0) {
+ d[DEXTERITY] -= 3;
+ flag = 1;
+ }
+ if (d[STRCOUNT])
+ if (--d[STRCOUNT] <= 0) {
+ d[STREXTRA] -= 3;
+ flag = 1;
+ }
+ if (d[BLINDCOUNT])
+ if (--d[BLINDCOUNT] <= 0) {
+ cursors();
+ lprcat("\nThe blindness lifts ");
+ beep();
+ }
+ if (d[CONFUSE])
+ if (--d[CONFUSE] <= 0) {
+ cursors();
+ lprcat("\nYou regain your senses");
+ beep();
+ }
+ if (d[GIANTSTR])
+ if (--d[GIANTSTR] <= 0) {
+ d[STREXTRA] -= 20;
+ flag = 1;
+ }
+ if (d[CHARMCOUNT])
+ if ((--d[CHARMCOUNT]) <= 0)
+ flag = 1;
+ if (d[INVISIBILITY])
+ if ((--d[INVISIBILITY]) <= 0)
+ flag = 1;
+ if (d[CANCELLATION])
+ if ((--d[CANCELLATION]) <= 0)
+ flag = 1;
+ if (d[WTW])
+ if ((--d[WTW]) <= 0)
+ flag = 1;
+ if (d[HASTESELF])
+ if ((--d[HASTESELF]) <= 0)
+ flag = 1;
+ if (d[AGGRAVATE])
+ --d[AGGRAVATE];
+ if (d[SCAREMONST])
+ if ((--d[SCAREMONST]) <= 0)
+ flag = 1;
+ if (d[STEALTH])
+ if ((--d[STEALTH]) <= 0)
+ flag = 1;
+ if (d[AWARENESS])
+ --d[AWARENESS];
+ if (d[HOLDMONST])
+ if ((--d[HOLDMONST]) <= 0)
+ flag = 1;
+ if (d[HASTEMONST])
+ --d[HASTEMONST];
+ if (d[FIRERESISTANCE])
+ if ((--d[FIRERESISTANCE]) <= 0)
+ flag = 1;
+ if (d[GLOBE])
+ if (--d[GLOBE] <= 0) {
+ d[MOREDEFENSES] -= 10;
+ flag = 1;
+ }
+ if (d[SPIRITPRO])
+ if (--d[SPIRITPRO] <= 0)
+ flag = 1;
+ if (d[UNDEADPRO])
+ if (--d[UNDEADPRO] <= 0)
+ flag = 1;
+ if (d[HALFDAM])
+ if (--d[HALFDAM] <= 0) {
+ cursors();
+ lprcat("\nYou now feel better ");
+ beep();
+ }
if (d[SEEINVISIBLE])
- if (--d[SEEINVISIBLE]<=0)
- { monstnamelist[INVISIBLESTALKER] = ' ';
- cursors(); lprcat("\nYou feel your vision return to normal"); beep(); }
- if (d[ITCHING])
- {
- if (d[ITCHING]>1)
- if ((d[WEAR]!= -1) || (d[SHIELD]!= -1))
- if (rnd(100)<50)
- {
- d[WEAR]=d[SHIELD]= -1; cursors();
- lprcat("\nThe hysteria of itching forces you to remove your armor!");
- beep(); recalc(); bottomline();
- }
- if (--d[ITCHING]<=0) { cursors(); lprcat("\nYou now feel the irritation subside!"); beep(); }
+ if (--d[SEEINVISIBLE] <= 0) {
+ monstnamelist[INVISIBLESTALKER] = ' ';
+ cursors();
+ lprcat("\nYou feel your vision return to normal");
+ beep();
+ }
+ if (d[ITCHING]) {
+ if (d[ITCHING] > 1)
+ if ((d[WEAR] != -1) || (d[SHIELD] != -1))
+ if (rnd(100) < 50) {
+ d[WEAR] = d[SHIELD] = -1;
+ cursors();
+ lprcat("\nThe hysteria of itching forces you to remove your armor!");
+ beep();
+ recalc();
+ bottomline();
+ }
+ if (--d[ITCHING] <= 0) {
+ cursors();
+ lprcat("\nYou now feel the irritation subside!");
+ beep();
}
- if (d[CLUMSINESS])
- {
+ }
+ if (d[CLUMSINESS]) {
if (d[WIELD] != -1)
- if (d[CLUMSINESS]>1)
- if (item[playerx][playery]==0) /* only if nothing there */
- if (rnd(100)<33) /* drop your weapon due to clumsiness */
- drop_object((int)d[WIELD]);
- if (--d[CLUMSINESS]<=0) { cursors(); lprcat("\nYou now feel less awkward!"); beep(); }
+ if (d[CLUMSINESS] > 1)
+ if (item[playerx][playery] == 0) /* only if nothing there */
+ if (rnd(100) < 33) /* drop your weapon due
+ * to clumsiness */
+ drop_object((int) d[WIELD]);
+ if (--d[CLUMSINESS] <= 0) {
+ cursors();
+ lprcat("\nYou now feel less awkward!");
+ beep();
}
- if (flag) bottomline();
}
-
+ if (flag)
+ bottomline();
+}