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