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

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

Revision 1.12, Tue Jun 19 05:30:43 2012 UTC (11 years, 10 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-3-RELEASE, netbsd-9-2-RELEASE, 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
Changes since 1.11: +9 -13 lines

WARNS=5

/*	$NetBSD: moreobj.c,v 1.12 2012/06/19 05:30:43 dholland Exp $	*/

/*
 * moreobj.c 		Larn is copyrighted 1986 by Noah Morgan.
 * 
 * Routines in this file:
 * 
 * oaltar() othrone() ochest() ofountain()
 */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: moreobj.c,v 1.12 2012/06/19 05:30:43 dholland Exp $");
#endif				/* not lint */
#include <stdlib.h>
#include <unistd.h>
#include "header.h"
#include "extern.h"

static void fch(int, long *);

/*
 *	subroutine to process an altar object
 */
void
oaltar(void)
{

	lprcat("\nDo you (p) pray  (d) desecrate");
	iopts();
	while (1) {
		while (1)
			switch (ttgetch()) {
			case 'p':
				lprcat(" pray\nDo you (m) give money or (j) just pray? ");
				while (1)
					switch (ttgetch()) {
					case 'j':
						act_just_pray();
						return;

					case 'm':
						act_donation_pray();
						return;

					case '\33':
						return;
					};

			case 'd':
				lprcat(" desecrate");
				act_desecrate_altar();
				return;

			case 'i':
			case '\33':
				ignore();
				act_ignore_altar();
				return;
			};
	}
}

/*
	subroutine to process a throne object
 */
void
othrone(int arg)
{

	lprcat("\nDo you (p) pry off jewels, (s) sit down");
	iopts();
	while (1) {
		while (1)
			switch (ttgetch()) {
			case 'p':
				lprcat(" pry off");
				act_remove_gems(arg);
				return;

			case 's':
				lprcat(" sit down");
				act_sit_throne(arg);
				return;

			case 'i':
			case '\33':
				ignore();
				return;
			};
	}
}

void
odeadthrone(void)
{
	int    k;

	lprcat("\nDo you (s) sit down");
	iopts();
	while (1) {
		while (1)
			switch (ttgetch()) {
			case 's':
				lprcat(" sit down");
				k = rnd(101);
				if (k < 35) {
					lprcat("\nZaaaappp!  You've been teleported!\n");
					beep();
					oteleport(0);
				} else
					lprcat("\nnothing happens");
				return;

			case 'i':
			case '\33':
				ignore();
				return;
			};
	}
}

/*
	subroutine to process a throne object
 */
void
ochest(void)
{

	lprcat("\nDo you (t) take it, (o) try to open it");
	iopts();
	while (1) {
		while (1)
			switch (ttgetch()) {
			case 'o':
				lprcat(" open it");
				act_open_chest(playerx, playery);
				return;

			case 't':
				lprcat(" take");
				if (take(OCHEST, iarg[playerx][playery]) == 0)
					item[playerx][playery] = know[playerx][playery] = 0;
				return;

			case 'i':
			case '\33':
				ignore();
				return;
			};
	}
}

/*
	process a fountain object
 */
void
ofountain(void)
{

	cursors();
	lprcat("\nDo you (d) drink, (w) wash yourself");
	iopts();
	while (1)
		switch (ttgetch()) {
		case 'd':
			lprcat("drink");
			act_drink_fountain();
			return;

		case '\33':
		case 'i':
			ignore();
			return;

		case 'w':
			lprcat("wash yourself");
			act_wash_fountain();
			return;
		}
}

/*
	***
	FCH
	***

	subroutine to process an up/down of a character attribute for ofountain
 */
static void
fch(int how, long *x)
{
	if (how < 0) {
		lprcat(" went down by one!");
		--(*x);
	} else {
		lprcat(" went up by one!");
		(*x)++;
	}
	bottomline();
}

/*
	a subroutine to raise or lower character levels
	if x > 0 they are raised   if x < 0 they are lowered
 */
void
fntchange(int how)
{
	long   j;
	lprc('\n');
	switch (rnd(9)) {
	case 1:
		lprcat("Your strength");
		fch(how, &c[0]);
		break;
	case 2:
		lprcat("Your intelligence");
		fch(how, &c[1]);
		break;
	case 3:
		lprcat("Your wisdom");
		fch(how, &c[2]);
		break;
	case 4:
		lprcat("Your constitution");
		fch(how, &c[3]);
		break;
	case 5:
		lprcat("Your dexterity");
		fch(how, &c[4]);
		break;
	case 6:
		lprcat("Your charm");
		fch(how, &c[5]);
		break;
	case 7:
		j = rnd(level + 1);
		if (how < 0) {
			lprintf("You lose %ld hit point", (long) j);
			if (j > 1)
				lprcat("s!");
			else
				lprc('!');
			losemhp((int) j);
		} else {
			lprintf("You gain %ld hit point", (long) j);
			if (j > 1)
				lprcat("s!");
			else
				lprc('!');
			raisemhp((int) j);
		}
		bottomline();
		break;

	case 8:
		j = rnd(level + 1);
		if (how > 0) {
			lprintf("You just gained %ld spell", (long) j);
			raisemspells((int) j);
			if (j > 1)
				lprcat("s!");
			else
				lprc('!');
		} else {
			lprintf("You just lost %ld spell", (long) j);
			losemspells((int) j);
			if (j > 1)
				lprcat("s!");
			else
				lprc('!');
		}
		bottomline();
		break;

	case 9:
		j = 5 * rnd((level + 1) * (level + 1));
		if (how < 0) {
			lprintf("You just lost %ld experience point", (long) j);
			if (j > 1)
				lprcat("s!");
			else
				lprc('!');
			loseexperience((long) j);
		} else {
			lprintf("You just gained %ld experience point", (long) j);
			if (j > 1)
				lprcat("s!");
			else
				lprc('!');
			raiseexperience((long) j);
		}
		break;
	}
	cursors();
}