Annotation of 43BSDReno/games/trek/nova.c, revision 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[] = "@(#)nova.c     5.4 (Berkeley) 6/1/90";
        !            22: #endif /* not lint */
        !            23: 
        !            24: # include      "trek.h"
        !            25: 
        !            26: /*
        !            27: **  CAUSE A NOVA TO OCCUR
        !            28: **
        !            29: **     A nova occurs.  It is the result of having a star hit with
        !            30: **     a photon torpedo.  There are several things which may happen.
        !            31: **     The star may not be affected.  It may go nova.  It may turn
        !            32: **     into a black hole.  Any (yummy) it may go supernova.
        !            33: **
        !            34: **     Stars that go nova cause stars which surround them to undergo
        !            35: **     the same probabilistic process.  Klingons next to them are
        !            36: **     destroyed.  And if the starship is next to it, it gets zapped.
        !            37: **     If the zap is too much, it gets destroyed.
        !            38: */
        !            39: 
        !            40: nova(x, y)
        !            41: int    x, y;
        !            42: {
        !            43:        register int            i, j;
        !            44:        register int            se;
        !            45: 
        !            46:        if (Sect[x][y] != STAR || Quad[Ship.quadx][Ship.quady].stars < 0)
        !            47:                return;
        !            48:        if (ranf(100) < 15)
        !            49:        {
        !            50:                printf("Spock: Star at %d,%d failed to nova.\n", x, y);
        !            51:                return;
        !            52:        }
        !            53:        if (ranf(100) < 5)
        !            54:                return (snova(x, y));
        !            55:        printf("Spock: Star at %d,%d gone nova\n", x, y);
        !            56: 
        !            57:        if (ranf(4) != 0)
        !            58:                Sect[x][y] = EMPTY;
        !            59:        else
        !            60:        {
        !            61:                Sect[x][y] = HOLE;
        !            62:                Quad[Ship.quadx][Ship.quady].holes += 1;
        !            63:        }
        !            64:        Quad[Ship.quadx][Ship.quady].stars -= 1;
        !            65:        Game.kills += 1;
        !            66:        for (i = x - 1; i <= x + 1; i++)
        !            67:        {
        !            68:                if (i < 0 || i >= NSECTS)
        !            69:                        continue;
        !            70:                for (j = y - 1; j <= y + 1; j++)
        !            71:                {
        !            72:                        if (j < 0 || j >= NSECTS)
        !            73:                                continue;
        !            74:                        se = Sect[i][j];
        !            75:                        switch (se)
        !            76:                        {
        !            77: 
        !            78:                          case EMPTY:
        !            79:                          case HOLE:
        !            80:                                break;
        !            81: 
        !            82:                          case KLINGON:
        !            83:                                killk(i, j);
        !            84:                                break;
        !            85: 
        !            86:                          case STAR:
        !            87:                                nova(i, j);
        !            88:                                break;
        !            89: 
        !            90:                          case INHABIT:
        !            91:                                kills(i, j, -1);
        !            92:                                break;
        !            93: 
        !            94:                          case BASE:
        !            95:                                killb(i, j);
        !            96:                                Game.killb += 1;
        !            97:                                break;
        !            98: 
        !            99:                          case ENTERPRISE:
        !           100:                          case QUEENE:
        !           101:                                se = 2000;
        !           102:                                if (Ship.shldup)
        !           103:                                        if (Ship.shield >= se)
        !           104:                                        {
        !           105:                                                Ship.shield -= se;
        !           106:                                                se = 0;
        !           107:                                        }
        !           108:                                        else
        !           109:                                        {
        !           110:                                                se -= Ship.shield;
        !           111:                                                Ship.shield = 0;
        !           112:                                        }
        !           113:                                Ship.energy -= se;
        !           114:                                if (Ship.energy <= 0)
        !           115:                                        lose(L_SUICID);
        !           116:                                break;
        !           117: 
        !           118:                          default:
        !           119:                                printf("Unknown object %c at %d,%d destroyed\n",
        !           120:                                        se, i, j);
        !           121:                                Sect[i][j] = EMPTY;
        !           122:                                break;
        !           123:                        }
        !           124:                }
        !           125:        }
        !           126:        return;
        !           127: }

unix.superglobalmegacorp.com

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