Home | History | Annotate | Line # | Download | only in larn
moreobj.c revision 1.11
      1  1.11  dholland /*	$NetBSD: moreobj.c,v 1.11 2008/02/19 06:05:26 dholland Exp $	*/
      2   1.2   mycroft 
      3   1.4  christos /*
      4   1.4  christos  * moreobj.c 		Larn is copyrighted 1986 by Noah Morgan.
      5   1.4  christos  *
      6   1.4  christos  * Routines in this file:
      7   1.4  christos  *
      8   1.4  christos  * oaltar() othrone() ochest() ofountain()
      9   1.1       cgd  */
     10   1.4  christos #include <sys/cdefs.h>
     11   1.4  christos #ifndef lint
     12  1.11  dholland __RCSID("$NetBSD: moreobj.c,v 1.11 2008/02/19 06:05:26 dholland Exp $");
     13   1.4  christos #endif				/* not lint */
     14   1.4  christos #include <stdlib.h>
     15   1.4  christos #include <unistd.h>
     16   1.1       cgd #include "header.h"
     17   1.4  christos #include "extern.h"
     18   1.1       cgd 
     19   1.6       jsm static void fch(int, long *);
     20   1.1       cgd 
     21   1.1       cgd /*
     22   1.1       cgd  *	subroutine to process an altar object
     23   1.1       cgd  */
     24   1.4  christos void
     25   1.1       cgd oaltar()
     26   1.4  christos {
     27   1.1       cgd 
     28   1.4  christos 	lprcat("\nDo you (p) pray  (d) desecrate");
     29   1.4  christos 	iopts();
     30   1.4  christos 	while (1) {
     31   1.4  christos 		while (1)
     32   1.9  dholland 			switch (ttgetch()) {
     33   1.4  christos 			case 'p':
     34   1.4  christos 				lprcat(" pray\nDo you (m) give money or (j) just pray? ");
     35   1.4  christos 				while (1)
     36   1.9  dholland 					switch (ttgetch()) {
     37   1.4  christos 					case 'j':
     38  1.11  dholland 						act_just_pray();
     39   1.4  christos 						return;
     40   1.4  christos 
     41   1.4  christos 					case 'm':
     42  1.11  dholland 						act_donation_pray();
     43   1.4  christos 						return;
     44   1.4  christos 
     45   1.4  christos 					case '\33':
     46   1.4  christos 						return;
     47   1.4  christos 					};
     48   1.4  christos 
     49   1.4  christos 			case 'd':
     50   1.4  christos 				lprcat(" desecrate");
     51  1.11  dholland 				act_desecrate_altar();
     52   1.4  christos 				return;
     53   1.4  christos 
     54   1.4  christos 			case 'i':
     55   1.4  christos 			case '\33':
     56   1.4  christos 				ignore();
     57  1.11  dholland 				act_ignore_altar();
     58   1.4  christos 				return;
     59   1.4  christos 			};
     60   1.1       cgd 	}
     61   1.4  christos }
     62   1.1       cgd 
     63   1.1       cgd /*
     64   1.1       cgd 	subroutine to process a throne object
     65   1.1       cgd  */
     66   1.4  christos void
     67   1.1       cgd othrone(arg)
     68   1.4  christos 	int             arg;
     69   1.4  christos {
     70   1.4  christos 
     71   1.4  christos 	lprcat("\nDo you (p) pry off jewels, (s) sit down");
     72   1.4  christos 	iopts();
     73   1.4  christos 	while (1) {
     74   1.4  christos 		while (1)
     75   1.9  dholland 			switch (ttgetch()) {
     76   1.4  christos 			case 'p':
     77   1.4  christos 				lprcat(" pry off");
     78  1.11  dholland 				act_remove_gems(arg);
     79   1.4  christos 				return;
     80   1.4  christos 
     81   1.4  christos 			case 's':
     82   1.4  christos 				lprcat(" sit down");
     83  1.11  dholland 				act_sit_throne(arg);
     84   1.4  christos 				return;
     85   1.4  christos 
     86   1.4  christos 			case 'i':
     87   1.4  christos 			case '\33':
     88   1.4  christos 				ignore();
     89   1.4  christos 				return;
     90   1.4  christos 			};
     91   1.1       cgd 	}
     92   1.4  christos }
     93   1.1       cgd 
     94   1.4  christos void
     95   1.1       cgd odeadthrone()
     96   1.4  christos {
     97   1.4  christos 	int    k;
     98   1.1       cgd 
     99   1.4  christos 	lprcat("\nDo you (s) sit down");
    100   1.4  christos 	iopts();
    101   1.4  christos 	while (1) {
    102   1.4  christos 		while (1)
    103   1.9  dholland 			switch (ttgetch()) {
    104   1.4  christos 			case 's':
    105   1.4  christos 				lprcat(" sit down");
    106   1.4  christos 				k = rnd(101);
    107   1.4  christos 				if (k < 35) {
    108   1.4  christos 					lprcat("\nZaaaappp!  You've been teleported!\n");
    109   1.4  christos 					beep();
    110   1.4  christos 					oteleport(0);
    111   1.4  christos 				} else
    112   1.4  christos 					lprcat("\nnothing happens");
    113   1.4  christos 				return;
    114   1.4  christos 
    115   1.4  christos 			case 'i':
    116   1.4  christos 			case '\33':
    117   1.4  christos 				ignore();
    118   1.4  christos 				return;
    119   1.4  christos 			};
    120   1.1       cgd 	}
    121   1.4  christos }
    122   1.1       cgd 
    123   1.1       cgd /*
    124   1.1       cgd 	subroutine to process a throne object
    125   1.1       cgd  */
    126   1.4  christos void
    127   1.1       cgd ochest()
    128   1.4  christos {
    129  1.11  dholland 
    130   1.4  christos 	lprcat("\nDo you (t) take it, (o) try to open it");
    131   1.4  christos 	iopts();
    132   1.4  christos 	while (1) {
    133   1.4  christos 		while (1)
    134   1.9  dholland 			switch (ttgetch()) {
    135   1.4  christos 			case 'o':
    136   1.4  christos 				lprcat(" open it");
    137  1.11  dholland 				act_open_chest(playerx, playery);
    138   1.4  christos 				return;
    139   1.4  christos 
    140   1.4  christos 			case 't':
    141   1.4  christos 				lprcat(" take");
    142   1.4  christos 				if (take(OCHEST, iarg[playerx][playery]) == 0)
    143   1.4  christos 					item[playerx][playery] = know[playerx][playery] = 0;
    144   1.4  christos 				return;
    145   1.4  christos 
    146   1.4  christos 			case 'i':
    147   1.4  christos 			case '\33':
    148   1.4  christos 				ignore();
    149   1.4  christos 				return;
    150   1.4  christos 			};
    151   1.1       cgd 	}
    152   1.4  christos }
    153   1.1       cgd 
    154   1.1       cgd /*
    155  1.10  dholland 	process a fountain object
    156   1.1       cgd  */
    157   1.4  christos void
    158   1.1       cgd ofountain()
    159   1.4  christos {
    160  1.11  dholland 
    161   1.1       cgd 	cursors();
    162   1.4  christos 	lprcat("\nDo you (d) drink, (w) wash yourself");
    163   1.4  christos 	iopts();
    164   1.4  christos 	while (1)
    165   1.9  dholland 		switch (ttgetch()) {
    166   1.4  christos 		case 'd':
    167   1.4  christos 			lprcat("drink");
    168  1.11  dholland 			act_drink_fountain();
    169   1.4  christos 			return;
    170   1.1       cgd 
    171   1.1       cgd 		case '\33':
    172   1.4  christos 		case 'i':
    173   1.4  christos 			ignore();
    174   1.4  christos 			return;
    175   1.1       cgd 
    176   1.4  christos 		case 'w':
    177   1.4  christos 			lprcat("wash yourself");
    178  1.11  dholland 			act_wash_fountain();
    179   1.4  christos 			return;
    180   1.1       cgd 		}
    181   1.4  christos }
    182   1.1       cgd 
    183   1.1       cgd /*
    184   1.1       cgd 	***
    185   1.1       cgd 	FCH
    186   1.1       cgd 	***
    187   1.1       cgd 
    188   1.1       cgd 	subroutine to process an up/down of a character attribute for ofountain
    189   1.1       cgd  */
    190   1.1       cgd static void
    191   1.4  christos fch(how, x)
    192   1.4  christos 	int             how;
    193   1.4  christos 	long           *x;
    194   1.4  christos {
    195   1.4  christos 	if (how < 0) {
    196   1.4  christos 		lprcat(" went down by one!");
    197   1.4  christos 		--(*x);
    198   1.4  christos 	} else {
    199   1.4  christos 		lprcat(" went up by one!");
    200   1.4  christos 		(*x)++;
    201   1.4  christos 	}
    202   1.1       cgd 	bottomline();
    203   1.4  christos }
    204   1.1       cgd 
    205   1.1       cgd /*
    206   1.1       cgd 	a subroutine to raise or lower character levels
    207   1.1       cgd 	if x > 0 they are raised   if x < 0 they are lowered
    208   1.1       cgd  */
    209   1.4  christos void
    210   1.1       cgd fntchange(how)
    211   1.4  christos 	int             how;
    212   1.4  christos {
    213   1.4  christos 	long   j;
    214   1.1       cgd 	lprc('\n');
    215   1.4  christos 	switch (rnd(9)) {
    216   1.4  christos 	case 1:
    217   1.4  christos 		lprcat("Your strength");
    218   1.4  christos 		fch(how, &c[0]);
    219   1.4  christos 		break;
    220   1.4  christos 	case 2:
    221   1.4  christos 		lprcat("Your intelligence");
    222   1.4  christos 		fch(how, &c[1]);
    223   1.4  christos 		break;
    224   1.4  christos 	case 3:
    225   1.4  christos 		lprcat("Your wisdom");
    226   1.4  christos 		fch(how, &c[2]);
    227   1.4  christos 		break;
    228   1.4  christos 	case 4:
    229   1.4  christos 		lprcat("Your constitution");
    230   1.4  christos 		fch(how, &c[3]);
    231   1.4  christos 		break;
    232   1.4  christos 	case 5:
    233   1.4  christos 		lprcat("Your dexterity");
    234   1.4  christos 		fch(how, &c[4]);
    235   1.4  christos 		break;
    236   1.4  christos 	case 6:
    237   1.4  christos 		lprcat("Your charm");
    238   1.4  christos 		fch(how, &c[5]);
    239   1.4  christos 		break;
    240   1.4  christos 	case 7:
    241   1.4  christos 		j = rnd(level + 1);
    242   1.4  christos 		if (how < 0) {
    243   1.7  dholland 			lprintf("You lose %ld hit point", (long) j);
    244   1.4  christos 			if (j > 1)
    245   1.4  christos 				lprcat("s!");
    246   1.4  christos 			else
    247   1.4  christos 				lprc('!');
    248   1.4  christos 			losemhp((int) j);
    249   1.4  christos 		} else {
    250   1.7  dholland 			lprintf("You gain %ld hit point", (long) j);
    251   1.4  christos 			if (j > 1)
    252   1.4  christos 				lprcat("s!");
    253   1.4  christos 			else
    254   1.4  christos 				lprc('!');
    255   1.4  christos 			raisemhp((int) j);
    256   1.4  christos 		}
    257   1.4  christos 		bottomline();
    258   1.4  christos 		break;
    259   1.4  christos 
    260   1.4  christos 	case 8:
    261   1.4  christos 		j = rnd(level + 1);
    262   1.4  christos 		if (how > 0) {
    263   1.7  dholland 			lprintf("You just gained %ld spell", (long) j);
    264   1.4  christos 			raisemspells((int) j);
    265   1.4  christos 			if (j > 1)
    266   1.4  christos 				lprcat("s!");
    267   1.4  christos 			else
    268   1.4  christos 				lprc('!');
    269   1.4  christos 		} else {
    270   1.7  dholland 			lprintf("You just lost %ld spell", (long) j);
    271   1.4  christos 			losemspells((int) j);
    272   1.4  christos 			if (j > 1)
    273   1.4  christos 				lprcat("s!");
    274   1.4  christos 			else
    275   1.4  christos 				lprc('!');
    276   1.4  christos 		}
    277   1.4  christos 		bottomline();
    278   1.4  christos 		break;
    279   1.4  christos 
    280   1.4  christos 	case 9:
    281   1.4  christos 		j = 5 * rnd((level + 1) * (level + 1));
    282   1.4  christos 		if (how < 0) {
    283   1.7  dholland 			lprintf("You just lost %ld experience point", (long) j);
    284   1.4  christos 			if (j > 1)
    285   1.4  christos 				lprcat("s!");
    286   1.4  christos 			else
    287   1.4  christos 				lprc('!');
    288   1.4  christos 			loseexperience((long) j);
    289   1.4  christos 		} else {
    290   1.7  dholland 			lprintf("You just gained %ld experience point", (long) j);
    291   1.4  christos 			if (j > 1)
    292   1.4  christos 				lprcat("s!");
    293   1.4  christos 			else
    294   1.4  christos 				lprc('!');
    295   1.4  christos 			raiseexperience((long) j);
    296   1.1       cgd 		}
    297   1.4  christos 		break;
    298   1.4  christos 	}
    299   1.1       cgd 	cursors();
    300   1.4  christos }
    301