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: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)capture.c	5.1 (Berkeley) 5/30/85";
   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;
  31:     double          x;
  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;
  57:     x *= Ship.energy;
  58:     x /= k->power * Etc.nkling;
  59:     x *= Param.srndrprob;
  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);
  70:         if ( i > 0 )
  71:             printf("%d klingons commit suicide rather than be taken captive\n", Param.klingcrew - i);
  72:         if (i > Ship.brigfree)
  73:             i = Ship.brigfree;
  74:         Ship.brigfree -= i;
  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: }

Defined functions

capture defined in line 27; used 2 times
selectklingon defined in line 92; used 2 times

Defined variables

sccsid defined in line 8; never used
Last modified: 1985-05-30
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 780
Valid CSS Valid XHTML 1.0 Strict