121269Sdist /* 221269Sdist * Copyright (c) 1980 Regents of the University of California. 334205Sbostic * All rights reserved. 434205Sbostic * 5*42605Sbostic * %sccs.include.redist.c% 621269Sdist */ 721269Sdist 811661Smckusick #ifndef lint 9*42605Sbostic static char sccsid[] = "@(#)checkcond.c 5.4 (Berkeley) 06/01/90"; 1034205Sbostic #endif /* not lint */ 1111661Smckusick 1211661Smckusick # include "trek.h" 1311661Smckusick 1411661Smckusick /* 1511661Smckusick ** Check for Condition After a Move 1611661Smckusick ** 1711661Smckusick ** Various ship conditions are checked. First we check 1811661Smckusick ** to see if we have already lost the game, due to running 1911661Smckusick ** out of life support reserves, running out of energy, 2011661Smckusick ** or running out of crew members. The check for running 2111661Smckusick ** out of time is in events(). 2211661Smckusick ** 2311661Smckusick ** If we are in automatic override mode (Etc.nkling < 0), we 2411661Smckusick ** don't want to do anything else, lest we call autover 2511661Smckusick ** recursively. 2611661Smckusick ** 2711661Smckusick ** In the normal case, if there is a supernova, we call 2811661Smckusick ** autover() to help us escape. If after calling autover() 2911661Smckusick ** we are still in the grips of a supernova, we get burnt 3011661Smckusick ** up. 3111661Smckusick ** 3211661Smckusick ** If there are no Klingons in this quadrant, we nullify any 3311661Smckusick ** distress calls which might exist. 3411661Smckusick ** 3511661Smckusick ** We then set the condition code, based on the energy level 3611661Smckusick ** and battle conditions. 3711661Smckusick */ 3811661Smckusick 3911661Smckusick checkcond() 4011661Smckusick { 4111661Smckusick register int i, j; 4211661Smckusick 4311661Smckusick /* see if we are still alive and well */ 4411661Smckusick if (Ship.reserves < 0.0) 4511661Smckusick lose(L_NOLIFE); 4611661Smckusick if (Ship.energy <= 0) 4711661Smckusick lose(L_NOENGY); 4811661Smckusick if (Ship.crew <= 0) 4911661Smckusick lose(L_NOCREW); 5011661Smckusick /* if in auto override mode, ignore the rest */ 5111661Smckusick if (Etc.nkling < 0) 5211661Smckusick return; 5311661Smckusick /* call in automatic override if appropriate */ 5411661Smckusick if (Quad[Ship.quadx][Ship.quady].stars < 0) 5511661Smckusick autover(); 5611661Smckusick if (Quad[Ship.quadx][Ship.quady].stars < 0) 5711661Smckusick lose(L_SNOVA); 5811661Smckusick /* nullify distress call if appropriate */ 5911661Smckusick if (Etc.nkling <= 0) 6011661Smckusick killd(Ship.quadx, Ship.quady, 1); 6111661Smckusick 6211661Smckusick /* set condition code */ 6311661Smckusick if (Ship.cond == DOCKED) 6411661Smckusick return; 6511661Smckusick 6611661Smckusick if (Etc.nkling > 0) 6711661Smckusick { 6811661Smckusick Ship.cond = RED; 6911661Smckusick return; 7011661Smckusick } 7111661Smckusick if (Ship.energy < Param.energylow) 7211661Smckusick { 7311661Smckusick Ship.cond = YELLOW; 7411661Smckusick return; 7511661Smckusick } 7611661Smckusick Ship.cond = GREEN; 7711661Smckusick return; 7811661Smckusick } 79