forked from 0ad/0ad
petra: small tweaks and cleanings
This was SVN commit r16471.
This commit is contained in:
parent
569b5e244d
commit
809cc074fa
@ -16,22 +16,25 @@ m.Template = m.Class({
|
||||
get: function(string)
|
||||
{
|
||||
var value = this._template;
|
||||
if (this._auraTemplateModif && this._auraTemplateModif.has(string)) {
|
||||
if (this._auraTemplateModif && this._auraTemplateModif.has(string))
|
||||
return this._auraTemplateModif.get(string);
|
||||
} else if (this._techModif && this._techModif.has(string)) {
|
||||
else if (this._techModif && this._techModif.has(string))
|
||||
return this._techModif.get(string);
|
||||
} else {
|
||||
else
|
||||
{
|
||||
if (!this._tpCache.has(string))
|
||||
{
|
||||
var args = string.split("/");
|
||||
for (var i = 0; i < args.length; ++i)
|
||||
if (value[args[i]])
|
||||
value = value[args[i]];
|
||||
for (let arg of args)
|
||||
{
|
||||
if (value[arg])
|
||||
value = value[arg];
|
||||
else
|
||||
{
|
||||
value = undefined;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this._tpCache.set(string, value);
|
||||
}
|
||||
return this._tpCache.get(string);
|
||||
|
@ -301,6 +301,9 @@ m.Army.prototype.checkEvents = function (gameState, events)
|
||||
{
|
||||
if (this.foeEntities.indexOf(msg.entity) !== -1)
|
||||
{
|
||||
let ent = gameState.getEntityById(msg.newentity);
|
||||
if (ent && ent.templateName().indexOf("resource|") !== -1) // corpse of animal killed
|
||||
continue;
|
||||
var idx = this.foeEntities.indexOf(msg.entity);
|
||||
this.foeEntities[idx] = msg.newentity;
|
||||
this.assignedAgainst[msg.newentity] = this.assignedAgainst[msg.entity];
|
||||
|
@ -782,9 +782,9 @@ m.BaseManager.prototype.assignToFoundations = function(gameState, noRepair)
|
||||
var assigned = gameState.getOwnEntitiesByMetadata("target-foundation", target.id()).length;
|
||||
var maxTotalBuilders = Math.ceil(workers.length * 0.2);
|
||||
var targetNB = 2;
|
||||
if (target.hasClass("House") || target.hasClass("Market") || target.hasClass("DropsiteWood"))
|
||||
if (target.hasClass("House") || target.hasClass("DropsiteWood"))
|
||||
targetNB = 3;
|
||||
else if (target.hasClass("Barracks") || target.hasClass("Tower"))
|
||||
else if (target.hasClass("Barracks") || target.hasClass("Tower") || target.hasClass("Market"))
|
||||
targetNB = 4;
|
||||
else if (target.hasClass("Fortress"))
|
||||
targetNB = 7;
|
||||
|
@ -55,7 +55,7 @@ m.DiplomacyManager.prototype.tributes = function(gameState)
|
||||
{
|
||||
if (mostNeeded[k].type == res && mostNeeded[k].wanted > 0)
|
||||
{
|
||||
this.nextTributeRequest.set("all", gameState.ai.elapsedTime + 60);
|
||||
this.nextTributeRequest.set("all", gameState.ai.elapsedTime + 90);
|
||||
this.nextTributeRequest.set(res, gameState.ai.elapsedTime + 240);
|
||||
m.chatRequestTribute(gameState, res);
|
||||
if (this.Config.debug > 1)
|
||||
|
@ -540,8 +540,9 @@ m.Worker.prototype.startHunting = function(gameState, position)
|
||||
if (nbGatherers > 0 && supply.resourceSupplyAmount()/(1+nbGatherers) < 40)
|
||||
return;
|
||||
|
||||
var canFlee = (!supply.hasClass("Domestic") && supply.templateName().indexOf("resource|") == -1);
|
||||
// Only cavalry and range units should hunt fleeing animals
|
||||
if (!supply.hasClass("Domestic") && !isCavalry && !isRanged)
|
||||
if (canFlee && !isCavalry && !isRanged)
|
||||
return;
|
||||
|
||||
// quickscope accessbility check
|
||||
@ -567,7 +568,7 @@ m.Worker.prototype.startHunting = function(gameState, position)
|
||||
if (dropsiteDist > 35000)
|
||||
return;
|
||||
// Only cavalry should hunt far from dropsite (specially for non domestic animals which flee)
|
||||
if (!isCavalry && (dropsiteDist > 10000 || ((dropsiteDist > 7000 || territoryOwner == 0 ) && !supply.hasClass("Domestic"))))
|
||||
if (!isCavalry && (dropsiteDist > 12000 || ((dropsiteDist > 7000 || territoryOwner == 0 ) && canFlee)))
|
||||
return;
|
||||
|
||||
if (dist < nearestSupplyDist)
|
||||
|
Loading…
Reference in New Issue
Block a user