Commit | Line | Data |
---|---|---|
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 | ||
45a83d41 | 7 | #ifndef lint |
b6f0a7e4 | 8 | static char sccsid[] = "@(#)capture.c 5.1 (Berkeley) %G%"; |
45a83d41 KM |
9 | #endif not lint |
10 | ||
11 | # include "trek.h" | |
12 | ||
13 | /* | |
14 | ** Ask a Klingon To Surrender | |
15 | ** | |
16 | ** (Fat chance) | |
17 | ** | |
18 | ** The Subspace Radio is needed to ask a Klingon if he will kindly | |
19 | ** surrender. A random Klingon from the ones in the quadrant is | |
20 | ** chosen. | |
21 | ** | |
22 | ** The Klingon is requested to surrender. The probability of this | |
23 | ** is a function of that Klingon's remaining power, our power, | |
24 | ** etc. | |
25 | */ | |
26 | ||
27 | capture() | |
28 | { | |
29 | register int i; | |
30 | register struct kling *k; | |
06d69904 | 31 | double x; |
45a83d41 KM |
32 | extern struct kling *selectklingon(); |
33 | ||
34 | /* check for not cloaked */ | |
35 | if (Ship.cloaked) | |
36 | { | |
37 | printf("Ship-ship communications out when cloaked\n"); | |
38 | return; | |
39 | } | |
40 | if (damaged(SSRADIO)) | |
41 | return (out(SSRADIO)); | |
42 | /* find out if there are any at all */ | |
43 | if (Etc.nkling <= 0) | |
44 | { | |
45 | printf("Uhura: Getting no response, sir\n"); | |
46 | return; | |
47 | } | |
48 | ||
49 | /* if there is more than one Klingon, find out which one */ | |
50 | k = selectklingon(); | |
51 | Move.free = 0; | |
52 | Move.time = 0.05; | |
53 | ||
54 | /* check out that Klingon */ | |
55 | k->srndreq++; | |
56 | x = Param.klingpwr; | |
35b95499 KL |
57 | x *= Ship.energy; |
58 | x /= k->power * Etc.nkling; | |
59 | x *= Param.srndrprob; | |
45a83d41 KM |
60 | i = x; |
61 | # ifdef xTRACE | |
62 | if (Trace) | |
63 | printf("Prob = %d (%.4f)\n", i, x); | |
64 | # endif | |
65 | if (i > ranf(100)) | |
66 | { | |
67 | /* guess what, he surrendered!!! */ | |
68 | printf("Klingon at %d,%d surrenders\n", k->x, k->y); | |
69 | i = ranf(Param.klingcrew); | |
06d69904 KL |
70 | if ( i > 0 ) |
71 | printf("%d klingons commit suicide rather than be taken captive\n", Param.klingcrew - i); | |
45a83d41 KM |
72 | if (i > Ship.brigfree) |
73 | i = Ship.brigfree; | |
35b95499 | 74 | Ship.brigfree -= i; |
45a83d41 KM |
75 | printf("%d captives taken\n", i); |
76 | killk(k->x, k->y); | |
77 | return; | |
78 | } | |
79 | ||
80 | /* big surprise, he refuses to surrender */ | |
81 | printf("Fat chance, captain\n"); | |
82 | return; | |
83 | } | |
84 | ||
85 | ||
86 | /* | |
87 | ** SELECT A KLINGON | |
88 | ** | |
89 | ** Cruddy, just takes one at random. Should ask the captain. | |
90 | */ | |
91 | ||
92 | struct kling *selectklingon() | |
93 | { | |
94 | register int i; | |
95 | ||
96 | if (Etc.nkling < 2) | |
97 | i = 0; | |
98 | else | |
99 | i = ranf(Etc.nkling); | |
100 | return (&Etc.klingon[i]); | |
101 | } |