/* * execute: * Execute a single command */ void execute(PLAYER *pp) { char ch; ch = pp->p_cbuf[pp->p_ncount++]; #ifdef FLY if (pp->p_flying >= 0) { switch (ch) { case CTRL('L'): sendcom(pp, REDRAW); break; case 'q': (void) strcpy(pp->p_death, "| Quit |"); break; } return; } #endif switch (ch) { case CTRL('L'): sendcom(pp, REDRAW); break; case 'h': move_player(pp, LEFTS); break; case 'H': turn_player(pp, LEFTS); break; case 'j': move_player(pp, BELOW); break; case 'J': turn_player(pp, BELOW); break; case 'k': move_player(pp, ABOVE); break; case 'K': turn_player(pp, ABOVE); break; case 'l': move_player(pp, RIGHT); break; case 'L': turn_player(pp, RIGHT); break; case 'f': case '1': fire(pp, 0); /* SHOT */ break; case 'g': case '2': fire(pp, 1); /* GRENADE */ break; case 'F': case '3': fire(pp, 2); /* SATCHEL */ break; case 'G': case '4': fire(pp, 3); /* 7x7 BOMB */ break; case '5': fire(pp, 4); /* 9x9 BOMB */ break; case '6': fire(pp, 5); /* 11x11 BOMB */ break; case '7': fire(pp, 6); /* 13x13 BOMB */ break; case '8': fire(pp, 7); /* 15x15 BOMB */ break; case '9': fire(pp, 8); /* 17x17 BOMB */ break; case '0': fire(pp, 9); /* 19x19 BOMB */ break; case '@': fire(pp, 10); /* 21x21 BOMB */ break; #ifdef OOZE case 'o': fire_slime(pp, 0); /* SLIME */ break; case 'O': fire_slime(pp, 1); /* SSLIME */ break; case 'p': fire_slime(pp, 2); break; case 'P': fire_slime(pp, 3); break; #endif case 's': scan(pp); break; case 'c': cloak(pp); break; case 'q': (void) strcpy(pp->p_death, "| Quit |"); break; } }
static void scramble(unsigned char *buf, int len) { rot13(buf, len); cloak(buf, len); }
static void makemoves(void) { int i, hitme; char ch; while (TRUE) { /* command loop */ hitme = FALSE; justin = 0; Time = 0.0; i = -1; while (TRUE) { /* get a command */ chew(); skip(1); proutn("COMMAND> "); if (scan() == IHEOL) continue; for (i=0; i < 29; i++) // Abbreviations allowed for the first 29 commands, only. if (isit(commands[i])) break; if (i < 29) break; for (; i < NUMCOMMANDS; i++) if (strcmp(commands[i], citem) == 0) break; if (i < NUMCOMMANDS #ifndef CLOAKING && i != 26 // ignore the CLOAK command #endif #ifndef CAPTURE && i != 27 // ignore the CAPTURE command #endif #ifndef SCORE && i != 28 // ignore the SCORE command #endif #ifndef DEBUG && i != 33 // ignore the DEBUG command #endif ) break; if (skill <= SFAIR) { prout("UNRECOGNIZED COMMAND. LEGAL COMMANDS ARE:"); listCommands(TRUE); } else prout("UNRECOGNIZED COMMAND."); } switch (i) { /* command switch */ case 0: // srscan srscan(1); break; case 1: // lrscan lrscan(); break; case 2: // phasers phasers(); if (ididit) { #ifdef CLOAKING if (irhere && d.date >= ALGERON && !isviolreported && iscloaked) { prout("The Romulan ship discovers you are breaking the Treaty of Algeron!"); ncviol++; isviolreported = TRUE; } #endif hitme = TRUE; } break; case 3: // photons photon(); if (ididit) { #ifdef CLOAKING if (irhere && d.date >= ALGERON && !isviolreported && iscloaked) { prout("The Romulan ship discovers you are breaking the Treaty of Algeron!"); ncviol++; isviolreported = TRUE; } #endif hitme = TRUE; } break; case 4: // move warp(1); break; case 5: // shields sheild(1); if (ididit) { attack(2); shldchg = 0; } break; case 6: // dock dock(); break; case 7: // damages dreprt(); break; case 8: // chart chart(0); break; case 9: // impulse impuls(); break; case 10: // rest waiting(); if (ididit) hitme = TRUE; break; case 11: // warp setwrp(); break; case 12: // status srscan(3); break; case 13: // sensors sensor(); break; case 14: // orbit orbit(); if (ididit) hitme = TRUE; break; case 15: // transport "beam" beam(); break; case 16: // mine mine(); if (ididit) hitme = TRUE; break; case 17: // crystals usecrystals(); break; case 18: // shuttle shuttle(); if (ididit) hitme = TRUE; break; case 19: // Planet list preport(); break; case 20: // Status information srscan(2); break; case 21: // Game Report report(0); break; case 22: // use COMPUTER! eta(); break; case 23: listCommands(TRUE); break; case 24: // Emergency exit clearscreen(); // Hide screen freeze(TRUE); // forced save exit(1); // And quick exit break; case 25: probe(); // Launch probe break; #ifdef CLOAKING case 26: cloak(); // turn on/off cloaking if (iscloaking) { attack(2); // We will be seen while we cloak iscloaking = FALSE; iscloaked = TRUE; } break; #endif #ifdef CAPTURE case 27: capture(); // Attempt to get Klingon ship to surrender if (ididit) hitme = TRUE; break; #endif #ifdef SCORE case 28: score(1); // get the score break; #endif case 29: // Abandon Ship abandn(); break; case 30: // Self Destruct dstrct(); break; case 31: // Save Game freeze(FALSE); if (skill > SGOOD) prout("WARNING--Frozen games produce no plaques!"); break; case 32: // Try a desparation measure deathray(); if (ididit) hitme = TRUE; break; #ifdef DEBUG case 33: // What do we want for debug??? debugme(); break; #endif case 34: // Call for help help(); break; case 35: alldone = 1; // quit the game #ifdef DEBUG if (idebug) score(0); #endif break; case 36: helpme(); // get help break; } for (;;) { if (alldone) break; // Game has ended #ifdef DEBUG if (idebug) prout("2500"); #endif if (Time != 0.0) { events(); if (alldone) break; // Events did us in } if (d.galaxy[quadx][quady] == 1000) { // Galaxy went Nova! atover(0); continue; } if (nenhere == 0) movetho(); if (hitme && justin==0) { attack(2); if (alldone) break; if (d.galaxy[quadx][quady] == 1000) { // went NOVA! atover(0); hitme = TRUE; continue; } } break; } if (alldone) break; } }
/* * execute: * Execute a single command from a player */ void execute(PLAYER *pp) { char ch; ch = pp->p_cbuf[pp->p_ncount++]; /* When flying, only allow refresh and quit. */ if (pp->p_flying >= 0) { switch (ch) { case CTRL('L'): sendcom(pp, REDRAW); break; case 'q': (void) strlcpy(pp->p_death, "| Quit |", sizeof pp->p_death); break; } return; } /* Decode the command character: */ switch (ch) { case CTRL('L'): sendcom(pp, REDRAW); /* Refresh */ break; case 'h': move_player(pp, LEFTS); /* Move left */ break; case 'H': face(pp, LEFTS); /* Face left */ break; case 'j': move_player(pp, BELOW); /* Move down */ break; case 'J': face(pp, BELOW); /* Face down */ break; case 'k': move_player(pp, ABOVE); /* Move up */ break; case 'K': face(pp, ABOVE); /* Face up */ break; case 'l': move_player(pp, RIGHT); /* Move right */ break; case 'L': face(pp, RIGHT); /* Face right */ break; case 'f': case '1': fire(pp, 0); /* SHOT */ break; case 'g': case '2': fire(pp, 1); /* GRENADE */ break; case 'F': case '3': fire(pp, 2); /* SATCHEL */ break; case 'G': case '4': fire(pp, 3); /* 7x7 BOMB */ break; case '5': fire(pp, 4); /* 9x9 BOMB */ break; case '6': fire(pp, 5); /* 11x11 BOMB */ break; case '7': fire(pp, 6); /* 13x13 BOMB */ break; case '8': fire(pp, 7); /* 15x15 BOMB */ break; case '9': fire(pp, 8); /* 17x17 BOMB */ break; case '0': fire(pp, 9); /* 19x19 BOMB */ break; case '@': fire(pp, 10); /* 21x21 BOMB */ break; case 'o': fire_slime(pp, 0); /* SLIME */ break; case 'O': fire_slime(pp, 1); /* SSLIME */ break; case 'p': fire_slime(pp, 2); /* large slime */ break; case 'P': fire_slime(pp, 3); /* very large slime */ break; case 's': /* start scanning */ scan(pp); break; case 'c': /* start cloaking */ cloak(pp); break; case 'q': /* quit */ (void) strlcpy(pp->p_death, "| Quit |", sizeof pp->p_death); break; } }