Skip to content

Commit

Permalink
pre-3.0: Port over AI improvements from master/trunk. Build hover tru…
Browse files Browse the repository at this point in the history
…cks when available.

Removing buggy sensor clump hack. More uses of pickDroidStructLocation instead of
pickStructLocation to avoid attempts to build on inaccessible map areas. Do not attempt
to build power gen if not available yet. Remove hacks that made AI not use certain methods
of attacks against human players (no more mr nice guy). Add thermite bombers (beware).
  • Loading branch information
perim committed Sep 4, 2011
1 parent 81da3ed commit 2e13cb5
Show file tree
Hide file tree
Showing 16 changed files with 288 additions and 328 deletions.
57 changes: 25 additions & 32 deletions data/base/multiplay/skirmish/player0.slo
Expand Up @@ -111,7 +111,7 @@ public int numTemplates[TECHS];
public TEMPLATE tmpl[TECHS][70];
private TEMPLATE tmplChoice[5];

public TEMPLATE cybTempl[10],superCyb[4],cybMechanic,cybEngineer;
public TEMPLATE cybTempl[10],superCyb[4],cybMechanic,cybEngineer,hovertruck;

public TEMPLATE vtols[18];
public int numVtolTemplates;
Expand Down Expand Up @@ -596,7 +596,6 @@ event buildOilDefenseOrRetreat(buildOilDefenseOrRetreatTr)
{
local int _numBuilders,_maxBuilders;


_maxBuilders = 1;

// check idle.
Expand Down Expand Up @@ -632,20 +631,8 @@ event buildOilDefenseOrRetreat(buildOilDefenseOrRetreatTr)
{
if( isStructureAvailable(defStructs[count],me))
{

// don't build multiple sensors together.
if(count == 5)
{
structure = structureBuiltInRange(defStructs[count], buildX, buildY,(6*128), me);
if(structure != NULLOBJECT)
{
count = 8;
}
}

structChoice[count2] = defStructs[count];
count2 = count2 + 1;

}
count = count - 1;
}
Expand All @@ -655,7 +642,7 @@ event buildOilDefenseOrRetreat(buildOilDefenseOrRetreatTr)
count = random(count2); //count = choice!

// pick a location
boolResult = pickStructLocation(structChoice[count], ref buildX, ref buildY,me);
boolResult = pickDroidStructLocation(droid, structChoice[count], ref buildX, ref buildY, me, -1);

_numBuilders = numBuildSameBuilding(NULLSTRUCTURESTAT, buildX, buildY);

Expand Down Expand Up @@ -862,6 +849,10 @@ event incendry(incendryTr)
// build a power gen for every 4 derricks. VITAL!
event buildPowerGenerators(buildPowerGeneratorsTr)
{
if (!isStructureAvailable(powGen, me))
{
exit;
}
initEnumStruct(FALSE,derrick,me,me); // count = numderricks
structure= enumStruct();
count = 0;
Expand All @@ -886,10 +877,10 @@ event buildPowerGenerators(buildPowerGeneratorsTr)
droid = iterateGroup(buildGroup);
while(droid != NULLOBJECT)
{
buildX = baseX; // try build powergen.
buildY = baseY;
if (droid.order != DORDER_HELPBUILD and droid.order != DORDER_BUILD and droid.order != DORDER_LINEBUILD and droidCanReach(droid, buildX, buildY))
if (droid.order != DORDER_HELPBUILD and droid.order != DORDER_BUILD and droid.order != DORDER_LINEBUILD)
{
buildX = baseX; // try build powergen.
buildY = baseY;
if (pickDroidStructLocation(droid, powGen, ref buildX, ref buildY, me, 1))
{
orderDroidStatsLoc(droid, DORDER_BUILD, powGen, buildX, buildY);
Expand All @@ -905,10 +896,9 @@ event buildPowerGenerators(buildPowerGeneratorsTr)
// ensure we have everything in the vital structs list.
event buildBase(buildBaseTr)
{
local int _numBuilders,_maxBuilders;

local int _numBuilders,_maxBuilders;

if( idleGroup(buildGroup) >= (buildGroup.members/2) )
if (idleGroup(buildGroup) >= (buildGroup.members / 2))
{
count = 0;
while(count < numStructs)
Expand Down Expand Up @@ -1491,11 +1481,17 @@ event conDroids(conDroidsTr)
initEnumStruct(FALSE,factory,me,me);
_factory = enumStruct();

while((_factory != NULLOBJECT) and (_numBuilding < _maxTruckFactories)
and (_totalTrucks < _maxTrucks))
while ((_factory != NULLOBJECT) and (_numBuilding < _maxTruckFactories) and (_totalTrucks < _maxTrucks))
{
//Try to build a truck
_bStartedBuilding = buildUnit(constructor, _factory, factory, FALSE); //build truck even if not idle
if (skCanBuildTemplate(me, _factory, hovertruck))
{
_bStartedBuilding = buildUnit(hovertruck, _factory, factory, FALSE); //build truck even if not idle
}
else
{
_bStartedBuilding = buildUnit(constructor, _factory, factory, FALSE); //build truck even if not idle
}

//Update statistics if started building a truck
if(_bStartedBuilding)
Expand Down Expand Up @@ -2577,10 +2573,7 @@ event vtolAttack(inactive)
{
if(defendObj != NULLOBJECT)
{
if(not isHumanPlayer(defendObj.player) ) // new in wdg1 //TODO:is this check needed?
{
orderGroupObj(vtolDefendGr, DORDER_ATTACK,defendObj); // get the defend target
}
orderGroupObj(vtolDefendGr, DORDER_ATTACK,defendObj); // get the defend target
}
}
}
Expand Down Expand Up @@ -2924,8 +2917,8 @@ event vtolDefend(vtolDefendTr)
}
if(count2 != (-1) )
{
boolResult = pickStructLocation(vtolDefStruct[count2], ref buildX, ref buildY,me);
if((boolResult == TRUE) and (_numBuilders < _maxBuilders) and droidCanReach(droid, buildX, buildY)) // build a vtol defense near the attacked struct...
boolResult = pickDroidStructLocation(droid, vtolDefStruct[count2], ref buildX, ref buildY, me, 1);
if (boolResult == TRUE and (_numBuilders < _maxBuilders)) // build a vtol defense near the attacked struct...
{
orderDroidStatsLoc(droid, DORDER_BUILD,vtolDefStruct[count2],buildX,buildY);
_numBuilders++;
Expand Down Expand Up @@ -4050,11 +4043,11 @@ function void buildOnExactLocation(DROID _truck, int _x, int _y, STRUCTURESTAT _
_newX = _x;
_newY = _y;

if(pickStructLocationB(_stat, ref _newX, ref _newY, me, -1))
if (pickDroidStructLocation(_truck, _stat, ref _newX, ref _newY, me, -1))
{
dbg("trying to rebuild on (" & _newX & "/" & _newY & ")", me);

if((_x != _newX) or (_y != _newY) or !droidCanReach(_truck, _x, _y))
if ((_x != _newX) or (_y != _newY))
{
return;
}
Expand Down
20 changes: 11 additions & 9 deletions data/base/multiplay/skirmish/player0.vlo
Expand Up @@ -329,6 +329,7 @@ run
// SENSORS / REPAIR TEMPLATES

constructor TEMPLATE "ConstructorDroid"
hovertruck TEMPLATE "ScorpHoverTruck"
repairUnit TEMPLATE "ViperRepairHalftrack"

numSenseTemplates int 10
Expand Down Expand Up @@ -369,7 +370,7 @@ run
/////////////////////////////////////////////////////////////////////
// VTOL TEMPLATES

numVtolTemplates int 7
numVtolTemplates int 8

vtols[0] TEMPLATE "P6-L-LTAT-V" //Viper Lancer
vtols[1] TEMPLATE "P6-L-Bomb1-V" //Viper Cluster Bombs Bay
Expand All @@ -378,7 +379,8 @@ run
vtols[4] TEMPLATE "H-Scorp-VTOL-Lancer"
vtols[5] TEMPLATE "H-Scorp-VTOL-BB"
vtols[6] TEMPLATE "H-Scorp-VTOL-Lancer"

vtols[7] TEMPLATE "SK-Retre-VTOL-Thermite"

/*
vtols[7] TEMPLATE "SK-Mantis-VTOL-BB"
vtols[8] TEMPLATE "SK-Leopard-VTOL-BB"
Expand All @@ -404,19 +406,19 @@ run
vtolTarget[2] STRUCTURESTAT "A0CyborgFactory"
vtolTargetWeight[2] int 60
vtolTarget[3] STRUCTURESTAT "A0VTolFactory1"
vtolTargetWeight[3] int 70
vtolTargetWeight[3] int 100
vtolTarget[4] STRUCTURESTAT "A0LasSatCommand"
vtolTargetWeight[4] int 40
vtolTargetWeight[4] int 90
vtolTarget[5] STRUCTURESTAT "A0Sat-linkCentre"
vtolTargetWeight[5] int 90
vtolTargetWeight[5] int 10
vtolTarget[6] STRUCTURESTAT "A0ResearchFacility"
vtolTargetWeight[6] int 55
vtolTargetWeight[6] int 10
vtolTarget[7] STRUCTURESTAT "A0PowerGenerator"
vtolTargetWeight[7] int 95
vtolTargetWeight[7] int 15
vtolTarget[8] STRUCTURESTAT "A0ResourceExtractor"
vtolTargetWeight[8] int 100
vtolTargetWeight[8] int 20
vtolTarget[9] STRUCTURESTAT "A0RepairCentre3"
vtolTargetWeight[9] int 20
vtolTargetWeight[9] int 10


// Structure types AI will rebuild when they get destroyed (per tech branch basis)
Expand Down
57 changes: 25 additions & 32 deletions data/base/multiplay/skirmish/player1.slo
Expand Up @@ -111,7 +111,7 @@ public int numTemplates[TECHS];
public TEMPLATE tmpl[TECHS][70];
private TEMPLATE tmplChoice[5];

public TEMPLATE cybTempl[10],superCyb[4],cybMechanic,cybEngineer;
public TEMPLATE cybTempl[10],superCyb[4],cybMechanic,cybEngineer,hovertruck;

public TEMPLATE vtols[18];
public int numVtolTemplates;
Expand Down Expand Up @@ -596,7 +596,6 @@ event buildOilDefenseOrRetreat(buildOilDefenseOrRetreatTr)
{
local int _numBuilders,_maxBuilders;


_maxBuilders = 1;

// check idle.
Expand Down Expand Up @@ -632,20 +631,8 @@ event buildOilDefenseOrRetreat(buildOilDefenseOrRetreatTr)
{
if( isStructureAvailable(defStructs[count],me))
{

// don't build multiple sensors together.
if(count == 5)
{
structure = structureBuiltInRange(defStructs[count], buildX, buildY,(6*128), me);
if(structure != NULLOBJECT)
{
count = 8;
}
}

structChoice[count2] = defStructs[count];
count2 = count2 + 1;

}
count = count - 1;
}
Expand All @@ -655,7 +642,7 @@ event buildOilDefenseOrRetreat(buildOilDefenseOrRetreatTr)
count = random(count2); //count = choice!

// pick a location
boolResult = pickStructLocation(structChoice[count], ref buildX, ref buildY,me);
boolResult = pickDroidStructLocation(droid, structChoice[count], ref buildX, ref buildY, me, -1);

_numBuilders = numBuildSameBuilding(NULLSTRUCTURESTAT, buildX, buildY);

Expand Down Expand Up @@ -862,6 +849,10 @@ event incendry(incendryTr)
// build a power gen for every 4 derricks. VITAL!
event buildPowerGenerators(buildPowerGeneratorsTr)
{
if (!isStructureAvailable(powGen, me))
{
exit;
}
initEnumStruct(FALSE,derrick,me,me); // count = numderricks
structure= enumStruct();
count = 0;
Expand All @@ -886,10 +877,10 @@ event buildPowerGenerators(buildPowerGeneratorsTr)
droid = iterateGroup(buildGroup);
while(droid != NULLOBJECT)
{
buildX = baseX; // try build powergen.
buildY = baseY;
if (droid.order != DORDER_HELPBUILD and droid.order != DORDER_BUILD and droid.order != DORDER_LINEBUILD and droidCanReach(droid, buildX, buildY))
if (droid.order != DORDER_HELPBUILD and droid.order != DORDER_BUILD and droid.order != DORDER_LINEBUILD)
{
buildX = baseX; // try build powergen.
buildY = baseY;
if (pickDroidStructLocation(droid, powGen, ref buildX, ref buildY, me, 1))
{
orderDroidStatsLoc(droid, DORDER_BUILD, powGen, buildX, buildY);
Expand All @@ -905,10 +896,9 @@ event buildPowerGenerators(buildPowerGeneratorsTr)
// ensure we have everything in the vital structs list.
event buildBase(buildBaseTr)
{
local int _numBuilders,_maxBuilders;

local int _numBuilders,_maxBuilders;

if( idleGroup(buildGroup) >= (buildGroup.members/2) )
if (idleGroup(buildGroup) >= (buildGroup.members / 2))
{
count = 0;
while(count < numStructs)
Expand Down Expand Up @@ -1491,11 +1481,17 @@ event conDroids(conDroidsTr)
initEnumStruct(FALSE,factory,me,me);
_factory = enumStruct();

while((_factory != NULLOBJECT) and (_numBuilding < _maxTruckFactories)
and (_totalTrucks < _maxTrucks))
while ((_factory != NULLOBJECT) and (_numBuilding < _maxTruckFactories) and (_totalTrucks < _maxTrucks))
{
//Try to build a truck
_bStartedBuilding = buildUnit(constructor, _factory, factory, FALSE); //build truck even if not idle
if (skCanBuildTemplate(me, _factory, hovertruck))
{
_bStartedBuilding = buildUnit(hovertruck, _factory, factory, FALSE); //build truck even if not idle
}
else
{
_bStartedBuilding = buildUnit(constructor, _factory, factory, FALSE); //build truck even if not idle
}

//Update statistics if started building a truck
if(_bStartedBuilding)
Expand Down Expand Up @@ -2577,10 +2573,7 @@ event vtolAttack(inactive)
{
if(defendObj != NULLOBJECT)
{
if(not isHumanPlayer(defendObj.player) ) // new in wdg1 //TODO:is this check needed?
{
orderGroupObj(vtolDefendGr, DORDER_ATTACK,defendObj); // get the defend target
}
orderGroupObj(vtolDefendGr, DORDER_ATTACK,defendObj); // get the defend target
}
}
}
Expand Down Expand Up @@ -2924,8 +2917,8 @@ event vtolDefend(vtolDefendTr)
}
if(count2 != (-1) )
{
boolResult = pickStructLocation(vtolDefStruct[count2], ref buildX, ref buildY,me);
if((boolResult == TRUE) and (_numBuilders < _maxBuilders) and droidCanReach(droid, buildX, buildY)) // build a vtol defense near the attacked struct...
boolResult = pickDroidStructLocation(droid, vtolDefStruct[count2], ref buildX, ref buildY, me, 1);
if (boolResult == TRUE and (_numBuilders < _maxBuilders)) // build a vtol defense near the attacked struct...
{
orderDroidStatsLoc(droid, DORDER_BUILD,vtolDefStruct[count2],buildX,buildY);
_numBuilders++;
Expand Down Expand Up @@ -4050,11 +4043,11 @@ function void buildOnExactLocation(DROID _truck, int _x, int _y, STRUCTURESTAT _
_newX = _x;
_newY = _y;

if(pickStructLocationB(_stat, ref _newX, ref _newY, me, -1))
if (pickDroidStructLocation(_truck, _stat, ref _newX, ref _newY, me, -1))
{
dbg("trying to rebuild on (" & _newX & "/" & _newY & ")", me);

if((_x != _newX) or (_y != _newY) or !droidCanReach(_truck, _x, _y))
if ((_x != _newX) or (_y != _newY))
{
return;
}
Expand Down
20 changes: 11 additions & 9 deletions data/base/multiplay/skirmish/player1.vlo
Expand Up @@ -329,6 +329,7 @@ run
// SENSORS / REPAIR TEMPLATES

constructor TEMPLATE "ConstructorDroid"
hovertruck TEMPLATE "ScorpHoverTruck"
repairUnit TEMPLATE "ViperRepairHalftrack"

numSenseTemplates int 10
Expand Down Expand Up @@ -369,7 +370,7 @@ run
/////////////////////////////////////////////////////////////////////
// VTOL TEMPLATES

numVtolTemplates int 7
numVtolTemplates int 8

vtols[0] TEMPLATE "P6-L-LTAT-V" //Viper Lancer
vtols[1] TEMPLATE "P6-L-Bomb1-V" //Viper Cluster Bombs Bay
Expand All @@ -378,7 +379,8 @@ run
vtols[4] TEMPLATE "H-Scorp-VTOL-Lancer"
vtols[5] TEMPLATE "H-Scorp-VTOL-BB"
vtols[6] TEMPLATE "H-Scorp-VTOL-Lancer"

vtols[7] TEMPLATE "SK-Retre-VTOL-Thermite"

/*
vtols[7] TEMPLATE "SK-Mantis-VTOL-BB"
vtols[8] TEMPLATE "SK-Leopard-VTOL-BB"
Expand All @@ -404,19 +406,19 @@ run
vtolTarget[2] STRUCTURESTAT "A0CyborgFactory"
vtolTargetWeight[2] int 60
vtolTarget[3] STRUCTURESTAT "A0VTolFactory1"
vtolTargetWeight[3] int 70
vtolTargetWeight[3] int 100
vtolTarget[4] STRUCTURESTAT "A0LasSatCommand"
vtolTargetWeight[4] int 40
vtolTargetWeight[4] int 90
vtolTarget[5] STRUCTURESTAT "A0Sat-linkCentre"
vtolTargetWeight[5] int 90
vtolTargetWeight[5] int 10
vtolTarget[6] STRUCTURESTAT "A0ResearchFacility"
vtolTargetWeight[6] int 55
vtolTargetWeight[6] int 10
vtolTarget[7] STRUCTURESTAT "A0PowerGenerator"
vtolTargetWeight[7] int 95
vtolTargetWeight[7] int 15
vtolTarget[8] STRUCTURESTAT "A0ResourceExtractor"
vtolTargetWeight[8] int 100
vtolTargetWeight[8] int 20
vtolTarget[9] STRUCTURESTAT "A0RepairCentre3"
vtolTargetWeight[9] int 20
vtolTargetWeight[9] int 10


// Structure types AI will rebuild when they get destroyed (per tech branch basis)
Expand Down

0 comments on commit 2e13cb5

Please sign in to comment.