|
|
1.1 ! root 1: #ifndef lint ! 2: static char sccsid[] = "@(#)shield.c 4.2 (Berkeley) 5/27/83"; ! 3: #endif not lint ! 4: ! 5: # include "trek.h" ! 6: # include "getpar.h" ! 7: ! 8: /* ! 9: ** SHIELD AND CLOAKING DEVICE CONTROL ! 10: ** ! 11: ** 'f' is one for auto shield up (in case of Condition RED), ! 12: ** zero for shield control, and negative one for cloaking ! 13: ** device control. ! 14: ** ! 15: ** Called with an 'up' or 'down' on the same line, it puts ! 16: ** the shields/cloak into the specified mode. Otherwise it ! 17: ** reports to the user the current mode, and asks if she wishes ! 18: ** to change. ! 19: ** ! 20: ** This is not a free move. Hits that occur as a result of ! 21: ** this move appear as though the shields are half up/down, ! 22: ** so you get partial hits. ! 23: */ ! 24: ! 25: struct cvntab Udtab[] = ! 26: { ! 27: "u", "p", (int (*)())1, 0, ! 28: "d", "own", 0, 0, ! 29: 0 ! 30: }; ! 31: ! 32: shield(f) ! 33: int f; ! 34: { ! 35: register int i; ! 36: char c; ! 37: struct cvntab *r; ! 38: char s[100]; ! 39: char *device, *dev2, *dev3; ! 40: int ind; ! 41: char *stat; ! 42: ! 43: if (f > 0 && (Ship.shldup || damaged(SRSCAN))) ! 44: return; ! 45: if (f < 0) ! 46: { ! 47: /* cloaking device */ ! 48: if (Ship.ship == QUEENE) ! 49: return (printf("Ye Faire Queene does not have the cloaking device.\n")); ! 50: device = "Cloaking device"; ! 51: dev2 = "is"; ! 52: ind = CLOAK; ! 53: dev3 = "it"; ! 54: stat = &Ship.cloaked; ! 55: } ! 56: else ! 57: { ! 58: /* shields */ ! 59: device = "Shields"; ! 60: dev2 = "are"; ! 61: dev3 = "them"; ! 62: ind = SHIELD; ! 63: stat = &Ship.shldup; ! 64: } ! 65: if (damaged(ind)) ! 66: { ! 67: if (f <= 0) ! 68: out(ind); ! 69: return; ! 70: } ! 71: if (Ship.cond == DOCKED) ! 72: { ! 73: printf("%s %s down while docked\n", device, dev2); ! 74: return; ! 75: } ! 76: if (f <= 0 && !testnl()) ! 77: { ! 78: r = getcodpar("Up or down", Udtab); ! 79: i = (int) r->value; ! 80: } ! 81: else ! 82: { ! 83: if (*stat) ! 84: sprintf(s, "%s %s up. Do you want %s down", device, dev2, dev3); ! 85: else ! 86: sprintf(s, "%s %s down. Do you want %s up", device, dev2, dev3); ! 87: if (!getynpar(s)) ! 88: return; ! 89: i = !*stat; ! 90: } ! 91: if (*stat == i) ! 92: { ! 93: printf("%s already ", device); ! 94: if (i) ! 95: printf("up\n"); ! 96: else ! 97: printf("down\n"); ! 98: return; ! 99: } ! 100: if (i) ! 101: if (f >= 0) ! 102: Ship.energy -= Param.shupengy; ! 103: else ! 104: Ship.cloakgood = 0; ! 105: Move.free = 0; ! 106: if (f >= 0) ! 107: Move.shldchg = 1; ! 108: *stat = i; ! 109: return; ! 110: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.