(linenum→info "unix/slp.c:2238")

bsd-games/2.17/trek/abandon.c

    1: /*      $NetBSD: abandon.c,v 1.6 2003/08/07 09:37:49 agc Exp $       */
    2: 
    3: /*
    4:  * Copyright (c) 1980, 1993
    5:  *      The Regents of the University of California.  All rights reserved.
    6:  *
    7:  * Redistribution and use in source and binary forms, with or without
    8:  * modification, are permitted provided that the following conditions
    9:  * are met:
   10:  * 1. Redistributions of source code must retain the above copyright
   11:  *    notice, this list of conditions and the following disclaimer.
   12:  * 2. Redistributions in binary form must reproduce the above copyright
   13:  *    notice, this list of conditions and the following disclaimer in the
   14:  *    documentation and/or other materials provided with the distribution.
   15:  * 3. Neither the name of the University nor the names of its contributors
   16:  *    may be used to endorse or promote products derived from this software
   17:  *    without specific prior written permission.
   18:  *
   19:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   20:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   23:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29:  * SUCH DAMAGE.
   30:  */
   31: 
   32: #include <sys/cdefs.h>
   33: #ifndef lint
   34: #if 0
   35: static char sccsid[] = "@(#)abandon.c   8.1 (Berkeley) 5/31/93";
   36: #else
   37: __RCSID("$NetBSD: abandon.c,v 1.6 2003/08/07 09:37:49 agc Exp $");
   38: #endif
   39: #endif /* not lint */
   40: 
   41: #include <stdio.h>
   42: #include "trek.h"
   43: 
   44: /*
   45: **  Abandon Ship
   46: **
   47: **      The ship is abandoned.  If your current ship is the Faire
   48: **      Queene, or if your shuttlecraft is dead, you're out of
   49: **      luck.  You need the shuttlecraft in order for the captain
   50: **      (that's you!!) to escape.
   51: **
   52: **      Your crew can beam to an inhabited starsystem in the
   53: **      quadrant, if there is one and if the transporter is working.
   54: **      If there is no inhabited starsystem, or if the transporter
   55: **      is out, they are left to die in outer space.
   56: **
   57: **      These currently just count as regular deaths, but they
   58: **      should count very heavily against you.
   59: **
   60: **      If there are no starbases left, you are captured by the
   61: **      Klingons, who torture you mercilessly.  However, if there
   62: **      is at least one starbase, you are returned to the
   63: **      Federation in a prisoner of war exchange.  Of course, this
   64: **      can't happen unless you have taken some prisoners.
   65: **
   66: **      Uses trace flag 40
   67: */
   68: 
   69: /*ARGSUSED*/
   70: void
   71: abandon(v)
   72:         int v __attribute__((__unused__));
   73: {
   74:         struct quad    *q;
   75:         int            i;
   76:         int            j;
   77:         struct event   *e;
   78: 
   79:         if (Ship.ship == QUEENE) {
   80:                 printf("You may not abandon ye Faire Queene\n");
   81:                 return;
   82:         }
   83:         if (Ship.cond != DOCKED)
   84:         {
   85:                 if (damaged(SHUTTLE)) {
   86:                         out(SHUTTLE);
   87:                         return;
   88:                 }
   89:                 printf("Officers escape in shuttlecraft\n");
   90:                 /* decide on fate of crew */
   91:                 q = &Quad[Ship.quadx][Ship.quady];
   92:                 if (q->qsystemname == 0 || damaged(XPORTER))
   93:                 {
   94:                         printf("Entire crew of %d left to die in outer space\n",
   95:                                 Ship.crew);
   96:                         Game.deaths += Ship.crew;
   97:                 }
   98:                 else
   99:                 {
  100:                         printf("Crew beams down to planet %s\n", systemname(q));
  101:                 }
  102:         }
  103:         /* see if you can be exchanged */
  104:         if (Now.bases == 0 || Game.captives < 20 * Game.skill)
  105:                 lose(L_CAPTURED);
  106:         /* re-outfit new ship */
  107:         printf("You are hereby put in charge of an antiquated but still\n");
  108:         printf("  functional ship, the Fairie Queene.\n");
  109:         Ship.ship = QUEENE;
  110:         Ship.shipname = "Fairie Queene";
  111:         Param.energy = Ship.energy = 3000;
  112:         Param.torped = Ship.torped = 6;
  113:         Param.shield = Ship.shield = 1250;
  114:         Ship.shldup = 0;
  115:         Ship.cloaked = 0;
  116:         Ship.warp = 5.0;
  117:         Ship.warp2 = 25.0;
  118:         Ship.warp3 = 125.0;
  119:         Ship.cond = GREEN;
  120:         /* clear out damages on old ship */
  121:         for (i = 0; i < MAXEVENTS; i++)
  122:         {
  123:                 e = &Event[i];
  124:                 if (e->evcode != E_FIXDV)
  125:                         continue;
  126:                 unschedule(e);
  127:         }
  128:         /* get rid of some devices and redistribute probabilities */
  129:         i = Param.damprob[SHUTTLE] + Param.damprob[CLOAK];
  130:         Param.damprob[SHUTTLE] = Param.damprob[CLOAK] = 0;
  131:         while (i > 0)
  132:                 for (j = 0; j < NDEV; j++)
  133:                 {
  134:                         if (Param.damprob[j] != 0)
  135:                         {
  136:                                 Param.damprob[j] += 1;
  137:                                 i--;
  138:                                 if (i <= 0)
  139:                                         break;
  140:                         }
  141:                 }
  142:         /* pick a starbase to restart at */
  143:         i = ranf(Now.bases);
  144:         Ship.quadx = Now.base[i].x;
  145:         Ship.quady = Now.base[i].y;
  146:         /* setup that quadrant */
  147:         while (1)
  148:         {
  149:                 initquad(1);
  150:                 Sect[Ship.sectx][Ship.secty] = EMPTY;
  151:                 for (i = 0; i < 5; i++)
  152:                 {
  153:                         Ship.sectx = Etc.starbase.x + ranf(3) - 1;
  154:                         if (Ship.sectx < 0 || Ship.sectx >= NSECTS)
  155:                                 continue;
  156:                         Ship.secty = Etc.starbase.y + ranf(3) - 1;
  157:                         if (Ship.secty < 0 || Ship.secty >= NSECTS)
  158:                                 continue;
  159:                         if (Sect[Ship.sectx][Ship.secty] == EMPTY)
  160:                         {
  161:                                 Sect[Ship.sectx][Ship.secty] = QUEENE;
  162:                                 dock(0);
  163:                                 compkldist(0);
  164:                                 return;
  165:                         }
  166:                 }
  167:         }
  168: }
Syntax (Markdown)