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