Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent scavenger AI from producing trikes over limits.
Make it use firetruck body. Make it use DORDER_SCOUT for attack, instead of DORDER_MOVE. Remove useless conversion to world coordinates (3.1 only)
- Loading branch information
Showing
1 changed file
with
19 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,20 @@ const maxDroids = 25; // max guys to handle. | |
var attackGroup; | ||
var lastAttack = 0; | ||
|
||
function activateProduction(fac) | ||
{ | ||
// Remind factory to produce | ||
if (structureIdle(fac)) | ||
function produceDroid(fac1) { | ||
if (fac1 && structureIdle(fac1) && groupSize(attackGroup) < maxDroids) | ||
{ | ||
buildDroid(fac, "Trike", "B4body-sml-trike01", "BaBaProp", "", DROID_WEAPON, "bTrikeMG"); | ||
} | ||
// We now have switch statements! And we can use the built-in Math library | ||
switch (Math.floor(Math.random() * 10)) | ||
{ | ||
case 0: buildDroid(fac1, "Trike", "B4body-sml-trike01", "BaBaProp", "", DROID_WEAPON, "bTrikeMG"); break; | ||
case 1: buildDroid(fac1, "Buggy", "B3body-sml-buggy01", "BaBaProp", "", DROID_WEAPON, "BuggyMG"); break; | ||
case 2: buildDroid(fac1, "Jeep", "B2JeepBody", "BaBaProp", "", DROID_WEAPON, "BJeepMG"); break; | ||
case 3: buildDroid(fac1, "Cannonbus", "BusBody", "BaBaProp", "", DROID_WEAPON, "BusCannon"); break; | ||
case 4: buildDroid(fac1, "Firebus", "FireBody", "BaBaProp", "", DROID_WEAPON, "BabaFlame"); break; | ||
default: buildDroid(fac1, "Bloke", "B1BaBaPerson01", "BaBaLegs", "", DROID_PERSON, "BaBaMG"); break; | ||
} | ||
} | ||
} | ||
|
||
// Regularly check back on our scavs | ||
|
@@ -25,7 +32,7 @@ function scavtick() | |
// one way of dealing with lists is running a function on each member of the list | ||
if (factorylist) | ||
{ | ||
factorylist.forEach(activateProduction); | ||
factorylist.forEach(produceDroid); | ||
} | ||
|
||
if ((gameTime - lastAttack) > 9000) | ||
|
@@ -75,6 +82,7 @@ function eventGameInit() | |
makeComponentAvailable("B3body-sml-buggy01", me); | ||
makeComponentAvailable("B2JeepBody", me); | ||
makeComponentAvailable("BusBody", me); | ||
makeComponentAvailable("FireBody", me); | ||
makeComponentAvailable("B1BaBaPerson01", me); | ||
makeComponentAvailable("BaBaProp", me); | ||
makeComponentAvailable("BaBaLegs", me); | ||
|
@@ -85,7 +93,7 @@ function eventGameInit() | |
makeComponentAvailable("BabaFlame", me); | ||
makeComponentAvailable("BaBaMG", me); | ||
attackGroup = newGroup(); // allocate a new group | ||
groupAddArea(attackGroup, 0, 0, (mapWidth * 128), (mapHeight * 128)); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
haoNoQ
Author
Member
|
||
groupAddArea(attackGroup, 0, 0, mapWidth, mapHeight); | ||
} | ||
|
||
function eventStartLevel() | ||
|
@@ -100,19 +108,7 @@ function eventDroidBuilt(droid, fac1) | |
groupAddDroid(attackGroup, droid); | ||
|
||
// Build another | ||
if (fac1 && structureIdle(fac1) && groupSize(attackGroup) < maxDroids) | ||
{ | ||
// We now have switch statements! And we can use the built-in Math library | ||
switch (Math.floor(Math.random() * 10)) | ||
{ | ||
case 0: buildDroid(fac1, "Trike", "B4body-sml-trike01", "BaBaProp", "", DROID_WEAPON, "bTrikeMG"); break; | ||
case 1: buildDroid(fac1, "Buggy", "B3body-sml-buggy01", "BaBaProp", "", DROID_WEAPON, "BuggyMG"); break; | ||
case 2: buildDroid(fac1, "Jeep", "B2JeepBody", "BaBaProp", "", DROID_WEAPON, "BJeepMG"); break; | ||
case 3: buildDroid(fac1, "Cannonbus", "BusBody", "BaBaProp", "", DROID_WEAPON, "BusCannon"); break; | ||
case 4: buildDroid(fac1, "Firebus", "BusBody", "BaBaProp", "", DROID_WEAPON, "BabaFlame"); break; | ||
default: buildDroid(fac1, "Bloke", "B1BaBaPerson01", "BaBaLegs", "", DROID_PERSON, "BaBaMG"); break; | ||
} | ||
} | ||
produceDroid(fac1); | ||
} | ||
|
||
// watch for structures being attacked. Send the cavalry as required. | ||
|
@@ -125,9 +121,9 @@ function eventAttacked(victim, attacker) | |
for (var i = 0; i < droidlist.length; i++) | ||
{ | ||
var droid = droidlist[i]; | ||
if (distBetweenTwoPoints(victim.x, victim.y, attacker.x, attacker.y) < (24 * 128)) | ||
if (distBetweenTwoPoints(victim.x, victim.y, attacker.x, attacker.y) < 24) | ||
{ | ||
orderDroidLoc(droid, DORDER_MOVE, attacker.x, attacker.y); | ||
orderDroidLoc(droid, DORDER_SCOUT, attacker.x, attacker.y); | ||
} | ||
} | ||
} | ||
|
I assume the world coords issue is fixed in 3.1.1? Did it occur anywhere else? (for updating docs wiki)