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