|
|
1.1 root 1: /*
2: * Copyright (c) 1980 Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted
6: * provided that the above copyright notice and this paragraph are
7: * duplicated in all such forms and that any documentation,
8: * advertising materials, and other materials related to such
9: * distribution and use acknowledge that the software was developed
10: * by the University of California, Berkeley. The name of the
11: * University may not be used to endorse or promote products derived
12: * from this software without specific prior written permission.
13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16: */
17:
18: #ifndef lint
19: static char sccsid[] = "@(#)capture.c 5.3 (Berkeley) 6/18/88";
20: #endif /* not lint */
21:
22: # include "trek.h"
23:
24: /*
25: ** Ask a Klingon To Surrender
26: **
27: ** (Fat chance)
28: **
29: ** The Subspace Radio is needed to ask a Klingon if he will kindly
30: ** surrender. A random Klingon from the ones in the quadrant is
31: ** chosen.
32: **
33: ** The Klingon is requested to surrender. The probability of this
34: ** is a function of that Klingon's remaining power, our power,
35: ** etc.
36: */
37:
38: capture()
39: {
40: register int i;
41: register struct kling *k;
42: double x;
43: extern struct kling *selectklingon();
44:
45: /* check for not cloaked */
46: if (Ship.cloaked)
47: {
48: printf("Ship-ship communications out when cloaked\n");
49: return;
50: }
51: if (damaged(SSRADIO))
52: return (out(SSRADIO));
53: /* find out if there are any at all */
54: if (Etc.nkling <= 0)
55: {
56: printf("Uhura: Getting no response, sir\n");
57: return;
58: }
59:
60: /* if there is more than one Klingon, find out which one */
61: k = selectklingon();
62: Move.free = 0;
63: Move.time = 0.05;
64:
65: /* check out that Klingon */
66: k->srndreq++;
67: x = Param.klingpwr;
68: x *= Ship.energy;
69: x /= k->power * Etc.nkling;
70: x *= Param.srndrprob;
71: i = x;
72: # ifdef xTRACE
73: if (Trace)
74: printf("Prob = %d (%.4f)\n", i, x);
75: # endif
76: if (i > ranf(100))
77: {
78: /* guess what, he surrendered!!! */
79: printf("Klingon at %d,%d surrenders\n", k->x, k->y);
80: i = ranf(Param.klingcrew);
81: if ( i > 0 )
82: printf("%d klingons commit suicide rather than be taken captive\n", Param.klingcrew - i);
83: if (i > Ship.brigfree)
84: i = Ship.brigfree;
85: Ship.brigfree -= i;
86: printf("%d captives taken\n", i);
87: killk(k->x, k->y);
88: return;
89: }
90:
91: /* big surprise, he refuses to surrender */
92: printf("Fat chance, captain\n");
93: return;
94: }
95:
96:
97: /*
98: ** SELECT A KLINGON
99: **
100: ** Cruddy, just takes one at random. Should ask the captain.
101: */
102:
103: struct kling *selectklingon()
104: {
105: register int i;
106:
107: if (Etc.nkling < 2)
108: i = 0;
109: else
110: i = ranf(Etc.nkling);
111: return (&Etc.klingon[i]);
112: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.