5 REM *** DEBUGGED AND CONVERTED TO BASIC-PLUS (PDP-11) BY DAVE AHL
6 REM *** CONVERTED TO 4K BASIC BY D GILLIS
10 PRINT "YOU COMMAND A FLEET OF SHIPS OPERATING IN ENEMY TERRITORY!!!"
20 PRINT "DO YOU NEED INSTRUCTIONS (0=NO 1=YES)";
40 INPUT Q0
50 IF Q0=1THEN90
60 IF Q0=0THEN170
70 PRINT "INPUT 1='YES' OR 0='NO'"
80 GOTO 40
90 PRINT "YOU TELL YOUR GUN CREWS THE ELEVATION TO SET THIER GUNS."
100 PRINT "ELEVATION IS IN DEGREES FROM 0 TO 360."
110 PRINT "YOUR TASK FORCE CONSISTS OF 3 DESTROYERS,2 CRUSERS"
120 PRINT "2 BATTLESHIPS, AND 2 HEAVY AIRCRAFT CARRIERS."
130 PRINT "THE ENEMY HAS 9 SHIPS FOR HIS DEFENSE."
140 PRINT "IF YOU SUCCEED IN SINKING ALL HIS SHIPS BEFORE HE SINKS"
150 PRINT "YOURS, YOU HAVE WON. HOWEVER, IF HE SINKS ALL YOUR SHIPS"
160 PRINT "BEFORE YOU HAVE DEFEATED HIM, YOU HAVE LOST!!"
170 PRINT "LET US BEGIN !!!"
190 A=0:O=0:P5=0:S1=0:S2=0:C=0:P2=0:P1=0:S=0:P4=0:G=0:R=0
200 M=0
210 PRINT:FOR Z5=1 TO 5
220 READ Z0
230 A=A+1
240 GOTO 320
250 RESTORE 
260 IF R=9THEN840
261 IF G=9THEN840
270 FOR X=1 TO A
280 READ Z0
290 NEXT X
300 READ Z0
310 A=A+1
320 IF Z0=9THEN390
330 IF Z0=1THEN2000
340 IF Z0=5THEN360
350 GOTO 1460
360 IF P5=1THEN840
370 P5=1
380 GOTO 400
390 RESTORE 
400 PRINT "YOUR FLAGSHIP REPORTS THE SIGHTING OF AN ENEMY ";
401 P0=Z0:GOSUB 3000:PRINT"."
410 T=43000.-30000*RND(0)+(RND(0)*10)*.987654+102
420 IF T<10000THEN410
430 S=0:P2=0
440 T=INT(T)
450 IF Z0=1THEN2030
460 PRINT "YOUR INSTRUMENTS READ THE RANGE TO THE TARGET AS"T"YARDS."
480 IF P=1THEN1480
490 IF S>4THEN510
500 GOTO 540
510 PRINT:PRINT "ALL RIGHT, BAD SHOT, THE TARGET HAS MOVED OUT OF"
520 PRINT "RANGE !!!  LETS TRY IT AGAIN !!!":PRINT
530 GOTO 250
540 PRINT "WHAT ELEVATION ** ";
550 REM ON ERROR GOTO 560
552 REM WAIT 10
554 INPUT B
556 GOTO 590
560 REM IF ERR<>15THENON ERROR GOTO 0
565 REM RESUME 570
570 PRINT:PRINT "   ADMIRAL !! YOU HAVE TO BE FAST IN THIS GAME !!"
580 GOTO 1590
590 PRINT "FIRE !!"
600 S=S+1
610 IF B=999THEN1850
620 IF B>360THEN1410
630 IF B<0THEN750
640 IF B=0THEN770
650 IF B=90THEN980
660 IF B>330THEN770
670 IF B>180THEN1370
680 IF B>150THEN1300
690 IF B>90THEN1020
700 E1=INT(T-(46500.*SIN(2*B/57.3)))
710 E2=ABS(E1)
711 IF E2<100THEN1050
720 IF E1>100THEN1200
730 IF E1<-100THEN1250
740 GOTO 1050
750 PRINT "GUN BACKFIRED, KILLING CREW!"
760 GOTO 820
770 PRINT "WHAT ARE YOU TRYING TO DO ? KILL SOME FISH ? THE SHELL"
780 PRINT "EXPLODED UNDER WATER FIFTY FEET FROM YOUR SHIP!!!"
790 IF P=1THEN1590
800 IF P3=1THEN830
810 IF P=1THEN830
820 PRINT "    ADMIRAL PLEASE !!!!"
830 GOTO 490
840 PRINT "    ******** PEACE ********"
850 PRINT 
860 PRINT 
870 PRINT 
880 PRINT "YOU FIRED"S1"ROUNDS. THE ENEMY FIRED"S2"ROUNDS."
900 IF R=9THEN920
910 IF G=9THEN950
920 PRINT "ALL OF YOUR SHIPS HAVE BEEN SUNK.  SO SORRY"
930 PRINT "THE BATTLE IS OVER..........THE ENEMY WINS."
940 GOTO 2220
950 PRINT "YOU HAVE DECIMATED THE ENEMY.........THAT'S NICE"
960 PRINT "THE BATTLE IS OVER.........YOU WIN!!!!"
970 GOTO 2220
980 PRINT "YOU IDIOT !! YOU SHOT STRAIGHT UP!!, AND THE SHELL"
990 PRINT "LANDED ON YOUR OWN GUN POSITION, DESTROYING IT!!!"
1000 IF P=1THEN1590
1010 GOTO 800
1020 PRINT "HEY STUPID, YOU'RE FIRING ON YOUR OWN SHIPS!!!"
1030 IF P=1THEN1590
1040 GOTO 800
1050 IF Z0=1THEN1070
1060 GOTO 1090
1070 PRINT "DEPTH CHARGE EXPLODED RIGHT ON TOP OF THAT BABY !!!"
1080 GOTO 1100
1090 PRINT:PRINT " ** BOOM **"
1100 PRINT:FOR Z5=1 TO 5
1110 PRINT "TARGET DESTROYED !!!",S"ROUNDS EXPENDED.":PRINT
1150 S1=S1+S
1160 P=0
1170 P3=0
1180 G=G+1
1190 GOTO 250
1200 IF Z0=1THEN2130
1210 PRINT "SHOT FELL"ABS(E1)"YARDS SHORT OF TARGET."
1230 IF P=1THEN1590
1240 GOTO 490
1250 IF Z0=1THEN2160
1260 PRINT "SHELL OVERSHOT TARGET BY"ABS(E1)"YARDS."
1280 IF P=1THEN1590
1290 GOTO 490
1300 PRINT 
1310 PRINT "  YOU SHOT A PROJECTILE, INTO THE AIR,"
1320 PRINT "  IT FELL TO THE WATER, YOU KNOW NOT WHERE."
1330 PRINT "BUT I DO, YOU IDIOT, YOU JUST SANK YOUR OWN FLEET TANKER!!"
1340 S1=S1+1
1350 IF P=1THEN1590
1360 GOTO 490
1370 PRINT "WHAT ARE YOU TRYING TO DO ?? DRILL A NEW HATCH ?? THE "
1380 PRINT "SHELL EXPLODED IN YOUR SHIP, DESTROYING IT!!!"
1390 IF P=1THEN1590
1400 GOTO 800
1410 PRINT "WHERE DID U LEARN TO TYPE? ";B;"DEGREES EXCEEDS 360 BY"
1420 PRINT B-360;" DEGREES."
1430 S1=S1+1
1440 IF P=1THEN1580
1450 GOTO 490
1460 LET P=1
1470 GOTO 400
1480 PRINT "THE ENEMY ";:P0=Z0:GOSUB 3000
1481 PRINT " IS FIRING ON YOUR SHIPS!"
1490 P4=1234*RND(RND(0))+(RND(0)*10)
1500 IF P4>500THEN1490
1510 IF P2=1THEN1600
1520 IF INT(P4)<100THEN1800
1530 IF Z0=1THEN2100
1540 PRINT "HIS FIRST ROUND FELL"INT(P4)"YARDS SHORT."
1560 LET S2=S2+1
1570 GOTO 490
1580 REM
1590 IF P2=1THEN1490
1600 P1=1250*RND(RND(0))+(RND(0)*10)
1610 IF P1>P4THEN1600
1620 IF P1<(P4-400)THEN1600
1630 IF P1<100THEN1710
1640 LET P4=P1
1650 S2=S2+1
1660 IF Z0=1THEN2190
1670 PRINT "THE ENEMY ROUND FELL"INT(P1)"YARDS SHORT."
1690 M=2
1700 GOTO 490
1710 S2=S2+1
1720 LET P2=1
1730 GOSUB 1850
1740 IF M=1THEN1490
1750 PRINT "THE ENEMY ";:P0=Z0:GOSUB 3000
1751 PRINT " SANK ";:P0=D0:GOSUB 3000:PRINT
1760 R=R+1
1770 IF R=9THEN840
1780 IF D0=18THEN840
1790 GOTO 830
1800 P2=1
1810 GOSUB 1850
1820 PRINT "IN FACT, HE JUST SANK ";:P0=D0:GOSUB 3000:PRINT
1830 R=R+1
1840 GOTO 830
1850 RESTORE 
1860 FOR C=1 TO (9+O)
1870 READ D0
1880 NEXT C
1890 READ D0
1900 O=O+1
1910 R=R+1
1920 DATA 1,2,3
1930 DATA 4,5,6
1940 DATA 7,8,9
1950 DATA 10,11
1960 DATA 12,13
1970 DATA 14,15,16
1980 DATA 17,18
1990 RETURN 
2000 PRINT "YOUR FLAGSHIP HAS DETECTED A U-BOAT APPROCHING AT 5";
2001 PRINT " FATHOMS."
2010 P=1
2020 GOTO 410
2030 PRINT "YOUR SUBMARINE DETECTION EQUIPMENT READS THE RANGE TO THE";
2031 PRINT " TARGET"
2040 T=INT(T-1500)
2050 IF T<0THEN410
2060 PRINT "AS"T"METERS."
2080 PRINT "THE U-BOAT HAS COMMENCED FIRING TORPEDOES AT YOUR SHIPS."
2090 GOTO 1490
2100 PRINT "HIS FIRST TORPEDO EXPLODED"INT(P4)-50;
2101 PRINT "METERS BEHIND YOUR SHIP."
2120 GOTO 1560
2130 PRINT "DEPTH CHARGE EXPLODED"ABS(E1)"METERS SHORT OF TARGET."
2150 GOTO 1590
2160 PRINT "DEPTH CHARGE EXPLODED"ABS(E1)"METERS AFT OF TARGET."
2180 GOTO 1590
2190 PRINT "THE ENEMY TORPEDO EXPLODED"INT(P1)-50;
2191 PRINT "METERS IN FRONT OF YOUR SHIP."
2210 GOTO 490
2220 END
3000 REM STRING VARIABLE PATCHES
3010 IF P0=1THENPRINT "U-BOAT";
3020 IF P0=2THENPRINT "210 MM SHORE GUN";
3030 IF P0=3THENPRINT "70,000 TON CRUISER";
3040 IF P0=4THENPRINT "BATTLESHIP";
3050 IF P0=5THENPRINT "TORPEDO BOAT";
3060 IF P0=6THENPRINT "HEAVY FRIGATE";
3070 IF P0=7THENPRINT "E-TYPE DESTROYER";
3080 IF P0=8THENPRINT "GUIDED-MISSLE SHIP";
3090 IF P0=9THENPRINT "AIRCRAFT CARRIER";
3100 IF P0=10THENPRINT "ONE OF YOUR DESTROYERS!!";
3110 IF P0=11THENPRINT "YOUR HEAVY CRUISER!!";
3120 IF P0=12THENPRINT "ANOTHER OF YOUR DESTROYERS!!";
3130 IF P0=13THENPRINT "ONE OF YOUR BATTLESHIPS!!";
3140 IF P0=14THENPRINT "YOUR LAST DESTROYER";
3150 IF P0=15THENPRINT "YOUR AIRCRAFT CARRIER";
3160 IF P0=16THENPRINT "YOUR LIGHT CRUISER";
3170 IF P0=17THENPRINT "YOUR LAST AIRCRAFT CARRIER";
3180 IF P0=18THENPRINT "YOUR LAST BATTLESHIP!!";
3190 RETURN
