[BACK]Return to regen.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / games / larn

File: [cvs.NetBSD.org] / src / games / larn / regen.c (download)

Revision 1.6, Tue Jun 19 05:30:44 2012 UTC (8 years, 4 months ago) by dholland
Branch: MAIN
CVS Tags: yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-9-base, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, is-mlppp-base, is-mlppp, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, agc-symver-base, agc-symver, HEAD
Changes since 1.5: +3 -3 lines

WARNS=5

/*	$NetBSD: regen.c,v 1.6 2012/06/19 05:30:44 dholland Exp $	*/

/* regen.c 			Larn is copyrighted 1986 by Noah Morgan. */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: regen.c,v 1.6 2012/06/19 05:30:44 dholland Exp $");
#endif				/* not lint */

#include "header.h"
#include "extern.h"
/*
	*******
	REGEN()
	*******
	regen()

	subroutine to regenerate player hp and spells
 */
void
regen(void)
{
	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[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];
			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[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[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 (flag)
		bottomline();
}