Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/ai/petra/worker.js
Show First 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | if (subrole == "gatherer") | ||||
else if (unitAIStateOrder == "GATHER") | else if (unitAIStateOrder == "GATHER") | ||||
{ | { | ||||
// we're already gathering. But let's check if there is nothing better | // we're already gathering. But let's check if there is nothing better | ||||
// in case UnitAI did something bad | // in case UnitAI did something bad | ||||
if (ent.unitAIOrderData().length) | if (ent.unitAIOrderData().length) | ||||
{ | { | ||||
let supplyId = ent.unitAIOrderData()[0].target; | let supplyId = ent.unitAIOrderData()[0].target; | ||||
let supply = gameState.getEntityById(supplyId); | let supply = gameState.getEntityById(supplyId); | ||||
if (supply && !supply.hasClass("Field") && !supply.hasClass("Animal") && | if (supply && !supply.hasClasses(["Field", "Animal"]) && | ||||
supplyId != ent.getMetadata(PlayerID, "supply")) | supplyId != ent.getMetadata(PlayerID, "supply")) | ||||
{ | { | ||||
let nbGatherers = supply.resourceSupplyNumGatherers() + gameState.ai.HQ.GetTCGatherer(supplyId); | let nbGatherers = supply.resourceSupplyNumGatherers() + gameState.ai.HQ.GetTCGatherer(supplyId); | ||||
if (nbGatherers > 1 && supply.resourceSupplyAmount()/nbGatherers < 30) | if (nbGatherers > 1 && supply.resourceSupplyAmount()/nbGatherers < 30) | ||||
{ | { | ||||
gameState.ai.HQ.RemoveTCGatherer(supplyId); | gameState.ai.HQ.RemoveTCGatherer(supplyId); | ||||
this.startGathering(gameState); | this.startGathering(gameState); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 873 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator