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