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