Home | History | Annotate | Line # | Download | only in phantasia
interplayer.c revision 1.8
      1  1.8     he /*	$NetBSD: interplayer.c,v 1.8 2004/04/11 13:35:06 he Exp $	*/
      2  1.2    cgd 
      3  1.1    jtc /*
      4  1.1    jtc  * interplayer.c - player to player routines for Phantasia
      5  1.1    jtc  */
      6  1.1    jtc 
      7  1.1    jtc #include "include.h"
      8  1.8     he #undef bool
      9  1.7   ross #include <curses.h>
     10  1.1    jtc 
     11  1.3  lukem void
     12  1.1    jtc checkbattle()
     13  1.1    jtc {
     14  1.3  lukem 	long    foeloc = 0L;	/* location in file of person to fight */
     15  1.1    jtc 
     16  1.3  lukem 	Users = 0;
     17  1.5    jsm 	fseek(Playersfp, 0L, SEEK_SET);
     18  1.1    jtc 
     19  1.3  lukem 	while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1) {
     20  1.3  lukem 		if (Other.p_status != S_OFF
     21  1.3  lukem 		    && Other.p_status != S_NOTUSED
     22  1.3  lukem 		    && Other.p_status != S_HUNGUP
     23  1.3  lukem 		    && (Other.p_status != S_CLOAKED || Other.p_specialtype != SC_VALAR))
     24  1.3  lukem 			/* player is on and not a cloaked valar */
     25  1.3  lukem 		{
     26  1.3  lukem 			++Users;
     27  1.3  lukem 
     28  1.3  lukem 			if (Player.p_x == Other.p_x
     29  1.3  lukem 			    && Player.p_y == Other.p_y
     30  1.3  lukem 			/* same coordinates */
     31  1.3  lukem 			    && foeloc != Fileloc
     32  1.3  lukem 			/* not self */
     33  1.3  lukem 			    && Player.p_status == S_PLAYING
     34  1.3  lukem 			    && (Other.p_status == S_PLAYING || Other.p_status == S_INBATTLE)
     35  1.3  lukem 			/* both are playing */
     36  1.3  lukem 			    && Other.p_specialtype != SC_VALAR
     37  1.3  lukem 			    && Player.p_specialtype != SC_VALAR)
     38  1.3  lukem 				/* neither is valar */
     39  1.3  lukem 			{
     40  1.3  lukem 				battleplayer(foeloc);
     41  1.3  lukem 				return;
     42  1.3  lukem 			}
     43  1.1    jtc 		}
     44  1.3  lukem 		foeloc += SZ_PLAYERSTRUCT;
     45  1.1    jtc 	}
     46  1.1    jtc }
     47  1.1    jtc 
     48  1.3  lukem void
     49  1.1    jtc battleplayer(foeplace)
     50  1.3  lukem 	long    foeplace;
     51  1.1    jtc {
     52  1.3  lukem 	double  dtemp;		/* for temporary calculations */
     53  1.3  lukem 	double  oldhits = 0.0;	/* previous damage inflicted by foe */
     54  1.3  lukem 	int     loop;		/* for timing out */
     55  1.3  lukem 	int     ch;		/* input */
     56  1.3  lukem 	short   oldtampered;	/* old value of foe's p_tampered */
     57  1.3  lukem 
     58  1.3  lukem 	Lines = 8;
     59  1.3  lukem 	Luckout = FALSE;
     60  1.3  lukem 	mvaddstr(4, 0, "Preparing for battle!\n");
     61  1.3  lukem 	refresh();
     62  1.1    jtc 
     63  1.1    jtc #ifdef SYS5
     64  1.3  lukem 	flushinp();
     65  1.1    jtc #endif
     66  1.1    jtc 
     67  1.3  lukem 	/* set up variables, file, etc. */
     68  1.3  lukem 	Player.p_status = S_INBATTLE;
     69  1.3  lukem 	Shield = Player.p_energy;
     70  1.3  lukem 
     71  1.3  lukem 	/* if p_tampered is not 0, someone else may try to change it (king,
     72  1.3  lukem 	 * etc.) */
     73  1.3  lukem 	Player.p_tampered = oldtampered = 1;
     74  1.3  lukem 	Player.p_1scratch = 0.0;
     75  1.3  lukem 	Player.p_istat = I_OFF;
     76  1.3  lukem 
     77  1.3  lukem 	readrecord(&Other, foeplace);
     78  1.3  lukem 	if (fabs(Player.p_level - Other.p_level) > 20.0)
     79  1.3  lukem 		/* see if players are greatly mismatched */
     80  1.1    jtc 	{
     81  1.3  lukem 		dtemp = (Player.p_level - Other.p_level) / MAX(Player.p_level, Other.p_level);
     82  1.3  lukem 		if (dtemp < -0.5)
     83  1.3  lukem 			/* foe outweighs this one */
     84  1.3  lukem 			Player.p_speed *= 2.0;
     85  1.1    jtc 	}
     86  1.3  lukem 	writerecord(&Player, Fileloc);	/* write out all our info */
     87  1.1    jtc 
     88  1.3  lukem 	if (Player.p_blindness)
     89  1.3  lukem 		Enemyname = "someone";
     90  1.3  lukem 	else
     91  1.3  lukem 		Enemyname = Other.p_name;
     92  1.1    jtc 
     93  1.3  lukem 	mvprintw(6, 0, "You have encountered %s   Level: %.0f\n", Enemyname, Other.p_level);
     94  1.3  lukem 	refresh();
     95  1.1    jtc 
     96  1.3  lukem 	for (loop = 0; Other.p_status != S_INBATTLE && loop < 30; ++loop)
     97  1.3  lukem 		/* wait for foe to respond */
     98  1.1    jtc 	{
     99  1.3  lukem 		readrecord(&Other, foeplace);
    100  1.3  lukem 		sleep(1);
    101  1.1    jtc 	}
    102  1.1    jtc 
    103  1.3  lukem 	if (Other.p_status != S_INBATTLE)
    104  1.3  lukem 		/* foe did not respond */
    105  1.1    jtc 	{
    106  1.3  lukem 		mvprintw(5, 0, "%s is not responding.\n", Enemyname);
    107  1.3  lukem 		goto LEAVE;
    108  1.1    jtc 	}
    109  1.3  lukem 	/* else, we are ready to battle */
    110  1.1    jtc 
    111  1.3  lukem 	move(4, 0);
    112  1.3  lukem 	clrtoeol();
    113  1.1    jtc 
    114  1.3  lukem 	/*
    115  1.3  lukem          * determine who is first master
    116  1.3  lukem          * if neither player is faster, check level
    117  1.3  lukem          * if neither level is greater, battle is not allowed
    118  1.3  lukem          * (this should never happen, but we have to handle it)
    119  1.3  lukem          */
    120  1.3  lukem 	if (Player.p_speed > Other.p_speed)
    121  1.3  lukem 		Foestrikes = FALSE;
    122  1.1    jtc 	else
    123  1.3  lukem 		if (Other.p_speed > Player.p_speed)
    124  1.3  lukem 			Foestrikes = TRUE;
    125  1.3  lukem 		else
    126  1.3  lukem 			if (Player.p_level > Other.p_level)
    127  1.3  lukem 				Foestrikes = FALSE;
    128  1.3  lukem 			else
    129  1.3  lukem 				if (Other.p_level > Player.p_level)
    130  1.3  lukem 					Foestrikes = TRUE;
    131  1.3  lukem 				else
    132  1.3  lukem 					/* no one is faster */
    133  1.3  lukem 				{
    134  1.3  lukem 					printw("You can't fight %s yet.", Enemyname);
    135  1.3  lukem 					goto LEAVE;
    136  1.3  lukem 				}
    137  1.3  lukem 
    138  1.3  lukem 	for (;;) {
    139  1.3  lukem 		displaystats();
    140  1.3  lukem 		readmessage();
    141  1.3  lukem 		mvprintw(1, 26, "%20.0f", Shield);	/* overprint energy */
    142  1.3  lukem 
    143  1.3  lukem 		if (!Foestrikes)
    144  1.3  lukem 			/* take action against foe */
    145  1.3  lukem 			myturn();
    146  1.3  lukem 		else
    147  1.3  lukem 			/* wait for foe to take action */
    148  1.1    jtc 		{
    149  1.3  lukem 			mvaddstr(4, 0, "Waiting...\n");
    150  1.3  lukem 			clrtoeol();
    151  1.3  lukem 			refresh();
    152  1.3  lukem 
    153  1.3  lukem 			for (loop = 0; loop < 20; ++loop)
    154  1.3  lukem 				/* wait for foe to act */
    155  1.3  lukem 			{
    156  1.3  lukem 				readrecord(&Other, foeplace);
    157  1.3  lukem 				if (Other.p_1scratch != oldhits)
    158  1.3  lukem 					/* p_1scratch changes to indicate
    159  1.3  lukem 					 * action */
    160  1.3  lukem 					break;
    161  1.3  lukem 				else
    162  1.3  lukem 					/* wait and try again */
    163  1.3  lukem 				{
    164  1.3  lukem 					sleep(1);
    165  1.3  lukem 					addch('.');
    166  1.3  lukem 					refresh();
    167  1.3  lukem 				}
    168  1.3  lukem 			}
    169  1.3  lukem 
    170  1.3  lukem 			if (Other.p_1scratch == oldhits) {
    171  1.3  lukem 				/* timeout */
    172  1.3  lukem 				mvaddstr(22, 0, "Timeout: waiting for response.  Do you want to wait ? ");
    173  1.3  lukem 				ch = getanswer("NY", FALSE);
    174  1.3  lukem 				move(22, 0);
    175  1.3  lukem 				clrtobot();
    176  1.3  lukem 				if (ch == 'Y')
    177  1.3  lukem 					continue;
    178  1.3  lukem 				else
    179  1.3  lukem 					break;
    180  1.3  lukem 			} else
    181  1.3  lukem 				/* foe took action */
    182  1.3  lukem 			{
    183  1.3  lukem 				switch (Other.p_istat) {
    184  1.3  lukem 				case I_RAN:	/* foe ran away */
    185  1.3  lukem 					mvprintw(Lines++, 0, "%s ran away!", Enemyname);
    186  1.3  lukem 					break;
    187  1.3  lukem 
    188  1.3  lukem 				case I_STUCK:	/* foe tried to run, but
    189  1.3  lukem 						 * couldn't */
    190  1.3  lukem 					mvprintw(Lines++, 0, "%s tried to run away.", Enemyname);
    191  1.3  lukem 					break;
    192  1.3  lukem 
    193  1.3  lukem 				case I_BLEWIT:	/* foe tried to luckout, but
    194  1.3  lukem 						 * didn't */
    195  1.3  lukem 					mvprintw(Lines++, 0, "%s tried to luckout!", Enemyname);
    196  1.3  lukem 					break;
    197  1.3  lukem 
    198  1.3  lukem 				default:
    199  1.3  lukem 					dtemp = Other.p_1scratch - oldhits;
    200  1.3  lukem 					mvprintw(Lines++, 0, "%s hit you %.0f times!", Enemyname, dtemp);
    201  1.3  lukem 					Shield -= dtemp;
    202  1.3  lukem 					break;
    203  1.3  lukem 				}
    204  1.3  lukem 
    205  1.3  lukem 				oldhits = Other.p_1scratch;	/* keep track of old
    206  1.3  lukem 								 * hits */
    207  1.3  lukem 
    208  1.3  lukem 				if (Other.p_tampered != oldtampered)
    209  1.3  lukem 					/* p_tampered changes to relinquish
    210  1.3  lukem 					 * turn */
    211  1.3  lukem 				{
    212  1.3  lukem 					oldtampered = Other.p_tampered;
    213  1.3  lukem 					Foestrikes = FALSE;
    214  1.3  lukem 				}
    215  1.3  lukem 			}
    216  1.1    jtc 		}
    217  1.1    jtc 
    218  1.3  lukem 		/* decide what happens next */
    219  1.3  lukem 		refresh();
    220  1.3  lukem 		if (Lines > LINES - 2) {
    221  1.3  lukem 			more(Lines);
    222  1.3  lukem 			move(Lines = 8, 0);
    223  1.3  lukem 			clrtobot();
    224  1.3  lukem 		}
    225  1.3  lukem 		if (Other.p_istat == I_KILLED || Shield < 0.0)
    226  1.3  lukem 			/* we died */
    227  1.1    jtc 		{
    228  1.3  lukem 			Shield = -2.0;	/* insure this value is negative */
    229  1.3  lukem 			break;
    230  1.1    jtc 		}
    231  1.3  lukem 		if (Player.p_istat == I_KILLED)
    232  1.3  lukem 			/* we killed foe; award treasre */
    233  1.1    jtc 		{
    234  1.3  lukem 			mvprintw(Lines++, 0, "You killed %s!", Enemyname);
    235  1.3  lukem 			Player.p_experience += Other.p_experience;
    236  1.3  lukem 			Player.p_crowns += (Player.p_level < 1000.0) ? Other.p_crowns : 0;
    237  1.3  lukem 			Player.p_amulets += Other.p_amulets;
    238  1.3  lukem 			Player.p_charms += Other.p_charms;
    239  1.3  lukem 			collecttaxes(Other.p_gold, Other.p_gems);
    240  1.3  lukem 			Player.p_sword = MAX(Player.p_sword, Other.p_sword);
    241  1.3  lukem 			Player.p_shield = MAX(Player.p_shield, Other.p_shield);
    242  1.3  lukem 			Player.p_quksilver = MAX(Player.p_quksilver, Other.p_quksilver);
    243  1.3  lukem 			if (Other.p_virgin && !Player.p_virgin) {
    244  1.3  lukem 				mvaddstr(Lines++, 0, "You have rescued a virgin.  Will you be honorable ? ");
    245  1.3  lukem 				if ((ch = getanswer("YN", FALSE)) == 'Y')
    246  1.3  lukem 					Player.p_virgin = TRUE;
    247  1.3  lukem 				else {
    248  1.3  lukem 					++Player.p_sin;
    249  1.3  lukem 					Player.p_experience += 8000.0;
    250  1.3  lukem 				}
    251  1.3  lukem 			}
    252  1.3  lukem 			sleep(3);	/* give other person time to die */
    253  1.1    jtc 			break;
    254  1.3  lukem 		} else
    255  1.3  lukem 			if (Player.p_istat == I_RAN || Other.p_istat == I_RAN)
    256  1.3  lukem 				/* either player ran away */
    257  1.3  lukem 				break;
    258  1.3  lukem 	}
    259  1.1    jtc 
    260  1.3  lukem LEAVE:
    261  1.3  lukem 	/* clean up things and leave */
    262  1.3  lukem 	writerecord(&Player, Fileloc);	/* update a final time */
    263  1.3  lukem 	altercoordinates(0.0, 0.0, A_NEAR);	/* move away from battle site */
    264  1.3  lukem 	Player.p_energy = Shield;	/* set energy to actual value */
    265  1.3  lukem 	Player.p_tampered = T_OFF;	/* clear p_tampered */
    266  1.1    jtc 
    267  1.3  lukem 	more(Lines);		/* pause */
    268  1.1    jtc 
    269  1.3  lukem 	move(4, 0);
    270  1.3  lukem 	clrtobot();		/* clear bottom area of screen */
    271  1.1    jtc 
    272  1.3  lukem 	if (Player.p_energy < 0.0)
    273  1.3  lukem 		/* we are dead */
    274  1.3  lukem 		death("Interterminal battle");
    275  1.1    jtc }
    276  1.1    jtc 
    277  1.3  lukem void
    278  1.1    jtc myturn()
    279  1.1    jtc {
    280  1.3  lukem 	double  dtemp;		/* for temporary calculations */
    281  1.3  lukem 	int     ch;		/* input */
    282  1.1    jtc 
    283  1.3  lukem 	mvaddstr(7, 0, "1:Fight  2:Run Away!  3:Power Blast  ");
    284  1.3  lukem 	if (Luckout)
    285  1.3  lukem 		clrtoeol();
    286  1.3  lukem 	else
    287  1.3  lukem 		addstr("4:Luckout  ");
    288  1.1    jtc 
    289  1.3  lukem 	ch = inputoption();
    290  1.3  lukem 	move(Lines = 8, 0);
    291  1.3  lukem 	clrtobot();
    292  1.3  lukem 
    293  1.3  lukem 	switch (ch) {
    294  1.3  lukem 	default:		/* fight */
    295  1.3  lukem 		dtemp = ROLL(2.0, Player.p_might);
    296  1.3  lukem HIT:
    297  1.3  lukem 		mvprintw(Lines++, 0, "You hit %s %.0f times!", Enemyname, dtemp);
    298  1.3  lukem 		Player.p_sin += 0.5;
    299  1.3  lukem 		Player.p_1scratch += dtemp;
    300  1.3  lukem 		Player.p_istat = I_OFF;
    301  1.3  lukem 		break;
    302  1.1    jtc 
    303  1.3  lukem 	case '2':		/* run away */
    304  1.3  lukem 		Player.p_1scratch -= 1.0;	/* change this to indicate
    305  1.3  lukem 						 * action */
    306  1.3  lukem 		if (drandom() > 0.25) {
    307  1.3  lukem 			mvaddstr(Lines++, 0, "You got away!");
    308  1.3  lukem 			Player.p_istat = I_RAN;
    309  1.3  lukem 		} else {
    310  1.3  lukem 			mvprintw(Lines++, 0, "%s is still after you!", Enemyname);
    311  1.3  lukem 			Player.p_istat = I_STUCK;
    312  1.1    jtc 		}
    313  1.3  lukem 		break;
    314  1.3  lukem 
    315  1.3  lukem 	case '3':		/* power blast */
    316  1.3  lukem 		dtemp = MIN(Player.p_mana, Player.p_level * 5.0);
    317  1.3  lukem 		Player.p_mana -= dtemp;
    318  1.3  lukem 		dtemp *= (drandom() + 0.5) * Player.p_magiclvl * 0.2 + 2.0;
    319  1.3  lukem 		mvprintw(Lines++, 0, "You blasted %s !", Enemyname);
    320  1.3  lukem 		goto HIT;
    321  1.3  lukem 
    322  1.3  lukem 	case '4':		/* luckout */
    323  1.3  lukem 		if (Luckout || drandom() > 0.1) {
    324  1.3  lukem 			if (Luckout)
    325  1.3  lukem 				mvaddstr(Lines++, 0, "You already tried that!");
    326  1.3  lukem 			else {
    327  1.3  lukem 				mvaddstr(Lines++, 0, "Not this time . . .");
    328  1.3  lukem 				Luckout = TRUE;
    329  1.3  lukem 			}
    330  1.3  lukem 
    331  1.3  lukem 			Player.p_1scratch -= 1.0;
    332  1.3  lukem 			Player.p_istat = I_BLEWIT;
    333  1.3  lukem 		} else {
    334  1.3  lukem 			mvaddstr(Lines++, 0, "You just lucked out!");
    335  1.3  lukem 			Player.p_1scratch = Other.p_energy * 1.1;
    336  1.1    jtc 		}
    337  1.3  lukem 		break;
    338  1.3  lukem 	}
    339  1.1    jtc 
    340  1.3  lukem 	refresh();
    341  1.3  lukem 	Player.p_1scratch = floor(Player.p_1scratch);	/* clean up any mess */
    342  1.1    jtc 
    343  1.3  lukem 	if (Player.p_1scratch > Other.p_energy)
    344  1.3  lukem 		Player.p_istat = I_KILLED;
    345  1.3  lukem 	else
    346  1.3  lukem 		if (drandom() * Player.p_speed < drandom() * Other.p_speed)
    347  1.3  lukem 			/* relinquish control */
    348  1.1    jtc 		{
    349  1.3  lukem 			++Player.p_tampered;
    350  1.3  lukem 			Foestrikes = TRUE;
    351  1.1    jtc 		}
    352  1.3  lukem 	writerecord(&Player, Fileloc);	/* let foe know what we did */
    353  1.1    jtc }
    354  1.1    jtc 
    355  1.3  lukem void
    356  1.1    jtc checktampered()
    357  1.1    jtc {
    358  1.3  lukem 	long    loc = 0L;	/* location in energy void file */
    359  1.1    jtc 
    360  1.3  lukem 	/* first check for energy voids */
    361  1.5    jsm 	fseek(Energyvoidfp, 0L, SEEK_SET);
    362  1.3  lukem 	while (fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp) == 1)
    363  1.3  lukem 		if (Enrgyvoid.ev_active
    364  1.3  lukem 		    && Enrgyvoid.ev_x == Player.p_x
    365  1.3  lukem 		    && Enrgyvoid.ev_y == Player.p_y)
    366  1.3  lukem 			/* sitting on one */
    367  1.3  lukem 		{
    368  1.3  lukem 			if (loc > 0L)
    369  1.3  lukem 				/* not the holy grail; inactivate energy void */
    370  1.3  lukem 			{
    371  1.3  lukem 				Enrgyvoid.ev_active = FALSE;
    372  1.3  lukem 				writevoid(&Enrgyvoid, loc);
    373  1.3  lukem 				tampered(T_NRGVOID, 0.0, 0.0);
    374  1.3  lukem 			} else
    375  1.3  lukem 				if (Player.p_status != S_CLOAKED)
    376  1.3  lukem 					/* holy grail */
    377  1.3  lukem 					tampered(T_GRAIL, 0.0, 0.0);
    378  1.3  lukem 			break;
    379  1.3  lukem 		} else
    380  1.3  lukem 			loc += SZ_VOIDSTRUCT;
    381  1.1    jtc 
    382  1.3  lukem 	/* now check for other things */
    383  1.3  lukem 	readrecord(&Other, Fileloc);
    384  1.3  lukem 	if (Other.p_tampered != T_OFF)
    385  1.3  lukem 		tampered(Other.p_tampered, Other.p_1scratch, Other.p_2scratch);
    386  1.1    jtc }
    387  1.1    jtc 
    388  1.3  lukem void
    389  1.1    jtc tampered(what, arg1, arg2)
    390  1.3  lukem 	int     what;
    391  1.3  lukem 	double  arg1;
    392  1.3  lukem 	double  arg2;
    393  1.1    jtc {
    394  1.3  lukem 	long    loc;		/* location in file of other players */
    395  1.1    jtc 
    396  1.3  lukem 	Changed = TRUE;
    397  1.3  lukem 	move(4, 0);
    398  1.1    jtc 
    399  1.3  lukem 	Player.p_tampered = T_OFF;	/* no longer tampered with */
    400  1.1    jtc 
    401  1.3  lukem 	switch (what) {
    402  1.1    jtc 	case T_NRGVOID:
    403  1.3  lukem 		addstr("You've hit an energy void !\n");
    404  1.3  lukem 		Player.p_mana /= 3.0;
    405  1.3  lukem 		Player.p_energy /= 2.0;
    406  1.3  lukem 		Player.p_gold = floor(Player.p_gold / 1.25) + 0.1;
    407  1.3  lukem 		altercoordinates(0.0, 0.0, A_NEAR);
    408  1.3  lukem 		break;
    409  1.1    jtc 
    410  1.1    jtc 	case T_TRANSPORT:
    411  1.3  lukem 		addstr("The king transported you !  ");
    412  1.3  lukem 		if (Player.p_charms > 0) {
    413  1.3  lukem 			addstr("But your charm saved you. . .\n");
    414  1.3  lukem 			--Player.p_charms;
    415  1.3  lukem 		} else {
    416  1.3  lukem 			altercoordinates(0.0, 0.0, A_FAR);
    417  1.3  lukem 			addch('\n');
    418  1.1    jtc 		}
    419  1.3  lukem 		break;
    420  1.1    jtc 
    421  1.1    jtc 	case T_BESTOW:
    422  1.3  lukem 		printw("The king has bestowed %.0f gold pieces on you !\n", arg1);
    423  1.3  lukem 		Player.p_gold += arg1;
    424  1.3  lukem 		break;
    425  1.1    jtc 
    426  1.1    jtc 	case T_CURSED:
    427  1.3  lukem 		addstr("You've been cursed !  ");
    428  1.3  lukem 		if (Player.p_blessing) {
    429  1.3  lukem 			addstr("But your blessing saved you. . .\n");
    430  1.3  lukem 			Player.p_blessing = FALSE;
    431  1.3  lukem 		} else {
    432  1.3  lukem 			addch('\n');
    433  1.3  lukem 			Player.p_poison += 2.0;
    434  1.3  lukem 			Player.p_energy = 10.0;
    435  1.3  lukem 			Player.p_maxenergy *= 0.95;
    436  1.3  lukem 			Player.p_status = S_PLAYING;	/* no longer cloaked */
    437  1.1    jtc 		}
    438  1.3  lukem 		break;
    439  1.1    jtc 
    440  1.1    jtc 	case T_VAPORIZED:
    441  1.3  lukem 		addstr("You have been vaporized!\n");
    442  1.3  lukem 		more(7);
    443  1.3  lukem 		death("Vaporization");
    444  1.3  lukem 		break;
    445  1.1    jtc 
    446  1.1    jtc 	case T_MONSTER:
    447  1.3  lukem 		addstr("The Valar zapped you with a monster!\n");
    448  1.3  lukem 		more(7);
    449  1.3  lukem 		encounter((int) arg1);
    450  1.3  lukem 		return;
    451  1.1    jtc 
    452  1.1    jtc 	case T_BLESSED:
    453  1.3  lukem 		addstr("The Valar has blessed you!\n");
    454  1.3  lukem 		Player.p_energy = (Player.p_maxenergy *= 1.05) + Player.p_shield;
    455  1.3  lukem 		Player.p_mana += 500.0;
    456  1.3  lukem 		Player.p_strength += 0.5;
    457  1.3  lukem 		Player.p_brains += 0.5;
    458  1.3  lukem 		Player.p_magiclvl += 0.5;
    459  1.3  lukem 		Player.p_poison = MIN(0.5, Player.p_poison);
    460  1.3  lukem 		break;
    461  1.1    jtc 
    462  1.1    jtc 	case T_RELOCATE:
    463  1.3  lukem 		addstr("You've been relocated. . .\n");
    464  1.3  lukem 		altercoordinates(arg1, arg2, A_FORCED);
    465  1.3  lukem 		break;
    466  1.1    jtc 
    467  1.1    jtc 	case T_HEAL:
    468  1.3  lukem 		addstr("You've been healed!\n");
    469  1.3  lukem 		Player.p_poison -= 0.25;
    470  1.3  lukem 		Player.p_energy = Player.p_maxenergy + Player.p_shield;
    471  1.3  lukem 		break;
    472  1.1    jtc 
    473  1.1    jtc 	case T_EXVALAR:
    474  1.3  lukem 		addstr("You are no longer Valar!\n");
    475  1.3  lukem 		Player.p_specialtype = SC_COUNCIL;
    476  1.3  lukem 		break;
    477  1.1    jtc 
    478  1.1    jtc 	case T_GRAIL:
    479  1.3  lukem 		addstr("You have found The Holy Grail!!\n");
    480  1.3  lukem 		if (Player.p_specialtype < SC_COUNCIL)
    481  1.3  lukem 			/* must be council of wise to behold grail */
    482  1.3  lukem 		{
    483  1.3  lukem 			addstr("However, you are not experienced enough to behold it.\n");
    484  1.3  lukem 			Player.p_sin *= Player.p_sin;
    485  1.3  lukem 			Player.p_mana += 1000;
    486  1.3  lukem 		} else
    487  1.3  lukem 			if (Player.p_specialtype == SC_VALAR
    488  1.3  lukem 			    || Player.p_specialtype == SC_EXVALAR) {
    489  1.3  lukem 				addstr("You have made it to the position of Valar once already.\n");
    490  1.3  lukem 				addstr("The Grail is of no more use to you now.\n");
    491  1.3  lukem 			} else {
    492  1.3  lukem 				addstr("It is now time to see if you are worthy to behold it. . .\n");
    493  1.3  lukem 				refresh();
    494  1.3  lukem 				sleep(4);
    495  1.3  lukem 
    496  1.3  lukem 				if (drandom() / 2.0 < Player.p_sin) {
    497  1.3  lukem 					addstr("You have failed!\n");
    498  1.3  lukem 					Player.p_strength =
    499  1.3  lukem 					    Player.p_mana =
    500  1.3  lukem 					    Player.p_energy =
    501  1.3  lukem 					    Player.p_maxenergy =
    502  1.3  lukem 					    Player.p_magiclvl =
    503  1.3  lukem 					    Player.p_brains =
    504  1.3  lukem 					    Player.p_experience =
    505  1.3  lukem 					    Player.p_quickness = 1.0;
    506  1.3  lukem 
    507  1.3  lukem 					altercoordinates(1.0, 1.0, A_FORCED);
    508  1.3  lukem 					Player.p_level = 0.0;
    509  1.3  lukem 				} else {
    510  1.3  lukem 					addstr("You made to position of Valar!\n");
    511  1.3  lukem 					Player.p_specialtype = SC_VALAR;
    512  1.3  lukem 					Player.p_lives = 5;
    513  1.5    jsm 					fseek(Playersfp, 0L, SEEK_SET);
    514  1.3  lukem 					loc = 0L;
    515  1.3  lukem 					while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
    516  1.3  lukem 						/* search for existing valar */
    517  1.3  lukem 						if (Other.p_specialtype == SC_VALAR
    518  1.3  lukem 						    && Other.p_status != S_NOTUSED)
    519  1.3  lukem 							/* found old valar */
    520  1.3  lukem 						{
    521  1.3  lukem 							Other.p_tampered = T_EXVALAR;
    522  1.3  lukem 							writerecord(&Other, loc);
    523  1.3  lukem 							break;
    524  1.3  lukem 						} else
    525  1.3  lukem 							loc += SZ_PLAYERSTRUCT;
    526  1.3  lukem 				}
    527  1.3  lukem 			}
    528  1.3  lukem 
    529  1.3  lukem 		/* move grail to new location */
    530  1.3  lukem 		Enrgyvoid.ev_active = TRUE;
    531  1.3  lukem 		Enrgyvoid.ev_x = ROLL(-1.0e6, 2.0e6);
    532  1.3  lukem 		Enrgyvoid.ev_y = ROLL(-1.0e6, 2.0e6);
    533  1.3  lukem 		writevoid(&Enrgyvoid, 0L);
    534  1.3  lukem 		break;
    535  1.1    jtc 	}
    536  1.3  lukem 	refresh();
    537  1.3  lukem 	sleep(2);
    538  1.1    jtc }
    539  1.1    jtc 
    540  1.3  lukem void
    541  1.1    jtc userlist(ingameflag)
    542  1.3  lukem 	bool    ingameflag;
    543  1.1    jtc {
    544  1.3  lukem 	int     numusers = 0;	/* number of users on file */
    545  1.1    jtc 
    546  1.3  lukem 	if (ingameflag && Player.p_blindness) {
    547  1.3  lukem 		mvaddstr(8, 0, "You cannot see anyone.\n");
    548  1.3  lukem 		return;
    549  1.1    jtc 	}
    550  1.5    jsm 	fseek(Playersfp, 0L, SEEK_SET);
    551  1.3  lukem 	mvaddstr(8, 0,
    552  1.3  lukem 	    "Name                         X         Y    Lvl Type Login    Status\n");
    553  1.1    jtc 
    554  1.3  lukem 	while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1) {
    555  1.3  lukem 		if (Other.p_status == S_NOTUSED
    556  1.3  lukem 		/* record is unused */
    557  1.3  lukem 		    || (Other.p_specialtype == SC_VALAR && Other.p_status == S_CLOAKED))
    558  1.3  lukem 			/* cloaked valar */
    559  1.3  lukem 		{
    560  1.3  lukem 			if (!Wizard)
    561  1.3  lukem 				/* wizard can see everything on file */
    562  1.3  lukem 				continue;
    563  1.3  lukem 		}
    564  1.3  lukem 		++numusers;
    565  1.1    jtc 
    566  1.3  lukem 		if (ingameflag &&
    567  1.1    jtc 		/* must be playing for the rest of these conditions */
    568  1.3  lukem 		    (Player.p_specialtype >= SC_KING
    569  1.1    jtc 		/* kings and higher can see others */
    570  1.3  lukem 			|| Other.p_specialtype >= SC_KING
    571  1.1    jtc 		/* kings and higher can be seen by others */
    572  1.3  lukem 			|| Circle >= CIRCLE(Other.p_x, Other.p_y)
    573  1.1    jtc 		/* those nearer the origin can be seen */
    574  1.3  lukem 			|| Player.p_palantir)
    575  1.1    jtc 		/* palantir enables one to see others */
    576  1.3  lukem 		    && (Other.p_status != S_CLOAKED
    577  1.3  lukem 			|| (Player.p_specialtype == SC_VALAR && Player.p_palantir))
    578  1.1    jtc 		/* not cloaked; valar can see through cloak with a palantir */
    579  1.3  lukem 		    && Other.p_specialtype != SC_VALAR)
    580  1.3  lukem 			/* not a valar */
    581  1.3  lukem 			/* coordinates should be printed */
    582  1.3  lukem 			printw("%-20s  %8.0f  %8.0f ",
    583  1.3  lukem 			    Other.p_name, Other.p_x, Other.p_y);
    584  1.3  lukem 		else
    585  1.3  lukem 			/* cannot see player's coordinates */
    586  1.3  lukem 			printw("%-20s %19.19s ",
    587  1.3  lukem 			    Other.p_name, descrlocation(&Other, TRUE));
    588  1.3  lukem 
    589  1.3  lukem 		printw("%6.0f %s  %-9.9s%s\n", Other.p_level, descrtype(&Other, TRUE),
    590  1.3  lukem 		    Other.p_login, descrstatus(&Other));
    591  1.3  lukem 
    592  1.3  lukem 		if ((numusers % (LINES - 10)) == 0) {
    593  1.3  lukem 			more(LINES - 1);
    594  1.3  lukem 			move(9, 0);
    595  1.3  lukem 			clrtobot();
    596  1.3  lukem 		}
    597  1.1    jtc 	}
    598  1.1    jtc 
    599  1.3  lukem 	printw("Total players on file = %d\n", numusers);
    600  1.3  lukem 	refresh();
    601  1.1    jtc }
    602  1.1    jtc 
    603  1.3  lukem void
    604  1.1    jtc throneroom()
    605  1.1    jtc {
    606  1.3  lukem 	FILE   *fp;		/* to clear energy voids */
    607  1.3  lukem 	long    loc = 0L;	/* location of old king in player file */
    608  1.1    jtc 
    609  1.3  lukem 	if (Player.p_specialtype < SC_KING)
    610  1.3  lukem 		/* not already king -- assumes crown */
    611  1.1    jtc 	{
    612  1.5    jsm 		fseek(Playersfp, 0L, SEEK_SET);
    613  1.3  lukem 		while (fread((char *) &Other, SZ_PLAYERSTRUCT, 1, Playersfp) == 1)
    614  1.3  lukem 			if (Other.p_specialtype == SC_KING && Other.p_status != S_NOTUSED)
    615  1.3  lukem 				/* found old king */
    616  1.3  lukem 			{
    617  1.3  lukem 				if (Other.p_status != S_OFF)
    618  1.3  lukem 					/* old king is playing */
    619  1.3  lukem 				{
    620  1.3  lukem 					mvaddstr(4, 0, "The king is playing, so you cannot steal his throne\n");
    621  1.3  lukem 					altercoordinates(0.0, 0.0, A_NEAR);
    622  1.3  lukem 					move(6, 0);
    623  1.3  lukem 					return;
    624  1.3  lukem 				} else
    625  1.3  lukem 					/* old king is not playing - remove
    626  1.3  lukem 					 * him/her */
    627  1.3  lukem 				{
    628  1.3  lukem 					Other.p_specialtype = SC_NONE;
    629  1.3  lukem 					if (Other.p_crowns)
    630  1.3  lukem 						--Other.p_crowns;
    631  1.3  lukem 					writerecord(&Other, loc);
    632  1.3  lukem 					break;
    633  1.3  lukem 				}
    634  1.3  lukem 			} else
    635  1.3  lukem 				loc += SZ_PLAYERSTRUCT;
    636  1.3  lukem 
    637  1.3  lukem 		/* make player new king */
    638  1.3  lukem 		Changed = TRUE;
    639  1.3  lukem 		Player.p_specialtype = SC_KING;
    640  1.3  lukem 		mvaddstr(4, 0, "You have become king!\n");
    641  1.3  lukem 
    642  1.3  lukem 		/* let everyone else know */
    643  1.3  lukem 		fp = fopen(_PATH_MESS, "w");
    644  1.3  lukem 		fprintf(fp, "All hail the new king!");
    645  1.3  lukem 		fclose(fp);
    646  1.3  lukem 
    647  1.3  lukem 		/* clear all energy voids; retain location of holy grail */
    648  1.5    jsm 		fseek(Energyvoidfp, 0L, SEEK_SET);
    649  1.3  lukem 		fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp);
    650  1.3  lukem 		fp = fopen(_PATH_VOID, "w");
    651  1.3  lukem 		fwrite((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, fp);
    652  1.3  lukem 		fclose(fp);
    653  1.1    jtc 	}
    654  1.3  lukem 	mvaddstr(6, 0, "0:Decree  ");
    655  1.1    jtc }
    656  1.1    jtc 
    657  1.3  lukem void
    658  1.1    jtc dotampered()
    659  1.1    jtc {
    660  1.3  lukem 	short   tamper;		/* value for tampering with other players */
    661  1.4    jsm 	const char   *option;		/* pointer to option description */
    662  1.3  lukem 	double  temp1 = 0.0, temp2 = 0.0;	/* other tampering values */
    663  1.3  lukem 	int     ch;		/* input */
    664  1.3  lukem 	long    loc;		/* location in energy void file */
    665  1.3  lukem 	FILE   *fp;		/* for opening gold file */
    666  1.1    jtc 
    667  1.1    jtc 	move(6, 0);
    668  1.1    jtc 	clrtoeol();
    669  1.3  lukem 	if (Player.p_specialtype < SC_COUNCIL && !Wizard)
    670  1.3  lukem 		/* king options */
    671  1.3  lukem 	{
    672  1.3  lukem 		addstr("1:Transport  2:Curse  3:Energy Void  4:Bestow  5:Collect Taxes  ");
    673  1.1    jtc 
    674  1.3  lukem 		ch = getanswer(" ", TRUE);
    675  1.3  lukem 		move(6, 0);
    676  1.3  lukem 		clrtoeol();
    677  1.3  lukem 		move(4, 0);
    678  1.3  lukem 		switch (ch) {
    679  1.3  lukem 		case '1':	/* transport someone */
    680  1.3  lukem 			tamper = T_TRANSPORT;
    681  1.3  lukem 			option = "transport";
    682  1.3  lukem 			break;
    683  1.1    jtc 
    684  1.3  lukem 		case '2':	/* curse another */
    685  1.3  lukem 			tamper = T_CURSED;
    686  1.3  lukem 			option = "curse";
    687  1.3  lukem 			break;
    688  1.1    jtc 
    689  1.3  lukem 		case '3':	/* create energy void */
    690  1.6    jsm 			if ((loc = allocvoid()) > 20L * (long)SZ_VOIDSTRUCT)
    691  1.3  lukem 				/* can only have 20 void active at once */
    692  1.3  lukem 				mvaddstr(5, 0, "Sorry, void creation limit reached.\n");
    693  1.3  lukem 			else {
    694  1.3  lukem 				addstr("Enter the X Y coordinates of void ? ");
    695  1.3  lukem 				getstring(Databuf, SZ_DATABUF);
    696  1.3  lukem 				sscanf(Databuf, "%lf %lf", &temp1, &temp2);
    697  1.3  lukem 				Enrgyvoid.ev_x = floor(temp1);
    698  1.3  lukem 				Enrgyvoid.ev_y = floor(temp2);
    699  1.3  lukem 				Enrgyvoid.ev_active = TRUE;
    700  1.3  lukem 				writevoid(&Enrgyvoid, loc);
    701  1.3  lukem 				mvaddstr(5, 0, "It is done.\n");
    702  1.3  lukem 			}
    703  1.3  lukem 			return;
    704  1.3  lukem 
    705  1.3  lukem 		case '4':	/* bestow gold to subject */
    706  1.3  lukem 			tamper = T_BESTOW;
    707  1.3  lukem 			addstr("How much gold to bestow ? ");
    708  1.3  lukem 			temp1 = infloat();
    709  1.3  lukem 			if (temp1 > Player.p_gold || temp1 < 0) {
    710  1.3  lukem 				mvaddstr(5, 0, "You don't have that !\n");
    711  1.3  lukem 				return;
    712  1.3  lukem 			}
    713  1.3  lukem 			/* adjust gold after we are sure it will be given to
    714  1.3  lukem 			 * someone */
    715  1.3  lukem 			option = "give gold to";
    716  1.3  lukem 			break;
    717  1.1    jtc 
    718  1.3  lukem 		case '5':	/* collect accumulated taxes */
    719  1.3  lukem 			if ((fp = fopen(_PATH_GOLD, "r+")) != NULL)
    720  1.3  lukem 				/* collect taxes */
    721  1.3  lukem 			{
    722  1.3  lukem 				fread((char *) &temp1, sizeof(double), 1, fp);
    723  1.5    jsm 				fseek(fp, 0L, SEEK_SET);
    724  1.3  lukem 				/* clear out value */
    725  1.3  lukem 				temp2 = 0.0;
    726  1.3  lukem 				fwrite((char *) &temp2, sizeof(double), 1, fp);
    727  1.3  lukem 				fclose(fp);
    728  1.3  lukem 			}
    729  1.3  lukem 			mvprintw(4, 0, "You have collected %.0f in gold.\n", temp1);
    730  1.3  lukem 			Player.p_gold += floor(temp1);
    731  1.3  lukem 			return;
    732  1.3  lukem 
    733  1.3  lukem 		default:
    734  1.3  lukem 			return;
    735  1.3  lukem 		}
    736  1.3  lukem 		/* end of king options */
    737  1.3  lukem 	} else
    738  1.3  lukem 		/* council of wise, valar, wizard options */
    739  1.3  lukem 	{
    740  1.3  lukem 		addstr("1:Heal  ");
    741  1.3  lukem 		if (Player.p_palantir || Wizard)
    742  1.3  lukem 			addstr("2:Seek Grail  ");
    743  1.3  lukem 		if (Player.p_specialtype == SC_VALAR || Wizard)
    744  1.3  lukem 			addstr("3:Throw Monster  4:Relocate  5:Bless  ");
    745  1.3  lukem 		if (Wizard)
    746  1.3  lukem 			addstr("6:Vaporize  ");
    747  1.1    jtc 
    748  1.3  lukem 		ch = getanswer(" ", TRUE);
    749  1.3  lukem 		if (!Wizard) {
    750  1.3  lukem 			if (ch > '2' && Player.p_specialtype != SC_VALAR) {
    751  1.3  lukem 				ILLCMD();
    752  1.3  lukem 				return;
    753  1.3  lukem 			}
    754  1.3  lukem 			if (Player.p_mana < MM_INTERVENE) {
    755  1.3  lukem 				mvaddstr(5, 0, "No mana left.\n");
    756  1.3  lukem 				return;
    757  1.3  lukem 			} else
    758  1.3  lukem 				Player.p_mana -= MM_INTERVENE;
    759  1.3  lukem 		}
    760  1.3  lukem 		switch (ch) {
    761  1.3  lukem 		case '1':	/* heal another */
    762  1.3  lukem 			tamper = T_HEAL;
    763  1.3  lukem 			option = "heal";
    764  1.3  lukem 			break;
    765  1.1    jtc 
    766  1.3  lukem 		case '2':	/* seek grail */
    767  1.3  lukem 			if (Player.p_palantir)
    768  1.3  lukem 				/* need a palantir to seek */
    769  1.3  lukem 			{
    770  1.5    jsm 				fseek(Energyvoidfp, 0L, SEEK_SET);
    771  1.3  lukem 				fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp);
    772  1.3  lukem 				temp1 = distance(Player.p_x, Enrgyvoid.ev_x, Player.p_y, Enrgyvoid.ev_y);
    773  1.3  lukem 				temp1 += ROLL(-temp1 / 10.0, temp1 / 5.0);	/* add some error */
    774  1.3  lukem 				mvprintw(5, 0, "The palantir says the Grail is about %.0f away.\n", temp1);
    775  1.3  lukem 			} else
    776  1.3  lukem 				/* no palantir */
    777  1.3  lukem 				mvaddstr(5, 0, "You need a palantir to seek the Grail.\n");
    778  1.3  lukem 			return;
    779  1.3  lukem 
    780  1.3  lukem 		case '3':	/* lob monster at someone */
    781  1.3  lukem 			mvaddstr(4, 0, "Which monster [0-99] ? ");
    782  1.3  lukem 			temp1 = infloat();
    783  1.3  lukem 			temp1 = MAX(0.0, MIN(99.0, temp1));
    784  1.3  lukem 			tamper = T_MONSTER;
    785  1.3  lukem 			option = "throw a monster at";
    786  1.3  lukem 			break;
    787  1.1    jtc 
    788  1.3  lukem 		case '4':	/* move another player */
    789  1.3  lukem 			mvaddstr(4, 0, "New X Y coordinates ? ");
    790  1.3  lukem 			getstring(Databuf, SZ_DATABUF);
    791  1.3  lukem 			sscanf(Databuf, "%lf %lf", &temp1, &temp2);
    792  1.3  lukem 			tamper = T_RELOCATE;
    793  1.3  lukem 			option = "relocate";
    794  1.3  lukem 			break;
    795  1.1    jtc 
    796  1.3  lukem 		case '5':	/* bless a player */
    797  1.3  lukem 			tamper = T_BLESSED;
    798  1.3  lukem 			option = "bless";
    799  1.3  lukem 			break;
    800  1.1    jtc 
    801  1.3  lukem 		case '6':	/* kill off a player */
    802  1.3  lukem 			if (Wizard) {
    803  1.3  lukem 				tamper = T_VAPORIZED;
    804  1.3  lukem 				option = "vaporize";
    805  1.3  lukem 				break;
    806  1.3  lukem 			} else
    807  1.3  lukem 				return;
    808  1.1    jtc 
    809  1.3  lukem 		default:
    810  1.3  lukem 			return;
    811  1.3  lukem 		}
    812  1.1    jtc 
    813  1.3  lukem 		/* adjust age after we are sure intervention will be done */
    814  1.3  lukem 		/* end of valar, etc. options */
    815  1.1    jtc 	}
    816  1.1    jtc 
    817  1.3  lukem 	for (;;)
    818  1.3  lukem 		/* prompt for player to affect */
    819  1.1    jtc 	{
    820  1.3  lukem 		mvprintw(4, 0, "Who do you want to %s ? ", option);
    821  1.3  lukem 		getstring(Databuf, SZ_DATABUF);
    822  1.3  lukem 		truncstring(Databuf);
    823  1.1    jtc 
    824  1.3  lukem 		if (Databuf[0] == '\0')
    825  1.3  lukem 			userlist(TRUE);
    826  1.3  lukem 		else
    827  1.3  lukem 			break;
    828  1.1    jtc 	}
    829  1.1    jtc 
    830  1.3  lukem 	if (strcmp(Player.p_name, Databuf) != 0)
    831  1.3  lukem 		/* name other than self */
    832  1.1    jtc 	{
    833  1.3  lukem 		if ((loc = findname(Databuf, &Other)) >= 0L) {
    834  1.3  lukem 			if (Other.p_tampered != T_OFF) {
    835  1.3  lukem 				mvaddstr(5, 0, "That person has something pending already.\n");
    836  1.3  lukem 				return;
    837  1.3  lukem 			} else {
    838  1.3  lukem 				if (tamper == T_RELOCATE
    839  1.3  lukem 				    && CIRCLE(temp1, temp2) < CIRCLE(Other.p_x, Other.p_y)
    840  1.3  lukem 				    && !Wizard)
    841  1.3  lukem 					mvaddstr(5, 0, "Cannot move someone closer to the Lord's Chamber.\n");
    842  1.3  lukem 				else {
    843  1.3  lukem 					if (tamper == T_BESTOW)
    844  1.3  lukem 						Player.p_gold -= floor(temp1);
    845  1.3  lukem 					if (!Wizard && (tamper == T_HEAL || tamper == T_MONSTER ||
    846  1.3  lukem 						tamper == T_RELOCATE || tamper == T_BLESSED))
    847  1.3  lukem 						Player.p_age += N_AGE;	/* age penalty */
    848  1.3  lukem 					Other.p_tampered = tamper;
    849  1.3  lukem 					Other.p_1scratch = floor(temp1);
    850  1.3  lukem 					Other.p_2scratch = floor(temp2);
    851  1.3  lukem 					writerecord(&Other, loc);
    852  1.3  lukem 					mvaddstr(5, 0, "It is done.\n");
    853  1.3  lukem 				}
    854  1.3  lukem 				return;
    855  1.3  lukem 			}
    856  1.3  lukem 		} else
    857  1.3  lukem 			/* player not found */
    858  1.3  lukem 			mvaddstr(5, 0, "There is no one by that name.\n");
    859  1.3  lukem 	} else
    860  1.3  lukem 		/* self */
    861  1.3  lukem 		mvaddstr(5, 0, "You may not do it to yourself!\n");
    862  1.1    jtc }
    863  1.1    jtc 
    864  1.3  lukem void
    865  1.1    jtc writevoid(vp, loc)
    866  1.3  lukem 	struct energyvoid *vp;
    867  1.3  lukem 	long    loc;
    868  1.1    jtc {
    869  1.1    jtc 
    870  1.5    jsm 	fseek(Energyvoidfp, loc, SEEK_SET);
    871  1.3  lukem 	fwrite((char *) vp, SZ_VOIDSTRUCT, 1, Energyvoidfp);
    872  1.3  lukem 	fflush(Energyvoidfp);
    873  1.5    jsm 	fseek(Energyvoidfp, 0L, SEEK_SET);
    874  1.1    jtc }
    875  1.1    jtc 
    876  1.1    jtc long
    877  1.1    jtc allocvoid()
    878  1.1    jtc {
    879  1.3  lukem 	long    loc = 0L;	/* location of new energy void */
    880  1.1    jtc 
    881  1.5    jsm 	fseek(Energyvoidfp, 0L, SEEK_SET);
    882  1.3  lukem 	while (fread((char *) &Enrgyvoid, SZ_VOIDSTRUCT, 1, Energyvoidfp) == 1)
    883  1.3  lukem 		if (Enrgyvoid.ev_active)
    884  1.3  lukem 			loc += SZ_VOIDSTRUCT;
    885  1.3  lukem 		else
    886  1.3  lukem 			break;
    887  1.1    jtc 
    888  1.3  lukem 	return (loc);
    889  1.1    jtc }
    890