xref: /csrg-svn/games/trek/ram.c (revision 60859)
121288Sdist /*
2*60859Sbostic  * Copyright (c) 1980, 1993
3*60859Sbostic  *	The Regents of the University of California.  All rights reserved.
434205Sbostic  *
542606Sbostic  * %sccs.include.redist.c%
621288Sdist  */
721288Sdist 
811689Smckusick #ifndef lint
9*60859Sbostic static char sccsid[] = "@(#)ram.c	8.1 (Berkeley) 05/31/93";
1034205Sbostic #endif /* not lint */
1111689Smckusick 
1211689Smckusick # include	"trek.h"
1311689Smckusick 
1411689Smckusick /*
1511689Smckusick **  RAM SOME OBJECT
1611689Smckusick **
1711689Smckusick **	You have run into some sort of object.  It may be a Klingon,
1811689Smckusick **	a star, or a starbase.  If you run into a star, you are really
1911689Smckusick **	stupid, because there is no hope for you.
2011689Smckusick **
2111689Smckusick **	If you run into something else, you destroy that object.  You
2211689Smckusick **	also rack up incredible damages.
2311689Smckusick */
2411689Smckusick 
ram(ix,iy)2511689Smckusick ram(ix, iy)
2611689Smckusick int	ix, iy;
2711689Smckusick {
2811689Smckusick 	register int		i;
2911689Smckusick 	register char		c;
3011689Smckusick 
3134715Sbostic 	printf("\07RED ALERT\07: collision imminent\n");
3211689Smckusick 	c = Sect[ix][iy];
3311689Smckusick 	switch (c)
3411689Smckusick 	{
3511689Smckusick 
3611689Smckusick 	  case KLINGON:
3711689Smckusick 		printf("%s rams Klingon at %d,%d\n", Ship.shipname, ix, iy);
3811689Smckusick 		killk(ix, iy);
3911689Smckusick 		break;
4011689Smckusick 
4111689Smckusick 	  case STAR:
4211689Smckusick 	  case INHABIT:
4311689Smckusick 		printf("Yeoman Rand: Captain, isn't it getting hot in here?\n");
4411689Smckusick 		sleep(2);
4511689Smckusick 		printf("Spock: Hull temperature approaching 550 Degrees Kelvin.\n");
4611689Smckusick 		lose(L_STAR);
4711689Smckusick 
4811689Smckusick 	  case BASE:
4911689Smckusick 		printf("You ran into the starbase at %d,%d\n", ix, iy);
5011689Smckusick 		killb(Ship.quadx, Ship.quady);
5111689Smckusick 		/* don't penalize the captain if it wasn't his fault */
5211689Smckusick 		if (!damaged(SINS))
5312344Slayer 			Game.killb += 1;
5411689Smckusick 		break;
5511689Smckusick 	}
5611689Smckusick 	sleep(2);
5711689Smckusick 	printf("%s heavily damaged\n", Ship.shipname);
5811689Smckusick 
5911689Smckusick 	/* select the number of deaths to occur */
6011689Smckusick 	i = 10 + ranf(20 * Game.skill);
6112344Slayer 	Game.deaths += i;
6212344Slayer 	Ship.crew -= i;
6311689Smckusick 	printf("McCoy: Take it easy Jim; we had %d casualties.\n", i);
6411689Smckusick 
6511689Smckusick 	/* damage devices with an 80% probability */
6611689Smckusick 	for (i = 0; i < NDEV; i++)
6711689Smckusick 	{
6811689Smckusick 		if (ranf(100) < 20)
6911689Smckusick 			continue;
7011689Smckusick 		damage(i, (2.5 * (franf() + franf()) + 1.0) * Param.damfac[i]);
7111689Smckusick 	}
7211689Smckusick 
7311689Smckusick 	/* no chance that your shields remained up in all that */
7411689Smckusick 	Ship.shldup = 0;
7511689Smckusick }
76