Commit | Line | Data |
---|---|---|
6f84b93e KM |
1 | #ifndef lint |
2 | static char sccsid[] = "@(#)checkcond.c 4.1 (Berkeley) %G%"; | |
3 | #endif not lint | |
4 | ||
5 | # include "trek.h" | |
6 | ||
7 | /* | |
8 | ** Check for Condition After a Move | |
9 | ** | |
10 | ** Various ship conditions are checked. First we check | |
11 | ** to see if we have already lost the game, due to running | |
12 | ** out of life support reserves, running out of energy, | |
13 | ** or running out of crew members. The check for running | |
14 | ** out of time is in events(). | |
15 | ** | |
16 | ** If we are in automatic override mode (Etc.nkling < 0), we | |
17 | ** don't want to do anything else, lest we call autover | |
18 | ** recursively. | |
19 | ** | |
20 | ** In the normal case, if there is a supernova, we call | |
21 | ** autover() to help us escape. If after calling autover() | |
22 | ** we are still in the grips of a supernova, we get burnt | |
23 | ** up. | |
24 | ** | |
25 | ** If there are no Klingons in this quadrant, we nullify any | |
26 | ** distress calls which might exist. | |
27 | ** | |
28 | ** We then set the condition code, based on the energy level | |
29 | ** and battle conditions. | |
30 | */ | |
31 | ||
32 | checkcond() | |
33 | { | |
34 | register int i, j; | |
35 | ||
36 | /* see if we are still alive and well */ | |
37 | if (Ship.reserves < 0.0) | |
38 | lose(L_NOLIFE); | |
39 | if (Ship.energy <= 0) | |
40 | lose(L_NOENGY); | |
41 | if (Ship.crew <= 0) | |
42 | lose(L_NOCREW); | |
43 | /* if in auto override mode, ignore the rest */ | |
44 | if (Etc.nkling < 0) | |
45 | return; | |
46 | /* call in automatic override if appropriate */ | |
47 | if (Quad[Ship.quadx][Ship.quady].stars < 0) | |
48 | autover(); | |
49 | if (Quad[Ship.quadx][Ship.quady].stars < 0) | |
50 | lose(L_SNOVA); | |
51 | /* nullify distress call if appropriate */ | |
52 | if (Etc.nkling <= 0) | |
53 | killd(Ship.quadx, Ship.quady, 1); | |
54 | ||
55 | /* set condition code */ | |
56 | if (Ship.cond == DOCKED) | |
57 | return; | |
58 | ||
59 | if (Etc.nkling > 0) | |
60 | { | |
61 | Ship.cond = RED; | |
62 | return; | |
63 | } | |
64 | if (Ship.energy < Param.energylow) | |
65 | { | |
66 | Ship.cond = YELLOW; | |
67 | return; | |
68 | } | |
69 | Ship.cond = GREEN; | |
70 | return; | |
71 | } |