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