xref: /original-bsd/games/trek/ram.c (revision b4971bb3)
1 /*
2  * Copyright (c) 1980, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)ram.c	8.1 (Berkeley) 05/31/93";
10 #endif /* not lint */
11 
12 # include	"trek.h"
13 
14 /*
15 **  RAM SOME OBJECT
16 **
17 **	You have run into some sort of object.  It may be a Klingon,
18 **	a star, or a starbase.  If you run into a star, you are really
19 **	stupid, because there is no hope for you.
20 **
21 **	If you run into something else, you destroy that object.  You
22 **	also rack up incredible damages.
23 */
24 
25 ram(ix, iy)
26 int	ix, iy;
27 {
28 	register int		i;
29 	register char		c;
30 
31 	printf("\07RED ALERT\07: collision imminent\n");
32 	c = Sect[ix][iy];
33 	switch (c)
34 	{
35 
36 	  case KLINGON:
37 		printf("%s rams Klingon at %d,%d\n", Ship.shipname, ix, iy);
38 		killk(ix, iy);
39 		break;
40 
41 	  case STAR:
42 	  case INHABIT:
43 		printf("Yeoman Rand: Captain, isn't it getting hot in here?\n");
44 		sleep(2);
45 		printf("Spock: Hull temperature approaching 550 Degrees Kelvin.\n");
46 		lose(L_STAR);
47 
48 	  case BASE:
49 		printf("You ran into the starbase at %d,%d\n", ix, iy);
50 		killb(Ship.quadx, Ship.quady);
51 		/* don't penalize the captain if it wasn't his fault */
52 		if (!damaged(SINS))
53 			Game.killb += 1;
54 		break;
55 	}
56 	sleep(2);
57 	printf("%s heavily damaged\n", Ship.shipname);
58 
59 	/* select the number of deaths to occur */
60 	i = 10 + ranf(20 * Game.skill);
61 	Game.deaths += i;
62 	Ship.crew -= i;
63 	printf("McCoy: Take it easy Jim; we had %d casualties.\n", i);
64 
65 	/* damage devices with an 80% probability */
66 	for (i = 0; i < NDEV; i++)
67 	{
68 		if (ranf(100) < 20)
69 			continue;
70 		damage(i, (2.5 * (franf() + franf()) + 1.0) * Param.damfac[i]);
71 	}
72 
73 	/* no chance that your shields remained up in all that */
74 	Ship.shldup = 0;
75 }
76