Annotation of 42BSD/games/trek/nova.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

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