! First 10 elements record hardiness, last 10 damage so far. Array ships-->20; [ Fight type quant i j offscreen standingorders lastorders runval oldquant runinc kills; @split_window height; @erase_window 0; @erase_window 1; DrawFightWindow(); oldquant=quant; offscreen=quant; ! Eeeagh we need quant^1.05. I've settled for time^17/16. fitos(real3,quant); fsqrt(real4,real3); fsqrt(real5,real4); fsqrt(real4,real5); fsqrt(real5,real4); fmul(real4,real5,real3); fitos(real3,32766); fitos(real5,random(32767)-1); fdiv(real1,real5,real3); fitos(real5,250); fmul(real2,real5,real1); fitos(real5,time); fmul(real1,real5,real2); fitos(real5,random(1000)+249); fadd(real3,real1,real5); frnd(real4,real3); for(i=0:i<=9:i++) ships-->i=0; while(1) ! This is better than it looks, really. { offscreen=ReplenishNavy(offscreen); RedrawFightWindow(quant); @set_cursor 4 1; i=100-(dam2*10-shipsize/10)/(shipsize/5); if(i<0) i=0; print "Current Seaworthiness: ", (string) qualnames-->(i/20)," (",i,"%)"; lastorders=standingorders; j=FightChoice(); if(j) standingorders=j; @set_cursor 4 1; spaces width; if(i<=0) { DrawTopWindow(); @erase_window 0; @set_window 0; print "^The buggers got us, Taipan!!!"; print "^It's all over, now!!!^"; ShortPause(); return 0; } i=FightChoice(); if(i) standingorders=i; i=standingorders; while(~~i) { @set_cursor 4 1; print "Taipan, what shall we do??"; Beep2512(); i=FightChoice(); } if (~~standingorders) { standingorders=i; } else { if(standingorders==1) { @set_cursor 4 1; spaces width; @set_cursor 4 1; print "Aye, we'll run, Taipan!"; ShortPause(); @set_cursor 4 1; spaces width; if (lastorders==1 or 3 or 5) { runval=runval+runinc; runinc++; } else { runval=3; runinc=1; } } else if(standingorders==2) { if(guns==0) { @set_cursor 4 1; print "We have no guns, Taipan!!"; j=FightChoice(); if(j) standingorders=j; @set_cursor 4 1; spaces width; } else { kills = 0; @set_cursor 4 1; print "We're firing on 'em, Taipan!"; for(i=1:i<=guns:i++) { do j=random(10)-1; until(ships-->j); if(fightmode) ShootShip(j); ships-->(j+10)=ships-->(j+10)+random(30)+9; if(ships-->(j+10)>ships-->j) { kills++; quant=quant-1; ships-->j=0; if(fightmode) SinkShip(j); else EraseShip(j); if((kills%10)==0) offscreen=ReplenishNavy(offscreen); RedrawFightWindow(quant); } if(quant==0) i=guns+1; } @set_cursor 4 1; if(kills) { print "Sunk ", kills, " of the buggers, Taipan!"; Beep2521(); } else print "Hit 'em, but didn't sink 'em, Taipan!"; j=FightChoice(); if(j) standingorders=j; @set_cursor 4 1; spaces width; if(quant>=3 && quantquant*6/(10*type))) { i=quant/(3*type); if (i) i=random(i); else i=1; quant=quant-i; offscreen=offscreen-i; offscreen=ReplenishNavy(offscreen); @set_cursor 4 1; print i," ran away, Taipan!"; RedrawFightWindow(quant); Beep2521(); j=FightChoice(); if(j) standingorders=j; @set_cursor 4 1; spaces width; } } } else if(standingorders==3) { @set_window 0; font on; print "You have the following on board, Taipan:^"; font off; @output_stream 3 typebuf; print " ", (string) scargonames-->0,": ", (fp) cargo; @output_stream -3; print (warrayp) typebuf; spaces 17-typebuf-->0; print (string) scargonames-->1,": ", (fp) cargo+4,"^"; @output_stream 3 typebuf; print " ", (string) scargonames-->2,": ", (fp) cargo+8; @output_stream -3; print (warrayp) typebuf; spaces 17-typebuf-->0; print (string) scargonames-->3,": ", (fp) cargo+12,"^"; font on; @set_cursor 4 1; print "^What shall I throw overboard, Taipan? "; do @read_char 1 -> i; until (i=='o' or 'O' or 's' or 'S' or 'a' or 'A' or 'g' or 'G' or '*'); @set_cursor 4 1; spaces width; if(i=='*') { fitos(real2,0); } else { if(i=='o' or 'O') i=0; else if(i=='s' or 'S') i=1; else if(i=='a' or 'A') i=2; else i=3; print cargonames-->i; j=1; do { if(~~j) StdBeep(); print "^How much, Taipan? "; j=ReadFP(real1,cargo+4*i); } until(j); fmin(real2,real1,cargo+4*i); fsub(real3,cargo+4*i,real2); frnd(cargo+4*i,real3); fadd(real3,holdfree,real2); frnd(holdfree,real3); } j=fstoi(real2); @erase_window 0; @set_window 1; @set_cursor 4 1; if (j==0) { print "There's nothing there, Taipan!"; Beep2518(); i=FightChoice(); if(i) standingorders=i; standingorders=5; @set_cursor 4 1; spaces width; } else { runval=runval+j/10; print "Let's hope we lose 'em, Taipan!"; Beep2521(); i=FightChoice(); if(i) standingorders=i; @set_cursor 4 1; spaces width; } } if(standingorders==1 or 3) { if (random(runval)>random(quant)) { @set_cursor 4 1; print "We got away from 'em, Taipan!!"; Beep2518(); ShortPause(); DrawTopWindow(); @erase_window 0; @set_window 0; print "^We made it, Taipan!"; Beep2518(); ShortPause(); LowerWindowSetup(1); return 3; } @set_cursor 4 1; print "Can't lose 'em!!"; i=FightChoice(); if(i) standingorders=i; @set_cursor 4 1; spaces width; if(quant>2 && random(5)==1) { i=random(quant/2); quant=quant-i; offscreen=offscreen-i; RedrawFightWindow(quant); offscreen=ReplenishNavy(offscreen); @set_cursor 4 1; print "But we escaped from ", i, " of 'em, Taipan!"; i=FightChoice(); if(i) standingorders=i; @set_cursor 4 1; spaces width; } } } if (standingorders==5) standingorders=3; if(quant==0) { @set_cursor 4 1; print "We got 'em all, Taipan!!"; Beep2521(); i=FightChoice(); if(i) standingorders=i; fadd(real3,real4,cash); frnd(cash,real3); DrawTopWindow(); @erase_window 0; @set_window 0; print "^We've captured some booty"; print "^It's worth ", (fpword) real4, "!"; ShortPause(); LowerWindowSetup(1); return 1; } @set_cursor 4 1; print "They're firing on us, Taipan!"; i=FightChoice(); if(i) standingorders=i; @set_cursor 4 1; spaces width; if(fightmode) { ReturningFire(); DrawFightWindow(); RedrawFightWindow(quant); @set_cursor 2 21; if (standingorders==1) print "Run "; else if (standingorders==2) print "Fight "; else if (standingorders==3) print "Throw cargo"; @set_cursor 4 1; spaces width; } @set_cursor 4 1; print "We've been hit, Taipan!!"; Beep2512(); i=quant; if(i>15) i=15; if(guns && (random(100)<((dam2*10-shipsize/10)/(shipsize/5)+1) || (dam2*10-shipsize/10)/(shipsize/5)>80)) { i=1; j=FightChoice(); if(j) standingorders=j; @set_cursor 4 1; spaces width; @set_cursor 4 1; print "The buggers hit a gun, Taipan!!"; Beep2512(); guns=guns-1; fitos(real2,GUN_SIZE); fadd(real3,holdfree,real2); frnd(holdfree,real3); j=FightChoice(); if(j) standingorders=j; @set_cursor 4 1; spaces width; } dam2=dam2+random(firepower*type*i)-1+i; ! Overflow check if(dam2<0) dam2=32767; if(type==1 && random(20)==1) { DrawTopWindow(); @erase_window 0; @set_window 0; print "^Li Yuen's fleet drove them off!"; ShortPause(); LowerWindowSetup(1); return 2; } } return 1; ]; [ FightChoice i; @set_cursor 2 21; @read_char 1 FIGHT_INPUT_TIME rettrue -> i; if(i=='r' or 'R') { print "Run "; return 1; } if(i=='f' or 'F') { print "Fight "; return 2; } if(i=='t' or 'T') { print "Throw cargo"; return 3; } return 0; ]; [ ReplenishNavy offscreen i; for (i=0:i<=9:i++) { if((ships-->i == 0) && (offscreen>0)) { offscreen--; ships-->i=random(hardiness)+19; ships-->(i+10)=0; DrawShip(i); } } for(i=9:i>=0:i--) { if(ships-->i && (offscreen<0)) { offscreen++; ships-->i=0; ships-->i=0; EraseShip(i); } } @set_window 1; @set_cursor 11 width; if(offscreen) print "+"; else print " "; return offscreen; ];