home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / seabatle.zip / SB.BAS next >
BASIC Source File  |  1987-02-11  |  20KB  |  653 lines

  1.     CLS
  2.     randomize timer
  3.     def seg = 0
  4.     PRINT TAB(33);"Seabattle"
  5.     PRINT TAB(20);"Creative Computing, Morristown, NJ"
  6.     PRINT:PRINT :PRINT
  7.     DIM A(20,20),D(9),B(9)
  8.     open "R",1,"score.dat",12
  9.     field #1, 2% as sc$
  10.     get 1,1
  11.     score% = cvi(sc$)
  12.     ships% = 0
  13.     INPUT "What is your name? ",N$
  14.     REM
  15.     PRINT
  16. 310 REM ***set up area
  17.     FOR I=1 TO 20
  18.     FOR J=1 TO 20
  19.     A(I,J)=0
  20.     NEXT J
  21.     NEXT I
  22.     REM ***Island
  23.     RESTORE 6300
  24.     FOR X=7 TO 13
  25.     FOR Y=7 TO 12
  26.     READ A(X,Y)
  27.     NEXT Y
  28.     NEXT X
  29.     REM *** sub
  30.     S1=10:S2=10
  31.     A(S1,S2)=2
  32.     REM*** enemy ships
  33.     S=INT(RND*16)+15
  34.     RESTORE 6090
  35.     FOR X=1 TO (INT(RND*4)+1)*2-1
  36.     READ D8,D9
  37.     NEXT X
  38.     FOR X=1 TO S
  39. 500 X1=INT(RND*20)+1
  40.     X2=INT(RND*20)+1
  41.     IF A(X1,X2)<>0 THEN 500
  42.     A(X1,X2)=3
  43.     NEXT X
  44.     PRINT "You must destroy";S;"enemy ships to win ";N$;"."
  45.     REM *** headquarters
  46. 570 S3=INT(RND*20)+1
  47.     S4=INT(RND*20)+1
  48.     IF A(S3,S4)<>0 THEN 570
  49.     A(S3,S4)=4
  50.     REM ***underwater mines
  51.     FOR X=1 TO INT(RND*8)+8
  52. 630 X1=INT(RND*20)+1
  53.     X2=INT(RND*20)+1
  54.     IF A(X1,X2)<>0 THEN 630
  55.     A(X1,X2)=5
  56.     NEXT X
  57.     REM *** sea monsters
  58.     FOR X=1 TO 4
  59. 700 X1=INT(RND*18)+1
  60.     X2=INT(RND*18)+1
  61.     IF A(X1,X2)<>0 THEN 700
  62.     A(X1,X2)=6
  63.     RESTORE 6090
  64.     FOR Y=1 TO INT(RND*8)+1
  65.     READ M1,M2
  66.     NEXT Y
  67.     NEXT X
  68.     REM *** set starting values
  69.     FOR I=1 TO 9
  70.     D(I)=0
  71.     NEXT I
  72.     C=30
  73.     P=6000
  74.     F=2500
  75.     T=10
  76.     M=3
  77.     D=100
  78.     D2=2
  79. 880 REM ***command section
  80.     color 9,0
  81.     PRINT:PRINT:PRINT "What are your orders, Captain ";N$;
  82.     INPUT Order$:if order$="" then order$="0"
  83.     o = instr("NSTPMDHXCQWnstpmdhxcqw",order$)
  84.     if o>11 then o=o-11
  85.     ON O GOTO 1040,1680,2220,2680,3250,3410,3700,3880,4400,4660,4690
  86.     PRINT "The commands are:"
  87.     PRINT "     N: Navigation"
  88.     PRINT "     S: Sonar"
  89.     PRINT "     T: Torpedo control"
  90.     PRINT "     P: Polaris missile control"
  91.     PRINT "     M: Manuevering"
  92.     PRINT "     D: Status/damage report"
  93.     PRINT "     H: Headquarters"
  94.     PRINT "     X: Sabotage"
  95.     PRINT "     C: Power conversion"
  96.     PRINT "     Q: Surrender"
  97.     PRINT "     W: Do nothing"
  98.     GOTO 880
  99. 1040 REM ***navigation
  100.      IF D(1)>=0 THEN 1080
  101.      PRINT "Engineering to Captain ";N$;", our engines are under repair!"
  102.      GOTO 880
  103. 1080 IF C>8 THEN 1110
  104.      PRINT "Not enough crew to man the engines, Captain ";N$;"!"
  105.      GOTO 880
  106. 1110 D1 = 1-((.23+RND/10)*(-(D<=50)))
  107.      GOSUB 6080
  108.      PRINT "Power available=";P;". Power to use";
  109.      INPUT P1
  110.      IF P1<0 OR P1>P THEN 880
  111.      IF P1<= 1000 THEN 1210
  112.      IF RND<.43 THEN 1210
  113.      PRINT "Atomic pile goes supercritical, Captain ";N$;"!!! Headquarters"
  114.      PRINT "will warn all subs to stay away from the radioactive area."
  115.      GOTO 6180
  116. 1210 X=S1
  117.      Y=S2
  118.      Q1=1
  119.      FOR X2 =1 TO INT(INT(P1/100+.5)*D1+.5)
  120.      IF X+X1>0 AND X+X1<21 AND Y+Y1>0 AND Y+Y1<21 THEN 1280
  121.      PRINT "You can't leave the area, Captain ";N$;"!!"
  122.      GOTO 1340
  123. 1280 ON A(X+X1,Y+Y1) + 1 GOTO 1290, 1330,1630,1390,1440,1470,1490
  124. 1290 X=X+X1
  125.      Y=Y+Y1
  126.      P=P-100
  127.      GOTO 1520
  128. 1330 PRINT "You almost ran aground, Captain ";N$;"!!"
  129. 1340 A(S1,S2)=0
  130.      A(X,Y)=2
  131.      S1=X
  132.      S2=Y
  133.      GOTO 4690
  134. 1390 IF D>50 THEN 1290
  135.      PRINT "You  rammed a ship!!! You're both sunk, Captain ";N$;"!!"
  136.      S=S-1
  137.      ships% = ships% + 1
  138.      IF S=0 THEN 6260
  139.      GOTO 6180
  140. 1440 IF D>50 THEN 1290
  141.      PRINT "You rammed your own headquarters, you idiot! You've been sunk!"
  142.      GOTO 6180
  143. 1470 PRINT "You've been blown up by a mine, Captain ";N$;"!!"
  144.      GOTO 6180
  145. 1490 IF RND<.21 THEN 1630
  146. 1500 PRINT "You've been eaten by a sea monster, Captain ";N$;"!!"
  147.      GOTO 6180
  148. 1520 REM *** check for nearby sea monsters
  149.      FOR X3=X-2 TO X+2
  150.      FOR Y3 = Y-2 TO Y+2
  151.      IF X3<1 OR X3>20 OR Y3<1 OR Y3>20 THEN 1610
  152.      IF A(X3,Y3)<>6 THEN 1610
  153.      IF RND<.25 THEN 1500
  154.      IF Q1=0 THEN 1610
  155.      PRINT "You just had a narrow escape with a sea monster, Captain ";N$;"!!"
  156.      Q1=0
  157. 1610 NEXT Y3
  158.      NEXT X3
  159. 1630 NEXT X2
  160.      PRINT "Navigation complete. Power left=";P;"."
  161.      IF P>0 THEN 1340
  162. 1660 PRINT "Atomic pile has gone dead!!! Sub sinks, crew suffocates."
  163.      GOTO 6180
  164. 1680 REM ***#1 Sonar
  165.      IF D(2) >= 0 THEN 1720
  166.      PRINT "Sonar is under repair, Captain ";N$;"."
  167.      GOTO 880
  168. 1720 IF C>5 THEN 1750
  169.      PRINT "Not enough crew to work sonar, Captain ";N$;"."
  170.      GOTO 880
  171. 1750 PRINT "Option #";
  172.      INPUT O
  173.      ON INT(O+1) GOTO 1790,2010
  174.      GOTO 1750
  175. 1790 REM ***print out map
  176.      PRINT
  177.      FOR X=1 TO 20
  178.      FOR Y=1 TO 20
  179. 1830 DATA "   ","***","(X)","\S/","!H!"," $ ","-#-"
  180.      IF A(X,Y)<>0 THEN 1880
  181.      goto 1880
  182. 1860 color 15,0: PRINT " . ";
  183.      GOTO 1950
  184. 1880 RESTORE 1830
  185.      FOR X1=1 TO A(X,Y)+1
  186.      READ A$
  187.      NEXT X1
  188.      x1 = x1 - 1
  189.      if x1=1 then color 1,1 else
  190.     if x1=2 then color 10,2 else
  191.     if x1=3 then color 4,1 else
  192.     if x1=4 then color 4,6 else
  193.     if x1=5 then color 6,1 else
  194.     if x1=6 then color 7,4 else
  195.     if x1=7 then color 2,1
  196.      IF D<50 AND RND<.23 AND A(X,Y)<>1 AND A(X,Y)<>2 THEN 1860
  197.      IF RND<.15  AND A(X,Y)>2 THEN 1860
  198.      PRINT A$;
  199. 1950 NEXT Y
  200.      color 0,0:PRINT
  201.      NEXT X
  202. 1980 P=P-50
  203.      IF P>0 THEN 880
  204.      GOTO 1660
  205. 2010 REM *** directional information
  206.      FOR I=1 TO 5
  207.      B(I)=0
  208.      NEXT I
  209.      PRINT "Direction   # of Ships     Distances"
  210.      RESTORE 6090
  211.      FOR X=1 TO 8
  212.      READ X1,Y1
  213.      X3 = 0
  214.      FOR X4 = 1 TO 20
  215.      IF S1+X1*X4<1 OR S1+X1*X4>20 OR S2+Y1*X4<1 OR S2+Y1*X4>20 THEN 2140
  216.      IF A(S1+X1*X4,S2+Y1*X4)<>3 THEN 2130
  217.      X3=X3+1
  218.      B(X3)=X4
  219. 2130 NEXT X4
  220. 2140 IF X3=0 THEN 2200
  221.      PRINT "   ";X,X3,
  222.      FOR X4=1 TO X3
  223.      PRINT B(X4);
  224.      NEXT X4
  225.      PRINT
  226. 2200 NEXT X
  227.      GOTO 1980
  228. 2220 REM *** #2 Torpedo control
  229.      IF D(3) >= 0 THEN 2260
  230.      PRINT "Torpedo tubes are under repair, Captain ";N$;"."
  231.      GOTO 880
  232. 2260 IF C >= 10 THEN 2290
  233.      PRINT "Not enough crew to fire torpedo, Captain ";N$;"."
  234.      GOTO 880
  235. 2290 IF T THEN 2320
  236.      PRINT "No torpedoes left, Captain ";N$;"."
  237.      GOTO 880
  238. 2320 IF D<2000 THEN 2360
  239.      IF RND>.5 THEN 2360
  240.      PRINT "Pressure implodes sub upon firing...you're crushed!!"
  241.      GOTO 6180
  242. 2360 GOSUB 6080
  243.      X=S1
  244.      Y=S2
  245.      FOR X2=1 TO INT(7+5*(-(D>50))-RND*4+.5)
  246.      IF X+X1>0 AND X+X1<21 AND Y+Y1>0 AND Y+Y1<21 THEN 2460
  247.      PRINT "Torpedo out of sonar range...Ineffectual, Captain ";N$;"."
  248. 2420 T=T-1
  249.      P=P-150
  250. 2440 IF P>0 THEN 4690
  251.      GOTO 1660
  252. 2460 ON A(X+X1,Y+Y1)+1 GOTO 2470,2510,2650,2540,2580,2610,2630
  253. 2470 X=X+X1
  254.      Y=Y+Y1
  255.      PRINT "..!.."
  256.      GOTO 2650
  257. 2510 PRINT "You took out some island, Captain ";N$;"."
  258. 2520 A(X+X1,Y+Y1)=0
  259.      GOTO 2420
  260. 2540 PRINT "Ouch!!! You got one Captain ";N$;"!!"
  261.      S=S-1:ships% = ships% + 1
  262.      IF S<>0 THEN 2520
  263.      GOTO 6260
  264. 2580 PRINT "You blew up, your headquarters, you bumblebrain!"
  265.      S3=0: S4=0:D2=0
  266.      GOTO 2520
  267. 2610 PRINT "Blam!! Shot wasted on a mine, Captain ";N$;"."
  268.      GOTO 2520
  269. 2630 PRINT "You killed a poor, helpless sea monster, Captain ";N$;"."
  270.      GOTO 2520
  271. 2650 NEXT X2
  272.      PRINT "Dud."
  273.      GOTO 2420
  274. 2680 REM *** #3: Polaris Missile Control
  275.      IF D(4) >= 0 THEN 2720
  276.      PRINT "Missile silos are under repair, Captain ";N$;"."
  277.      GOTO 880
  278. 2720 IF C>23 THEN 2750
  279.      PRINT "Not enough crew to launch a missile, Captain ";N$;"."
  280.      GOTO 880
  281. 2750 IF M<>0 THEN 2780
  282.      PRINT "No missiles left, Captain ";N$;"."
  283.      GOTO 880
  284. 2780 IF D>50 AND D<2000 THEN 2850
  285.      PRINT "Recommend that you do not fire at this depth...Proceed";
  286.      INPUT A$
  287.      IF LEFT$(A$,1) ="n" OR LEFT$(A$,1) = "N" THEN 880
  288.      IF RND<.5 THEN 2850
  289.      PRINT "Missile explodes on firing, Captain ";N$;"! You're dead!"
  290.      GOTO 6180
  291. 2850 GOSUB 6080
  292. 2860 PRINT "Fuel (lbs.)";
  293.      INPUT F1
  294.      IF F1>0 AND F1 <= F THEN 2910
  295.      PRINT "You have";F;"lbs. of fuel left, Captain ";N$;"."
  296.      GOTO 2860
  297. 2910 F2 = INT (F1/75 +.5)
  298.      IF S1+X1*F2>0 AND S1+X1*F2<21 AND S2+Y1*F2>0 AND S2+Y1*F2<21 THEN 2980
  299.      PRINT "Missile out of sonar tracking, Captain ";N$;". Missile lost."
  300. 2940 M=M-1
  301.      F=F-F1
  302.      P=P-300
  303.      GOTO 2440
  304. 2980 D3=0: D4=0: D5 = 0: D6 =0
  305.      FOR X=S1+X1*F2 -1 TO S1+X1*F2 +1
  306.      FOR Y=S2+Y1*F2 -1 TO S2+Y1*F2 +1
  307.      IF X<1 OR X>20 OR Y<1 OR Y>20 THEN 3140
  308.      D3=D3-(A(X,Y)=3)
  309.      D4=D4-(A(X,Y)=6)
  310.      D5=D5-(A(X,Y)=5)
  311.      D6=D6-(A(X,Y)=1)
  312.      IF A(X,Y)<>4 THEN 3100
  313.      PRINT "You just destroyed your headquarters, Seaman 3rd class ";N$;"!"
  314.      D3=0:S4=0:D2=0
  315.      GOTO 3130
  316. 3100 IF A(X,Y)<>2 THEN 3130
  317.      PRINT "You just destroyed yourself, Captain ";N$;", you idiot!"
  318.      GOTO 6180
  319. 3130 A(X,Y)=0
  320. 3140 NEXT Y
  321.      NEXT X
  322.      IF D6=0 THEN 3180
  323.      PRINT "You blew out some island, Captain ";N$;"."
  324. 3180 IF D5=0 THEN 3200
  325.      PRINT "You destroyed";D5;"mines, Captain ";N$;"."
  326. 3200 IF D4=0 THEN 3220
  327.      PRINT "You got";D4;"sea monsters, Captain ";N$;". Good work!"
  328. 3220 PRINT "You destroyed";D3;"enemy ships, Captain ";N$;"."
  329.      S=S-D3:ships% = ships% + d3:if s = 0 then 6260
  330.      GOTO 2940
  331. 3250 REM ***maneuvering
  332.      IF D(5) >= 0 THEN 3290
  333.      PRINT "Ballast controls are being repaired, Captain ";N$;"."
  334.      GOTO 880
  335. 3290 IF C>12 THEN 3320
  336.      PRINT "There are not enough crew to work the controls, Captain ";N$;"."
  337.      GOTO 880
  338. 3320 PRINT "New depth;"
  339.      INPUT D1
  340.      IF D1 >= 0 AND D1<3000 THEN 3370
  341.      PRINT "Hull crushed by pressure, Captain ";N$;"!"
  342.      GOTO 6180
  343. 3370 P=P-INT(ABS((D-D1)/2+.5))
  344.      PRINT "Maneuver complete. Power loss ="INT(ABS((D-D1)/2+.5))
  345.      D=D1
  346.      GOTO 4690
  347. 3410 REM *** #5 status / damage report
  348.      IF D(6) >= 0 THEN 3450
  349.      PRINT "No reports are able to get through, Captain ";N$;"."
  350.      GOTO 880
  351. 3450 IF C>3 THEN 3480
  352.      PRINT "No one left to give the report, Captain ";N$;"."
  353.      GOTO 880
  354. 3480 PRINT "# of enemy ships left........";S
  355.      PRINT "# of power units left........";P
  356.      PRINT "# of torpedoes left..........";T
  357.      PRINT "# of missiles left...........";M
  358.      PRINT "lbs of fuel left.............";F
  359.      PRINT
  360.      PRINT "Want damage report";
  361.      INPUT A$
  362.      IF LEFT$(A$,1)="n" OR LEFT$(A$,1)="N" THEN 3670
  363.      PRINT "   Item    Damage  (+ good, 0 Neutral, - Bad)"
  364.      PRINT "   ----    ------"
  365. 3600 DATA "Engines","Sonar","Torpedos","Missiles","Maneuvering"
  366.      DATA "Status","Headquarters","Sabotage","Converter"
  367.      RESTORE 3600
  368.      FOR X=1 TO 9
  369.      READ A$
  370.      PRINT A$,D(X)
  371.      NEXT X
  372. 3670 PRINT "You are at location (";S1;",";S2;")."
  373.      PRINT
  374.      GOTO 880
  375. 3700 REM ***# 6 Headquarters
  376.      IF D(7)>=0 THEN 3740
  377.      PRINT "Headquarters is damaged. Unable to help, Captain ";N$;"."
  378.      GOTO 880
  379. 3740 IF D2<>0  THEN 3770
  380.      PRINT "Headquarters is deserted, Captain ";N$;"."
  381.      GOTO 880
  382. 3770 IF SQR((S1-S3)^2 + (S2-S4)^2) <=2 AND D<51 THEN 3800
  383.      PRINT "Unable to comply with docking orders, Captain ";N$;"."
  384.      GOTO 880
  385. 3800 PRINT "Divers from headquarters bring out supplies and men."
  386.      if p<4000 then P=4000
  387.      if t<8 then T=8
  388.      if m<2 then M=2
  389.      if f<1500 then F=1500
  390.      if c<25 then C=25
  391.      D2=D2-1
  392.      GOTO 4690
  393. 3880 REM *** #7 sabotage
  394.      IF D(8)>=0 THEN 3920
  395.      PRINT "Hatches inaccessible, Captain ";N$;". No sabotages possible."
  396.      GOTO 880
  397. 3920 IF C>10 THEN 3950
  398.      PRINT "Not enough crew to go on a mission, Captain ";N$;"."
  399.      GOTO 880
  400. 3950 D3=0:D4=0
  401.      FOR X=S1-2 TO S1+2
  402.      FOR Y=S2-2 TO S2+2
  403.      IF X<1 OR X>20 OR Y<1 OR Y>20 THEN 4010
  404.      D3=D3-(A(X,Y) = 3)
  405.      D4=D4-(A(X,Y) = 6)
  406. 4010 NEXT Y
  407.      NEXT X
  408.      IF D3<>0 THEN 4060
  409.      PRINT "No ships in range, Captain ";N$;"."
  410.      GOTO 880
  411. 4060 PRINT "There are";D3;"ships in range, Captain ";N$;"."
  412. 4070 PRINT "How many men are going, Captain ";N$;
  413. 4080 INPUT Q1
  414.      if q1 < 1 then print "You need at least 1 man, idiot!!":goto 4080
  415.      IF C-Q1 >= 10 THEN 4120
  416.      PRINT "You must leave at least 10 men on board, Captain ";N$;"."
  417.      GOTO 4070
  418. 4120 D5 = INT(D3/Q1 +.5)
  419.      D6=0
  420.      FOR X=S1-2 TO S1+2
  421.      FOR Y=S2-2 TO S2+2
  422.      IF D3/Q1>1-RND AND RND + D3/Q1<.9 THEN 4220
  423.      IF A(X,Y)<>3 THEN 4220
  424.      D6=D6+1
  425.      A(X,Y)=0
  426.      S=S-1:ships% = ships% + 1
  427.      IF S=0 THEN 6260
  428. 4220 NEXT Y
  429.      NEXT X
  430.      PRINT D6;"ships were destroyed, Captain ";N$;"."
  431.      D6=0:D7=0
  432.      FOR X=1 TO Q1
  433.      D7=D7-(RND>.6)
  434.      NEXT X
  435.      FOR X=1 TO Q1-D7
  436.      D6=D6-(RND<.15)
  437.      NEXT X
  438.      IF D4=0 THEN 4360
  439.      PRINT "A sea monster smells the men on the way back!!!"
  440.      PRINT D7;"Men were eaten, Captain ";N$;"!"
  441.      C=C-D7
  442. 4360 PRINT D6;"men were lost through accidents, Captain ";N$;"."
  443.      C=C-D6
  444.      P=P-INT(10*Q1+RND*10)
  445.      GOTO 4690
  446. 4400 REM *** #8 power conversion
  447.      IF D(9) >= 0 THEN 4440
  448.      PRINT "Power converter is damaged, Captain ";N$;"."
  449.      GOTO 880
  450. 4440 IF C>5 THEN 4470
  451.      PRINT "Not enough men to work the converter, Captain ";N$;"."
  452.      GOTO 880
  453. 4470 PRINT "Option? (1=Fuel to power, 2=Power to fuel)";
  454.      INPUT O
  455.      ON O GOTO 4510, 4580
  456.      GOTO 4470
  457. 4510 REM *** Fuel to power conversion
  458. 4520 PRINT "Fuel available=";F;". Convert";
  459.      INPUT C1
  460.      IF C1>F OR C1<0 THEN 4520
  461.      F=F-C1
  462.      P=P+INT(C1/3)
  463.      GOTO 4640
  464. 4580 REM ***power to fuel conversion
  465. 4590 PRINT "Power available="P-1;". Convert";
  466.      INPUT C1
  467.      IF C1>P-1 OR C1<0 THEN 4590
  468.      P=P-C1
  469.      F=F+INT(C1*3)
  470. 4640 PRINT "Conversion complete. Power=";P;". fuel=";F;"."
  471.      GOTO 4690
  472. 4660 REM *** #9 surrender
  473.      PRINT "Coward!!! You're not very patriotic, ex-Captain ";N$;"!"
  474.      GOTO 6180
  475. 4690 REM ***Retaliation section
  476.      Q=0
  477.      FOR X=S1-4 TO S1+4
  478.      FOR Y=S2-4 TO S2+4
  479.      IF X<1 OR X>20 OR Y<1 OR Y>20 THEN 4760
  480.      IF A(X,Y)<>3 THEN 4760
  481.      Q=Q+(RND/SQR((S1-X)^2+(S2-Y)^2))
  482. 4760 NEXT Y
  483.      NEXT X
  484.      IF Q THEN 4810
  485.      PRINT "No ships in range to depth charge you, Captain ";N$;"."
  486.      GOTO 5210
  487. 4810 PRINT "Depth charges off ";
  488.      IF RND>.5 THEN 4850
  489.      PRINT "port side, Captain ";N$;"!!!"
  490.      GOTO 4860
  491. 4850 PRINT "starboard side, Captain ";N$;"!!!"
  492. 4860 IF Q>.13 OR RND >92 THEN 4890
  493.      PRINT "No real damage sustained, Captain ";N$;"."
  494.      GOTO 5210
  495. 4890 IF Q>.36 OR RND>.96 THEN 4940
  496.      PRINT "Light, superficial damage, Captain ";N$;"."
  497.      P=P-50
  498.      D(INT(RND*9)+1)=-RND*2
  499.      GOTO 5210
  500. 4940 IF Q>.6 OR RND>.975 THEN 5020
  501.      PRINT "Moderate damage. Repairs needed."
  502.      P=P-75+INT(RND*30)
  503.      FOR Y=1 TO 2
  504.      X=INT(RND*9)+1
  505.      D(X)=D(X)-RND*8
  506.      NEXT Y
  507.      GOTO 5210
  508. 5020 IF Q>.9 OR RND>.983 THEN 5100
  509.      PRINT "Heavy damage!! Repairs immediate, Captain ";N$;"!!!"
  510. 5040 P=P-(200+INT(RND*76))
  511.      FOR X=1 TO 4+INT(RND*2)
  512.      Y=INT(RND*9)+1
  513.      D(Y)=D(Y)-RND*11
  514.      NEXT X
  515.      GOTO 5210
  516. 5100 PRINT "Damage critical !!!!! We need help!!!!"
  517.      A$="VRAVUKXCNVPCRHFDRSAXQURLQTRHXYACVFZYITLCBSSYYKDQIPCAEGQGPCNOTSIO"
  518.      X=INT(RND*64)+1
  519.      test = peek(1047):poke 1047, test or 64
  520.      PRINT "Send 'HELP'in code. Here is the code:";MID$(A$,X,4);
  521.      REM time delay and then erase the code
  522.      FOR I=1 TO 5000:NEXT I
  523.      for counter = 1 to 4:print chr$(29);" ";chr$(29);:next:print
  524.      INPUT "Enter code";B$
  525.      PRINT
  526.      poke 1047, test
  527.      IF B$<>MID$(A$,X,4) THEN 5190
  528.      PRINT "Fast work, Captain ";N$;"!! Help arrives in time to save you!!!"
  529.      GOTO 5040
  530. 5190 PRINT "Message garbled, Captain ";N$;"...No help arrives!!!"
  531.      GOTO 6180
  532. 5210 if p<0 then 1660
  533.      rem ***Move ships, sea monsters
  534.      IF D(1) >=0 OR D(3)>=0 OR D(4)>=0 OR D(5)>=0 OR D(7)>=0 THEN 5260
  535.      IF D(8) >=0 OR D(9)>=0 THEN 5260
  536.      PRINT "Damage too much, Captain ";N$;"!! You're sunk!!!"
  537.      GOTO 6180
  538. 5260 REM ***move ships/sea monsters
  539.      PRINT:PRINT:PRINT "---***Result of Last Enemy Manuever ***---"
  540.      FOR X=1 TO 20
  541.      FOR Y=1 TO 20
  542.      tries = 0
  543.      IF A(X,Y)<>3 THEN 5690
  544.      REM **move a ship
  545.      W=D8
  546.      V=D9
  547.      IF X+W>0 AND X+W<21 AND Y+V>0 AND Y+V<21 THEN 5420
  548.      FOR X0=19 TO 1 STEP -1
  549.      IF A(X-W*X0,Y-V*X0)<>0 THEN 5400
  550.      A(X-W*X0,Y-V*X0)=3
  551.      A(X,Y)=0
  552.      GOTO 6000
  553. 5400 NEXT X0
  554.      goto 6320
  555. 5420 ON A(X+W,Y+V)+1 GOTO 5430,5460,5530, 5460,5560,5600,5650
  556. 5430 A(X+W,Y+V)=3
  557. 5440 A(X,Y)=0
  558.      GOTO 6000
  559. 5460 REM ***change direction
  560. 5470 RESTORE 6090
  561.      FOR X0=1 TO INT(RND*8)+1
  562.      READ W,V
  563.      NEXT X0
  564.      tries = tries + 1: if tries > 30 goto 6000
  565.      IF X+W<1 OR X+W>20 OR Y+V<1 OR Y+V>20 THEN 5470
  566.      GOTO 5420
  567. 5530 IF D>50 THEN 5460
  568.      PRINT "*** You've been rammed by a ship, Captain ";N$;"!!!"
  569.      GOTO 6180
  570. 5560 IF RND<.15 THEN 5460
  571.      PRINT "*** Your headquarters was rammed, Captain ";N$;"!!!"
  572.      S3=0:S4=0:D2=0:A(X+W,Y+V)=0
  573.      GOTO 5620
  574. 5600 IF RND<.7 THEN 5460
  575.      PRINT "*** Ship destroyed by a mine, Captain ";N$;"!!!"
  576. 5620 S=S-1
  577. 5630 IF S<>0 THEN 5440
  578.      GOTO 6260
  579. 5650 IF RND<.9 THEN 5460
  580.      PRINT "*** Ship eaten by a sea monster, Captain ";N$;"!!!"
  581.      S=S-1
  582.      GOTO 5630
  583. 5690 REM *** Move a sea monster
  584.      IF A(X,Y)<>6 THEN 6000
  585.      IF X+M1<1 OR X+M1>20 OR Y+M2<1 OR Y+M2>20 THEN 5760
  586. 5720 ON A(X+M1,Y+M2)+1 GOTO 5730,5760,5830,5850,5900,5725,5930
  587. 5725 print "*** A sea monster ate a mine (urp!), Captain ";N$;"!!"
  588. 5730 A(X+M1,Y+M2) = 6
  589.      A(X,Y) = 0
  590.      GOTO 6000
  591. 5760 REM *** change direction
  592.      RESTORE 6090
  593.      FOR X0 = 1 TO INT(RND*8)+1
  594.      READ M1,M2
  595.      NEXT X0
  596.      IF X+M1<1 OR X+M1>20 OR Y+M2<1 OR Y+M2>20 THEN 5760
  597.      GOTO 5720
  598. 5830 PRINT "*** You've been eaten by a sea monster, Captain ";N$;"!!!"
  599.      GOTO 6180
  600. 5850 IF RND>.2 THEN 5760
  601.      PRINT "*** Ship eaten by a sea monster, Captain ";N$;"!!!"
  602.      S=S-1
  603.      IF S<>0 THEN 5730
  604.      GOTO 6260
  605. 5900 PRINT "*** A sea monster ate your headquarters, Captain ";N$;"!!!"
  606.      S3=0:S4=0:D2=0
  607.      GOTO 5730
  608. 5930 IF RND<.75 THEN 5760
  609.      PRINT "*** A sea monster fight, Captain ";N$;"!!!";
  610.      IF RND<.8 THEN 5980
  611.      PRINT " And one dies!!!"
  612.      GOTO 5730
  613. 5980 PRINT " It's a tie!!!"
  614.      GOTO 5760
  615. 6000 NEXT Y
  616.      NEXT X
  617.      REM *** make repairs
  618.      FOR Y=1 TO 9
  619.      X=INT(RND*9)+1
  620.      D(X)=D(X)+(RND*(2+RND*2))*(1+(-(D<51) OR -(D>2000)))*(-(D(X)<3))
  621.      NEXT Y
  622.      GOTO 880
  623. 6080 REM *** gosub for course / direction ***
  624. 6090 DATA -1,0,-1,1,0,1,1,1,1,0,1,-1,0,-1,-1,-1
  625. 6100 PRINT "Course (1-8)";
  626.      INPUT C1
  627.      IF C1<1 OR C1>8 THEN 6100
  628.      RESTORE 6090
  629.      FOR X9=1 TO INT(C1+.5)
  630.      READ X1,Y1
  631.      NEXT X9
  632.      RETURN
  633. 6180 REM *** Destroyed?
  634.      if s = 0 then 6260
  635.      PRINT "There are still";S;"enemy ships left, Captain ";N$;"."
  636.      PRINT "You will be demoted to rank of deck scrubber!!!!!"
  637.      score% = score% - (s * 3)
  638. 6210 ships% = 0:PRINT "Score is: ";score%;" Want another game";
  639.      lset sc$ = mki$(score%)
  640.      put 1,1
  641.      INPUT A$
  642.      IF LEFT$(A$,1)<>"Y" AND LEFT$(A$,1)<>"y" THEN 6250
  643.      GOTO 310
  644. 6250 goto 6320
  645. 6260 PRINT "Good work, Admiral ";N$;"!!!  You got them all!!!"
  646.      PRINT "Promotion and commendations are effective, immediately!!!"
  647.      score% = score% + ships%
  648.      GOTO 6210
  649.      REM *** island data
  650. 6300 DATA 0,1,1,1,0,0,0,1,1,1,1,0,1,1,1,0,1,1,1,1,0,0,0,1
  651.      DATA 1,1,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,0
  652. 6320 close 1:color 15,1,1:cls:END
  653.