Annotation of 43BSDReno/games/trek/capture.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.