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