Make AI use event chainloading for basic structures and new trucks. This means that instead of calling

common AI functions from several places, which can lead to the CPU spending much time doing AI stuff
that frame, or setting the object to idle and wait for a repeat event to pick it up, which can lead to
long delays, it queues up another event for the next AI frame to continue processing.


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@9133 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2010-01-11 20:16:57 +00:00 committed by Git SVN Gateway
parent 58425f4144
commit 027cb31486
8 changed files with 96 additions and 176 deletions

View File

@ -221,9 +221,10 @@ trigger manageAllyHelpTr (every, 80);
trigger everySec (every, 10);
trigger manageDefendLocationTr (every, 70);
trigger startLevelTr (CALL_START_NEXT_LEVEL);
trigger launchFundamentalsTr (wait, 1);
trigger chainloadTr (wait, 1);
/* Events */
event conDroids;
event multiMsgEv;
event beaconEv;
event watchBaseThreat;
@ -277,7 +278,6 @@ function int numEnemyAAInRange(int _x, int _y, int _range);
function BASEOBJ chooseVtolTarget(bool bExclusiveTarget);
function int getVtolTargetWeight(BASEOBJ _target);
function bool vtolTargetAssigned(BASEOBJ _target);
function void buildTruck();
function int numBuildSameBuilding(STRUCTURESTAT _checkStat, int _x, int _y);
function void expandBase(DROID _truck);
function int totalVtols();
@ -382,19 +382,18 @@ event initialisedEvent(CALL_GAMEINIT)
fundamentalBeingBuilt = derrick; // to avoid ever being null
bRunning = false;
if(aiResponsibleForPlayer(me))
{
bRunning = true;
}
else
{
bRunning = false;
shutDownAI();
}
}
function void buildFundamentals()
event buildFundamentals(inactive)
{
count = 0;
while (count < numFundamental)
@ -428,18 +427,14 @@ function void buildFundamentals()
count = count + 1;
}
fundamentalBeingBuilt = derrick;
}
event launchFundamentals(inactive)
{
buildFundamentals();
setEventTrigger(launchFundamentals, inactive);
setEventTrigger(buildFundamentals, inactive);
}
event startLevel(startLevelTr)
{
buildFundamentals();
buildTruck();
setEventTrigger(buildFundamentals, chainloadTr);
setEventTrigger(conDroids, chainloadTr);
setEventTrigger(startLevel, inactive);
}
// decide what technology branch we will use
@ -1386,7 +1381,7 @@ event structBuilt(structBuiltTr)
}
else
{
buildTruck();
setEventTrigger(conDroids, chainloadTr);
}
}
/* vtol factory or vtol factory module */
@ -1414,7 +1409,7 @@ event structBuilt(structBuiltTr)
// Check if available trucks need to build more absolute necessities right away. We need a trigger here because
// droids involved in building have not yet come out of their build orders.
setEventTrigger(launchFundamentals, launchFundamentalsTr);
setEventTrigger(buildFundamentals, chainloadTr);
//see if we have just rebuilt a destroyed structure
_count = 0;
@ -1480,11 +1475,6 @@ event droidDestroyed(droidDestroyedTr)
/////////////////////////////////////////////////////////////////////
// build more con droids.
event conDroids(conDroidsTr)
{
buildTruck();
}
function void buildTruck()
{
local int _maxTrucks;
local STRUCTURE _factory;
@ -1545,9 +1535,9 @@ function void buildTruck()
_factory = enumStruct();
}
setEventTrigger(conDroids, conDroidsTr);
}
//Build a droid
function bool buildUnit(TEMPLATE _tankTemplate, STRUCTURE _factory, STRUCTURESTAT _factoryType, bool _bIdleOnly)
{
@ -4136,8 +4126,8 @@ event consoleEv(consoleTr)
if(not bRunning) //make sure current machine is responsible for this AI and it's not already active
{
console(getPlayerName(me) & " is active");
reassignAI();
setEventTrigger(startLevel, chainloadTr);
}
}
}

View File

@ -221,9 +221,10 @@ trigger manageAllyHelpTr (every, 80);
trigger everySec (every, 10);
trigger manageDefendLocationTr (every, 70);
trigger startLevelTr (CALL_START_NEXT_LEVEL);
trigger launchFundamentalsTr (wait, 1);
trigger chainloadTr (wait, 1);
/* Events */
event conDroids;
event multiMsgEv;
event beaconEv;
event watchBaseThreat;
@ -277,7 +278,6 @@ function int numEnemyAAInRange(int _x, int _y, int _range);
function BASEOBJ chooseVtolTarget(bool bExclusiveTarget);
function int getVtolTargetWeight(BASEOBJ _target);
function bool vtolTargetAssigned(BASEOBJ _target);
function void buildTruck();
function int numBuildSameBuilding(STRUCTURESTAT _checkStat, int _x, int _y);
function void expandBase(DROID _truck);
function int totalVtols();
@ -382,19 +382,18 @@ event initialisedEvent(CALL_GAMEINIT)
fundamentalBeingBuilt = derrick; // to avoid ever being null
bRunning = false;
if(aiResponsibleForPlayer(me))
{
bRunning = true;
}
else
{
bRunning = false;
shutDownAI();
}
}
function void buildFundamentals()
event buildFundamentals(inactive)
{
count = 0;
while (count < numFundamental)
@ -428,18 +427,14 @@ function void buildFundamentals()
count = count + 1;
}
fundamentalBeingBuilt = derrick;
}
event launchFundamentals(inactive)
{
buildFundamentals();
setEventTrigger(launchFundamentals, inactive);
setEventTrigger(buildFundamentals, inactive);
}
event startLevel(startLevelTr)
{
buildFundamentals();
buildTruck();
setEventTrigger(buildFundamentals, chainloadTr);
setEventTrigger(conDroids, chainloadTr);
setEventTrigger(startLevel, inactive);
}
// decide what technology branch we will use
@ -1386,7 +1381,7 @@ event structBuilt(structBuiltTr)
}
else
{
buildTruck();
setEventTrigger(conDroids, chainloadTr);
}
}
/* vtol factory or vtol factory module */
@ -1414,7 +1409,7 @@ event structBuilt(structBuiltTr)
// Check if available trucks need to build more absolute necessities right away. We need a trigger here because
// droids involved in building have not yet come out of their build orders.
setEventTrigger(launchFundamentals, launchFundamentalsTr);
setEventTrigger(buildFundamentals, chainloadTr);
//see if we have just rebuilt a destroyed structure
_count = 0;
@ -1480,11 +1475,6 @@ event droidDestroyed(droidDestroyedTr)
/////////////////////////////////////////////////////////////////////
// build more con droids.
event conDroids(conDroidsTr)
{
buildTruck();
}
function void buildTruck()
{
local int _maxTrucks;
local STRUCTURE _factory;
@ -1545,9 +1535,9 @@ function void buildTruck()
_factory = enumStruct();
}
setEventTrigger(conDroids, conDroidsTr);
}
//Build a droid
function bool buildUnit(TEMPLATE _tankTemplate, STRUCTURE _factory, STRUCTURESTAT _factoryType, bool _bIdleOnly)
{
@ -4136,8 +4126,8 @@ event consoleEv(consoleTr)
if(not bRunning) //make sure current machine is responsible for this AI and it's not already active
{
console(getPlayerName(me) & " is active");
reassignAI();
setEventTrigger(startLevel, chainloadTr);
}
}
}

View File

@ -221,9 +221,10 @@ trigger manageAllyHelpTr (every, 80);
trigger everySec (every, 10);
trigger manageDefendLocationTr (every, 70);
trigger startLevelTr (CALL_START_NEXT_LEVEL);
trigger launchFundamentalsTr (wait, 1);
trigger chainloadTr (wait, 1);
/* Events */
event conDroids;
event multiMsgEv;
event beaconEv;
event watchBaseThreat;
@ -277,7 +278,6 @@ function int numEnemyAAInRange(int _x, int _y, int _range);
function BASEOBJ chooseVtolTarget(bool bExclusiveTarget);
function int getVtolTargetWeight(BASEOBJ _target);
function bool vtolTargetAssigned(BASEOBJ _target);
function void buildTruck();
function int numBuildSameBuilding(STRUCTURESTAT _checkStat, int _x, int _y);
function void expandBase(DROID _truck);
function int totalVtols();
@ -382,19 +382,18 @@ event initialisedEvent(CALL_GAMEINIT)
fundamentalBeingBuilt = derrick; // to avoid ever being null
bRunning = false;
if(aiResponsibleForPlayer(me))
{
bRunning = true;
}
else
{
bRunning = false;
shutDownAI();
}
}
function void buildFundamentals()
event buildFundamentals(inactive)
{
count = 0;
while (count < numFundamental)
@ -428,18 +427,14 @@ function void buildFundamentals()
count = count + 1;
}
fundamentalBeingBuilt = derrick;
}
event launchFundamentals(inactive)
{
buildFundamentals();
setEventTrigger(launchFundamentals, inactive);
setEventTrigger(buildFundamentals, inactive);
}
event startLevel(startLevelTr)
{
buildFundamentals();
buildTruck();
setEventTrigger(buildFundamentals, chainloadTr);
setEventTrigger(conDroids, chainloadTr);
setEventTrigger(startLevel, inactive);
}
// decide what technology branch we will use
@ -1386,7 +1381,7 @@ event structBuilt(structBuiltTr)
}
else
{
buildTruck();
setEventTrigger(conDroids, chainloadTr);
}
}
/* vtol factory or vtol factory module */
@ -1414,7 +1409,7 @@ event structBuilt(structBuiltTr)
// Check if available trucks need to build more absolute necessities right away. We need a trigger here because
// droids involved in building have not yet come out of their build orders.
setEventTrigger(launchFundamentals, launchFundamentalsTr);
setEventTrigger(buildFundamentals, chainloadTr);
//see if we have just rebuilt a destroyed structure
_count = 0;
@ -1480,11 +1475,6 @@ event droidDestroyed(droidDestroyedTr)
/////////////////////////////////////////////////////////////////////
// build more con droids.
event conDroids(conDroidsTr)
{
buildTruck();
}
function void buildTruck()
{
local int _maxTrucks;
local STRUCTURE _factory;
@ -1545,9 +1535,9 @@ function void buildTruck()
_factory = enumStruct();
}
setEventTrigger(conDroids, conDroidsTr);
}
//Build a droid
function bool buildUnit(TEMPLATE _tankTemplate, STRUCTURE _factory, STRUCTURESTAT _factoryType, bool _bIdleOnly)
{
@ -4136,8 +4126,8 @@ event consoleEv(consoleTr)
if(not bRunning) //make sure current machine is responsible for this AI and it's not already active
{
console(getPlayerName(me) & " is active");
reassignAI();
setEventTrigger(startLevel, chainloadTr);
}
}
}

View File

@ -221,9 +221,10 @@ trigger manageAllyHelpTr (every, 80);
trigger everySec (every, 10);
trigger manageDefendLocationTr (every, 70);
trigger startLevelTr (CALL_START_NEXT_LEVEL);
trigger launchFundamentalsTr (wait, 1);
trigger chainloadTr (wait, 1);
/* Events */
event conDroids;
event multiMsgEv;
event beaconEv;
event watchBaseThreat;
@ -277,7 +278,6 @@ function int numEnemyAAInRange(int _x, int _y, int _range);
function BASEOBJ chooseVtolTarget(bool bExclusiveTarget);
function int getVtolTargetWeight(BASEOBJ _target);
function bool vtolTargetAssigned(BASEOBJ _target);
function void buildTruck();
function int numBuildSameBuilding(STRUCTURESTAT _checkStat, int _x, int _y);
function void expandBase(DROID _truck);
function int totalVtols();
@ -382,19 +382,18 @@ event initialisedEvent(CALL_GAMEINIT)
fundamentalBeingBuilt = derrick; // to avoid ever being null
bRunning = false;
if(aiResponsibleForPlayer(me))
{
bRunning = true;
}
else
{
bRunning = false;
shutDownAI();
}
}
function void buildFundamentals()
event buildFundamentals(inactive)
{
count = 0;
while (count < numFundamental)
@ -428,18 +427,14 @@ function void buildFundamentals()
count = count + 1;
}
fundamentalBeingBuilt = derrick;
}
event launchFundamentals(inactive)
{
buildFundamentals();
setEventTrigger(launchFundamentals, inactive);
setEventTrigger(buildFundamentals, inactive);
}
event startLevel(startLevelTr)
{
buildFundamentals();
buildTruck();
setEventTrigger(buildFundamentals, chainloadTr);
setEventTrigger(conDroids, chainloadTr);
setEventTrigger(startLevel, inactive);
}
// decide what technology branch we will use
@ -1386,7 +1381,7 @@ event structBuilt(structBuiltTr)
}
else
{
buildTruck();
setEventTrigger(conDroids, chainloadTr);
}
}
/* vtol factory or vtol factory module */
@ -1414,7 +1409,7 @@ event structBuilt(structBuiltTr)
// Check if available trucks need to build more absolute necessities right away. We need a trigger here because
// droids involved in building have not yet come out of their build orders.
setEventTrigger(launchFundamentals, launchFundamentalsTr);
setEventTrigger(buildFundamentals, chainloadTr);
//see if we have just rebuilt a destroyed structure
_count = 0;
@ -1480,11 +1475,6 @@ event droidDestroyed(droidDestroyedTr)
/////////////////////////////////////////////////////////////////////
// build more con droids.
event conDroids(conDroidsTr)
{
buildTruck();
}
function void buildTruck()
{
local int _maxTrucks;
local STRUCTURE _factory;
@ -1545,9 +1535,9 @@ function void buildTruck()
_factory = enumStruct();
}
setEventTrigger(conDroids, conDroidsTr);
}
//Build a droid
function bool buildUnit(TEMPLATE _tankTemplate, STRUCTURE _factory, STRUCTURESTAT _factoryType, bool _bIdleOnly)
{
@ -4136,8 +4126,8 @@ event consoleEv(consoleTr)
if(not bRunning) //make sure current machine is responsible for this AI and it's not already active
{
console(getPlayerName(me) & " is active");
reassignAI();
setEventTrigger(startLevel, chainloadTr);
}
}
}

View File

@ -221,9 +221,10 @@ trigger manageAllyHelpTr (every, 80);
trigger everySec (every, 10);
trigger manageDefendLocationTr (every, 70);
trigger startLevelTr (CALL_START_NEXT_LEVEL);
trigger launchFundamentalsTr (wait, 1);
trigger chainloadTr (wait, 1);
/* Events */
event conDroids;
event multiMsgEv;
event beaconEv;
event watchBaseThreat;
@ -277,7 +278,6 @@ function int numEnemyAAInRange(int _x, int _y, int _range);
function BASEOBJ chooseVtolTarget(bool bExclusiveTarget);
function int getVtolTargetWeight(BASEOBJ _target);
function bool vtolTargetAssigned(BASEOBJ _target);
function void buildTruck();
function int numBuildSameBuilding(STRUCTURESTAT _checkStat, int _x, int _y);
function void expandBase(DROID _truck);
function int totalVtols();
@ -382,19 +382,18 @@ event initialisedEvent(CALL_GAMEINIT)
fundamentalBeingBuilt = derrick; // to avoid ever being null
bRunning = false;
if(aiResponsibleForPlayer(me))
{
bRunning = true;
}
else
{
bRunning = false;
shutDownAI();
}
}
function void buildFundamentals()
event buildFundamentals(inactive)
{
count = 0;
while (count < numFundamental)
@ -428,18 +427,14 @@ function void buildFundamentals()
count = count + 1;
}
fundamentalBeingBuilt = derrick;
}
event launchFundamentals(inactive)
{
buildFundamentals();
setEventTrigger(launchFundamentals, inactive);
setEventTrigger(buildFundamentals, inactive);
}
event startLevel(startLevelTr)
{
buildFundamentals();
buildTruck();
setEventTrigger(buildFundamentals, chainloadTr);
setEventTrigger(conDroids, chainloadTr);
setEventTrigger(startLevel, inactive);
}
// decide what technology branch we will use
@ -1386,7 +1381,7 @@ event structBuilt(structBuiltTr)
}
else
{
buildTruck();
setEventTrigger(conDroids, chainloadTr);
}
}
/* vtol factory or vtol factory module */
@ -1414,7 +1409,7 @@ event structBuilt(structBuiltTr)
// Check if available trucks need to build more absolute necessities right away. We need a trigger here because
// droids involved in building have not yet come out of their build orders.
setEventTrigger(launchFundamentals, launchFundamentalsTr);
setEventTrigger(buildFundamentals, chainloadTr);
//see if we have just rebuilt a destroyed structure
_count = 0;
@ -1480,11 +1475,6 @@ event droidDestroyed(droidDestroyedTr)
/////////////////////////////////////////////////////////////////////
// build more con droids.
event conDroids(conDroidsTr)
{
buildTruck();
}
function void buildTruck()
{
local int _maxTrucks;
local STRUCTURE _factory;
@ -1545,9 +1535,9 @@ function void buildTruck()
_factory = enumStruct();
}
setEventTrigger(conDroids, conDroidsTr);
}
//Build a droid
function bool buildUnit(TEMPLATE _tankTemplate, STRUCTURE _factory, STRUCTURESTAT _factoryType, bool _bIdleOnly)
{
@ -4136,8 +4126,8 @@ event consoleEv(consoleTr)
if(not bRunning) //make sure current machine is responsible for this AI and it's not already active
{
console(getPlayerName(me) & " is active");
reassignAI();
setEventTrigger(startLevel, chainloadTr);
}
}
}

View File

@ -221,9 +221,10 @@ trigger manageAllyHelpTr (every, 80);
trigger everySec (every, 10);
trigger manageDefendLocationTr (every, 70);
trigger startLevelTr (CALL_START_NEXT_LEVEL);
trigger launchFundamentalsTr (wait, 1);
trigger chainloadTr (wait, 1);
/* Events */
event conDroids;
event multiMsgEv;
event beaconEv;
event watchBaseThreat;
@ -277,7 +278,6 @@ function int numEnemyAAInRange(int _x, int _y, int _range);
function BASEOBJ chooseVtolTarget(bool bExclusiveTarget);
function int getVtolTargetWeight(BASEOBJ _target);
function bool vtolTargetAssigned(BASEOBJ _target);
function void buildTruck();
function int numBuildSameBuilding(STRUCTURESTAT _checkStat, int _x, int _y);
function void expandBase(DROID _truck);
function int totalVtols();
@ -382,19 +382,18 @@ event initialisedEvent(CALL_GAMEINIT)
fundamentalBeingBuilt = derrick; // to avoid ever being null
bRunning = false;
if(aiResponsibleForPlayer(me))
{
bRunning = true;
}
else
{
bRunning = false;
shutDownAI();
}
}
function void buildFundamentals()
event buildFundamentals(inactive)
{
count = 0;
while (count < numFundamental)
@ -428,18 +427,14 @@ function void buildFundamentals()
count = count + 1;
}
fundamentalBeingBuilt = derrick;
}
event launchFundamentals(inactive)
{
buildFundamentals();
setEventTrigger(launchFundamentals, inactive);
setEventTrigger(buildFundamentals, inactive);
}
event startLevel(startLevelTr)
{
buildFundamentals();
buildTruck();
setEventTrigger(buildFundamentals, chainloadTr);
setEventTrigger(conDroids, chainloadTr);
setEventTrigger(startLevel, inactive);
}
// decide what technology branch we will use
@ -1386,7 +1381,7 @@ event structBuilt(structBuiltTr)
}
else
{
buildTruck();
setEventTrigger(conDroids, chainloadTr);
}
}
/* vtol factory or vtol factory module */
@ -1414,7 +1409,7 @@ event structBuilt(structBuiltTr)
// Check if available trucks need to build more absolute necessities right away. We need a trigger here because
// droids involved in building have not yet come out of their build orders.
setEventTrigger(launchFundamentals, launchFundamentalsTr);
setEventTrigger(buildFundamentals, chainloadTr);
//see if we have just rebuilt a destroyed structure
_count = 0;
@ -1480,11 +1475,6 @@ event droidDestroyed(droidDestroyedTr)
/////////////////////////////////////////////////////////////////////
// build more con droids.
event conDroids(conDroidsTr)
{
buildTruck();
}
function void buildTruck()
{
local int _maxTrucks;
local STRUCTURE _factory;
@ -1545,9 +1535,9 @@ function void buildTruck()
_factory = enumStruct();
}
setEventTrigger(conDroids, conDroidsTr);
}
//Build a droid
function bool buildUnit(TEMPLATE _tankTemplate, STRUCTURE _factory, STRUCTURESTAT _factoryType, bool _bIdleOnly)
{
@ -4136,8 +4126,8 @@ event consoleEv(consoleTr)
if(not bRunning) //make sure current machine is responsible for this AI and it's not already active
{
console(getPlayerName(me) & " is active");
reassignAI();
setEventTrigger(startLevel, chainloadTr);
}
}
}

View File

@ -221,9 +221,10 @@ trigger manageAllyHelpTr (every, 80);
trigger everySec (every, 10);
trigger manageDefendLocationTr (every, 70);
trigger startLevelTr (CALL_START_NEXT_LEVEL);
trigger launchFundamentalsTr (wait, 1);
trigger chainloadTr (wait, 1);
/* Events */
event conDroids;
event multiMsgEv;
event beaconEv;
event watchBaseThreat;
@ -277,7 +278,6 @@ function int numEnemyAAInRange(int _x, int _y, int _range);
function BASEOBJ chooseVtolTarget(bool bExclusiveTarget);
function int getVtolTargetWeight(BASEOBJ _target);
function bool vtolTargetAssigned(BASEOBJ _target);
function void buildTruck();
function int numBuildSameBuilding(STRUCTURESTAT _checkStat, int _x, int _y);
function void expandBase(DROID _truck);
function int totalVtols();
@ -382,19 +382,18 @@ event initialisedEvent(CALL_GAMEINIT)
fundamentalBeingBuilt = derrick; // to avoid ever being null
bRunning = false;
if(aiResponsibleForPlayer(me))
{
bRunning = true;
}
else
{
bRunning = false;
shutDownAI();
}
}
function void buildFundamentals()
event buildFundamentals(inactive)
{
count = 0;
while (count < numFundamental)
@ -428,18 +427,14 @@ function void buildFundamentals()
count = count + 1;
}
fundamentalBeingBuilt = derrick;
}
event launchFundamentals(inactive)
{
buildFundamentals();
setEventTrigger(launchFundamentals, inactive);
setEventTrigger(buildFundamentals, inactive);
}
event startLevel(startLevelTr)
{
buildFundamentals();
buildTruck();
setEventTrigger(buildFundamentals, chainloadTr);
setEventTrigger(conDroids, chainloadTr);
setEventTrigger(startLevel, inactive);
}
// decide what technology branch we will use
@ -1386,7 +1381,7 @@ event structBuilt(structBuiltTr)
}
else
{
buildTruck();
setEventTrigger(conDroids, chainloadTr);
}
}
/* vtol factory or vtol factory module */
@ -1414,7 +1409,7 @@ event structBuilt(structBuiltTr)
// Check if available trucks need to build more absolute necessities right away. We need a trigger here because
// droids involved in building have not yet come out of their build orders.
setEventTrigger(launchFundamentals, launchFundamentalsTr);
setEventTrigger(buildFundamentals, chainloadTr);
//see if we have just rebuilt a destroyed structure
_count = 0;
@ -1480,11 +1475,6 @@ event droidDestroyed(droidDestroyedTr)
/////////////////////////////////////////////////////////////////////
// build more con droids.
event conDroids(conDroidsTr)
{
buildTruck();
}
function void buildTruck()
{
local int _maxTrucks;
local STRUCTURE _factory;
@ -1545,9 +1535,9 @@ function void buildTruck()
_factory = enumStruct();
}
setEventTrigger(conDroids, conDroidsTr);
}
//Build a droid
function bool buildUnit(TEMPLATE _tankTemplate, STRUCTURE _factory, STRUCTURESTAT _factoryType, bool _bIdleOnly)
{
@ -4136,8 +4126,8 @@ event consoleEv(consoleTr)
if(not bRunning) //make sure current machine is responsible for this AI and it's not already active
{
console(getPlayerName(me) & " is active");
reassignAI();
setEventTrigger(startLevel, chainloadTr);
}
}
}

View File

@ -221,9 +221,10 @@ trigger manageAllyHelpTr (every, 80);
trigger everySec (every, 10);
trigger manageDefendLocationTr (every, 70);
trigger startLevelTr (CALL_START_NEXT_LEVEL);
trigger launchFundamentalsTr (wait, 1);
trigger chainloadTr (wait, 1);
/* Events */
event conDroids;
event multiMsgEv;
event beaconEv;
event watchBaseThreat;
@ -277,7 +278,6 @@ function int numEnemyAAInRange(int _x, int _y, int _range);
function BASEOBJ chooseVtolTarget(bool bExclusiveTarget);
function int getVtolTargetWeight(BASEOBJ _target);
function bool vtolTargetAssigned(BASEOBJ _target);
function void buildTruck();
function int numBuildSameBuilding(STRUCTURESTAT _checkStat, int _x, int _y);
function void expandBase(DROID _truck);
function int totalVtols();
@ -382,19 +382,18 @@ event initialisedEvent(CALL_GAMEINIT)
fundamentalBeingBuilt = derrick; // to avoid ever being null
bRunning = false;
if(aiResponsibleForPlayer(me))
{
bRunning = true;
}
else
{
bRunning = false;
shutDownAI();
}
}
function void buildFundamentals()
event buildFundamentals(inactive)
{
count = 0;
while (count < numFundamental)
@ -428,18 +427,14 @@ function void buildFundamentals()
count = count + 1;
}
fundamentalBeingBuilt = derrick;
}
event launchFundamentals(inactive)
{
buildFundamentals();
setEventTrigger(launchFundamentals, inactive);
setEventTrigger(buildFundamentals, inactive);
}
event startLevel(startLevelTr)
{
buildFundamentals();
buildTruck();
setEventTrigger(buildFundamentals, chainloadTr);
setEventTrigger(conDroids, chainloadTr);
setEventTrigger(startLevel, inactive);
}
// decide what technology branch we will use
@ -1386,7 +1381,7 @@ event structBuilt(structBuiltTr)
}
else
{
buildTruck();
setEventTrigger(conDroids, chainloadTr);
}
}
/* vtol factory or vtol factory module */
@ -1414,7 +1409,7 @@ event structBuilt(structBuiltTr)
// Check if available trucks need to build more absolute necessities right away. We need a trigger here because
// droids involved in building have not yet come out of their build orders.
setEventTrigger(launchFundamentals, launchFundamentalsTr);
setEventTrigger(buildFundamentals, chainloadTr);
//see if we have just rebuilt a destroyed structure
_count = 0;
@ -1480,11 +1475,6 @@ event droidDestroyed(droidDestroyedTr)
/////////////////////////////////////////////////////////////////////
// build more con droids.
event conDroids(conDroidsTr)
{
buildTruck();
}
function void buildTruck()
{
local int _maxTrucks;
local STRUCTURE _factory;
@ -1545,9 +1535,9 @@ function void buildTruck()
_factory = enumStruct();
}
setEventTrigger(conDroids, conDroidsTr);
}
//Build a droid
function bool buildUnit(TEMPLATE _tankTemplate, STRUCTURE _factory, STRUCTURESTAT _factoryType, bool _bIdleOnly)
{
@ -4136,8 +4126,8 @@ event consoleEv(consoleTr)
if(not bRunning) //make sure current machine is responsible for this AI and it's not already active
{
console(getPlayerName(me) & " is active");
reassignAI();
setEventTrigger(startLevel, chainloadTr);
}
}
}