1 /* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)pl_4.c 8.1 (Berkeley) 05/31/93"; 10 #endif /* not lint */ 11 12 #include "player.h" 13 14 changesail() 15 { 16 int rig, full; 17 18 rig = mc->rig1; 19 full = mf->FS; 20 if (windspeed == 6 || windspeed == 5 && mc->class > 4) 21 rig = 0; 22 if (mc->crew3 && rig) { 23 if (!full) { 24 if (sgetch("Increase to Full sails? ", 25 (struct ship *)0, 1) == 'y') { 26 changed = 1; 27 Write(W_FS, ms, 0, 1, 0, 0, 0); 28 } 29 } else { 30 if (sgetch("Reduce to Battle sails? ", 31 (struct ship *)0, 1) == 'y') { 32 Write(W_FS, ms, 0, 0, 0, 0, 0); 33 changed = 1; 34 } 35 } 36 } else if (!rig) 37 Signal("Sails rent to pieces", (struct ship *)0); 38 } 39 40 acceptsignal() 41 { 42 char buf[60]; 43 register char *p = buf; 44 45 *p++ = '"'; 46 sgetstr("Message? ", p, sizeof buf - 2); 47 while (*p++) 48 ; 49 p[-1] = '"'; 50 *p = 0; 51 Write(W_SIGNAL, ms, 1, (int)buf, 0, 0, 0); 52 } 53 54 lookout() 55 { 56 register struct ship *sp; 57 char buf[3]; 58 register char c; 59 60 sgetstr("What ship? ", buf, sizeof buf); 61 foreachship(sp) { 62 c = *countryname[sp->nationality]; 63 if ((c == *buf || tolower(c) == *buf || colours(sp) == *buf) 64 && (sp->file->stern == buf[1] || sterncolour(sp) == buf[1] 65 || buf[1] == '?')) { 66 eyeball(sp); 67 } 68 } 69 } 70 71 char * 72 saywhat(sp, flag) 73 register struct ship *sp; 74 char flag; 75 { 76 if (sp->file->captain[0]) 77 return sp->file->captain; 78 else if (sp->file->struck) 79 return "(struck)"; 80 else if (sp->file->captured != 0) 81 return "(captured)"; 82 else if (flag) 83 return "(available)"; 84 else 85 return "(computer)"; 86 } 87 88 eyeball(ship) 89 register struct ship *ship; 90 { 91 int i; 92 93 if (ship->file->dir != 0) { 94 Signal("Sail ho! (range %d, %s)", 95 (struct ship *)0, range(ms, ship), saywhat(ship, 0)); 96 i = portside(ms, ship, 1) - mf->dir; 97 if (i <= 0) 98 i += 8; 99 Signal("%s (%c%c) %s %s %s.", 100 ship, countryname[ship->nationality], 101 classname[ship->specs->class], directionname[i]); 102 } 103 } 104