Use chained events instead of relying on a 40 second repeat trigger for research. This
makes the AI much faster at researching, as it eliminates long delays. Also clean up the base expansion code and make it stop trying to expand when out of power. git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@9243 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
7a9bd0c47b
commit
423ac3df4f
|
@ -128,6 +128,7 @@ private bool defendbusy;
|
|||
private BASEOBJ defendObj;
|
||||
|
||||
public RESEARCHSTAT nexusDefence;
|
||||
private RESEARCHSTAT research;
|
||||
|
||||
//build
|
||||
private GROUP buildGroup;
|
||||
|
@ -200,7 +201,7 @@ trigger attackStuffTr (every, 300 );
|
|||
trigger allOutAttackTr (every, 4000);
|
||||
trigger defendWatchTr (CALL_STRUCT_ATTACKED, me, ref structure, ref baseobj);
|
||||
trigger defendReturnTr (every, 500 );
|
||||
trigger doResearchTr (every, 400 );
|
||||
trigger doResearchTr (CALL_RESEARCHCOMPLETED, ref research, ref structure, me);
|
||||
trigger vtolDefendTr (CALL_STRUCT_ATTACKED, me, ref structure, ref baseobj);
|
||||
trigger vtolStructsTr (every, 290);
|
||||
trigger buildVtolsTr (every, 360);
|
||||
|
@ -233,6 +234,7 @@ event everySecEv;
|
|||
event manageDefendLocationEv;
|
||||
event structureDestroyed;
|
||||
event rebuildStructureEv;
|
||||
event doResearch;
|
||||
|
||||
/* Function prototypes */
|
||||
function bool haveBeacon(int _player);
|
||||
|
@ -279,7 +281,6 @@ function BASEOBJ chooseVtolTarget(bool bExclusiveTarget);
|
|||
function int getVtolTargetWeight(BASEOBJ _target);
|
||||
function bool vtolTargetAssigned(BASEOBJ _target);
|
||||
function int numBuildSameBuilding(STRUCTURESTAT _checkStat, int _x, int _y);
|
||||
function void expandBase(DROID _truck);
|
||||
function int totalVtols();
|
||||
function bool needTank();
|
||||
function void setTechBranch(int _tech);
|
||||
|
@ -435,6 +436,7 @@ event startLevel(startLevelTr)
|
|||
{
|
||||
setEventTrigger(buildFundamentals, chainloadTr);
|
||||
setEventTrigger(conDroids, chainloadTr);
|
||||
setEventTrigger(doResearch, chainloadTr);
|
||||
setEventTrigger(startLevel, inactive);
|
||||
}
|
||||
|
||||
|
@ -952,14 +954,14 @@ event buildBase(buildBaseTr)
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// build other stuff, grow the base slowly...
|
||||
event buildExpand( buildExpandTr )
|
||||
{
|
||||
expandBase(NULLOBJECT);
|
||||
}
|
||||
|
||||
function void expandBase(DROID _truck)
|
||||
{
|
||||
local int _numBuilders,_maxBuilders;
|
||||
|
||||
if (playerPower(me) < LOW_POWER)
|
||||
{
|
||||
exit; // do not expand base with low power
|
||||
}
|
||||
|
||||
if(extraStruct == numExtraStructs[curTech]) // loop round
|
||||
{
|
||||
extraStruct = 0;
|
||||
|
@ -976,16 +978,6 @@ function void expandBase(DROID _truck)
|
|||
_numBuilders = numBuildSameBuilding(extraStructs[curTech][extraStruct], buildX, buildY);
|
||||
_maxBuilders = 2;
|
||||
|
||||
if(_truck != NULLOBJECT)
|
||||
{
|
||||
if ((_truck.order != DORDER_BUILD) and (_truck.order != DORDER_LINEBUILD) and droidCanReach(_truck, buildX, buildY))
|
||||
{
|
||||
orderDroidStatsLoc(_truck, DORDER_BUILD,extraStructs[curTech][extraStruct], buildX,buildY);// build it.
|
||||
_numBuilders++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
initIterateGroup(buildGroup); // find idle droids in build group.
|
||||
droid = iterateGroup(buildGroup);
|
||||
while((droid != NULLOBJECT) and (_numBuilders < _maxBuilders))
|
||||
|
@ -999,7 +991,6 @@ function void expandBase(DROID _truck)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extraStruct = extraStruct + 1;
|
||||
}
|
||||
|
@ -1407,6 +1398,10 @@ event structBuilt(structBuiltTr)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (structure.stattype == REF_RESEARCH)
|
||||
{
|
||||
setEventTrigger(doResearch, chainloadTr);
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
@ -2166,6 +2161,7 @@ event doResearch(doResearchTr)
|
|||
|
||||
structure = enumStruct();
|
||||
}
|
||||
setEventTrigger(doResearch, doResearchTr);
|
||||
}
|
||||
|
||||
// find next available research of our research branch
|
||||
|
@ -3854,7 +3850,7 @@ function FEATURE closestOil(int _x, int _y, bool _bAvoidThreat)
|
|||
_bestDist = 99999;
|
||||
_closestOil = NULLOBJECT;
|
||||
|
||||
initGetFeature(oilRes,me,me);
|
||||
initGetFeature(oilRes, -1, me);
|
||||
_oil = getFeatureB(me);
|
||||
while(_oil != NULLOBJECT)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue