111697Smckusick #ifndef lint 2*12798Slayer static char sccsid[] = "@(#)shield.c 4.2 (Berkeley) 05/27/83"; 311697Smckusick #endif not lint 411697Smckusick 511697Smckusick # include "trek.h" 611697Smckusick # include "getpar.h" 711697Smckusick 811697Smckusick /* 911697Smckusick ** SHIELD AND CLOAKING DEVICE CONTROL 1011697Smckusick ** 1111697Smckusick ** 'f' is one for auto shield up (in case of Condition RED), 1211697Smckusick ** zero for shield control, and negative one for cloaking 1311697Smckusick ** device control. 1411697Smckusick ** 1511697Smckusick ** Called with an 'up' or 'down' on the same line, it puts 1611697Smckusick ** the shields/cloak into the specified mode. Otherwise it 1711697Smckusick ** reports to the user the current mode, and asks if she wishes 1811697Smckusick ** to change. 1911697Smckusick ** 2011697Smckusick ** This is not a free move. Hits that occur as a result of 2111697Smckusick ** this move appear as though the shields are half up/down, 2211697Smckusick ** so you get partial hits. 2311697Smckusick */ 2411697Smckusick 25*12798Slayer struct cvntab Udtab[] = 2611697Smckusick { 27*12798Slayer "u", "p", (int (*)())1, 0, 2811697Smckusick "d", "own", 0, 0, 2911697Smckusick 0 3011697Smckusick }; 3111697Smckusick 3211697Smckusick shield(f) 3311697Smckusick int f; 3411697Smckusick { 3511697Smckusick register int i; 3611697Smckusick char c; 3711697Smckusick struct cvntab *r; 3811697Smckusick char s[100]; 3911697Smckusick char *device, *dev2, *dev3; 4011697Smckusick int ind; 4111697Smckusick char *stat; 4211697Smckusick 4311697Smckusick if (f > 0 && (Ship.shldup || damaged(SRSCAN))) 4411697Smckusick return; 4511697Smckusick if (f < 0) 4611697Smckusick { 4711697Smckusick /* cloaking device */ 4811697Smckusick if (Ship.ship == QUEENE) 4911697Smckusick return (printf("Ye Faire Queene does not have the cloaking device.\n")); 5011697Smckusick device = "Cloaking device"; 5111697Smckusick dev2 = "is"; 5211697Smckusick ind = CLOAK; 5311697Smckusick dev3 = "it"; 5411697Smckusick stat = &Ship.cloaked; 5511697Smckusick } 5611697Smckusick else 5711697Smckusick { 5811697Smckusick /* shields */ 5911697Smckusick device = "Shields"; 6011697Smckusick dev2 = "are"; 6111697Smckusick dev3 = "them"; 6211697Smckusick ind = SHIELD; 6311697Smckusick stat = &Ship.shldup; 6411697Smckusick } 6511697Smckusick if (damaged(ind)) 6611697Smckusick { 6711697Smckusick if (f <= 0) 6811697Smckusick out(ind); 6911697Smckusick return; 7011697Smckusick } 7111697Smckusick if (Ship.cond == DOCKED) 7211697Smckusick { 7311697Smckusick printf("%s %s down while docked\n", device, dev2); 7411697Smckusick return; 7511697Smckusick } 7611697Smckusick if (f <= 0 && !testnl()) 7711697Smckusick { 7811697Smckusick r = getcodpar("Up or down", Udtab); 79*12798Slayer i = (int) r->value; 8011697Smckusick } 8111697Smckusick else 8211697Smckusick { 8311697Smckusick if (*stat) 84*12798Slayer sprintf(s, "%s %s up. Do you want %s down", device, dev2, dev3); 8511697Smckusick else 86*12798Slayer sprintf(s, "%s %s down. Do you want %s up", device, dev2, dev3); 8711697Smckusick if (!getynpar(s)) 8811697Smckusick return; 8911697Smckusick i = !*stat; 9011697Smckusick } 9111697Smckusick if (*stat == i) 9211697Smckusick { 9311697Smckusick printf("%s already ", device); 9411697Smckusick if (i) 9511697Smckusick printf("up\n"); 9611697Smckusick else 9711697Smckusick printf("down\n"); 9811697Smckusick return; 9911697Smckusick } 10011697Smckusick if (i) 10111697Smckusick if (f >= 0) 102*12798Slayer Ship.energy -= Param.shupengy; 10311697Smckusick else 10411697Smckusick Ship.cloakgood = 0; 10511697Smckusick Move.free = 0; 10611697Smckusick if (f >= 0) 10711697Smckusick Move.shldchg = 1; 10811697Smckusick *stat = i; 10911697Smckusick return; 11011697Smckusick } 111