Annotation of 43BSDTahoe/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
        !             6:  * provided that the above copyright notice and this paragraph are
        !             7:  * duplicated in all such forms and that any documentation,
        !             8:  * advertising materials, and other materials related to such
        !             9:  * distribution and use acknowledge that the software was developed
        !            10:  * by the University of California, Berkeley.  The name of the
        !            11:  * University may not be used to endorse or promote products derived
        !            12:  * from this software without specific prior written permission.
        !            13:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            14:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            15:  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            16:  */
        !            17: 
        !            18: #ifndef lint
        !            19: static char sccsid[] = "@(#)nova.c     5.3 (Berkeley) 6/18/88";
        !            20: #endif /* not lint */
        !            21: 
        !            22: # include      "trek.h"
        !            23: 
        !            24: /*
        !            25: **  CAUSE A NOVA TO OCCUR
        !            26: **
        !            27: **     A nova occurs.  It is the result of having a star hit with
        !            28: **     a photon torpedo.  There are several things which may happen.
        !            29: **     The star may not be affected.  It may go nova.  It may turn
        !            30: **     into a black hole.  Any (yummy) it may go supernova.
        !            31: **
        !            32: **     Stars that go nova cause stars which surround them to undergo
        !            33: **     the same probabilistic process.  Klingons next to them are
        !            34: **     destroyed.  And if the starship is next to it, it gets zapped.
        !            35: **     If the zap is too much, it gets destroyed.
        !            36: */
        !            37: 
        !            38: nova(x, y)
        !            39: int    x, y;
        !            40: {
        !            41:        register int            i, j;
        !            42:        register int            se;
        !            43: 
        !            44:        if (Sect[x][y] != STAR || Quad[Ship.quadx][Ship.quady].stars < 0)
        !            45:                return;
        !            46:        if (ranf(100) < 15)
        !            47:        {
        !            48:                printf("Spock: Star at %d,%d failed to nova.\n", x, y);
        !            49:                return;
        !            50:        }
        !            51:        if (ranf(100) < 5)
        !            52:                return (snova(x, y));
        !            53:        printf("Spock: Star at %d,%d gone nova\n", x, y);
        !            54: 
        !            55:        if (ranf(4) != 0)
        !            56:                Sect[x][y] = EMPTY;
        !            57:        else
        !            58:        {
        !            59:                Sect[x][y] = HOLE;
        !            60:                Quad[Ship.quadx][Ship.quady].holes += 1;
        !            61:        }
        !            62:        Quad[Ship.quadx][Ship.quady].stars -= 1;
        !            63:        Game.kills += 1;
        !            64:        for (i = x - 1; i <= x + 1; i++)
        !            65:        {
        !            66:                if (i < 0 || i >= NSECTS)
        !            67:                        continue;
        !            68:                for (j = y - 1; j <= y + 1; j++)
        !            69:                {
        !            70:                        if (j < 0 || j >= NSECTS)
        !            71:                                continue;
        !            72:                        se = Sect[i][j];
        !            73:                        switch (se)
        !            74:                        {
        !            75: 
        !            76:                          case EMPTY:
        !            77:                          case HOLE:
        !            78:                                break;
        !            79: 
        !            80:                          case KLINGON:
        !            81:                                killk(i, j);
        !            82:                                break;
        !            83: 
        !            84:                          case STAR:
        !            85:                                nova(i, j);
        !            86:                                break;
        !            87: 
        !            88:                          case INHABIT:
        !            89:                                kills(i, j, -1);
        !            90:                                break;
        !            91: 
        !            92:                          case BASE:
        !            93:                                killb(i, j);
        !            94:                                Game.killb += 1;
        !            95:                                break;
        !            96: 
        !            97:                          case ENTERPRISE:
        !            98:                          case QUEENE:
        !            99:                                se = 2000;
        !           100:                                if (Ship.shldup)
        !           101:                                        if (Ship.shield >= se)
        !           102:                                        {
        !           103:                                                Ship.shield -= se;
        !           104:                                                se = 0;
        !           105:                                        }
        !           106:                                        else
        !           107:                                        {
        !           108:                                                se -= Ship.shield;
        !           109:                                                Ship.shield = 0;
        !           110:                                        }
        !           111:                                Ship.energy -= se;
        !           112:                                if (Ship.energy <= 0)
        !           113:                                        lose(L_SUICID);
        !           114:                                break;
        !           115: 
        !           116:                          default:
        !           117:                                printf("Unknown object %c at %d,%d destroyed\n",
        !           118:                                        se, i, j);
        !           119:                                Sect[i][j] = EMPTY;
        !           120:                                break;
        !           121:                        }
        !           122:                }
        !           123:        }
        !           124:        return;
        !           125: }

unix.superglobalmegacorp.com

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