Program KATTIVIK; Uses Cptpu,Dos,Crt; {$I cplayer.inc} {contiene la struttura di tutti i records} type string20=string[20]; campiminati=Record x: integer; y: integer; race: integer; num: integer; web: integer; zero: integer; end; {record} sbasebrain=Record mlayer: integer; mfield: integer; merlin: integer; end; {record} ShpNames=String[20]; ShipNM=^ShpNames; Const lowtech : INTEGER=0; {1: explorer} {2: freighter} {3: small warship} {4: large warship} {5: neutronic rafinery} {6: merlin} {7: refueler} {8: terraformer} {9: glory device} {10: minelayer} {11: Gambling (soldi)} {12: imperial assault} {valori di default attribuiti alle navi di origine} Data: Array[1..105] of integer=(1,3,8,3,3,3,3,8,1,3,4,4,4,7,1,2,2,2,4,4,3, 3,4,1,3,3,1,3,4,4,4,3,4,3,4,3,3,3,9,3,9,11,3, 1,3,3,3,3,4,4,1,4,4,3,3,3,1,3,1,3,4,3,4, 8,3,1,4,3,12,4,3,3,3,4,3,3,1,3,4,4,10,7,3, 3,3,10,1,3,3,3,3,3,2,4,3,3,1,1,4,3,2,3,3,5,6); playrace : Array[1..11] of INTEGER=(0,0,0,0,0,0,0,0,0,0,0); var x,r,a,i,ii: integer; {per i vari conteggi for, ecc...} z,v: integer; code: integer; tempstring: string[1]; playernum: string[2]; trovati: SearchRec; classcount: Array[1..10] of INTEGER; planetSlot : INTEGER; {'Slot of planet to be loaded in to} {'plan } shipSlot : INTEGER; {'Slot of ship that is to be } {'loaded into me } baseSlot : INTEGER; baseT : BASETYPE; {'base data } seed : LONGINT; dist : INTEGER; targetcount : INTEGER; comandline: string[20]; path : STRING; classlist : Array [1..105] of INTEGER; pbrain : Array[1..500] of INTEGER; {valore dei pianeti vedi pcheck} sbrain : Array[1..500] of INTEGER; {tipo di nave} sbbrain: Array[1..500] of sbasebrain; abrain : Array[1..500] of INTEGER; {tipo di pianeta} ebrain : Array[1..11] of INTEGER; {nemici?} ShipClass: Array[1..20] of Array[1..11] of integer; truehull : Array[1..20] of Array[1..11] of INTEGER; pcount,sbcount,myships: integer; mapc : Array[1..500] of INTEGER; ingame : Array[1..11] of INTEGER; plrace : Array[1..11] of INTEGER; cprace : Array[1..11] of INTEGER; frrace : Array[1..11] of INTEGER; bsrace : Array[1..11] of INTEGER; dumpoldm: Array[1..11] of INTEGER; Minefile: file; THull: file of integer; brainfile: file of integer; SSName: String[20]; LOGFILE: text; genfile: file of integer; mine: Array [1..500] of campiminati; ShipName: Array[1..200] of ShipNM; UseInternalName: Boolean; MaxName: byte; {*******************************************************************} Procedure Writelog(stringAlunga:STRING); begin Writeln(stringalunga); Writeln(LOGFILE,stringalunga); end; {*******************************************************************} Procedure LoadHostData; var x : integer; ShipNameF: Text; begin Writelog('Loading Ships Positions'); ReadShipXY(path); Assign(genfile,path+'GEN.HST'); {$I-} Reset(Genfile); {$I+} if IORESULT<>0 then begin Writeln('Error opening ',path,'GEN.HST'); Halt(1); end; Seek(genfile,23); FOR I := 1 TO 11 do begin Read(genfile,ingame[I]); end; CLOSE(genfile); Assign(Minefile,path+'MINES.HST'); {$I-} Reset(Minefile,1); {$I+} if IORESULT<>0 then begin Writeln('Error opening ',path,'MINES.HST'); Halt(1); end; Writelog('Loading Mines'); FOR I := 1 TO 500 do Blockread(Minefile,mine[I],sizeof(mine[i])); CLOSE(MInefile); Writelog('Loading Planets Positions'); ReadXyPlan(path); Writelog('Searching For Planets...'); ReadPlan(path); Writelog('Searching For Starbases...'); ReadSBase(path); ReadHull(path); ReadEng(path); ReadBeam(path); ReadTorp(path); ReadRace(path); ReadConfig(path); Writelog('Searching For Ships...'); Readship(path); Writelog('Checking ShipClass...'); Assign(THull,path+'TRUEHULL.DAT'); {$I-} Reset(Thull); {$I+} if IORESULT<>0 then begin Assign(THull,'TRUEHULL.DAT'); {$I-} Reset(Thull); {$I+} if IORESULT<>0 then begin Writeln('Error opening TrueHull.dat'); Halt(1); end; end; FOR r := 1 TO 11 do begin FOR I := 1 TO 20 do begin Read(THull,Truehull[i][r]); end; {for} end; {for} Close (Thull); Assign(THull,path+'KattHull.dat'); {$I-} Reset(Thull); {$I+} if IORESULT=0 then begin For i:= 1 to 105 do Read(THull,Data[i]); Close(Thull); end; {if} FOR i := 1 TO 105 do classlist[i]:=0; FOR r := 1 TO 11 do FOR I := 1 TO 20 do begin (* if classlist[Truehull[i][r]] = 0 then *) classlist[Truehull[i][r]] := Data[Truehull[i][r]]; ShipClass[i][r] := Data[Truehull[i][r]]; end; {for i} FOR i := 1 TO 105 do begin IF classlist[i] = 0 THEN Writelog('ERROR! : Ship Type '+stringa(i,0)+ ' is undefined!'); end; {for i} UseInternalName:=FALSE; Assign(ShipNameF,path+'KATTIVIK.NM'); {$I-} Reset(ShipNameF); {$I+} If IOResult<>0 then begin Assign(ShipNameF,'KATTIVIK.NM'); {$I-} Reset(ShipNameF); {$I+} If IOResult<>0 then UseinternalName:=TRUE end; For i:=1 to 200 do begin New(ShipName[i]); FillChar(ShipName[i]^,20,' '); end; if NOT UseInternalName then begin i:=0; While Not EOF(ShipNameF) AND (i<200) do begin inc(i); ReadLn(ShipNameF,ShipName[i]^); end; MaxName:=i; end; end; {procedure loadhostdata} {*******************************************************************} Procedure LoadBrain; const NUL:INTEGER=0; begin {procedure} str(a,playernum); Writelog('Loading Brain Data...'); Assign(brainfile,path+'kbrain'+playernum+'.hst'); {$I-} Reset(brainfile); {$I+} (* Writelog(stringa(filesize(brainfile),0)); *) if (IORESULT=0) AND (Filesize(brainfile)>3000) then begin FOR I := 1 TO 500 do Read(brainfile,pbrain[i]); FOR I := 1 TO 500 do Read(brainfile,abrain[i]); FOR I := 1 TO 500 do Read(brainfile,sbrain[i]); FOR I := 1 TO 500 do Read(brainfile,sbbrain[i].mlayer,sbbrain[i].mfield,sbbrain[i].merlin); FOR I := 1 TO 11 do Read(brainfile,ebrain[i]); close(brainfile); end Else BEGIN ReWrite(brainfile); FOR I := 1 TO 4000 do Write(brainfile,NUL); Close (brainfile); {$I-} Reset(brainfile); {$I+} FOR I := 1 TO 500 do Read(brainfile,pbrain[i]); FOR I := 1 TO 500 do Read(brainfile,abrain[i]); FOR I := 1 TO 500 do Read(brainfile,sbrain[i]); FOR I := 1 TO 500 do Read(brainfile,sbbrain[i].mlayer,sbbrain[i].mfield,sbbrain[i].merlin); FOR I := 1 TO 11 do Read(brainfile,ebrain[i]); close(brainfile); end; end; {procedure} {*******************************************************************} Procedure PCheck(i:integer; var v:integer); begin v:=0; inc(v,(plan[i]^.eleN + plan[i]^.resN) div 50); inc(v,(plan[i]^.eleM + plan[i]^.resM) div 25); inc(v,(plan[i]^.eleT + plan[i]^.resT) div 50); inc(v,(plan[i]^.eleD + plan[i]^.resD) div 50); inc(v,(plan[i]^.money) div 10); inc(v,(plan[i]^.EleS) div 2); IF (plan[i]^.climate > 30) AND (plan[i]^.climate < 70) THEN inc(v,150); IF (plan[i]^.climate > 45) AND (plan[i]^.climate < 55) THEN inc(v,100); IF plan[i]^.native > 500 THEN begin CASE plan[i]^.species of 1: v := v + 10; 2: v := v + 1000; 3: v := v + 30; 4: v := v + 300; 5: v := v - 200; 6: v := v + 400; 7: v := v + 30; 9: v := v + 60; end; {case} end; {endif} IF plan[i]^.species <> 5 THEN v := v + (plan[i]^.SPI * 10); end; {*******************************************************************} Procedure PlanetCheck; (* '**** ABRAIN **** *) (* ' 0 None *) (* ' 1 Explored *) (* ' 2 Attack *) (* ' 3 Dropping Some Colonists *) (* ' 4 Dropping Many Colonists *) (* ' 5 My Planet *) (* ' 6 Starbase *) (* ' 7 Building Starbase here *) (* ' 8 Please send colonists *) (* ' 9 Enemy Planet *) begin {procedure} Writelog('THINKING ABOUT: Planetary Values'); FOR i := 1 TO 500 do begin IF abrain[i] = 3 THEN begin PCheck(i,v); pbrain[i] := v; IF (Plancoord[i].pNum <> a) AND (Plancoord[i].pNum > 0) THEN abrain[i] := 9 ELSE abrain[i] := 1; END; {endif} IF Plancoord[i].pNum = a THEN begin IF Sbase[i]^.pNum = a THEN abrain[i] := 6; IF abrain[i] = 0 THEN abrain[i] := 5; IF abrain[i] = 3 THEN abrain[i] := 5; IF Plan[i]^.pNum = a THEN begin PCheck(i,v); pbrain[i] := v; end ELSE Writelog('Planet ID Error!'); END; {if rbase/plancoord} IF abrain[i] = 5 THEN begin IF (Plan[i]^.pNum <> a) AND (Plancoord[i].pNum > 0) THEN abrain[i] := 9; END; {endif} if (abrain[i] = 5) THEN IF (Plan[i]^.climate>30) AND (plan[i]^.climate<70) AND ((plan[i]^.eleN + plan[i]^.resN) > 100) AND ((plan[i]^.eleM + plan[i]^.resM) > 740) AND ((plan[i]^.eleT + plan[i]^.resT) > 802) AND ((plan[i]^.eleD + plan[i]^.resD) > 540) AND (plan[i]^.species <> 5) THEN abrain[i]:=7; END; {end for i} end; {procedure} {*******************************************************************} FUNCTION RANDCHAR:Char; var CH:Char; Begin Ch:=Char(Random(127)); if (Ord(ch)<49) then ch:=#49; if (Ord(ch)>126) then ch:=#126; RANDCHAR:=Ch; end; Procedure PlanetEcon; var maxfact, maxmines,maxsdi: integer; begin Writelog('THINKING ABOUT: Planetary Economies'); FOR i := 1 TO 500 DO BEGIN IF Plancoord[i].pNum = a THEN begin IF plan[i]^.pNum = a THEN begin if plan[i]^.eleS > Plan[i]^.money then begin plan[i]^.eleS := plan[i]^.eleS - ((plan[i]^.EleS div 4)*3); plan[i]^.money := plan[i]^.money + ((plan[i]^.EleS div 4)*3); end; IF plan[i]^.happynessC > 80 THEN plan[i]^.taxC := plan[i]^.taxC + 1; IF plan[i]^.happynessN > 80 THEN plan[i]^.taxN := plan[i]^.taxN + 1; IF plan[i]^.happynessC < 70 THEN begin plan[i]^.taxC := 0; end; {endif} IF plan[i]^.happynessN < 80 THEN plan[i]^.taxN := 0; END; {endif} IF plan[i]^.eleC < 101 THEN maxfact := plan[i]^.eleC ELSE maxfact := 100 + round(SQRT(plan[i]^.eleC - 95.0)); WHILE (plan[i]^.factories < maxfact) AND (plan[i]^.money > 3) AND (plan[i]^.eleS > 0) do begin plan[i]^.eleS := plan[i]^.eleS - 1; plan[i]^.money := plan[i]^.money - 3; plan[i]^.factories := plan[i]^.factories + 1; END; {while} IF Plan[i]^.EleC < 201 then maxmines := plan[i]^.eleC ELSE maxmines := 200 + round(SQRT(plan[i]^.eleC - 200)); WHILE (plan[i]^.mines < maxmines) AND (plan[i]^.money > 4) AND (plan[i]^.eleS > 0) do begin plan[i]^.eleS := plan[i]^.eleS - 1; plan[i]^.money := plan[i]^.money - 4; plan[i]^.mines := plan[i]^.mines + 1; END; {while} IF plan[i]^.eleC<=50 THEN maxsdi:=Plan[i]^.eleC ELSE maxsdi := round(SQRT(plan[i]^.eleC-50)) + 50; IF (plan[i]^.money > 100) AND (plan[i]^.eleS > 10) THEN begin WHILE (plan[i]^.money > 10) AND (plan[i]^.eleS > 0) AND ((sbrain[i]=3) OR (sbrain[i]=4)) THEN GOWAR; END; END; END; END; {FOR I} END; {PROCEDURE} {*******************************************************************} Procedure SaveBrain; begin Assign(brainfile,path+'kbrain'+playernum+'.hst'); Rewrite(brainfile); FOR I := 1 TO 500 DO Write(brainfile,pbrain[i]); FOR I := 1 TO 500 DO Write(brainfile,abrain[i]); FOR I := 1 TO 500 DO Write(brainfile,sbrain[i]); FOR I := 1 TO 500 DO Write(brainfile,sbbrain[i].mlayer,sbbrain[i].mfield,sbbrain[i].merlin); FOR I := 1 TO 11 DO Write(brainfile,ebrain[i]); CLOSE(brainfile); END; {proc} {*******************************************************************} Procedure Alchemy; var FgN,FgM: byte; { 'hull = 104 netronic refineray } { 'hull = 105 merlin class } BEGIN Writelog('Checking for Alchemy ships'); FOR I := 1 TO 500 do begin IF shipcoord[i].race = a THEN begin IF Ship[i]^.hull = 104 THEN fgN := 1; IF Ship[i]^.hull = 105 THEN fgM := 1; END; END; {FOR} IF (fgN = 1) OR (fgM = 1) THEN BEGIN FOR i := 1 TO 500 DO BEGIN IF plan[i]^.pNum = a THEN BEGIN IF fgM = 1 THEN BEGIN IF plan[i]^.eleS > 333 THEN BEGIN plan[i]^.eleS := plan[i]^.eleS - 333; plan[i]^.eleM := plan[i]^.eleM + 111; plan[i]^.eleD := plan[i]^.eleD + 111; plan[i]^.eleT := plan[i]^.eleT + 111; END; END; IF fgN = 1 THEN BEGIN IF plan[i]^.eleN < 200 THEN BEGIN IF (plan[i]^.eleD > 200) OR (plan[i]^.eleT > 200) OR (plan[i]^.eleM > 200) THEN BEGIN IF plan[i]^.eleS > 200 THEN BEGIN plan[i]^.eleS := plan[i]^.eleS - 100; plan[i]^.eleN := plan[i]^.eleN + 100; IF plan[i]^.eleD > 200 THEN plan[i]^.eleD := plan[i]^.eleD - 100 ELSE IF plan[i]^.eleT > 200 THEN plan[i]^.eleT := plan[i]^.eleT - 100 ELSE IF plan[i]^.eleM > 200 THEN plan[i]^.eleM := plan[i]^.eleM - 100; END; END; END; END; END; END; {for i} END; END; {procedure} {*******************************************************************} Procedure Refuel; var sw,maxme,maxyou: integer; tfuel,fgtank,c : integer; dx : LONGINT; dy : LONGINT; d : LONGINT; fgD: LONGINT; fghelp: Array[1..6] of INTEGER; begin FOR I := 1 TO 6 DO fghelp[I] := 0; c := 1; Writelog('Setting Refueler Way Points'); FOR I := 1 TO 500 DO BEGIN IF shipcoord[i].race = a THEN BEGIN IF (Ship[i]^.eleN = 0) AND (c < 7) THEN BEGIN fghelp[c] := I; c := c + 1; END; END; END; {FOR I} FOR c := 1 TO 6 do begin IF fghelp[c] > 0 THEN begin fgD := 30000; fgtank := 0; FOR I := 1 TO 500 DO BEGIN IF shipcoord[i].race = a THEN BEGIN IF Ship[i]^.eleN >= 130 THEN BEGIN dx := shipcoord[i].x - shipcoord[fghelp[c]].x; dy := shipcoord[i].y - shipcoord[fghelp[c]].y; d := round(SQRT(SQR(dx) + SQR(dy))); IF d < fgD THEN BEGIN fgD := d; fgtank := I; END; AND (sc > 10)) OR (Sbase[i]^.techT < 3) THEN begin IF plan[i]^.money > (Sbase[i]^.techT * 500) THEN begin Writelog('Improving Torp Tech Level'); plan[i]^.money := plan[i]^.money - (Sbase[i]^.techT * 100); Sbase[i]^.techT := Sbase[i]^.techT + 1; END; {endif} END; {endif} END ELSE BEGIN IF ((Sbase[i]^.techT < 6) AND (sc > 10)) OR (Sbase[i]^.techT < 3) THEN BEGIN IF plan[i]^.money > (Sbase[i]^.techT * 500) THEN BEGIN Writelog('Improving Torp Tech Level'); plan[i]^.money := plan[i]^.money - (Sbase[i]^.techT * 100); Sbase[i]^.techT := Sbase[i]^.techT + 1; END; {endif} END; {endif} END; {endif} IF lowtech = 0 THEN BEGIN IF ((Sbase[i]^.techW < 10) AND (sc > 10)) OR (Sbase[i]^.techW < 4) THEN BEGIN IF plan[i]^.money > (Sbase[i]^.techW * 500) THEN BEGIN Writelog('Improving Beam Weapon Tech Level'); plan[i]^.money := plan[i]^.money - (Sbase[i]^.techW * 100); Sbase[i]^.techW := Sbase[i]^.techW + 1; END; {endif} END; {endif} END ELSE BEGIN IF ((Sbase[i]^.techW < 6) AND (sc > 10)) OR (Sbase[i]^.techW < 4) THEN BEGIN IF plan[i]^.money > (Sbase[i]^.techW * 500) THEN BEGIN Writelog('Improving Beam Weapon Tech Level'); plan[i]^.money := plan[i]^.money - (Sbase[i]^.techW * 100); Sbase[i]^.techW := Sbase[i]^.techW + 1; END; {endif} END; {endif} END; {endif} IF (a = 9) OR (a = 10) OR (a = 11) THEN begin Writelog('Building fighters in space'); WHILE (plan[i]^.eleT > 300) AND (plan[i]^.eleM > 200) AND (Sbase[i]^.storeF < 60) AND (plan[i]^.eleS > 500) do begin plan[i]^.eleT := plan[i]^.eleT - 3; plan[i]^.eleM := plan[i]^.eleM - 2; Sbase[i]^.storeF := Sbase[i]^.storeF + 1; plan[i]^.eleS := plan[i]^.eleS - 5; END; {end while} END ELSE BEGIN IF plan[i]^.money > 20000 THEN begin Writelog('Building 100mc fighters'); WHILE (plan[i]^.money > 20000) AND (plan[i]^.eleT > 3) AND (plan[i]^.eleM > 2) AND (Sbase[i]^.storeF < 60) do begin plan[i]^.eleT := plan[i]^.eleT - 3; plan[i]^.eleM := plan[i]^.eleM - 2; Sbase[i]^.storeF := Sbase[i]^.storeF + 1; plan[i]^.money := plan[i]^.money - 100; END; {end while} END; {endif} END; {endif} (* IF Sbase[i]^.techE >= 6 THEN begin Writelog('Building Engines'); b := Sbase[i]^.techE; IF b > 9 THEN b := 9; IF Sbase[i]^.storeE[b] < 4 THEN begin WHILE (Sbase[i]^.storeE[b] < 4) AND (plan[i]^.money > EngT[b].cost) AND (plan[i]^.eleM > EngT[b].eleM) AND (plan[i]^.eleD > EngT[b].eleD) AND (plan[i]^.eleT > EngT[b].eleT) do begin plan[i]^.money := plan[i]^.money - EngT[b].cost; plan[i]^.eleM := plan[i]^.eleM - EngT[b].eleM; plan[i]^.eleD := plan[i]^.eleD - EngT[b].eleD; plan[i]^.eleT := plan[i]^.eleT - EngT[b].eleT; Sbase[i]^.storeE[b] := Sbase[i]^.storeE[b] + 1; END; {end while} END; {endif} END; {endif} *) WHILE (Sbase[i]^.defense < 200) AND (plan[i]^.money > 2000) DO BEGIN Sbase[i]^.defense := Sbase[i]^.defense + 1; plan[i]^.money := plan[i]^.money - 10; END; for x := 1 to 500 do begin if shipcoord[x].race=a then if shipcoord[x].x=plancoord[i].x then if shipcoord[x].y=plancoord[i].y then begin if ship[x]^.EleN<100 then Sbase[i]^.mission := 1 else Sbase[i]^.mission := 6; IF ship[x]^.damage> 0 then Sbase[i]^.WorkOnShipID := Ship[x]^.ID; Sbase[i]^.WorkOnShipAction:= 1; end; end; {for x} END; {endif rbase} END; {end for i} END; {procedure} {*******************************************************************} Procedure BuildNewStarbase; { 7 Building Starbase here } BEGIN {PROCEDURE} FOR i := 1 TO 500 do BEGIN IF plan[i]^.pNum = a THEN BEGIN IF (Sbase[i]^.pNum <> a) THEN BEGIN IF (plan[i]^.money+plan[i]^.eleS) > 900 THEN BEGIN IF plan[i]^.eleT > 402 THEN BEGIN IF plan[i]^.eleD > 120 THEN BEGIN IF plan[i]^.eleM > 340 THEN BEGIN Writelog('Building starbase!'); while plan[i]^.money<900 do begin dec(plan[i]^.eleS); inc(plan[i]^.money); end; plan[i]^.money:= plan[i]^.money - 900; plan[i]^.eleT:= plan[i]^.eleT - 402; plan[i]^.eleD:= plan[i]^.eleD - 120; plan[i]^.eleM:= plan[i]^.eleM - 340; Sbase[i]^.ID:= i; Sbase[i]^.pNum:= a; Sbase[i]^.defense:= 0; Sbase[i]^.damage:= 0; Sbase[i]^.techE:= 1; Sbase[i]^.techH:= 1; Sbase[i]^.techW:= 1; Sbase[i]^.techT:= 1; CASE plan[i]^.species OF 1: Sbase[i]^.techH:= 10; 7: Sbase[i]^.techW:= 10; 8: Sbase[i]^.techE:= 10; 9: Sbase[i]^.techT:= 10; END; {CASE} FOR x:= 1 TO 9 do Sbase[i]^.storeE[x]:= 0; FOR x:= 1 TO 20 do Sbase[i]^.storeH[x]:= 0; FOR x:= 1 TO 10 do begin Sbase[i]^.storeW[x]:= 0; Sbase[i]^.storeT[x]:= 0; Sbase[i]^.storeTorps[x]:= 0; end; {for} Sbase[i]^.storeF:= 0; Sbase[i]^.mission:= 1; Sbase[i]^.makeshipH:= 0; Sbase[i]^.makeshipE:= 0; Sbase[i]^.makeshipW:= 0; Sbase[i]^.makeshipWc:= 0; Sbase[i]^.makeshipT:= 0; Sbase[i]^.makeshipTc:= 0; Sbase[i]^.makeshipFc:= 0; END; END; END; END; END; END; END; {FOR I} END; {procedure} {*******************************************************************} FUNCTION RNDNAME:string20; var Tempname,BSName:String20; begin If NOT UseinternalName THEN BEGIN BSName := ' '; TempName:=ShipName[Random(MaxName)]^; for x := 1 to Length(TempName) do BsName[x]:=TempName[x]; END ELSE BEGIN BSName := ' '; CASE RANDOM(65) of 0: BSName := 'USS Africa '; 1: BSName := 'USS Bounty '; 2: BSName := 'USS Bovanova '; 3: BSName := 'Red October '; 4: BSName := 'Eat Flaming Death '; 5: BSName := 'Rust Bucket '; 6: BSName := 'Tax Man '; 7: BSName := 'Space Seed '; 8: BSName := 'USS Enterprise '; 9: BSName := 'Termy '; 10: BSName := 'Death From Above '; 11: BSName := 'The Searcher '; 12: BSName := 'USS Sean Penn '; 13: BSName := 'USS Gates '; 14: BSName := 'Raptor '; 15: BSName := 'Heart of Topring '; 16: BSName := 'Topaw '; 17: BSName := 'USS Stargazer '; 18: BSName := 'USS Clinton '; 19: BSName := 'USS Kennedy '; 20: BSName := 'USS Reagan '; 21: BSName := 'USS Kaden '; 22: BSName := 'USS Kaiser '; 23: BSName := 'USS Kammere '; 24: BSName := 'USS Kang '; 25: BSName := 'USS Kashi '; 26: BSName := 'USS Keller '; 27: BSName := 'USS Kelly '; 28: BSName := 'Portland '; 29: BSName := 'USS Hood '; 30: BSName := 'Casnovia '; 31: BSName := 'USS Tucson '; 32: BSName := 'USS Daytona '; 33: BSName := 'USS Hamilton '; 34: BSName := 'USS Providence '; 35: BSName := 'Atlanta '; 36: BSName := 'Tacoma '; 37: BSName := 'Phoenix Sun '; 38: BSName := 'USS Spokane '; 39: BSName := 'York '; 40: BSName := 'Seabrook '; 41: BSName := 'USS Redmond '; 42: BSName := 'USS Bellevue '; 43: BSName := 'The Knoxville '; 44: BSName := 'HMCS Kamloops '; 45: BSName := 'USS Orem '; 46: BSName := 'USS Aptos '; 47: BSName := 'Dave '; 48: BSName := 'Durham '; 49: BSName := 'Sierra '; 50: BSName := 'USS Reston '; 51: BSName := 'California '; 52: BSName := 'USS Forestfire '; 53: BSName := 'USS Independence '; 54: BSName := 'Monkey Business '; 55: BSName := 'USS Minow '; 56: BSName := 'Larry Bud Melman '; 57: BSName := 'USS Dave '; 58: BSName := 'USS Wallace '; 59: BSName := 'USS Billery '; 60: BSName := 'USS Joyceland '; 61: BSName := 'Lizard Face '; 62: BSName := 'USS Algore '; 63: BSName := 'USS Ackman '; 64: BSName := 'USS Emmit Smith '; 65: BSName := 'USS Rush '; END; {case} END; {IF} RNDNAME := BSName; END; {function} {********************************************************************} Procedure BuildShip (fgship:integer); var BestE,BestT,BestW: integer; fg: integer; begin fg:=truehull[fgship][a]; if Sbase[i]^.MakeShipH<>0 then begin Writelog('I allready have a ship in build queue'); Exit; end; if Sbase[i]^.storeH[fgship]=0 then begin plan[i]^.money:=plan[i]^.money - HullT[fg].cost; plan[i]^.eleM:=plan[i]^.eleM - HullT[fg].eleM; plan[i]^.eleT:=plan[i]^.eleT - HullT[fg].eleT; plan[i]^.eleD:=plan[i]^.eleD - HullT[fg].eleD; Sbase[i]^.storeH[fgship]:=Sbase[i]^.storeH[fgship]+1; end; {if} IF Sbase[i]^.techE >= 6 THEN begin x := Sbase[i]^.techE; IF x > 9 THEN x := 9; IF (classlist[fg] = 5) OR (classlist[fg] = 6) THEN BEGIN x:=6; WHILE (x > 0) AND (Sbase[i]^.storeE[x] < hullT[fg].engines) DO BEGIN IF (Sbase[i]^.storeE[x] < hullT[fg].engines) AND (plan[i]^.money >(EngT[x].cost*(hullT[fg].engines-Sbase[i]^.storeE[x]))) AND (plan[i]^.eleM > (EngT[x].eleM*(hullT[fg].engines-Sbase[i]^.storeE[x]))) AND (plan[i]^.eleD > (EngT[x].eleD*(hullT[fg].engines-Sbase[i]^.storeE[x]))) AND (plan[i]^.eleT > (EngT[x].eleT*(hullT[fg].engines-Sbase[i]^.storeE[x]))) THEN begin WHILE (Sbase[i]^.storeE[x] < hullT[fg].engines) AND (plan[i]^.money > EngT[x].cost) AND (plan[i]^.eleM > EngT[x].eleM) AND (plan[i]^.eleD > EngT[x].eleD) AND (plan[i]^.eleT > EngT[x].eleT) do begin plan[i]^.money := plan[i]^.money - EngT[x].cost; plan[i]^.eleM := plan[i]^.eleM - EngT[x].eleM; plan[i]^.eleD := plan[i]^.eleD - EngT[x].eleD; plan[i]^.eleT := plan[i]^.eleT - EngT[x].eleT; Sbase[i]^.storeE[x] := Sbase[i]^.storeE[x] + 1; END; {end while} END ELSE dec(x); END; {WHILE} END ELSE BEGIN WHILE (x > 5) AND (Sbase[i]^.storeE[x] < hullT[fg].engines) DO BEGIN (* Writelog('Engine: '+Stringa(x,0)); *) IF (Sbase[i]^.storeE[x] < hullT[fg].engines) AND (plan[i]^.money >(EngT[x].cost*(hullT[fg].engines-Sbase[i]^.storeE[x]))) AND (plan[i]^.eleM > (EngT[x].eleM*(hullT[fg].engines-Sbase[i]^.storeE[x]))) AND (plan[i]^.eleD > (EngT[x].eleD*(hullT[fg].engines-Sbase[i]^.storeE[x]))) AND (plan[i]^.eleT > (EngT[x].eleT*(hullT[fg].engines-Sbase[i]^.storeE[x]))) THEN begin WHILE (Sbase[i]^.storeE[x] < hullT[fg].engines) AND (plan[i]^.money > EngT[x].cost) AND (plan[i]^.eleM > EngT[x].eleM) AND (plan[i]^.eleD > EngT[x].eleD) AND (plan[i]^.eleT > EngT[x].eleT) do begin plan[i]^.money := plan[i]^.money - EngT[x].cost; plan[i]^.eleM := plan[i]^.eleM - EngT[x].eleM; plan[i]^.eleD := plan[i]^.eleD - EngT[x].eleD; plan[i]^.eleT := plan[i]^.eleT - EngT[x].eleT; Sbase[i]^.storeE[x] := Sbase[i]^.storeE[x] + 1; END; {end while} END ELSE dec(x); END; {WHILE} END; x := Sbase[i]^.techW; WHILE (x > 0) AND (Sbase[i]^.storeW[x] < hullT[fg].weapon) DO BEGIN (* Writelog('Weapon: '+Stringa(x,0)); *) IF (Sbase[i]^.storeW[x] < hullT[fg].weapon) AND (plan[i]^.money > (BeamT[x].cost*(hullT[fg].weapon-Sbase[i]^.storeW[x]))) AND (plan[i]^.eleD > (BeamT[x].eleD*(hullT[fg].weapon-Sbase[i]^.storeW[x]))) AND (plan[i]^.eleT > (BeamT[x].eleT*(hullT[fg].weapon-Sbase[i]^.storeW[x]))) AND (plan[i]^.eleM > (BeamT[x].eleM*(hullT[fg].weapon-Sbase[i]^.storeW[x]))) THEN begin WHILE (Sbase[i]^.storeW[x] < hullT[fg].weapon) AND (plan[i]^.money > BeamT[x].cost) AND (plan[i]^.eleD > BeamT[x].eleD) AND (plan[i]^.eleT > BeamT[x].eleT) AND (plan[i]^.eleM > BeamT[x].eleM) DO BEGIN plan[i]^.money := plan[i]^.money - BeamT[x].cost; plan[i]^.eleD := plan[i]^.eleD - BeamT[x].eleD; plan[i]^.eleT := plan[i]^.eleT - BeamT[x].eleT; plan[i]^.eleM := plan[i]^.eleM - BeamT[x].eleM; Sbase[i]^.storeW[x] := Sbase[i]^.storeW[x] + 1; END; {end while} END ELSE dec(x); END; {WHILE} x := Sbase[i]^.techT; WHILE (x > 0) AND (Sbase[i]^.storeT[x] < hullT[fg].torp) DO BEGIN (* Writelog('Torps : '+Stringa(x,0)); *) IF (Sbase[i]^.storeT[x] < hullT[fg].torp) AND (plan[i]^.money > (TorpT[x].tubecost*(hullT[fg].torp-Sbase[i]^.storeT[x]))) AND (plan[i]^.eleD > (TorpT[x].eleD*(hullT[fg].torp-Sbase[i]^.storeT[x]))) AND (plan[i]^.eleT > (TorpT[x].eleT*(hullT[fg].torp-Sbase[i]^.storeT[x]))) AND (plan[i]^.eleM > (TorpT[x].eleM*(hullT[fg].torp-Sbase[i]^.storeT[x]))) THEN begin WHILE (Sbase[i]^.storeT[x] < hullT[fg].torp) AND (plan[i]^.money > TorpT[x].tubecost) AND (plan[i]^.eleD > TorpT[x].eleD) AND (plan[i]^.eleT > TorpT[x].eleT) AND (plan[i]^.eleM > TorpT[x].eleM) DO BEGIN plan[i]^.money := plan[i]^.money - TorpT[x].tubecost; plan[i]^.eleD := plan[i]^.eleD - TorpT[x].eleD; plan[i]^.eleT := plan[i]^.eleT - TorpT[x].eleT; plan[i]^.eleM := plan[i]^.eleM - TorpT[x].eleM; Sbase[i]^.storeT[x] := Sbase[i]^.storeT[x] + 1; END; {end while} END ELSE dec(x); END; END; {endif starbase>=6} BestE:=0; FOR x := 1 TO 9 do IF Sbase[i]^.storeE[x] >= hullT[fg].engines THEN bestE := x; BestT:=0; FOR x := 1 TO Sbase[i]^.TechT DO IF Sbase[i]^.storeT[x] >= hullT[fg].torp THEN bestT := x; BestW:=0; FOR x := 1 TO Sbase[i]^.TechW DO IF Sbase[i]^.storeW[x] >= hullT[fg].weapon THEN bestW := x; IF (bestE < 6) AND (classlist[fg]<> 5) AND (classlist[fg]<> 6) THEN begin Writelog('I don''t want low tech engines. . .'); EXIT; END; {endif} IF (bestE = 0) OR (bestT = 0) OR (bestW = 0) THEN begin Writelog('I don''t have all the parts to build a ship. . .'); EXIT; END; {endif} With Sbase[i]^ do begin MakeshipH:=fgship; MakeshipE:=bestE; if HullT[fg].weapon>0 then begin MakeshipW:=bestW; MakeshipWc:=hullT[fg].weapon; end; if HullT[fg].torp>0 then begin MakeshipT:=bestT; MakeshipTc:=hullT[fg].torp; end; if HullT[fg].bays>0 then begin MakeshipFc:=hullT[fg].bays; end; end; {with} Writelog(Stringa(i,3)+' NOW Queueing a '+HullT[fg].nm); IF HullT[fg].engines > 0 THEN Writelog(' with: '+ stringa(HullT[fg].engines,0)+ ' '+EngT[BestE].nm); IF HullT[fg].weapon > 0 THEN Writelog(' '+ stringa(HullT[fg].weapon,0)+ ' '+BeamT[BestW].nm); IF HullT[fg].torp > 0 THEN Writelog(' '+ stringa(HullT[fg].torp,0)+ ' '+TorpT[BestT].nm); IF HullT[fg].bays > 0 THEN Writelog(' '+ stringa(HullT[fg].bays,0)+' bays'); IF classlist[fg] = 0 THEN begin Writelog('FATAL DATA ERROR !'); Delay(100); END; END; {end procedure} {*******************************************************************} Procedure BuildNewShips; const shiptry:Array [1..12] of string[19]=('Explorer Ship', 'Freighter Ship', 'Small Warship', 'Large Warship', 'Neutronic Refinery', 'Merlin Class', 'Refueler', 'Terraformer', 'Glory Device', 'Mine Layer', 'Gambling Ship', 'Assault Ship'); var c,fgship: integer; oldc: integer; makethis: byte; Oldmakethis: byte; conteggio: byte; Procedure ShipConstEvaluation; Begin conteggio:=0; WHILE (HullT[truehull[fgship][a]].tech > Sbase[i]^.techH) OR (HullT[truehull[fgship][a]].cost > plan[i]^.money) OR (HullT[truehull[fgship][a]].eleM > plan[i]^.eleM) OR (HullT[truehull[fgship][a]].eleT > plan[i]^.eleT) OR (HullT[truehull[fgship][a]].eleD > plan[i]^.eleD) DO BEGIN (* REPEAT*) (* if makethis=1 then r:=1; *) (* WriteLOG('R='+stringa(r,0)); *) c:=0; FOR ii := 1 TO 20 do begin IF shipclass[ii][A] = makethis THEN c := c + 1; IF c = r THEN BEGIN c:=999; fgship := II; (* Writelog('Fgship='+stringa(fgship,0)); *) IF truehull[fgship][A] = 0 THEN begin Writelog('BAD HULL DATA ERROR!'); Halt(1); END; {endif} END; {endif} END; {end for} if (r>0) AND ((HullT[truehull[fgship][a]].tech > Sbase[i]^.techH) OR (HullT[truehull[fgship][a]].cost > plan[i]^.money) OR (HullT[truehull[fgship][a]].eleM > plan[i]^.eleM) OR (HullT[truehull[fgship][a]].eleT > plan[i]^.eleT) OR (HullT[truehull[fgship][a]].eleD > plan[i]^.eleD)) then dec(r); if (makethis=4) AND (R=0) AND (Classcount[3]<20) THEN begin makethis:=3; c:=0; FOR x := 1 TO 20 DO begin IF shipclass[x][a] = makethis THEN c := c + 1; end; {for} r:=c; end; {if} (* Writelog('R='+stringa(r,0)); *) if r=0 then Exit; inc(conteggio); if conteggio>20 then BEGIN Writelog('BUG!! BUG!! in ship costruction evaluation module'); EXIT; END; END; {WHILE} (* UNTIL (r>=0) AND (HullT[truehull[fgship][a]].tech <= Sbase[i]^.techH); *) End; begin {procedure} for i := 1 to 12 do classcount[i]:=0; FOR i := 1 TO 500 DO BEGIN IF shipcoord[i].race = a THEN BEGIN if Sbrain[i]=0 then begin SSName:=RndName; for x := 1 to 20 do if (SSName[x]<>'') AND (SSName[x]<>#10) AND (SSName[x]<>#13) then Ship[i]^.nm[x] := SSNAME[x]; Sbrain[i]:=Classlist[Ship[i]^.hull]; end; IF (Ship[i]^.hull > 0) AND (Ship[i]^.hull < 106) THEN begin classcount[Sbrain[i]] := classcount[Sbrain[i]] + 1; END; { *** KILL MISSION 4 *** } CASE Sbrain[i] OF 3, 4, 5, 6: Ship[i]^.mission := 4; ELSE Ship[i]^.mission := 1; END; {END CASE} if (Sbrain[i] <> 10) AND (Sbrain[i]>0) then Sbrain[i]:=Classlist[Ship[i]^.hull]; { *** *** } Ship[i]^.fCode[1] := RANDCHAR; Ship[i]^.fCode[2] := RANDCHAR; Ship[i]^.fCode[3] := RANDCHAR; END ELSE Sbrain[i]:=0; {ENDIF} END; {END FOR I} pcount:=0; sbcount:=0; myships:=0; FOR x := 1 TO 500 DO BEGIN if plan[x]^.pNum=a then inc(pcount); if sbase[x]^.pnum=a then inc(sbcount); if ship[x]^.pNum=a then inc(myships); END; {END FOR} Writelog('I have in my Fleet:'); for x := 1 to 10 do if classcount[x]>0 then Writelog(stringa(Classcount[x],3)+' '+Shiptry[x]); makethis:=1; if (Classcount[1]>2) THEN BEGIN makethis:=2; if (classcount[2]>sbcount*2) OR (classcount[2]>10) then BEGIN makethis:=3; if (classcount[3]>=3) OR (myships>20) then makethis:=4; IF (classcount[6] < 1) AND (pcount > 20) AND (classcount[3] > 3) AND (fig.Alchemy=1) THEN makethis := 6; IF (classcount[5] < 1) AND (pcount > 25) AND (classcount[6] >= 1) AND (fig.Alchemy=1) THEN makethis := 5; END; END; c := 0; IF makethis > 0 THEN BEGIN FOR I := 1 TO 20 DO IF shipclass[I][a] = makethis THEN c := c + 1; (* Writelog('Makethis='+stringa(makethis,0)); *) Writelog('Ship Building'); IF c > 0 THEN BEGIN FOR I := 1 TO 500 do BEGIN fgship:=0; c:=0; FOR II := 1 TO 20 DO IF shipclass[II][a] = makethis THEN c := c + 1; R:=C; IF (SBase[i]^.pNum = a) AND (plan[i]^.pNum = a) THEN BEGIN (* With Sbase[i]^ do begin Writelog('Starbase ID# '+Stringa(ID,0)); Writelog('Hull Techlevel : '+Stringa(TechH,0)); Writelog('Engine Techlevel: '+Stringa(TechE,0)); Writelog('Weapon Techlevel: '+Stringa(TechW,0)); Writelog('Trops Techlevel: '+Stringa(TechT,0)); Writelog(''); end; *) C:=0; FOR ii := 1 TO 20 do begin IF shipclass[ii][A] = makethis THEN c := c + 1; IF c = r THEN BEGIN c:=999; fgship := II; (* Writelog('Fgship='+stringa(fgship,0)); *) IF truehull[fgship][A] = 0 THEN begin Writelog('BAD HULL DATA ERROR!'); Halt(1); END; {endif} END; {endif} END; {end for} OldMakethis:=Makethis; ShipConstEvaluation; IF Sbase[i]^.techE >= 6 THEN BEGIN IF HullT[truehull[fgship][a]].cost < plan[i]^.money THEN BEGIN IF HullT[truehull[fgship][a]].eleM < plan[i]^.eleM THEN BEGIN IF HullT[truehull[fgship][a]].eleT < plan[i]^.eleT THEN BEGIN IF HullT[truehull[fgship][a]].eleD < plan[i]^.eleD THEN BEGIN IF HullT[truehull[fgship][a]].tech <= Sbase[i]^.techH THEN BEGIN Writelog('Our Starbase ID#'+Stringa(Sbase[i]^.ID,0)+ ' is trying to build a '+SHIPTRY[makethis]); BuildShip(fgship); END; END; END; END; END; END; Makethis:=OldMakethis; END; {ENDIF} END; {END FOR I} END; {ENDIF} (* END; {ENDIF} *) END; {ENDIF} END; {end procedure} {*******************************************************************} FUNCTION CargoR:integer; var c:integer; begin c := hullT[Ship[i]^.hull].cargo; c := c - Ship[i]^.col - Ship[i]^.eleT - Ship[i]^.eleD - Ship[i]^.eleM - Ship[i]^.eleS; c := c - Ship[i]^.torp; IF c < 0 THEN c := 0; CargoR := c; END; {function} {*******************************************************************} Procedure SWAPLONG(var ALTO, BASSO: LONGINT); var templong: longint; begin templong:=alto; alto:=basso; basso:=templong; end; {*******************************************************************} Procedure SWAPINT(var ALTO, BASSO: INTEGER); var tempint: integer; begin tempint:=alto; alto:=basso; basso:=tempint; end; {*******************************************************************} Procedure LoadFuel; var max: integer; begin {procedure} max:=SQR(Ship[i]^.warp); WHILE (Ship[i]^.EleN < hullT[Ship[i]^.hull].eleN) AND (max>0) DO BEGIN inc(Ship[i]^.EleN); dec(max); END; {while} END; {procedure} {*******************************************************************} Procedure RepairShip(pla,shi:integer); Begin While (Plan[pla]^.eleS>5) AND (Ship[shi]^.damage>0) do begin dec(plan[pla]^.eleS,5); dec(Ship[shi]^.damage); end; {while} end; {procedure} {*******************************************************************} Procedure Explore; var near : INTEGER; nearD: LONGINT; dx : LONGINT; dy : LONGINT; d : LONGINT; c: integer; tagged: Array[1..500] of boolean; dontmove: Array[1..500] of boolean; BEGIN {procedure} Writelog('Setting Explorer Way Points'); FOR I := 1 TO 500 DO Tagged[I]:=FALSE; FOR I := 1 TO 500 do begin IF shipcoord[i].race = a THEN begin Dontmove[i]:=FALSE; Ship[i]^.mission :=0; if Sbrain[i] = 0 then Sbrain[i]:=Classlist[Ship[i]^.hull]; IF Sbrain[i] = 1 THEN begin LoadFuel; IF (CargoR >= 10) AND (Ship[i]^.col < 10) THEN Ship[i]^.col := 10; IF (Ship[i]^.tbanks > 0) AND (CargoR >= 10) AND (Ship[i]^.torp < 10) THEN Ship[i]^.torp := 10; FOR ii := 1 TO 500 do begin IF Ship[i]^.xShip = Plancoord[ii].x THEN begin IF Ship[i]^.yShip = Plancoord[ii].y THEN begin IF ((Plancoord[ii].pNum = 0) OR (Plancoord[ii].pNum = a)) THEN BEGIN Ship[i]^.mission := 11; {beam up fuel} if Ship[i]^.cash>0 then begin inc(plan[ii]^.money,Ship[i]^.cash); Ship[i]^.cash:=0; end; if Ship[i]^.eleS>0 then begin inc(plan[ii]^.eleS,Ship[i]^.eleS); Ship[i]^.eleS:=0; end; END; IF plancoord[ii].pNum = 0 THEN begin plan[ii]^.pNum := a; plan[ii]^.eleC := 15; plan[ii]^.eleS := plan[ii]^.eleS + 10; plan[ii]^.money := plan[ii]^.money + 30; Plancoord[ii].pNum := a; abrain[ii] := 3; END ELSE begin IF (Plancoord[ii].pNum <> a) THEN BEGIN abrain[ii] := 9; if (a = 10) AND (fig.rebelga=1) AND ((Plan[ii]^.eleC > 10) OR (Plan[ii]^.HappynessN>60)) THEN begin Ship[i]^.mission:=9; {Rebel Ground Attack} Dontmove[i]:=TRUE; end; if (a = 4) AND (Ship[i]^.Wbanks>0) AND ((Plan[ii]^.eleC > 10) OR (Plan[ii]^.HappynessC>50)) then begin Ship[i]^.mission := 9; {Fascist pillage} Dontmove[i]:=TRUE; end; {if} END; END; PCheck(ii,v); pbrain[ii] := v; END; END; end; {end for} c := 0; near := 0; nearD:= 30000; FOR ii := 1 TO 500 do begin IF (abrain[ii] = 0) AND NOT dontmove[i] AND NOT TAGGED[ii] THEN begin dx := Plancoord[ii].x - Ship[i]^.xShip; dy := Plancoord[ii].y - Ship[i]^.yShip; d := round(SQRT(SQR(dx) + SQR(dy))); IF d < nearD THEN begin nearD := d; near := ii; END; {ENDIF} END; {ENDIF} END; {END FOR II} if near>0 then begin dx := Plancoord[near].x - Ship[i]^.xShip; dy := Plancoord[near].y - Ship[i]^.yShip; WHILE (ABS(dx) > 160) OR (ABS(dy) > 160) DO BEGIN dx := round(dx * 0.8); dy := round(dy * 0.8); END; {end while} Ship[i]^.xWay := dx; Ship[i]^.yWay := dy; IF (Ship[i]^.wbanks > 1) AND (Ship[i]^.mission=0) THEN Ship[i]^.mission := 4; IF (Ship[i]^.wbanks > 1) AND ((a=4) OR (a=10)) AND (Plan[near]^.pNum<>a) THEN Ship[i]^.mission := 9; Ship[i]^.warp := Ship[i]^.eng; Ship[i]^.enemy := Plan[near]^.pNum; tagged[near]:=TRUE; end; END; {endif} END; {endif} END; {end for i} END; { end procedure} {*******************************************************************} PROCEDURE UNLOADEGGS; BEGIN Writelog('Unloading Freighter'); FOR x := 1 to 500 do BEGIN if (Sbase[x]^.pnum = a) OR (abrain[x]=7) then BEGIN for i := 1 to 500 do BEGIN if Sbrain[i]=2 then BEGIN If (Ship[i]^.xShip=Plancoord[x].x) AND (Ship[i]^.yShip=Plancoord[x].y) THEN BEGIN plan[x]^.eleM := plan[x]^.eleM + Ship[i]^.eleM; Ship[i]^.eleM := 0; plan[x]^.eleD := plan[x]^.eleD + Ship[i]^.eleD; Ship[i]^.eleD := 0; plan[x]^.eleT := plan[x]^.eleT + Ship[i]^.eleT; Ship[i]^.eleT := 0; plan[x]^.eleS := plan[x]^.eleS + Ship[i]^.eleS; Ship[i]^.eleS := 0; plan[x]^.money := plan[x]^.money + Ship[i]^.cash; Ship[i]^.cash := 0; plan[x]^.eleC := plan[x]^.eleC + Ship[i]^.col; Ship[i]^.col := 0; Ship[i]^.mission := 11; If Plan[x]^.eleC>5000 then BEGIN If Ship[i]^.damage>0 then Repairship(x,i); Ship[i]^.col:=round(CargoR *0.3); DEC(Plan[x]^.eleC,round(CargoR *0.3)); If Plan[x]^.eleS>=round(CargoR *0.3) THEN BEGIN Ship[i]^.eleS:=round(CargoR *0.3); DEC(Plan[x]^.eleS,round(CargoR *0.3)) END ELSE BEGIN Ship[i]^.eleS:=Plan[x]^.eleS div 2; Plan[x]^.eleS:=Plan[x]^.eleS div 2; END; If Plan[x]^.money>=round(CargoR *0.3) THEN BEGIN Ship[i]^.cash:=round(CargoR *0.3); DEC(Plan[x]^.money,round(CargoR *0.3)) END ELSE BEGIN Ship[i]^.cash:=Plan[x]^.money div 2; Plan[x]^.money:=plan[x]^.money div 2; END; END; END; END; END; END ELSE BEGIN for i := 1 to 500 do BEGIN if Sbrain[i]=2 then BEGIN IF (Plancoord[x].x = Ship[i]^.xship) AND (Plancoord[x].Y = Ship[i]^.Yship) THEN BEGIN IF (Plan[x]^.pnum = a) AND ((abrain[x]=7) OR (pbrain[x]>200)) AND (plan[x]^.eleC<200) THEN BEGIN inc(Plan[x]^.eleC,Ship[i]^.col); Ship[i]^.col:=0; inc(Plan[x]^.eleS,Ship[i]^.eleS); Ship[i]^.eleS:=0; inc(Plan[x]^.money,Ship[i]^.cash); Ship[i]^.cash:=0; END; END; END; END; {FOR I} END; {IF/ELSE} END; {FOR X} end; {proc} {**********************************************************************} Procedure Eggs; VAR distold: LONGINT; dx: LONGINT; dy: LONGINT; d : LONGINT; fgBD: LONGINT; c,FgP,FgP2,fgBase: integer; near: Array[1..6] of INTEGER; nearD: Array[1..6] of LONGINT; distold2: LONGINT; Procedure GOHOME; begin fgBase := 0; fgBD := 30000; FOR ii := 1 TO 500 DO BEGIN IF (SBase[ii]^.pNum = a) THEN BEGIN dx := Plancoord[ii].x - Ship[i]^.xShip; dy := Plancoord[ii].y - Ship[i]^.yShip; d := round(SQRT(SQR(dx) + SQR(dy))); IF d < fgBD THEN BEGIN fgBD := d; fgBase := ii; END; END; END; {FOR ii} IF fgBase > 0 THEN BEGIN dx := Plancoord[fgBase].x - Ship[i]^.xShip; dy := Plancoord[fgBase].y - Ship[i]^.yShip; WHILE (ABS(dx) > 160) OR (ABS(dy) > 160) DO BEGIN dx := round(dx * 0.8); dy := round(dy * 0.8); END; {while} Ship[i]^.xWay := dx; Ship[i]^.yWay := dy; Ship[i]^.warp := Ship[i]^.eng; END; END; {PROCEDURE} Procedure NEWPLANET; begin fgBase := 0; fgBD := 30000; FOR ii := 1 TO 500 DO BEGIN IF (Sbase[ii]^.pnum<>a) AND (abrain[ii]<>7) THEN BEGIN IF (Plancoord[ii].x = Ship[i]^.xship) AND (Plancoord[ii].Y = Ship[i]^.Yship) AND (plan[ii]^.eleM+plan[i]^.eleT+plan[ii]^.eleD>100) THEN BEGIN IF (Plan[ii]^.pnum = a) AND (abrain[ii]<>7) THEN BEGIN If Plan[ii]^.eleM> round(CargoR *0.3) then BEGIN Ship[i]^.eleM:=Ship[i]^.eleM+round(CargoR *0.3); DEC(Plan[ii]^.eleM,round(CargoR *0.3)) END ELSE BEGIN Ship[i]^.eleM:=Ship[i]^.eleM+Plan[ii]^.eleM; Plan[ii]^.eleM:=0; END; If Plan[ii]^.eleD>=round(CargoR *0.3) THEN BEGIN Ship[i]^.eleD:=Ship[i]^.eleD+round(CargoR *0.3); DEC(Plan[ii]^.eleD,round(CargoR *0.3)) END ELSE BEGIN Ship[i]^.eleD:=Ship[i]^.eleD+Plan[ii]^.eleD; Plan[ii]^.eleD:=0; END; If Plan[ii]^.eleT>=round(CargoR *0.3) THEN BEGIN Ship[i]^.eleT:=Ship[i]^.eleT+round(CargoR *0.3); DEC(Plan[ii]^.eleT,round(CargoR *0.3)) END ELSE BEGIN Ship[i]^.eleT:=Ship[i]^.eleT+Plan[ii]^.eleT; Plan[ii]^.eleT:=0; END; If (Plan[ii]^.money >100) AND (Plan[ii]^.money>=round(CargoR *0.3)) THEN BEGIN Ship[i]^.cash:=Ship[i]^.cash+round(CargoR *0.3); DEC(Plan[ii]^.money,round(CargoR *0.3)) END ELSE BEGIN Ship[i]^.cash:=Ship[i]^.cash+Plan[ii]^.money div 2; Plan[ii]^.money:=plan[ii]^.money div 2; END; END; END ELSE BEGIN IF (Plan[ii]^.pnum = a) AND (plan[ii]^.eleM+plan[i]^.eleT+plan[ii]^.eleD>100) THEN BEGIN dx := Plancoord[ii].x - Ship[i]^.xShip; dy := Plancoord[ii].y - Ship[i]^.yShip; d := round(SQRT(SQR(dx) + SQR(dy))); IF d < fgBD THEN BEGIN fgBD := d; fgBase := ii; END; END; END; END; END; {FOR ii} IF fgBase > 0 THEN BEGIN dx := Plancoord[fgBase].x - Ship[i]^.xShip; dy := Plancoord[fgBase].y - Ship[i]^.yShip; WHILE (ABS(dx) > 160) OR (ABS(dy) > 160) DO BEGIN dx := round(dx * 0.8); dy := round(dy * 0.8); END; {while} Ship[i]^.xWay := dx; Ship[i]^.yWay := dy; Ship[i]^.warp := Ship[i]^.eng; END; IF (Ship[i]^.xWay=0) AND (Ship[i]^.yWay=0) then GOHOME; END; {PROCEDURE} Procedure GOODPLANET; begin fgBase := 0; fgBD := 30000; FOR ii := 1 TO 500 DO BEGIN IF Sbase[ii]^.pnum<>a THEN BEGIN IF (Plancoord[ii].x = Ship[i]^.xship) AND (Plancoord[ii].Y = Ship[i]^.Yship) THEN BEGIN IF (Plan[ii]^.pnum = a) AND ((abrain[ii]=7) OR (pbrain[ii]>200)) AND (plan[ii]^.eleC<200) THEN BEGIN inc(Plan[ii]^.eleC,Ship[i]^.col); Ship[i]^.col:=0; inc(Plan[ii]^.eleS,Ship[i]^.eleS); Ship[i]^.eleS:=0; inc(Plan[ii]^.money,Ship[i]^.cash); Ship[i]^.cash:=0; END; IF (Plan[ii]^.pnum = 0) OR (Plan[ii]^.pnum=a) THEN BEGIN inc(Plan[ii]^.eleC,Ship[i]^.col); Ship[i]^.col:=0; inc(Plan[ii]^.eleS,Ship[i]^.eleS); Ship[i]^.eleS:=0; inc(Plan[ii]^.money,Ship[i]^.cash); Ship[i]^.cash:=0; Plan[ii]^.pnum:=a; END; END ELSE BEGIN IF (Plan[ii]^.pnum = a) AND ((abrain[ii]=7) OR (pbrain[ii]>pbrain[fgBase])) AND (plan[ii]^.eleC<200) THEN BEGIN dx := Plancoord[ii].x - Ship[i]^.xShip; dy := Plancoord[ii].y - Ship[i]^.yShip; d := round(SQRT(SQR(dx) + SQR(dy))); IF (d < fgBD) THEN BEGIN fgBD := d; fgBase := ii; END; END; END; END; END; {FOR ii} IF fgBase > 0 THEN BEGIN dx := Plancoord[fgBase].x - Ship[i]^.xShip; dy := Plancoord[fgBase].y - Ship[i]^.yShip; WHILE (ABS(dx) > 160) OR (ABS(dy) > 160) DO BEGIN dx := round(dx * 0.8); dy := round(dy * 0.8); END; {while} Ship[i]^.xWay := dx; Ship[i]^.yWay := dy; Ship[i]^.warp := Ship[i]^.eng; END; END; {PROCEDURE} BEGIN {PROCEDURE} FOR I := 1 TO 6 DO BEGIN near[I] := 1; nearD[I] := 50000; END; {FOR} Writelog('Setting Freighter Way Points'); FOR I := 1 TO 500 do begin IF shipcoord[i].race = a THEN begin IF Sbrain[i] = 2 THEN begin LoadFuel; IF Ship[i]^.col < 20 THEN begin IF (CargoR < HullT[Ship[i]^.hull].cargo) then begin GOHOME; END ELSE BEGIN NEWPLANET; END; END ELSE BEGIN GOODPLANET; END; END; END; END; END; {PROCEDURE} {*******************************************************************} Procedure WarShips; VAR Tagged: Array[1..500] of boolean; near: INTEGER; nearD: LONGINT; near1: INTEGER; nearD1: LONGINT; dx : LONGINT; dy : LONGINT; d : LONGINT; fgBD : LONGINT; fgBase: integer; {*****************************************} Procedure LoadShip; begin IF (Ship[i]^.tbanks > 0) AND (Ship[i]^.tube > 0) THEN begin If Ship[i]^.damage>0 then Repairship(fgBase,i); WHILE plan[fgbase]^.eleS>10 DO BEGIN inc(plan[fgbase]^.money); dec(plan[fgbase]^.eleS); END; {while} WHILE (plan[fgbase]^.money > (TorpT[Ship[i]^.tube].cost+10)) AND (plan[fgbase]^.eleM > 0) AND (plan[fgbase]^.eleT > 0) AND (plan[fgbase]^.eleD > 0) AND (Ship[i]^.torp < (Ship[i]^.Tbanks*10)) AND (CargoR > 1) do begin plan[fgbase]^.money := plan[fgbase]^.money - TorpT[Ship[i]^.tube].cost; plan[fgbase]^.eleM := plan[fgbase]^.eleM - 1; plan[fgbase]^.eleD := plan[fgbase]^.eleD - 1; plan[fgbase]^.eleT := plan[fgbase]^.eleT - 1; Ship[i]^.torp := Ship[i]^.torp + 1; END; {while} END; {if} IF Ship[i]^.bays > 0 THEN begin IF (a = 9) OR (a = 10) OR (a = 11) THEN begin WHILE (plan[fgbase]^.eleS > 5) AND (plan[fgbase]^.eleT > 2) AND (plan[fgbase]^.eleM > 3) AND (Ship[i]^.torp < (Ship[i]^.bays*10)) AND (CargoR > 1) do begin plan[fgbase]^.eleS := plan[fgbase]^.eleS - 5; plan[fgbase]^.eleM := plan[fgbase]^.eleM - 3; plan[fgbase]^.eleT := plan[fgbase]^.eleT - 2; Ship[i]^.torp := Ship[i]^.torp + 1; END; {while} END ELSE BEGIN IF a=8 THEN BEGIN IF (Sbase[fgbase]^.pnum=a) AND (a=8) THEN BEGIN WHILE (Sbase[fgbase]^.StoreF>5) AND (Ship[i]^.torp < (Ship[i]^.bays*10)) AND (CargoR > 1) DO BEGIN (* Writelog('ID#'+Stringa(fgbase,0)+ ' Trasfering 1 fighter to ship ID#'+Stringa(i,0)); *) inc(Ship[i]^.torp); dec(Sbase[fgbase]^.StoreF); END; {while} END; {IF} END ELSE BEGIN WHILE (plan[fgbase]^.money > 1000) AND (plan[fgbase]^.eleT > 2) AND (plan[fgbase]^.eleM > 3) AND (Ship[i]^.torp < (Ship[i]^.bays*10)) AND (CargoR > 1) DO BEGIN plan[fgbase]^.money := plan[fgbase]^.money - 100; plan[fgbase]^.eleM := plan[fgbase]^.eleM - 3; plan[fgbase]^.eleT := plan[fgbase]^.eleT - 2; Ship[i]^.torp := Ship[i]^.torp + 1; END; {while} END; {if/else} END; END; END; {PROCEDURE} {*****************************************} Procedure GOHOME; begin fgBase := 0; fgBD := 30000; FOR ii := 1 TO 500 DO BEGIN IF (plan[ii]^.pNum = a) AND (Sbase[ii]^.pNum <> a) AND (abrain[ii]<>7) THEN BEGIN IF (Ship[i]^.tbanks > 0) AND (Ship[i]^.tube > 0) THEN begin IF (((plan[ii]^.money+plan[ii]^.eleS) > (TorpT[ship[i]^.tube].cost*3)) AND (plan[ii]^.eleM > 30) AND (plan[ii]^.eleT > 30) AND (plan[ii]^.eleD > 30)) THEN BEGIN dx := Plancoord[ii].x - Ship[i]^.xShip; dy := Plancoord[ii].y - Ship[i]^.yShip; d := round(SQRT(SQR(dx) + SQR(dy))); IF d < fgBD THEN BEGIN fgBD := d; fgBase := ii; END; END; END; IF Ship[i]^.bays > 0 THEN begin IF (a = 9) OR (a = 10) OR (a = 11) THEN begin IF ((plan[ii]^.eleS > 100) AND (plan[ii]^.eleM > 60) AND (plan[ii]^.eleT > 40)) THEN BEGIN dx := Plancoord[ii].x - Ship[i]^.xShip; dy := Plancoord[ii].y - Ship[i]^.yShip; d := round(SQRT(SQR(dx) + SQR(dy))); IF d < fgBD THEN BEGIN fgBD := d; fgBase := ii; END; END; END; END; END; {IF} IF (plan[ii]^.pNum = a) AND (Sbase[ii]^.pNum = a) AND (a=8) THEN BEGIN IF Ship[i]^.bays > 0 THEN begin IF Sbase[ii]^.StoreF > 20 THEN BEGIN dx := Plancoord[ii].x - Ship[i]^.xShip; dy := Plancoord[ii].y - Ship[i]^.yShip; d := round(SQRT(SQR(dx) + SQR(dy))); IF d < fgBD THEN BEGIN fgBD := d; fgBase := ii; END; END; END; END; END; {FOR ii} IF fgBase > 0 THEN BEGIN dx := Plancoord[fgBase].x - Ship[i]^.xShip; dy := Plancoord[fgBase].y - Ship[i]^.yShip; WHILE (ABS(dx) > 160) OR (ABS(dy) > 160) DO BEGIN dx := round(dx * 0.8); dy := round(dy * 0.8); END; {while} Ship[i]^.xWay := dx; Ship[i]^.yWay := dy; Ship[i]^.warp := Ship[i]^.eng; IF (dx <= 50) AND (dy <= 50) THEN LoadShip; END; END; {PROCEDURE} {*****************************************} PROCEDURE GOWAR; begin near := 0; nearD:= 30000; FOR ii := 1 TO 500 DO BEGIN IF (abrain[ii] = 9) AND (Plan[ii]^.pNum<> a) THEN BEGIN dx := Plancoord[ii].x - Ship[i]^.xShip; dy := Plancoord[ii].y - Ship[i]^.yShip; d := round(SQRT(SQR(dx) + SQR(dy))); IF d < nearD THEN begin nearD:= d; near := ii; END; {IF} END; {IF} END; {for ii} if near > 0 then begin dx := Plancoord[near].x - Ship[i]^.xShip; dy := Plancoord[near].y - Ship[i]^.yShip; WHILE (ABS(dx) > 160) OR (ABS(dy) > 160) DO BEGIN dx := round(dx * 0.8); dy := round(dy * 0.8); END; {while} d := round(SQRT(SQR(dx) + SQR(dy))); IF d <= SQR(Ship[i]^.eng) THEN BEGIN if (a = 10) AND (fig.rebelga=1) AND (Plan[near]^.eleC>50) THEN BEGIN Ship[i]^.mission:=9; Ship[i]^.enemy:=0; Ship[i]^.xWay := dx; Ship[i]^.yWay := dy; Ship[i]^.warp := Ship[i]^.eng; {Rebel Ground Attack} end; if (a = 4) AND (Ship[i]^.Wbanks>0) AND (Plan[near]^.eleC>50) THEN BEGIN Ship[i]^.mission := 9; Ship[i]^.enemy:=0; Ship[i]^.xWay := dx; Ship[i]^.yWay := dy; Ship[i]^.warp := Ship[i]^.eng; {Fascist pillage} end; END; Ship[i]^.xWay := dx; Ship[i]^.yWay := dy; Ship[i]^.warp := Ship[i]^.eng; IF Ship[i]^.mission<>9 then begin Ship[i]^.enemy:=Plancoord[near].pNum; Ship[i]^.mission:=4; END; {if} end; {if} near1:=0; nearD1:=30000; FOR ii := 1 TO 500 DO BEGIN If (shipcoord[ii].race > 0) AND (shipcoord[ii].race <> a) AND (Classlist[Ship[ii]^.hull]<=Sbrain[i]) AND (Ship[ii]^.mission<>10) then begin dx := Shipcoord[ii].x - Ship[i]^.xShip; dy := Shipcoord[ii].y - Ship[i]^.yShip; d := round(SQRT(SQR(dx) + SQR(dy))); IF d < nearD1 THEN begin nearD1:= d; near1 := ii; END; {IF} end; end; {for} if (nearD1 < nearD) AND (near1>0) AND (nearD1<=300) then begin if ((a=7) OR (a=5)) AND (Ship[i]^.xShip=Ship[near1]^.xShip) AND (Ship[i]^.yShip=Ship[near1]^.yShip) AND (fig.boarding<>0) AND (Ship[near1]^.eleN=0) AND NOT Tagged[near1] THEN BEGIN Ship[i]^.mission:=7; Ship[i]^.tow:=Ship[near1]^.id; {for tow/capture} Ship[i]^.warp := Ship[i]^.eng; Tagged[near1]:=TRUE; Ship[i]^.xWay:=1; Ship[i]^.yWay:=1; GOHOME; end; dx := shipcoord[near1].x - Ship[i]^.xShip; dy := shipcoord[near1].y - Ship[i]^.yShip; WHILE (ABS(dx) > 160) OR (ABS(dy) > 160) DO BEGIN dx := round(dx * 0.8); dy := round(dy * 0.8); END; {while} if (Ship[i]^.mission<>7) then begin Ship[i]^.mission:=8; Ship[i]^.iTarget:=Ship[near1]^.id; end; if Ship[i]^.mission<>7 then begin Ship[i]^.enemy:=Ship[near1]^.pNum; Ship[i]^.xWay := dx; Ship[i]^.yWay := dy; Ship[i]^.warp := Ship[i]^.eng; end; end; {if} END; {PROCEDURE} {*****************************************} BEGIN Writelog('Setting WAR Way Points'); IF Classcount[10]0) then begin inc(Plan[x]^.eleM,Ship[i]^.eleM); Ship[i]^.eleM:=0; end; if (Ship[i]^.eleT>0) then begin inc(Plan[x]^.eleT,Ship[i]^.eleT); Ship[i]^.eleT:=0; end; if (Ship[i]^.eleD>0) then begin inc(Plan[x]^.eleD,Ship[i]^.eleD); Ship[i]^.eleD:=0; end; if (Sbase[x]^.pnum = a) then if (Ship[i]^.tbanks>0) AND (Sbbrain[x].mlayer=0) AND (fig.mine=1) then begin Sbrain[i]:=10; Sbbrain[x].mlayer:=1; end; {if} END; {IF} END; {FOR X} end; {if race=a} end; {for i} END; {IF} FOR i := 1 TO 500 DO Tagged[i]:=FALSE; FOR I := 1 TO 500 do begin IF shipcoord[i].race = a THEN BEGIN IF (Sbrain[i] = 3) OR (Sbrain[i] = 4) THEN BEGIN LoadFuel; IF (Ship[i]^.eleN > 50) THEN BEGIN IF ((hullT[Ship[i]^.hull].bays > 0) AND (Ship[i]^.torp >= (Ship[i]^.bays * 10))) OR ((hullT[Ship[i]^.hull].torp > 0) AND (Ship[i]^.torp >= (Ship[i]^.Tbanks * 10))) OR (CargoR<2) THEN BEGIN GOWAR; END ELSE GOHOME; IF (Ship[i]^.damage>=10) THEN GOHOME; IF ((hullT[Ship[i]^.hull].bays = 0) AND (hullT[Ship[i]^.hull].torp = 0)) AND ((sbrain[i]=3) OR (sbrain[i]=4)) THEN GOWAR; END; END; END; END; {FOR I} END; {PROCEDURE} {*******************************************************************} Procedure SaveBrain; begin Assign(brainfile,path+'kbrain'+playernum+'.hst'); Rewrite(brainfile); FOR I := 1 TO 500 DO Write(brainfile,pbrain[i]); FOR I := 1 TO 500 DO Write(brainfile,abrain[i]); FOR I := 1 TO 500 DO Write(brainfile,sbrain[i]); FOR I := 1 TO 500 DO Write(brainfile,sbbrain[i].mlayer,sbbrain[i].mfield,sbbrain[i].merlin); FOR I := 1 TO 11 DO Write(brainfile,ebrain[i]); CLOSE(brainfile); END; {proc} {*******************************************************************} Procedure Alchemy; var FgN,FgM: byte; { 'hull = 104 netronic refineray } { 'hull = 105 merlin class } BEGIN Writelog('Checking for Alchemy ships'); FOR I := 1 TO 500 do begin IF shipcoord[i].race = a THEN begin IF Ship[i]^.hull = 104 THEN fgN := 1; IF Ship[i]^.hull = 105 THEN fgM := 1; END; END; {FOR} IF (fgN = 1) OR (fgM = 1) THEN BEGIN FOR i := 1 TO 500 DO BEGIN IF plan[i]^.pNum = a THEN BEGIN IF fgM = 1 THEN BEGIN IF plan[i]^.eleS > 333 THEN BEGIN plan[i]^.eleS := plan[i]^.eleS - 333; plan[i]^.eleM := plan[i]^.eleM + 111; plan[i]^.eleD := plan[i]^.eleD + 111; plan[i]^.eleT := plan[i]^.eleT + 111; END; END; IF fgN = 1 THEN BEGIN IF plan[i]^.eleN < 200 THEN BEGIN IF (plan[i]^.eleD > 200) OR (plan[i]^.eleT > 200) OR (plan[i]^.eleM > 200) THEN BEGIN IF plan[i]^.eleS > 200 THEN BEGIN plan[i]^.eleS := plan[i]^.eleS - 100; plan[i]^.eleN := plan[i]^.eleN + 100; IF plan[i]^.eleD > 200 THEN plan[i]^.eleD := plan[i]^.eleD - 100 ELSE IF plan[i]^.eleT > 200 THEN plan[i]^.eleT := plan[i]^.eleT - 100 ELSE IF plan[i]^.eleM > 200 THEN plan[i]^.eleM := plan[i]^.eleM - 100; END; END; END; END; END; END; {for i} END; END; {procedure} {*******************************************************************} Procedure Refuel; var sw,maxme,maxyou: integer; tfuel,fgtank,c : integer; dx : LONGINT; dy : LONGINT; d : LONGINT; fgD: LONGINT; fghelp: Array[1..6] of INTEGER; begin FOR I := 1 TO 6 DO fghelp[I] := 0; c := 1; Writelog('Setting Refueler Way Points'); FOR I := 1 TO 500 DO BEGIN IF shipcoord[i].race = a THEN BEGIN IF (Ship[i]^.eleN = 0) AND (c < 7) THEN BEGIN fghelp[c] := I; c := c + 1; END; END; END; {FOR I} FOR c := 1 TO 6 do begin IF fghelp[c] > 0 THEN begin fgD := 30000; fgtank := 0; FOR I := 1 TO 500 DO BEGIN IF shipcoord[i].race = a THEN BEGIN IF Ship[i]^.eleN >= 130 THEN BEGIN dx := shipcoord[i].x - shipcoord[fghelp[c]].x; dy := shipcoord[i].y - shipcoord[fghelp[c]].y; d := round(SQRT(SQR(dx) + SQR(dy))); IF d < fgD THEN BEGIN fgD := d; fgtank := I; END; END; END; END; {FOR I} IF fgtank > 0 THEN BEGIN dx := shipcoord[fghelp[c]].x - Ship[fgtank]^.xShip; dy := shipcoord[fghelp[c]].y - Ship[fgtank]^.yShip; WHILE (ABS(dx) > 160) OR (ABS(dy) > 160) do BEGIN dx := round(dx * 0.8); dy := round(dy * 0.8); END; {while} Ship[fgtank]^.xWay := dx; Ship[fgtank]^.yWay := dy; Ship[fgtank]^.warp := Ship[fgtank]^.eng; LoadFuel; END; {if} END; {if} END; {for c} FOR v := 1 TO 499 do begin FOR z := v + 1 TO 500 do begin IF shipcoord[v].race = a THEN BEGIN IF shipcoord[z].race = a THEN BEGIN IF shipcoord[v].x = shipcoord[z].x THEN BEGIN IF shipcoord[v].y = shipcoord[z].y THEN BEGIN maxyou := hullT[Ship[v]^.hull].eleN; maxme := hullT[Ship[z]^.hull].eleN; tfuel := Ship[z]^.eleN + Ship[v]^.eleN; Ship[z]^.eleN := 0; Ship[v]^.eleN := 0; sw := 1; WHILE tfuel > 0 do begin sw := sw + 1; IF sw > 1 THEN sw := 0; tfuel := tfuel - 1; IF sw = 0 THEN begin IF Ship[z]^.eleN < maxme THEN inc(Ship[z]^.eleN) ELSE IF Ship[v]^.eleN < maxyou THEN inc(Ship[v]^.eleN); END; IF sw = 1 THEN begin IF Ship[v]^.eleN < maxyou THEN inc(Ship[v]^.eleN) ELSE IF Ship[z]^.eleN < maxme THEN inc(Ship[z]^.eleN); END; END; {while} END; {if} END; {if} END; {if} END; {if} END; {for z} END; {for v} END; {procedure} {*******************************************************************} Procedure Shipmission; var dx : LONGINT; dy : LONGINT; d : LONGINT; Procedure Minelayer; var nomines: Array [1..500] of boolean; Procedure Loadmine; begin IF (Ship[i]^.tbanks > 0) AND (Ship[i]^.tube > 0) THEN begin WHILE plan[ii]^.eleS>10 DO BEGIN inc(plan[ii]^.money); dec(plan[ii]^.eleS); END; {while} WHILE (plan[ii]^.money > 200) AND (plan[ii]^.eleM > 50) AND (plan[ii]^.eleT > 50) AND (plan[ii]^.eleD > 50) AND (CargoR > 1) do begin plan[ii]^.money := plan[ii]^.money - TorpT[Ship[i]^.tube].cost; plan[ii]^.eleM := plan[ii]^.eleM - 1; plan[ii]^.eleD := plan[ii]^.eleD - 1; plan[ii]^.eleT := plan[ii]^.eleT - 1; Ship[i]^.torp := Ship[i]^.torp + 1; END; {while} END; {if} end; begin for x := 1 to 500 do begin IF (plan[ii]^.pNum = a) AND (Sbase[ii]^.pNum = a) THEN BEGIN if mine[x].x = plancoord[ii].x then begin if mine[x].y = plancoord[ii].y then begin if (mine[x].race = a) then begin sbbrain[ii].mfield:=x; Loadmine; if (mine[x].num<3600) then begin (* Writelog('ID#'+stringa(x,0)+' num of mine '+stringa(mine[x].num,0)); *) Ship[i]^.mission:=3; if (a=7) and (fig.web<>0) then Ship[i]^.mission:=9; Ship[i]^.xWay := 0; Ship[i]^.yWay := 0; Ship[i]^.warp := 0; end else Ship[i]^.mission:=4; end; end; end; END; IF (plan[ii]^.pNum = a) AND (Sbase[ii]^.pNum = a) THEN if shipcoord[i].x = plancoord[ii].x then if shipcoord[i].y = plancoord[ii].y then IF (sbbrain[ii].mfield=0) THEN BEGIN Loadmine; Ship[i]^.mission:=3; if (a=7) and (fig.web<>0) then Ship[i]^.mission:=9; Ship[i]^.xWay := 0; Ship[i]^.yWay := 0; Ship[i]^.warp := 0; END; {if} END; {for x} END; {PROCEDURE} begin Writelog('Assigning Ships Mission'); For i := 1 to 500 do begin if (Sbase[i]^.pnum=a) AND (Sbase[i]^.damage>0) then Sbase[i]^.mission:=5; if Shipcoord[i].race = a then begin Write('.'); if (Ship[i]^.damage>10) AND (Ship[i]^.warp>10-(Ship[i]^.damage div 10)) then Ship[i]^.warp:=10 - (Ship[i]^.damage div 10); for ii := 1 to 500 do begin if (Ship[i]^.damage<=fig.nocloakdamage) AND (Ship[i]^.eleN>0) THEN BEGIN if (Sbrain[i]<>10) AND (Ship[i]^.mission<>9) AND (Ship[i]^.mission<>8) THEN BEGIN Case Ship[i]^.hull of 21,22,25,26,27,28, 29,31,32,33,36,38, 43,44,45,46,47 : Ship[i]^.mission:=10; {cloak} end; {case} end; {if} end; {if} if (a=2) AND (Plancoord[ii].x=Shipcoord[i].x) AND (Plancoord[ii].y=Shipcoord[i].y) AND (Ship[i]^.wbanks>0) AND (sbrain[i]<>10) AND (abrain[ii]<>9) then Ship[i]^.mission:=9; if (sbrain[i]=10) AND (Shipcoord[i].x=plancoord[ii].x) AND (Shipcoord[i].y=plancoord[ii].y) then minelayer; if (mine[ii].race>0) then begin dx := mine[ii].x - Ship[i]^.xShip; dy := mine[ii].y - Ship[i]^.yShip; d := round(SQRT(SQR(dx) + SQR(dy))); if (d < round(SQRT(mine[ii].num))) AND (mine[ii].race <> a) then begin if Ship[i]^.warp>7 then Ship[i]^.warp:=7; if (Ship[i]^.wbanks>0) OR ((a=11) AND (Ship[i]^.Torp>0)) then begin Ship[i]^.mission := 2; if mine[ii].web=0 then Ship[i]^.warp:=7 else Ship[i]^.warp:=1; end; {if} end; {if} end; {if} end; {for ii} if (Ship[i]^.damage>0) AND (a=6) then begin Ship[i]^.warp:=0; Ship[i]^.mission:=9; end; end; {if shipcoord} end; {for i} Writeln; end; {procedure} {*******************************************************************} Procedure ShipXYR; BEGIN Writelog('Saving Host Data...'); FOR I := 1 TO 500 do begin IF ship[i]^.pNum > 0 THEN begin shipcoord[i].x := Ship[i]^.xShip; shipcoord[i].y := Ship[i]^.yShip; shipcoord[i].race := Ship[i]^.pNum; END; END; END; {END PROC.} {*******************************************************************} Procedure Savehostdata; begin Writeplan(path); Writesbase(path); writeship(path); WriteshipXY(path); END; {*******************************************************************} (* SUB CheckFig DIM oldfig AS CONFIGTYPE f1 = FREEFILE OPEN path + "OLDFIG.HST" FOR BINARY AS #f1 GET #f1, 1, oldfig PUT #f1, 1, fig CLOSE #f1 fg = 0 IF oldfig.recycle <> fig.recycle THEN fg = 1 IF oldfig.meteor <> fig.meteor THEN fg = 1 IF oldfig.mine <> fig.mine THEN fg = 1 IF oldfig.Alchemy <> fig.Alchemy THEN fg = 1 IF oldfig.delold <> fig.delold THEN fg = 1 IF fg = 1 THEN g$ = "< Message from Mr. Host >" + ek + ek g$ = g$ + " I have set the following:" + ek + ek g$ = g$ + " Colonize recycle rate : " + STR$(fig.recycle) + " % " + ek g$ = g$ + " ^ ( minerals recovered from hull )" + ek + ek g$ = g$ + " Odds of a meteor " + STR$(fig.meteor) + " %" + ek g$ = g$ + " Antiship space mines " IF fig.mine = 0 THEN g$ = g$ + " : NO " + ek ELSE g$ = g$ + " : YES " + ek END IF g$ = g$ + " Alchemy ships " IF fig.Alchemy = 0 THEN g$ = g$ + " : NO " + ek ELSE g$ = g$ + " : YES " + ek END IF g$ = g$ + " Delete Old Messages" IF fig.delold = 0 THEN g$ = g$ + " : NO " + ek ELSE g$ = g$ + " : YES " + ek END IF FOR I = 1 TO 11 IF ingame(I) THEN PutMessage I, g$ END IF NEXT I END IF END SUB DEFSNG A-Z DEFINT A-Z SUB CKI (n%) IF n > 10000 THEN e$ = "DATA OVERFLOW ERROR! in player " + STR$(race) + " .TRN file " PutError e$ n = 0 END IF IF n < 0 THEN e$ = "DATA UNDERFLOW ERROR! in player " + STR$(race) + " .TRN file" PutError e$ n = 0 END IF END SUB DEFSNG A-Z DEFLNG A-Z SUB CKL (n&) IF n& > 1000000000 THEN e$ = "BIG DATA OVERFLOW ERROR! in player " + STR$(race) + " .TRN file " PutError e$ n& = 0 END IF IF n& < 0 THEN e$ = "BIG DATA UNDERFLOW ERROR! in player " + STR$(race) + " .TRN file" PutError e$ n& = 0 END IF END SUB DEFINT A-Z SUB DelOldMess 'this sub searches messages to the computer player and dumps them 'or recycles them DIM x1 AS LONG DIM x2 AS LONG DIM x3 AS LONG DIM mpt AS LONG DIM char AS STRING * 1 DIM messcount(11) AS INTEGER IF LEN(DIR$(path + "MESSPNT.NEW")) > 0 THEN KILL path + "MESSPNT.NEW" IF LEN(DIR$(path + "MESS.NEW")) > 0 THEN KILL path + "MESS.NEW" nul = 0 PRINT "Saving subspace message traffic..." IF LEN(DIR$(path + "MESSPNT.OLD")) = 0 THEN f2 = FREEFILE OPEN path + "MESSPNT.OLD" FOR BINARY AS #f2 PUT #f2, 1, nul CLOSE #f2 END IF IF LEN(DIR$(path + "MESSPNT.EXT")) = 0 THEN f2 = FREEFILE OPEN path + "MESSPNT.EXT" FOR BINARY AS #f2 PUT #f2, 1, nul CLOSE #f2 END IF f2 = FREEFILE OPEN path + "MESSPNT.OLD" FOR BINARY AS #f2 GET #f2, 1, c IF c > 0 THEN ic = 1 WHILE ic <= c x1 = (ic - 1) * 8 + 3 GET #f2, x1, r IF r > 0 AND r < 12 THEN IF playrace(r) = 0 THEN PRINT "."; x2 = x1 + 2 x3 = x2 + 4 GET #f2, x2, mpt GET #f2, x3, l m$ = "" f3 = FREEFILE OPEN path + "MESS.OLD" FOR BINARY AS #f3 I = 0 WHILE I < l I = I + 1 GET #f3, mpt, char mpt = mpt + 1 m$ = m$ + char WEND CLOSE #f3 StoreNewMess r, m$ END IF ELSE er$ = "Race Message ERROR" + STR$(r) + "message # " + STR$(ic) PutError er$ END IF ic = ic + 1 WEND END IF CLOSE #f2 IF LEN(DIR$(path + "MESSPNT.TMP")) > 0 THEN KILL path + "MESSPNT.TMP" IF LEN(DIR$(path + "MESS.TMP")) > 0 THEN KILL path + "MESS.TMP" IF LEN(DIR$(path + "MESSPNT.NEW")) > 0 AND LEN(DIR$(path + "MESS.NEW")) > 0 THEN NAME path + "MESSPNT.NEW" AS path + "MESSPNT.TMP" NAME path + "MESS.NEW" AS path + "MESS.TMP" ELSE nul = 0 f1 = FREEFILE OPEN path + "MESSPNT.TMP" FOR BINARY AS #f1 PUT #f1, 1, nul CLOSE #f1 OPEN path + "MESS.TMP" FOR BINARY AS #f1 PUT #f1, 1, nul CLOSE #f1 END IF PRINT END SUB SUB Dumpmess 'this sub searches old read messages and dumps them 'or recycles them DIM x1 AS LONG DIM x2 AS LONG DIM x3 AS LONG DIM mpt AS LONG DIM char AS STRING * 1 DIM messcount(11) AS INTEGER IF LEN(DIR$(path + "MESSPNT.NEW")) > 0 THEN KILL path + "MESSPNT.NEW" IF LEN(DIR$(path + "MESS.NEW")) > 0 THEN KILL path + "MESS.NEW" nul = 0 IF LEN(DIR$(path + "MESSPNT.OLD")) = 0 THEN f2 = FREEFILE OPEN path + "MESSPNT.OLD" FOR BINARY AS #f2 PUT #f2, 1, nul CLOSE #f2 END IF f2 = FREEFILE OPEN path + "MESSPNT.OLD" FOR BINARY AS #f2 f3 = FREEFILE OPEN path + "MESSPNT.NEW" FOR BINARY AS #f3 GET #f2, 1, c newc = 0 IF c > 0 THEN ic = 1 WHILE ic <= c x1 = (ic - 1) * 8 + 3 GET #f2, x1, r IF r > 0 AND r < 12 THEN IF playrace(r) = 0 THEN newc = newc + 1 x2 = x1 + 2 x3 = x2 + 4 GET #f2, x2, mpt GET #f2, x3, l x1 = (newc - 1) * 8 + 3 x2 = x1 + 2 x3 = x2 + 4 PUT #f3, x1, r PUT #f3, x2, mpt PUT #f3, x3, l END IF END IF ic = ic + 1 WEND END IF PUT #f3, 1, newc CLOSE #f3 CLOSE #f2 IF LEN(DIR$(path + "MESSPNT.OLD")) > 0 THEN KILL path + "MESSPNT.OLD" NAME path + "MESSPNT.NEW" AS path + "MESSPNT.OLD" END SUB FUNCTION FuelR% FuelR = hull.eleN - Ship[i]^.eleN END FUNCTION FUNCTION PLANETNAME$ (n%) DIM nm AS STRING * 20 f5 = FREEFILE OPEN "PLANET.NM" FOR BINARY AS #f5 x1 = (n - 1) * 20 + 1 GET #f5, x1, nm a$ = RTRIM$(nm) CLOSE #f5 PLANETNAME = a$ END FUNCTION SUB PutError (g$) DIM pt AS LONG DIM char AS STRING * 1 PRINT g$ f4 = FREEFILE OPEN path + "CPERROR.LOG" FOR BINARY AS #f4 pt = LOF(f4) + 1 g$ = g$ + ek + CHR$(10) l = LEN(g$) FOR I = 1 TO l char = MID$(g$, I, 1) PUT #f4, pt, char pt = pt + 1 NEXT I CLOSE #f4 OPEN path + "CPOLD.LOG" FOR BINARY AS #f4 pt = LOF(f4) + 1 l = LEN(g$) FOR I = 1 TO l char = MID$(g$, I, 1) PUT #f4, pt, char pt = pt + 1 NEXT I CLOSE #f4 END SUB SUB PutMessage (rc%, gg$) DIM pt AS LONG DIM ptold AS LONG DIM x1 AS LONG DIM x2 AS LONG DIM x3 AS LONG DIM x1old AS LONG DIM x2old AS LONG DIM x3old AS LONG DIM char AS STRING * 1 ' ' this sub stores a message and data on the message for later use 'MESSPNT.TMP '|2 integer (count) |2 integer (race) |4 long (pointer to MESS.TMP) |2 integer (length) |... 'MESS.TMP '| message data | message data | m$ = gg$ IF rc > 11 OR rc < 1 THEN EXIT SUB IF m$ = "" THEN EXIT SUB f2 = FREEFILE OPEN path + "MESSPNT.TMP" FOR BINARY AS #f2 GET #f2, 1, count count = count + 1 PUT #f2, 1, count x1 = (count - 1) * 8 + 3 x2 = x1 + 2 x3 = x2 + 4 l = LEN(m$) IF count > 1 THEN x1old = (count - 2) * 8 + 3 x2old = x1old + 2 x3old = x2old + 4 GET #f2, x2old, ptold GET #f2, x3old, lold pt = ptold + (lold) ELSE pt = 1 END IF PUT #f2, x1, rc PUT #f2, x2, pt PUT #f2, x3, l CLOSE #f2 OPEN path + "MESS.TMP" FOR BINARY AS #f2 FOR I = 1 TO l IF ASC(MID$(m$, I, 1)) + 13 > 254 THEN MID$(m$, I, 1) = " " END IF MID$(m$, I, 1) = CHR$(ASC(MID$(m$, I, 1)) + 13) ' PUT #f2, pt&, char ' pt = pt + 1 NEXT I PUT #f2, pt&, m$ pt = pt + 1 CLOSE #f2 END SUB SUB ShipMass DIM x1 AS LONG DIM size AS LONG DIM S AS LONG DIM I AS LONG 'figures the ships mass and stores mass in shipcoord[i].mass() 'mass is in Kilotons PRINT "Figuring mass of all ships." f1 = FREEFILE OPEN path + "SHIP.HST" FOR BINARY AS #f1 f2 = FREEFILE OPEN "HULLSPEC.DAT" FOR BINARY AS #f2 f3 = FREEFILE OPEN "BEAMSPEC.DAT" FOR BINARY AS #f3 f4 = FREEFILE OPEN "TORPSPEC.DAT" FOR BINARY AS #f4 FOR I = 1 TO 500 IF shipcoord[i].race(I) > 0 THEN w = 0 shipSlot = I size = 107 x1 = (I - 1) * size + 3 GET #f1, x1, me IF Ship[i]^.eleN < 1 THEN Ship[i]^.mission = 0 IF Ship[i]^.mission = 10 AND Ship[i]^.eleN > 0 THEN mapc(Ship[i]^.ID) = 1 ELSE mapc(Ship[i]^.ID) = 0 END IF IF Ship[i]^.mission = 9 AND Ship[i]^.eleN > 0 AND Ship[i]^.pNum = 3 THEN SELECT CASE Ship[i]^.hull CASE 21, 22, 25, 26, 27, 28, 29, 47, 31 mapc(Ship[i]^.ID) = 1 CASE 32, 33, 45, 38, 36, 43, 46, 44, 45 mapc(Ship[i]^.ID) = 1 END SELECT END IF IF Ship[i]^.mission < 7 AND (Ship[i]^.tow > 0 OR Ship[i]^.iTarget > 0) THEN Ship[i]^.tow = 0 Ship[i]^.iTarget = 0 PUT #f1, x1, me END IF IF hull.bays = 0 AND Ship[i]^.bays > 0 THEN Ship[i]^.torp = 0 Ship[i]^.bays = 0 PUT #f1, x1, me END IF IF hull.torp = 0 AND Ship[i]^.tbanks > 0 THEN Ship[i]^.tbanks = 0 Ship[i]^.torp = 0 PUT #f1, x1, me END IF IF Ship[i]^.bays < 1 AND Ship[i]^.tbanks < 1 AND Ship[i]^.torp > 0 THEN Ship[i]^.torp = 0 PUT #f1, x1, me END IF IF (Ship[i]^.damage > 99 AND Ship[i]^.pNum <> 2) THEN Ship[i]^.pNum = 0 Ship[i]^.ID = 0 shipcoord[i].race(I) = 0 PUT #f1, x1, me END IF IF Ship[i]^.damage > 151 AND Ship[i]^.pNum = 2 THEN Ship[i]^.pNum = 0 Ship[i]^.ID = 0 shipcoord[i].race(I) = 0 PUT #f1, x1, me END IF IF ABS(Ship[i]^.xWay) > 200 OR ABS(Ship[i]^.yWay) > 200 THEN Ship[i]^.xWay = 0 Ship[i]^.yWay = 0 PUT #f1, x1, me END IF IF Ship[i]^.damage > 0 AND Ship[i]^.eleS >= 5 THEN WHILE Ship[i]^.damage > 0 AND Ship[i]^.eleS >= 5 Ship[i]^.damage = Ship[i]^.damage - 1 Ship[i]^.eleS = Ship[i]^.eleS - 5 WEND PUT #f1, x1, me END IF IF Ship[i]^.damage > 10 THEN maxspeed = 10 - Ship[i]^.damage \ 10 IF Ship[i]^.pNum = 2 THEN maxspeed = maxspeed + 4 IF Ship[i]^.warp > maxspeed THEN Ship[i]^.warp = maxspeed PUT #f1, x1, me END IF size = 60 x1 = (Ship[i]^.hull - 1) * size + 1 GET #f2, x1, hull IF Ship[i]^.weapon > 0 THEN size = 36 x1 = (Ship[i]^.weapon - 1) * size + 1 GET #f3, x1, beam w = w + beam.mass * Ship[i]^.wbanks END IF IF Ship[i]^.tube > 0 THEN size = 38 x1 = (Ship[i]^.tube - 1) * size + 1 GET #f4, x1, TorpT w = w + TorpT.mass * Ship[i]^.tbanks END IF w = hull.mass + Ship[i]^.torp + Ship[i]^.eleM + Ship[i]^.eleN + Ship[i]^.eleT w = w + Ship[i]^.eleD + Ship[i]^.col + Ship[i]^.eleS shipcoord[i].mass(I) = w END IF NEXT I CLOSE #f4 CLOSE #f3 CLOSE #f2 CLOSE #f1 END SUB SUB StoreNewMess (rc%, m$) ' ' this sub stores a message and data on the message for later use ' in the event that a player misses a turn 'MESSPNT.NEW '|2 integer (count) |2 integer (race) |4 long (pointer to MESS.TMP) |2 integer (length) |... 'MESS.NEW '| message data | message data | DIM pt AS LONG DIM ptold AS LONG DIM char AS STRING * 1 DIM x1 AS LONG DIM x2 AS LONG DIM x3 AS LONG DIM x1old AS LONG DIM x2old AS LONG DIM x3old AS LONG IF m$ = "" THEN EXIT SUB f3 = FREEFILE OPEN path + "MESSPNT.NEW" FOR BINARY AS #f3 GET #f3, 1, count count = count + 1 PUT #f3, 1, count x1 = (count - 1) * 8 + 3 x2 = x1 + 2 x3 = x2 + 4 l = LEN(m$) IF count > 1 THEN x1old = (count - 2) * 8 + 3 x2old = x1old + 2 x3old = x2old + 4 GET #f3, x2old, ptold GET #f3, x3old, lold pt = ptold + (lold) ELSE pt = 1 END IF PUT #f3, x1, rc PUT #f3, x2, pt PUT #f3, x3, l CLOSE #f3 OPEN path + "MESS.NEW" FOR BINARY AS #f3 FOR I = 1 TO l char = MID$(m$, I, 1) PUT #f3, pt, char pt = pt + 1 NEXT I CLOSE #f3 END SUB fine parte commentata *) Function UpStr(var stringa:string):string; begin for i := 1 to length(stringa) do Stringa[i]:=Upcase(Stringa[i]); UpStr:=Stringa; end; Procedure FreeAllData; begin FreeSbase; FreePlan; FreeShip; (* for i:= 1 to maxname do Dispose(Shipname[i]); *) end; Begin {main} If paramcount<2 then begin Writeln; Writeln; Writeln('VGA Planets(tm)'); Writeln('KATTIVIK >>> Beta 3 <<< Don''t Distribute!'); Writeln('Copyright (c) 1996 by Jean-Marie Clement'); Writeln('All rights reserved'); Writeln; Writeln('KATTIVIK.EXE is a freeware program'); Writeln; Writeln('Synthax is KATTIVIK.EXE [/123456789ab]'); Writeln; halt(1); end; {endif} path:= paramstr(1); comandline:=paramstr(2); for i := 2 to length(comandline) do begin tempstring:=comandline[i]; val(tempstring,a,code); if (a>0) AND (code=0) then playrace[a]:=1 else begin if (comandline[i]='a') OR (comandline[i]='A') then playrace[10]:=1; if (comandline[i]='b') OR (comandline[i]='B') then playrace[11]:=1; if comandline[i]='*' then lowtech:=1; end; {endif} end; {endfor} if path[length(path)]<>'\' then path:=path+'\'; Assign(LOGFILE,path+'KATTIVIK.LOG'); Rewrite(logfile); Writelog(''); Writelog(''); Writelog('VGA Planets(tm)'); Writelog('KATTIVIK >>> Beta 3 <<< Don''t Distribute!'); Writelog('Copyright (c) 1996 by Jean-Marie Clement'); Writelog('All rights reserved'); Writelog(''); Writelog('KATTIVIK.EXE is a freeware program'); Writelog(''); ReadNexttrn(PATH); If Nexttrn.turn=0 then begin Writeln('Cannot play before 1st host!'); halt(1); end; Writelog('Turn: '+stringa(nexttrn.turn,0)); Writelog(''); Writelog('Processing files in: '+UpStr(path)); LoadHostData; FOR a := 1 TO 11 do IF playrace[a] = 1 THEN BEGIN IF ingame[a] = 1 THEN BEGIN str(a,playernum); FindFirst(path+'player'+playernum+'.trn',AnyFile,trovati); if DosError=0 then begin Writelog('Turn file found for '+RACELONG[A]); Writelog('Computer will skip this player this turn'); playrace[a] := 0; end else Writelog('*** Computer will play for '+RACELONG[A]+' ***'); END ELSE BEGIN playrace[a] := 0; Writelog('*** Sorry '+RACELONG[A]+' is not active! ***'); END; {if ingame} END; Writeln; Writeln('FREE MEMORY: ', Memavail, ' bytes'); Writeln; RANDOMIZE; FOR a := 1 TO 11 do IF playrace[a] = 1 THEN BEGIN Writelog('Playing : '+RACELONG[a]); LoadBrain; UnLoadEggs; PlanetCheck; PlanetEcon; MoveMinerals; WorkOnSBase; BuildNewShips; BuildNewStarbase; Eggs; Explore; WarShips; Alchemy; Refuel; Shipmission; SaveBrain END; {end if} ShipXYR; SaveHostData; FreeAllData; Close(LOGFILE); end. {main}