1
0
forked from 0ad/0ad

various small petra tunings

This was SVN commit r15880.
This commit is contained in:
mimo 2014-10-17 17:15:06 +00:00
parent a29e233fdf
commit 620399270d
8 changed files with 56 additions and 18 deletions

View File

@ -590,9 +590,20 @@ m.BaseManager.prototype.setWorkersIdleByPriority = function(gameState)
// but we require a bit more to avoid too frequent changes
if ((scale*moreNeed.wanted - moreNeed.current) - (scale*lessNeed.wanted - lessNeed.current) > 1.5)
{
this.gatherersByType(gameState, lessNeed.type).forEach( function (ent) {
let only = undefined;
// in average, females are less efficient for stone and metal, and citizenSoldiers for food
let gatherers = this.gatherersByType(gameState, lessNeed.type);
if (lessNeed.type === "food" && gatherers.filter(API3.Filters.byClass("CitizenSoldier")).length)
only = "CitizenSoldier";
else if ((lessNeed.type === "stone" || lessNeed.type === "metal") && moreNeed.type !== "stone" && moreNeed.type !== "metal"
&& gatherers.filter(API3.Filters.byClass("Female")).length)
only = "Female";
gatherers.forEach( function (ent) {
if (nb === 0)
return;
if (only && !ent.hasClass(only))
return;
--nb;
ent.stopMoving();
ent.setMetadata(PlayerID, "gather-type", moreNeed.type);

View File

@ -157,7 +157,7 @@ m.Config.prototype.setConfig = function(gameState)
if (gameState.getPopulationMax() < 300)
this.popScaling = Math.sqrt(gameState.getPopulationMax() / 300);
if (this.debug < 1)
if (this.debug < 2)
return;
API3.warn(" >>> Petra bot: personality = " + uneval(this.personality));
};

View File

@ -28,7 +28,6 @@ m.HQ = function(Config)
this.currentRates = { "food": 0, "wood": 0, "stone":0, "metal": 0 };
this.lastFailedGather = { "wood": undefined, "stone": undefined, "metal": undefined };
// this means we'll have about a big third of women, and thus we can maximize resource gathering rates.
this.femaleRatio = this.Config.Economy.femaleRatio;

View File

@ -108,8 +108,6 @@ m.createObstructionMap = function(gameState, accessIndex, template)
var tileAccessible = (accessIndex === gameState.ai.accessibility.landPassMap[i]);
else
var tileAccessible = true;
if (placementType === "shore")
tileAccessible = true;
obstructionTiles[i] = (!tileAccessible || invalidTerritory || (passabilityMap.data[i] & obstructionMask)) ? 0 : 255;
}
}

View File

@ -469,7 +469,37 @@ m.NavalManager.prototype.moveApart = function(gameState)
for (var sea = 0; sea < gameState.ai.accessibility.regionSize.length; ++sea)
{
this.seaShips[sea].forEach(function(ship) {
if (ship.hasClass("FishingBoat")) // small ships should not be a problem
return;
if (ship.getMetadata(PlayerID, "transporter") === undefined)
{
if (ship.isIdle()) // do not stay idle near a dock to not disturb other ships
{
gameState.getOwnStructures().filter(API3.Filters.byClass("Dock")).forEach(function(dock) {
if (dock.getMetadata(PlayerID, "sea") !== sea)
return;
if (API3.SquareVectorDistance(ship.position(), dock.position()) > 2500)
return;
ship.moveApart(dock.position(), 50);
});
}
return;
}
self.seaShips[sea].forEach(function(blockingShip) {
if (blockingShip === ship || !blockingShip.isIdle())
return;
if (API3.SquareVectorDistance(ship.position(), blockingShip.position()) > 900)
return;
if (blockingShip.getMetadata(PlayerID, "transporter") === undefined)
blockingShip.moveApart(ship.position(), 12);
else
blockingShip.moveApart(ship.position(), 6);
});
});
gameState.ai.HQ.tradeManager.traders.filter(API3.Filters.byMetadata(PlayerID, "sea", sea)).forEach(function(ship) {
if (ship.getMetadata(PlayerID, "route") === undefined)
return;
self.seaShips[sea].forEach(function(blockingShip) {
if (blockingShip === ship || !blockingShip.isIdle())

View File

@ -95,7 +95,7 @@ m.TrainingPlan.prototype.start = function(gameState)
this.metadata.base = trainers[0].getMetadata(PlayerID, "base");
trainers[0].train(this.type, this.number, this.metadata, this.promotedTypes(gameState));
}
else if (gameState.ai.Config.debug > 1)
else if (gameState.Config.debug > 1)
warn(" no trainers for this queue " + this.type);
this.onStart(gameState);
};
@ -120,7 +120,7 @@ m.TrainingPlan.prototype.promotedTypes = function(gameState)
promotion = gameState.getTemplate(promotion).promotion();
if (previous === promotion)
{
if (gameState.ai.Config.debug > 0)
if (gameState.Config.debug > 0)
API3.warn(" unit " + promotion + " is its own promoted unit");
promotion = undefined;
}

View File

@ -101,7 +101,7 @@ m.TransportPlan.prototype.assignUnitToShip = function(gameState, ent)
{
ent.setMetadata(PlayerID, "onBoard", ship.id());
done = true;
if (self.debug > 0)
if (self.debug > 1)
{
if (ent.getMetadata(PlayerID, "role") === "attack")
Engine.PostCommand(PlayerID,{"type": "set-shading-color", "entities": [ent.id()], "rgb": [2,0,0]});
@ -252,7 +252,7 @@ m.TransportPlan.prototype.onBoarding = function(gameState)
var ship = gameState.getEntityById(shipId);
if (!self.boardingPos[shipId])
{
self.boardingPos[shipId] = self.getBoardingPos(gameState, self.startIndex, self.sea, ent.position(), false);
self.boardingPos[shipId] = self.getBoardingPos(gameState, ship, self.startIndex, self.sea, ent.position(), false);
ship.move(self.boardingPos[shipId][0], self.boardingPos[shipId][1]);
ship.setMetadata(PlayerID, "timeGarrison", time);
}
@ -282,7 +282,7 @@ m.TransportPlan.prototype.onBoarding = function(gameState)
self.nTry[shipId] = 0;
if (self.debug > 1)
API3.warn("ship " + shipId + " new attempt for a landing point ");
self.boardingPos[shipId] = self.getBoardingPos(gameState, self.startIndex, self.sea, undefined, false);
self.boardingPos[shipId] = self.getBoardingPos(gameState, ship, self.startIndex, self.sea, undefined, false);
}
ship.move(self.boardingPos[shipId][0], self.boardingPos[shipId][1]);
ship.setMetadata(PlayerID, "timeGarrison", time);
@ -328,7 +328,7 @@ m.TransportPlan.prototype.onBoarding = function(gameState)
this.ships.forEach(function (ship) {
self.boardingPos[ship.id()] = undefined;
self.boardingPos[ship.id()] = self.getBoardingPos(gameState, self.endIndex, self.sea, self.endPos, true);
self.boardingPos[ship.id()] = self.getBoardingPos(gameState, ship, self.endIndex, self.sea, self.endPos, true);
ship.move(self.boardingPos[ship.id()][0], self.boardingPos[ship.id()][1]);
});
this.state = "sailing";
@ -351,7 +351,7 @@ m.TransportPlan.prototype.isOnBoard = function(ent)
};
// when avoidEnnemy is true, we try to not board/unboard in ennemy territory
m.TransportPlan.prototype.getBoardingPos = function(gameState, landIndex, seaIndex, destination, avoidEnnemy)
m.TransportPlan.prototype.getBoardingPos = function(gameState, ship, landIndex, seaIndex, destination, avoidEnnemy)
{
if (!gameState.ai.HQ.navalManager.landingZones[landIndex][seaIndex])
{
@ -359,7 +359,7 @@ m.TransportPlan.prototype.getBoardingPos = function(gameState, landIndex, seaInd
return destination;
}
var startPos = this.transportShips.getCentrePosition();
var startPos = ship.position();
var distmin = Math.min();
var posmin = destination;
var width = gameState.getMap().width;
@ -380,7 +380,7 @@ m.TransportPlan.prototype.getBoardingPos = function(gameState, landIndex, seaInd
// require a small distance between all ships of the transport plan to avoid path finder problems
// this is also used when the ship is blocked and we want to find a new boarding point
for (var shipId in this.boardingPos)
if (this.boardingPos[shipId] !== undefined && API3.SquareVectorDistance(this.boardingPos[shipId], pos) < 100)
if (this.boardingPos[shipId] !== undefined && API3.SquareVectorDistance(this.boardingPos[shipId], pos) < 225)
dist += 1000000;
if (dist > distmin)
continue;
@ -488,7 +488,7 @@ m.TransportPlan.prototype.onSailing = function(gameState)
}
for (var shipId in shipsToMove)
{
this.boardingPos[shipId] = this.getBoardingPos(gameState, this.endIndex, this.sea, this.endPos, true);
this.boardingPos[shipId] = this.getBoardingPos(gameState, shipsToMove[shipId], this.endIndex, this.sea, this.endPos, true);
shipsToMove[shipId].move(this.boardingPos[shipId][0], this.boardingPos[shipId][1]);
}
this.unloaded = [];
@ -497,7 +497,7 @@ m.TransportPlan.prototype.onSailing = function(gameState)
{
this.ships.forEach(function (ship) {
self.boardingPos[ship.id()] = undefined;
self.boardingPos[ship.id()] = self.getBoardingPos(gameState, self.endIndex, self.sea, self.endPos, true);
self.boardingPos[ship.id()] = self.getBoardingPos(gameState, ship, self.endIndex, self.sea, self.endPos, true);
ship.move(self.boardingPos[ship.id()][0], self.boardingPos[ship.id()][1]);
});
this.canceled = undefined;
@ -549,7 +549,7 @@ m.TransportPlan.prototype.onSailing = function(gameState)
self.nTry[shipId] = 0;
if (self.debug > 1)
API3.warn(shipId + " new attempt for a landing point ");
self.boardingPos[shipId] = self.getBoardingPos(gameState, self.endIndex, self.sea, undefined, true);
self.boardingPos[shipId] = self.getBoardingPos(gameState, ship, self.endIndex, self.sea, undefined, true);
}
ship.move(self.boardingPos[shipId][0], self.boardingPos[shipId][1]);
}

View File

@ -32,7 +32,7 @@
<History>The Ptolemaic kings invited Greeks, Macedonians, Galatians (Gauls), Cretans, and Thracians alike to settle within Egypt in military colonies called cleruchies (klēroukhia). Under this arrangement, the settlers were given a plot of land, or a kleros, and in return were required to serve in the great king's army when called to duty. This created a upper-middle class of military settlers who owed their livelihoods and fortunes to the Ptolemaic kings and helped grow the available manpower for the imperial Ptolemaic army. A side effect of this system was that it drained the Greek homeland of military-aged men, a contributing factor to Greece's eventual conquest by Rome.</History>
<Tooltip>This is the Ptolemaic expansion building, similar to Civic Centers for other factions. It is weaker and carries a smaller territory influence, but is cheaper and built faster.
- Train settler-soldiers of various nationalities.
- Min. distance from other Military Colonies: 100 meters.</Tooltip>
- Min. distance from other Military Colonies: 120 meters.</Tooltip>
<Icon>structures/military_settlement.png</Icon>
<RequiredTechnology>phase_town</RequiredTechnology>
</Identity>