'=========================================================================== ' Subject: AI TEST Date: 02-05-99 (01:41) ' Author: Brant Kraushar Code: VBDOS ' Origin: brant_k@hotmail.com Packet: AI.ABC '=========================================================================== REM $INCLUDE: 'VBDOS.BI' 'by Brant Kraushar 'Edmonton, Alberta, Canada ÞÝÞÝ ' 'Alot of glitches in the program... unfortunately i can hardly understand 'my own code... complicated relationships between vars ' 'this program written in Visual basic for ms-dos v1.00 ' on a 286, then 486, then P100, now P300 (long time being developed, eh?) 'actually, the 286 was upgraded to 486, same fate for the p100 'in the so-called game, push A or B to build a base or turret, respectively 'use the 1,2,3,4 keys to build units. 'see sub initunits to make new units or see old ones. 'you are WHITE player 'READ HERE IF YOU WANT TO CHANGE ANYTHING 'fell free to change, modify, destroy, implant viruses, twist, dement, 'rip off or otherwise improve this crap, but email me the result... 'this program does have a higher purpose in life, this is just to test some 'AI and stuff for a DirectX game i am making... so far its a failure... 'anyway my email address is at 'Brant_K@hotmail.com 'any feedback would be appreciated ' DECLARE SUB loadm () DECLARE SUB game () DECLARE SUB initunits () DECLARE SUB mapgen () TYPE UnitType ALevel(1 TO 16) AS INTEGER 'acces level 0=owner, 1=bought, 2=licensec, 3=stolen\copied, 4=none buildtime AS INTEGER ShotRange AS INTEGER Strength AS LONG Speed AS INTEGER AP AS INTEGER 'armor peircing? FirePower AS INTEGER shotrate AS INTEGER symbol AS STRING * 1 Armor AS INTEGER FuelCap AS INTEGER flags AS INTEGER price AS INTEGER Stealth AS INTEGER Radar AS INTEGER END TYPE TYPE BuildingType price AS INTEGER AP AS INTEGER Strength AS LONG ShotRange AS INTEGER shotrate AS INTEGER FirePower AS INTEGER symbol AS STRING * 1 Armor AS INTEGER flags AS INTEGER Visibility AS INTEGER Radar AS INTEGER buildtime AS INTEGER END TYPE TYPE Unit hasshotat AS INTEGER type AS INTEGER damage AS LONG Fuel AS INTEGER loc AS INTEGER owner AS INTEGER order AS INTEGER '1=move 2=attack 3=guard 0=sleep 4=repair 5=findpath flags AS INTEGER Path(1 TO 256) AS INTEGER PathPos AS INTEGER 'PATH array element # PathNum AS INTEGER '# of PATH array elements spcx AS INTEGER StickyX AS INTEGER nextorder AS INTEGER atpos AS INTEGER '# of loops at current pos; for regulating speed shotfrompos AS INTEGER shotby AS INTEGER END TYPE TYPE country money AS LONG controller AS INTEGER '1-16=ai, 100+n = player color AS INTEGER funding AS INTEGER CType AS INTEGER '1=active, 0=passive WarState(1 TO 16) AS INTEGER ' ..<5000-8000-10000 END TYPE TYPE Building repairing AS INTEGER build AS INTEGER timeleft AS INTEGER owner AS INTEGER damage AS LONG btype AS INTEGER loc AS INTEGER order AS INTEGER Spc AS INTEGER flags AS INTEGER atpos AS INTEGER shotfrompos AS INTEGER shotby AS INTEGER buildtime AS INTEGER END TYPE TYPE AI UnitRating(1 TO 100) AS INTEGER UnitPriceR(1 TO 100) AS INTEGER BldRating(1 TO 100) AS INTEGER BldPriceRating(1 TO 100) AS INTEGER EnUnitMem(1 TO 100, 1 TO 2) AS INTEGER 'x+y,type EnBldMem(1 TO 100, 1 TO 2) AS INTEGER 'x+y,type EnUnitClassMem(1 TO 100, 1 TO 2) AS INTEGER 'shoots at type1,2,4,8..., Threat level (if it's type usually attacks), based on average damage one inflicts EnBuildMem(1 TO 100, 1 TO 2) AS INTEGER ' <<<<<<<< AI PERSONALITY SECTION >>>>>>>>> AIPTER AS INTEGER 'ai $ to effect rate AICautious AS INTEGER ' AIBuildey AS INTEGER AIBuy AS INTEGER 'use alot research? buy? AIType AS INTEGER 'ai level of 'intelligence' AIDTOR AS INTEGER 'ai def. to off. rat AIDefType AS INTEGER 'turrets? or tanks? AIOffType AS INTEGER 'blitz? geurrilla? AISneaky AS INTEGER 'does it care if being seen? AIAngry AS INTEGER AIFriendly AS INTEGER AIsavey AS INTEGER 'saves money AIAggressive AS INTEGER AIFixy AS INTEGER 'repair? target AS INTEGER END TYPE TYPE map Name AS STRING * 20 players AS INTEGER Landmap(1 TO 50, 1 TO 80) AS INTEGER ' trrn FBUMap(-5 TO 55, -5 TO 85) AS INTEGER 'unit bldng '+1000 = unit +10000 = passable, country(1 TO 16) AS country END TYPE SCREEN 0 DEFINT A-Z DIM SHARED AI(1 TO 16) AS AI DIM SHARED unittypes(1 TO 10) AS UnitType DIM SHARED units(1 TO 100) AS Unit DIM SHARED bldtypes(1 TO 10) AS BuildingType DIM SHARED blds(1 TO 100) AS Building DIM SHARED map AS map DIM inreg AS RegType, outreg AS RegType CLS RANDOMIZE TIMER 'DIM SHARED map(1 TO 50, 1 TO 80, 1 TO 3) AS INTEGER 'unit bldng trrn WIDTH 80, 50 PRINT "type n if you wanna make a new map. (press escape when satisfied with the map's growth)" INPUT ""; n$ IF LCASE$(n$) = "n" THEN mapgen ELSE loadm initunits game ' ' SUB game () ON ERROR RESUME NEXT PLAY "MB" SCREEN 0, , 2, 0 FOR a = 1 TO map.players map.country(a).money = 50000 NEXT a FOR a = 1 TO 80 FOR b = 1 TO 45 LOCATE b, a IF map.Landmap(b, a) = 1 THEN COLOR 11: PRINT "Û" IF map.Landmap(b, a) = 3 THEN COLOR 0, 3: PRINT "ÿ" IF map.Landmap(b, a) = 2 THEN COLOR 0, 9: PRINT "ÿ" IF map.Landmap(b, a) = 0 THEN COLOR 0, 0: PRINT " " NEXT b, a FOR a = 1 TO map.players COLOR map.country(a).color, 0 69 y = INT(RND * 30) + 6 x = INT(RND * 65) + 12 IF SCREEN(y, x) = 32 THEN LOCATE y, x: PRINT "" ELSE GOTO 69 blds(a).owner = a blds(a).damage = 0'INT(RND * 10000) blds(a).btype = 1'INT(RND * 2) + 1 blds(a).loc = x + (y * 256) blds(a).order = 3 blds(a).flags = 10 x = blds(a).loc MOD 256 y = (blds(a).loc - x) / 256 map.Landmap(y + 1, x) = 0 units(a).loc = x + (256 * (y + 1)) units(a).damage = 0'INT(RND * 1000) units(a).owner = a units(a).type = INT(RND * 4) + 1 units(a).order = 0'((a + 1) MOD 2) * 3 45 x2 = INT(RND * 80) + 1 y2 = INT(RND * 45) + 1 IF map.Landmap(y2, x2) = 1 THEN GOTO 45 units(a).spcx = (x2) + (256 * (y2)) x = blds(a).loc MOD 256 y = (blds(a).loc - x) / 256 map.Landmap(y - 1, x) = 0 units(a + map.players).loc = x + (256 * (y - 1)) units(a + map.players).damage = INT(RND * 1000) units(a + map.players).owner = a units(a + map.players).type = INT(RND * 3) + 1 units(a + map.players).order = ((a) MOD 2) * 3 145 x2 = INT(RND * 80) + 1 y2 = INT(RND * 45) + 1 IF map.Landmap(y2, x2) = 1 THEN GOTO 145 units(a + map.players).spcx = (x2) + (256 * (y2)) NEXT DO 'main loop FOR a = 1 TO map.players IF map.country(a).funding > 15 THEN map.country(a).funding = map.country(a).funding - 1 NEXT a SCREEN 0, , 1, 0 PCOPY 1, 0 CLS PCOPY 2, 1 ERASE map.FBUMap FOR a = 1 TO 100 IF units(a).owner <> 0 THEN y = (units(a).loc - (units(a).loc MOD 256)) / 256 x = units(a).loc MOD 256 LOCATE y, x IF map.Landmap(y, x) = 0 THEN bc = 0 ELSEIF map.Landmap(y, x) = 3 THEN bc = 3 ELSEIF map.Landmap(y, x) = 2 THEN bc = 9 END IF IF units(a).order = 4 THEN IF units(a).damage > INT(unittypes(units(a).type).Strength / 2) THEN COLOR map.country(units(a).owner).color + 8, bc ELSE COLOR map.country(units(a).owner).color + 16, bc END IF ELSE IF units(a).damage > INT(unittypes(units(a).type).Strength / 2) THEN COLOR map.country(units(a).owner).color - 8, bc ELSE COLOR map.country(units(a).owner).color, bc END IF END IF IF units(a).damage > INT(unittypes(units(a).type).Strength) THEN units(a).owner = 0: PRINT " " ELSE PRINT unittypes(units(a).type).symbol map.FBUMap(y, x) = a + 1000 ELSE : END IF NEXT a FOR a = 1 TO 100 IF blds(a).owner <> 0 THEN y = (blds(a).loc - (blds(a).loc MOD 256)) / 256 x = blds(a).loc MOD 256 LOCATE y, x IF map.Landmap(y, x) = 0 THEN bc = 0 ELSEIF map.Landmap(y, x) = 3 THEN bc = 3 ELSEIF map.Landmap(y, x) = 2 THEN bc = 9 END IF IF blds(a).repairing <> 0 THEN IF blds(a).damage > INT(bldtypes(blds(a).btype).Strength / 2) THEN COLOR map.country(blds(a).owner).color + 8, bc ELSE COLOR map.country(blds(a).owner).color + 16, bc END IF ELSE IF blds(a).damage > INT(bldtypes(blds(a).btype).Strength / 2) THEN COLOR map.country(blds(a).owner).color - 8, bc ELSE COLOR map.country(blds(a).owner).color, bc END IF END IF IF blds(a).damage > INT(bldtypes(blds(a).btype).Strength) THEN blds(a).owner = 0: PRINT " " ELSE PRINT bldtypes(blds(a).btype).symbol map.FBUMap(y, x) = a ' >Ä×- (plane) ELSE : END IF ' NEXT a ' LOCATE 50, 5 FOR a = 1 TO map.players map.country(a).money = map.country(a).money + map.country(a).funding COLOR map.country(a).color, 0: PRINT "$" + STR$(map.country(a).money) + " "; NEXT LOCATE 49, 5 FOR a = 1 TO map.players COLOR map.country(a).color, 0: PRINT "$" + STR$(map.country(a).funding) + " "; NEXT DO: LOOP UNTIL TIMER >= ti1! + .05 ti1! = TIMER FOR a = 1 TO 100 'unit orders IF units(a).owner = 0 THEN GOTO 679 IF units(a).order = 5 THEN 'Find Path to 'Units(n).SpcX' position t1! = INT(TIMER) fb = 0 20 d = 0 DO h = 0 b = fb - 5 d = d + 1 'd a 10 IF TIMER >= t1! + .25 THEN units(a).order = 0: GOTO 65 h = h + 1: IF (d >= 255) OR (h = 25) THEN fb = fb + 5: GOTO 20 IF h <= 1 THEN fb = fb - 2: IF fb <= 0 THEN fb = 0 b = b + 5 sx = units(a).spcx MOD 256 sy = (units(a).spcx - sx) / 256 IF d = 1 THEN x = (units(a).loc) MOD 256 ELSE x = units(a).Path(d - 1) MOD 256 IF d = 1 THEN y = (units(a).loc - x) / 256 ELSE y = (units(a).Path(d - 1) - x) / 256 IF x > sx AND y > sy THEN ac1 = 16: ac2 = 8: ac3 = 8: ac4 = 1: ac5 = 2: ac6 = 2: ac7 = 4: ac8 = 4 IF x = sx AND y > sy THEN ac1 = 8: ac2 = 16: ac3 = 4: ac4 = 2: ac5 = 4: ac6 = 1: ac7 = 8: ac8 = 2 IF x > sx AND y = sy THEN ac1 = 8: ac2 = 4: ac3 = 16: ac4 = 2: ac5 = 1: ac6 = 4: ac7 = 2: ac8 = 8 IF x < sx AND y < sy THEN ac1 = 1: ac2 = 2: ac3 = 2: ac4 = 16: ac5 = 8: ac6 = 8: ac7 = 4: ac8 = 4 IF x < sx AND y = sy THEN ac1 = 2: ac2 = 4: ac3 = 1: ac4 = 8: ac5 = 16: ac6 = 4: ac7 = 8: ac8 = 2 IF x = sx AND y < sy THEN ac1 = 2: ac2 = 1: ac3 = 4: ac4 = 8: ac5 = 4: ac6 = 16: ac7 = 2: ac8 = 8 IF x < sx AND y > sy THEN ac1 = 4: ac2 = 8: ac3 = 2: ac4 = 4: ac5 = 8: ac6 = 2: ac7 = 16: ac8 = 1 IF x > sx AND y < sy THEN ac1 = 4: ac2 = 2: ac3 = 8: ac4 = 4: ac5 = 2: ac6 = 8: ac7 = 1: ac8 = 16 IF (y > 48) OR (y < 2) OR (x > 79) OR (x < 2) THEN GOTO 10 ac1 = ac1 + (25 - map.Landmap(y - 1, x - 1) * 3) ac2 = ac2 + (25 - map.Landmap(y - 1, x) * 3) ac3 = ac3 + (25 - map.Landmap(y, x - 1) * 3) ac4 = ac4 + (25 - map.Landmap(y + 1, x + 1) * 3) ac5 = ac5 + (25 - map.Landmap(y, x + 1) * 3) ac6 = ac6 + (25 - map.Landmap(y + 1, x) * 3) ac7 = ac7 + (25 - map.Landmap(y - 1, x + 1) * 3) ac8 = ac8 + (25 - map.Landmap(y + 1, x - 1) * 3) ac1 = ac1 + INT(RND * (b + (ac1 / 3))) ac2 = ac2 + INT(RND * (b + (ac2 \ 3))) ac3 = ac3 + INT(RND * (b + (ac3 / 3))) ac4 = ac4 + INT(RND * (b + (ac4 \ 3))) ac5 = ac5 + INT(RND * (b + (ac5 / 3))) ac6 = ac6 + INT(RND * (b + (ac6 \ 3))) ac7 = ac7 + INT(RND * (b + (ac7 / 3))) ac8 = ac8 + INT(RND * (b + (ac8 \ 3))) IF (ac1 > ac2) AND (ac1 > ac3) AND (ac1 > ac4) AND (ac1 > ac5) AND (ac1 > ac6) AND (ac1 > ac7) AND (ac1 > ac8) THEN IF (map.FBUMap(y - 1, x - 1) = 0) AND (map.Landmap(y - 1, x - 1) <> 1) THEN units(a).Path(d) = (x - 1) + ((y - 1) * 256) ELSE GOTO 10 ELSEIF (ac2 > ac1) AND (ac2 > ac3) AND (ac2 > ac4) AND (ac2 > ac5) AND (ac2 > ac6) AND (ac2 > ac7) AND (ac2 > ac8) THEN IF (map.FBUMap(y - 1, x) = 0) AND (map.Landmap(y - 1, x) <> 1) THEN units(a).Path(d) = (x) + ((y - 1) * 256) ELSE GOTO 10 ELSEIF (ac3 > ac2) AND (ac3 > ac1) AND (ac3 > ac4) AND (ac3 > ac5) AND (ac3 > ac6) AND (ac3 > ac7) AND (ac3 > ac8) THEN IF (map.FBUMap(y, x - 1) = 0) AND (map.Landmap(y, x - 1) <> 1) THEN units(a).Path(d) = (x - 1) + ((y) * 256) ELSE GOTO 10 ELSEIF (ac4 > ac2) AND (ac4 > ac3) AND (ac4 > ac1) AND (ac4 > ac5) AND (ac4 > ac6) AND (ac4 > ac7) AND (ac4 > ac8) THEN IF (map.FBUMap(y + 1, x + 1) = 0) AND (map.Landmap(y + 1, x + 1) <> 1) THEN units(a).Path(d) = (x + 1) + ((y + 1) * 256) ELSE GOTO 10 ELSEIF (ac5 > ac2) AND (ac5 > ac3) AND (ac5 > ac4) AND (ac5 > ac1) AND (ac5 > ac6) AND (ac5 > ac7) AND (ac5 > ac8) THEN IF (map.FBUMap(y, x + 1) = 0) AND (map.Landmap(y, x + 1) <> 1) THEN units(a).Path(d) = (x + 1) + ((y) * 256) ELSE GOTO 10 ELSEIF (ac6 > ac2) AND (ac6 > ac3) AND (ac6 > ac4) AND (ac6 > ac5) AND (ac6 > ac1) AND (ac6 > ac7) AND (ac6 > ac8) THEN IF (map.FBUMap(y + 1, x) = 0) AND (map.Landmap(y + 1, x) <> 1) THEN units(a).Path(d) = (x) + ((y + 1) * 256) ELSE GOTO 10 ELSEIF (ac7 > ac2) AND (ac7 > ac3) AND (ac7 > ac4) AND (ac7 > ac5) AND (ac7 > ac6) AND (ac7 > ac1) AND (ac7 > ac8) THEN IF (map.FBUMap(y - 1, x + 1) = 0) AND (map.Landmap(y - 1, x + 1) <> 1) THEN units(a).Path(d) = (x + 1) + ((y - 1) * 256) ELSE GOTO 10 ELSEIF (ac8 > ac2) AND (ac8 > ac3) AND (ac8 > ac4) AND (ac8 > ac5) AND (ac8 > ac6) AND (ac8 > ac7) AND (ac8 > ac1) THEN IF (map.FBUMap(y + 1, x - 1) = 0) AND (map.Landmap(y + 1, x - 1) <> 1) THEN units(a).Path(d) = (x - 1) + ((y + 1) * 256) ELSE GOTO 10 ELSE GOTO 10 END IF IF (units(a).Path(d) MOD 256) = sx AND ((units(a).Path(d) - (units(a).Path(d) MOD 256)) / 256) = sy THEN units(a).order = 3: EXIT DO LOOP units(a).PathNum = d units(a).PathPos = 1 units(a).order = 1 65 ELSEIF units(a).order = 1 THEN 'Follow path units(a).atpos = units(a).atpos + 1 IF units(a).atpos >= (map.Landmap(y, x) + (6 - unittypes(units(a).type).Speed)) THEN units(a).loc = units(a).Path(units(a).PathPos) units(a).PathPos = units(a).PathPos + 1 IF units(a).PathPos > units(a).PathNum THEN units(a).order = units(a).nextorder: units(a).atpos = 0 END IF ELSEIF units(a).order = 0 THEN 451 x2 = INT(RND * 60) + 10 y2 = INT(RND * 35) + 10 IF map.Landmap(y2, x2) = 1 THEN GOTO 451 units(a).spcx = (x2) + (256 * (y2)) IF INT(RND * (unittypes(units(a).type).shotrate * 5)) <> 0 THEN units(a).order = 3 ELSE units(a).order = 5 ELSEIF units(a).order = 3 THEN 'guard IF units(a).hasshotat = 0 THEN units(a).order = 0 units(a).hasshotat = 0 IF units(a).shotby <> 0 THEN units(a).order = 5: units(a).spcx = units(a).shotfrompos - 1: units(a).nextorder = 3: units(a).shotby = 0 x2 = units(a).loc MOD 256 y2 = (units(a).loc - x2) / 256 IF units(a).atpos < unittypes(units(a).type).shotrate THEN 4571 FOR ty = y2 - unittypes(units(a).type).ShotRange TO y2 + unittypes(units(a).type).ShotRange FOR tx = x2 - unittypes(units(a).type).ShotRange TO x2 + unittypes(units(a).type).ShotRange IF map.FBUMap(ty, tx) <> 0 THEN IF map.FBUMap(ty, tx) < 1000 THEN IF blds(map.FBUMap(ty, tx)).owner <> units(a).owner THEN IF units(a).atpos >= unittypes(units(a).type).shotrate THEN units(a).atpos = 0 dx = unittypes(units(a).type).AP * (RND * 1) + .5 dx = dx + (unittypes(units(a).type).FirePower * (bldtypes(blds(map.FBUMap(ty, tx)).btype).Armor / 10)) blds(map.FBUMap(ty, tx)).damage = blds(map.FBUMap(ty, tx)).damage + dx blds(map.FBUMap(ty, tx)).shotby = units(a).type blds(map.FBUMap(ty, tx)).shotfrompos = units(a).loc units(a).hasshotat = blds(map.FBUMap(ty, tx)).loc: map.country(units(a).owner).money = map.country(units(a).owner).money + 500 y2 = (units(a).loc - (units(a).loc MOD 256)) / 256 x2 = units(a).loc MOD 256 COLOR 14, 0 LOCATE y2, x2: PRINT "ù" 'SOUND 50, .1 y2 = (blds(map.FBUMap(ty, tx) - 1000).loc - (blds(map.FBUMap(ty, tx) - 1000).loc MOD 256)) / 256 x2 = blds(map.FBUMap(ty, tx) - 1000).loc MOD 256 COLOR 14, 0 LOCATE y2, x2: PRINT "" 'SOUND 200, .3 GOTO 890 ELSE 4571 units(a).atpos = units(a).atpos + 1 units(a).hasshotat = blds(map.FBUMap(ty, tx)).loc GOTO 890 END IF END IF ELSE IF units(map.FBUMap(ty, tx) - 1000).owner <> units(a).owner THEN IF units(a).atpos >= unittypes(units(a).type).shotrate THEN units(a).atpos = 0 dx = unittypes(units(a).type).AP * (RND * 1) + .5 dx = dx + (unittypes(units(a).type).FirePower * (unittypes(units(map.FBUMap(ty, tx) - 1000).type).Armor / 10)) units(map.FBUMap(ty, tx) - 1000).damage = units(map.FBUMap(ty, tx) - 1000).damage + dx units(map.FBUMap(ty, tx) - 1000).shotby = units(a).type + 1000 units(map.FBUMap(ty, tx) - 1000).shotfrompos = units(a).loc units(a).hasshotat = units(map.FBUMap(ty, tx) - 1000).loc: map.country(units(a).owner).money = map.country(units(a).owner).money + 500 y2 = (units(a).loc - (units(a).loc MOD 256)) / 256 x2 = units(a).loc MOD 256 COLOR 14, 0 LOCATE y2, x2: PRINT "ù" 'SOUND 80, .1 y2 = (units(map.FBUMap(ty, tx) - 1000).loc - (units(map.FBUMap(ty, tx) - 1000).loc MOD 256)) / 256 x2 = units(map.FBUMap(ty, tx) - 1000).loc MOD 256 COLOR 14, 0 LOCATE y2, x2: PRINT "" 'SOUND 300, .2 GOTO 890 ELSE units(a).atpos = units(a).atpos + 1 units(a).hasshotat = units(map.FBUMap(ty, tx) - 1000).loc GOTO 890 END IF END IF END IF EXIT FOR END IF NEXT NEXT 890 ELSEIF units(a).order = 4 THEN 'fix IF map.country(units(a).owner).money >= 10 THEN units(a).damage = units(a).damage - 10 map.country(units(a).owner).money = map.country(units(a).owner).money - 10 IF units(a).damage <= 0 THEN units(a).order = 0: units(a).damage = 0: units(a).nextorder = 0 ELSE END IF END IF 679 NEXT a FOR a = 1 TO 100 'building orders IF blds(a).owner = 0 THEN GOTO 680 IF blds(a).repairing <> 0 THEN 'fix IF map.country(blds(a).owner).money >= 1000 THEN blds(a).damage = blds(a).damage - 100 map.country(blds(a).owner).money = map.country(blds(a).owner).money - 1000 IF blds(a).damage <= 0 THEN blds(a).repairing = 0: blds(a).damage = 0: blds(a).order = 3 ELSE END IF END IF IF blds(a).order = 0 THEN blds(a).order = 3 GOTO 169 ELSEIF blds(a).build <> 0 THEN IF blds(a).timeleft > 0 THEN IF map.country(blds(a).owner).money >= INT(unittypes(blds(a).build).price / unittypes(blds(a).build).buildtime) THEN blds(a).timeleft = blds(a).timeleft - 1 map.country(blds(a).owner).money = map.country(blds(a).owner).money - INT(unittypes(blds(a).build).price / unittypes(blds(a).build).buildtime) END IF ELSE FOR ab = 1 TO 100 IF units(ab).owner = 0 THEN 63 NEXT ab 63 units(ab).loc = blds(a).loc + 256 units(ab).damage = 0 units(ab).owner = blds(a).owner units(ab).type = blds(a).build units(ab).order = 0 blds(a).build = 0 blds(a).order = 3 END IF ELSEIF blds(a).order = 3 THEN 'guard 169 x2 = blds(a).loc MOD 256 y2 = (blds(a).loc - x2) / 256 IF units(a).atpos < unittypes(units(a).type).shotrate THEN 45712 FOR ty = y2 - bldtypes(blds(a).btype).ShotRange TO y2 + bldtypes(blds(a).btype).ShotRange FOR tx = x2 - bldtypes(blds(a).btype).ShotRange TO x2 + bldtypes(blds(a).btype).ShotRange IF map.FBUMap(ty, tx) <> 0 THEN IF map.FBUMap(ty, tx) < 1000 THEN IF blds(map.FBUMap(ty, tx)).owner <> blds(a).owner THEN IF blds(a).atpos >= bldtypes(blds(a).btype).shotrate THEN blds(a).atpos = 0 dx = bldtypes(blds(a).btype).AP * (RND * 1) + .5 dx = dx + (bldtypes(blds(a).btype).FirePower * (bldtypes(blds(map.FBUMap(ty, tx)).btype).Armor / 10)) blds(map.FBUMap(ty, tx)).damage = blds(map.FBUMap(ty, tx)).damage + dx: map.country(units(a).owner).money = map.country(blds(a).owner).money + 500 y2 = (blds(a).loc - (blds(a).loc MOD 256)) / 256 x2 = blds(a).loc MOD 256 COLOR 14, 0 LOCATE y2, x2: PRINT "ù" y2 = (blds(map.FBUMap(ty, tx) - 1000).loc - (blds(map.FBUMap(ty, tx) - 1000).loc MOD 256)) / 256 x2 = blds(map.FBUMap(ty, tx) - 1000).loc MOD 256 COLOR 14, 0 LOCATE y2, x2: PRINT "" 'SOUND 40, .1 'SOUND 400, .2 GOTO 450 ELSE 45712 blds(a).atpos = blds(a).atpos + 3 GOTO 450 END IF END IF ELSE IF units(map.FBUMap(ty, tx) - 1000).owner <> blds(a).owner THEN IF blds(a).atpos >= bldtypes(blds(a).btype).shotrate THEN blds(a).atpos = 0 dx = bldtypes(blds(a).btype).AP * (RND * 1) + .5 dx = dx + (bldtypes(blds(a).btype).FirePower * (unittypes(units(map.FBUMap(ty, tx) - 1000).type).Armor / 10)) units(map.FBUMap(ty, tx) - 1000).damage = units(map.FBUMap(ty, tx) - 1000).damage + dx units(map.FBUMap(ty, tx) - 1000).shotby = blds(a).btype units(map.FBUMap(ty, tx) - 1000).shotfrompos = blds(a).loc: map.country(units(a).owner).money = map.country(blds(a).owner).money + 500 y2 = (blds(a).loc - (blds(a).loc MOD 256)) / 256 x2 = blds(a).loc MOD 256 COLOR 14, 0 LOCATE y2, x2: PRINT "ù" 'SOUND 50, .1 y2 = (units(map.FBUMap(ty, tx) - 1000).loc - (units(map.FBUMap(ty, tx) - 1000).loc MOD 256)) / 256 x2 = units(map.FBUMap(ty, tx) - 1000).loc MOD 256 COLOR 14, 0 LOCATE y2, x2: PRINT "*" 'SOUND 600, .4 GOTO 450 ELSE blds(a).atpos = blds(a).atpos + 3 GOTO 450 END IF END IF END IF EXIT FOR END IF NEXT NEXT 450 END IF 680 NEXT a '<<<<<<<<<[AI Section]>>>>>>>>> ((((((((((((((((((((((((((({{{{{{{{CCCCC[[[[](){}C) dr = (dr + 1) MOD 5 IF dr <> 2 THEN 678 FOR a = 1 TO map.players IF map.country(a).controller <= 16 THEN FOR ab = 1 TO 100 'BUILDING REPAIRS IF blds(ab).owner = a THEN IF blds(ab).damage >= 1 THEN IF (blds(ab).repairing <> 4) THEN blds(ab).repairing = 4 blds(ab).order = 3 END IF END IF END IF NEXT ab FOR ab = 1 TO 100 'UNIT REPAIRS IF units(ab).owner = a THEN IF units(ab).damage >= (unittypes(units(ab).type).Strength * (AI(map.country(a).controller).AIFixy / 100)) THEN IF (units(ab).nextorder <> 4) THEN units(ab).order = 5 units(ab).nextorder = 4 FOR t = 1 TO 100 IF blds(t).btype = 1 THEN IF blds(t).owner = a THEN cx = blds(t).loc + 1 units(ab).spcx = cx EXIT FOR END IF END IF NEXT t END IF END IF END IF NEXT ab FOR ab = 1 TO 100 'BUILD UNITS IF blds(ab).owner = a THEN IF (blds(ab).build = 0) AND (blds(ab).btype = 1) THEN IF map.country(blds(ab).owner).money >= (12000 * (AI(map.country(a).controller).AIsavey / 100)) THEN blds(ab).build = INT(RND * 4) + 1 blds(ab).timeleft = unittypes(blds(ab).build).buildtime END IF END IF END IF NEXT ab FOR ab = 1 TO 100 'FIND TARGETS + ATTACK IF units(ab).owner = a THEN IF (units(ab).shotby > 0) AND (units(ab).shotby < 1000) THEN AI(map.country(a).controller).target = units(ab).shotfrompos FOR abc = 1 TO 100 IF (units(abc).owner = a) AND (INT(RND * 2) = 0) AND (units(abc).order <> 1) AND (units(abc).order <> 5) THEN units(abc).order = 5 units(abc).spcx = AI(map.country(a).controller).target + ((INT(RND * 8) - 4) + ((INT(RND * 8) - 4) * 256)) units(abc).nextorder = 3 END IF NEXT abc units(ab).shotby = 0 units(ab).shotfrompos = 0 END IF END IF NEXT ab FOR ab = 1 TO 100 'DEFEND THE BASE!!! IF blds(ab).owner = a THEN IF (blds(ab).shotby <> 0) THEN FOR abc = 1 TO 100 IF (units(abc).owner = a) AND (units(abc).order <> 1) AND (units(abc).order <> 5) THEN IF units(abc).nextorder <> 3 THEN units(abc).order = 5 units(abc).spcx = blds(ab).shotfrompos + ((INT(RND * 8) - 4) + ((INT(RND * 8) - 4) * 256)) units(abc).nextorder = 3 blds(ab).shotby = 0 blds(ab).shotfrompos = 0 blds(ab).order = 3 END IF NEXT abc END IF END IF NEXT ab IF map.country(a).money >= (40000 * (AI(map.country(a).controller).AIsavey / 100)) THEN map.country(a).money = map.country(a).money - bldtypes(2).price FOR abc = 1 TO 100 IF blds(abc).owner = 0 THEN GOTO 34 NEXT abc 34 FOR ab = 99 TO 1 STEP -1 IF (blds(a).btype = 1) AND (blds(ab).owner = a) THEN GOTO 35 NEXT ab 35 blds(abc).owner = a blds(abc).damage = 0 blds(abc).btype = INT(RND * 2) + 1 blds(abc).loc = blds(ab).loc + (((INT(RND * 8) - 4) MOD 40) + (((INT(RND * 8) - 4) MOD 79) * 256)) blds(abc).order = 3 blds(abc).flags = 10 END IF END IF NEXT a 678 FOR a = 1 TO map.players IF map.country(a).controller >= 100 THEN a$ = INKEY$ a$ = UCASE$(a$) FOR u = 1 TO 100 IF (blds(u).build = 0) AND (blds(u).owner = a) THEN 6789 NEXT u 6789 IF u >= 100 THEN EXIT FOR SELECT CASE a$ CASE "1": blds(u).build = 1 blds(u).timeleft = unittypes(blds(u).build).buildtime CASE "2": blds(u).build = 2 blds(u).timeleft = unittypes(blds(u).build).buildtime CASE "3": blds(u).build = 3 blds(u).timeleft = unittypes(blds(u).build).buildtime CASE "4": blds(u).build = 4 blds(u).timeleft = unittypes(blds(u).build).buildtime CASE "A", "B", "C": map.country(a).money = map.country(a).money - bldtypes(2).price FOR abc = 1 TO 100 IF blds(abc).owner = 0 THEN GOTO 134 NEXT abc 134 FOR ab = 99 TO 1 STEP -1 IF blds(ab).owner = a THEN GOTO 135 NEXT ab 135 blds(abc).owner = a blds(abc).damage = 0 IF a$ = "A" THEN blds(abc).btype = 1 IF a$ = "B" THEN blds(abc).btype = 2 IF a$ = "C" THEN blds(abc).btype = 3 blds(abc).loc = blds(ab).loc + ((INT(RND * 8) - 4 MOD 20) + ((INT(RND * 8) - 4 MOD 78) * 256)) blds(abc).order = 3 blds(abc).flags = 10 END SELECT END IF NEXT a LOOP END SUB SUB initunits () unittypes(4).Strength = 3000 unittypes(4).Speed = 5 unittypes(4).FirePower = 2500 unittypes(4).ShotRange = 14 unittypes(4).price = 1000 unittypes(4).AP = 1300 ' unittypes(4).Armor = 95 ' 5% of ap damage avoided unittypes(4).symbol = "ñ" 'scout unittypes(4).shotrate = 20'cycles unittypes(4).buildtime = 400 unittypes(1).Strength = 2000 unittypes(1).Speed = 6 unittypes(1).FirePower = 50 unittypes(1).ShotRange = 4 unittypes(1).price = 1000 unittypes(1).AP = 5 'armor piercing damage unittypes(1).Armor = 9 ' 10% of ap damage avoided unittypes(1).symbol = "" 'scout unittypes(1).shotrate = 1'cycles unittypes(1).buildtime = 100 unittypes(2).Strength = 10000 unittypes(2).Speed = 2 unittypes(2).FirePower = 250 unittypes(2).ShotRange = 6 unittypes(2).price = 3000 unittypes(2).AP = 180 unittypes(2).Armor = 3 unittypes(2).symbol = CHR$(2) 'tank unittypes(2).shotrate = 12'cycles unittypes(2).buildtime = 500 unittypes(3).Strength = 6000 unittypes(3).Speed = 4 unittypes(3).FirePower = 150 unittypes(3).ShotRange = 6 unittypes(3).price = 2000 unittypes(3).AP = 120 unittypes(3).Armor = 4 unittypes(3).symbol = CHR$(1) 'small tank unittypes(3).shotrate = 9'cycles unittypes(3).buildtime = 300 bldtypes(1).Strength = 10000 bldtypes(1).ShotRange = 3 bldtypes(1).FirePower = 200 bldtypes(1).symbol = "" 'base bldtypes(1).flags = 25 bldtypes(1).price = 20000 bldtypes(1).AP = 100 bldtypes(1).Armor = 7 bldtypes(1).shotrate = 10 bldtypes(1).buildtime = 2500 bldtypes(2).Strength = 5000 bldtypes(2).ShotRange = 8 bldtypes(2).FirePower = 1000 bldtypes(2).symbol = "" 'Turret bldtypes(2).price = 10000 bldtypes(2).AP = 500 bldtypes(2).Armor = 9 bldtypes(2).shotrate = 30 bldtypes(2).buildtime = 1200 bldtypes(3).Strength = 100000 bldtypes(3).ShotRange = 0 bldtypes(3).FirePower = 0 bldtypes(3).symbol = "Î" 'wallÅ bldtypes(3).flags = 100 ' 1 = builds units, 2 = blocks fire, 4 = passable, 8 = repairs units 16 = builds buildings 32 = fires bldtypes(3).price = 100 bldtypes(3).AP = 0 bldtypes(3).Armor = 7 bldtypes(3).shotrate = 0 bldtypes(3).buildtime = 600 map.Name = "The Map" map.players = 5 map.country(1).controller = 101 map.country(1).color = 15 map.country(1).CType = 1 map.country(1).funding = 15 map.country(2).controller = 2 map.country(2).color = 10 map.country(2).CType = 1 map.country(2).funding = 15 map.country(3).controller = 3 map.country(3).color = 12 map.country(3).CType = 1 map.country(3).funding = 15 map.country(4).controller = 4 map.country(4).color = 13 map.country(4).CType = 1 map.country(4).funding = 15 map.country(5).controller = 5 map.country(5).color = 11 map.country(5).CType = 1 map.country(5).funding = 15 map.country(6).controller = 6 map.country(6).color = 14 map.country(6).CType = 1 map.country(6).funding = 15 AI(1).AIPTER = 10'ai $ to effect rate 1 to 100 AI(1).AICautious = 10 AI(1).AIBuildey = 10 AI(1).AIFixy = 10 AI(1).AIBuy = 10 AI(1).AIType = 10 AI(1).AIDTOR = 10 AI(1).AIDefType = 10 AI(1).AIOffType = 10 AI(1).AISneaky = 10 AI(1).AIAngry = 10 AI(1).AIFriendly = 10 AI(1).AIAggressive = 10 AI(1).AIsavey = 10 AI(2).AIPTER = 50'ai $ to effect rate 1 to 100 AI(2).AIFixy = 50 AI(2).AICautious = 50 AI(2).AIBuildey = 50 AI(2).AIBuy = 50 AI(2).AIType = 50 AI(2).AIDTOR = 50 AI(2).AIDefType = 50 AI(2).AIOffType = 50 AI(2).AISneaky = 50 AI(2).AIAngry = 50 AI(2).AIFriendly = 50 AI(2).AIAggressive = 50 AI(2).AIsavey = 50 AI(3).AIPTER = 90'ai $ to effect rate 1 to 100 AI(3).AIFixy = 10 AI(3).AICautious = 90 AI(3).AIBuildey = 90 AI(3).AIBuy = 90 AI(3).AIType = 90 AI(3).AIDTOR = 90 AI(3).AIDefType = 90 AI(3).AIOffType = 90 AI(3).AISneaky = 90 AI(3).AIAngry = 90 AI(3).AIFriendly = 90 AI(3).AIAggressive = 90 AI(3).AIsavey = 90 AI(4).AIPTER = 10'ai $ to effect rate 1 to 100 AI(4).AICautious = 10 AI(4).AIBuildey = 10 AI(4).AIFixy = 10 AI(4).AIBuy = 10 AI(4).AIType = 10 AI(4).AIDTOR = 10 AI(4).AIDefType = 10 AI(4).AIOffType = 10 AI(4).AISneaky = 10 AI(4).AIAngry = 10 AI(4).AIFriendly = 10 AI(4).AIAggressive = 10 AI(4).AIsavey = 10 AI(5).AIPTER = 50'ai $ to effect rate 1 to 100 AI(5).AIFixy = 50 AI(5).AICautious = 50 AI(5).AIBuildey = 50 AI(5).AIBuy = 50 AI(5).AIType = 50 AI(5).AIDTOR = 50 AI(5).AIDefType = 50 AI(5).AIOffType = 50 AI(5).AISneaky = 50 AI(5).AIAngry = 50 AI(5).AIFriendly = 50 AI(5).AIAggressive = 50 AI(5).AIsavey = 50 AI(6).AIPTER = 90'ai $ to effect rate 1 to 100 AI(6).AIFixy = 10 AI(6).AICautious = 90 AI(6).AIBuildey = 90 AI(6).AIBuy = 90 AI(6).AIType = 90 AI(6).AIDTOR = 90 AI(6).AIDefType = 90 AI(6).AIOffType = 90 AI(6).AISneaky = 90 AI(6).AIAngry = 90 AI(6).AIFriendly = 90 AI(6).AIAggressive = 90 AI(6).AIsavey = 90 END SUB SUB loadm () PRINT "type a map name (no EXT), or press enter." INPUT ""; f$ IF f$ = "" THEN EXIT SUB'f$ = "map" OPEN f$ + ".map" FOR BINARY AS #1 GET #1, , map CLOSE #1 END SUB SUB mapgen () n = INT(RND * 3) + 1 FOR tt = 0 TO n x = INT(RND * 40) - 20 y = INT(RND * 20) - 10 t = INT(RND * 10) LOCATE 25 + y, 40 + x PRINT STRING$(t, ASC("Û")) NEXT 'DIM x, y, r AS INTEGER COLOR 11, 0 DO FOR x = 2 TO 79 FOR y = 2 TO 45 IF SCREEN(y, x) = ASC("Û") THEN r = INT(RND * 6) a = INT(RND * 3) - 1 z = INT(RND * 3) - 1 IF r = 0 THEN IF SCREEN(y + 1, x) = 32 THEN LOCATE y + 1, x: PRINT "Û": map.Landmap(y + 1, x) = 1 IF r = 1 THEN IF SCREEN(y - 1, x) = 32 THEN LOCATE y - 1, x: PRINT "Û": map.Landmap(y - 1, x) = 1 IF r = 2 THEN IF SCREEN(y, x + 1) = 32 THEN LOCATE y, x + 1: PRINT "Û": map.Landmap(y, x + 1) = 1 IF r = 3 THEN IF SCREEN(y, x - 1) = 32 THEN LOCATE y, x - 1: PRINT "Û": map.Landmap(y, x - 1) = 1 IF r = 4 THEN IF SCREEN(y + z, x + a) = ASC("±") THEN LOCATE y + z, x + a: PRINT " ": map.Landmap(y + z, x + a) = 3 IF r >= 5 THEN j = 0 DO j = j + 1 a = INT(RND * 3) - 1 z = INT(RND * 3) - 1 IF SCREEN(y + z, x + a) = 32 THEN LOCATE y + z, x + a: PRINT "±": map.Landmap(y + z, x + a) = 3: EXIT DO IF j = 2 THEN EXIT DO LOOP END IF ELSEIF SCREEN(y, x) = ASC("±") THEN a = INT(RND * 3) - 1 z = INT(RND * 3) - 1 t = INT(RND * 3) IF t = 0 THEN IF SCREEN(y + z, x + a) = 32 THEN LOCATE y + z, x + a: PRINT "±": map.Landmap(y + z, x + a) = 3 IF t >= 1 THEN IF SCREEN(y + z, x + a) = 32 THEN LOCATE y + z, x + a: PRINT "°": map.Landmap(y + z, x + a) = 2 END IF NEXT y, x ' SLEEP LOOP WHILE INKEY$ <> CHR$(27) PRINT "press Y to save map, or just push enter to play it." INPUT ""; i$ IF UCASE$(i$) = "Y" THEN PRINT "type map name (no EXT!)" INPUT ""; f$ OPEN f$ + ".map" FOR BINARY AS #1 PUT #1, , map CLOSE #1 END IF CLS END SUB