1*25995Smckusick /* 2*25995Smckusick * Copyright (c) 1980 Regents of the University of California. 3*25995Smckusick * All rights reserved. The Berkeley software License Agreement 4*25995Smckusick * specifies the terms and conditions for redistribution. 5*25995Smckusick */ 6*25995Smckusick 711697Smckusick #ifndef lint 8*25995Smckusick static char sccsid[] = "@(#)shield.c 5.1 (Berkeley) 01/29/86"; 911697Smckusick #endif not lint 1011697Smckusick 1111697Smckusick # include "trek.h" 1211697Smckusick # include "getpar.h" 1311697Smckusick 1411697Smckusick /* 1511697Smckusick ** SHIELD AND CLOAKING DEVICE CONTROL 1611697Smckusick ** 1711697Smckusick ** 'f' is one for auto shield up (in case of Condition RED), 1811697Smckusick ** zero for shield control, and negative one for cloaking 1911697Smckusick ** device control. 2011697Smckusick ** 2111697Smckusick ** Called with an 'up' or 'down' on the same line, it puts 2211697Smckusick ** the shields/cloak into the specified mode. Otherwise it 2311697Smckusick ** reports to the user the current mode, and asks if she wishes 2411697Smckusick ** to change. 2511697Smckusick ** 2611697Smckusick ** This is not a free move. Hits that occur as a result of 2711697Smckusick ** this move appear as though the shields are half up/down, 2811697Smckusick ** so you get partial hits. 2911697Smckusick */ 3011697Smckusick 3112798Slayer struct cvntab Udtab[] = 3211697Smckusick { 3312798Slayer "u", "p", (int (*)())1, 0, 3411697Smckusick "d", "own", 0, 0, 3511697Smckusick 0 3611697Smckusick }; 3711697Smckusick 3811697Smckusick shield(f) 3911697Smckusick int f; 4011697Smckusick { 4111697Smckusick register int i; 4211697Smckusick char c; 4311697Smckusick struct cvntab *r; 4411697Smckusick char s[100]; 4511697Smckusick char *device, *dev2, *dev3; 4611697Smckusick int ind; 4711697Smckusick char *stat; 4811697Smckusick 4911697Smckusick if (f > 0 && (Ship.shldup || damaged(SRSCAN))) 5011697Smckusick return; 5111697Smckusick if (f < 0) 5211697Smckusick { 5311697Smckusick /* cloaking device */ 5411697Smckusick if (Ship.ship == QUEENE) 5511697Smckusick return (printf("Ye Faire Queene does not have the cloaking device.\n")); 5611697Smckusick device = "Cloaking device"; 5711697Smckusick dev2 = "is"; 5811697Smckusick ind = CLOAK; 5911697Smckusick dev3 = "it"; 6011697Smckusick stat = &Ship.cloaked; 6111697Smckusick } 6211697Smckusick else 6311697Smckusick { 6411697Smckusick /* shields */ 6511697Smckusick device = "Shields"; 6611697Smckusick dev2 = "are"; 6711697Smckusick dev3 = "them"; 6811697Smckusick ind = SHIELD; 6911697Smckusick stat = &Ship.shldup; 7011697Smckusick } 7111697Smckusick if (damaged(ind)) 7211697Smckusick { 7311697Smckusick if (f <= 0) 7411697Smckusick out(ind); 7511697Smckusick return; 7611697Smckusick } 7711697Smckusick if (Ship.cond == DOCKED) 7811697Smckusick { 7911697Smckusick printf("%s %s down while docked\n", device, dev2); 8011697Smckusick return; 8111697Smckusick } 8211697Smckusick if (f <= 0 && !testnl()) 8311697Smckusick { 8411697Smckusick r = getcodpar("Up or down", Udtab); 8512798Slayer i = (int) r->value; 8611697Smckusick } 8711697Smckusick else 8811697Smckusick { 8911697Smckusick if (*stat) 9012798Slayer sprintf(s, "%s %s up. Do you want %s down", device, dev2, dev3); 9111697Smckusick else 9212798Slayer sprintf(s, "%s %s down. Do you want %s up", device, dev2, dev3); 9311697Smckusick if (!getynpar(s)) 9411697Smckusick return; 9511697Smckusick i = !*stat; 9611697Smckusick } 9711697Smckusick if (*stat == i) 9811697Smckusick { 9911697Smckusick printf("%s already ", device); 10011697Smckusick if (i) 10111697Smckusick printf("up\n"); 10211697Smckusick else 10311697Smckusick printf("down\n"); 10411697Smckusick return; 10511697Smckusick } 10611697Smckusick if (i) 10711697Smckusick if (f >= 0) 10812798Slayer Ship.energy -= Param.shupengy; 10911697Smckusick else 11011697Smckusick Ship.cloakgood = 0; 11111697Smckusick Move.free = 0; 11211697Smckusick if (f >= 0) 11311697Smckusick Move.shldchg = 1; 11411697Smckusick *stat = i; 11511697Smckusick return; 11611697Smckusick } 117