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