Index: binaries/data/mods/public/simulation/components/Builder.js
===================================================================
--- binaries/data/mods/public/simulation/components/Builder.js
+++ binaries/data/mods/public/simulation/components/Builder.js
@@ -11,6 +11,9 @@
"" +
"" +
"" +
+ "" +
+ "" +
+ "" +
"" +
"" +
"tokens" +
@@ -57,6 +60,11 @@
return { "max": max, "min": 0 };
};
+Builder.prototype.GetAutoBuildRange = function()
+{
+ return ApplyValueModificationsToEntity("Builder/AutoBuildRange", +this.template.AutoBuildRange, this.entity);
+};
+
Builder.prototype.GetRate = function()
{
return ApplyValueModificationsToEntity("Builder/Rate", +this.template.Rate, this.entity);
Index: binaries/data/mods/public/simulation/components/ResourceGatherer.js
===================================================================
--- binaries/data/mods/public/simulation/components/ResourceGatherer.js
+++ binaries/data/mods/public/simulation/components/ResourceGatherer.js
@@ -21,6 +21,9 @@
"" +
"" +
"" +
+ "" +
+ "" +
+ "" +
"" +
"" +
"" +
@@ -149,6 +152,11 @@
// maybe this should depend on the unit or target or something?
};
+ResourceGatherer.prototype.GetAutoGatherRange = function()
+{
+ return ApplyValueModificationsToEntity("ResourceGatherer/AutoGatherRange", +this.template.AutoGatherRange, this.entity);
+};
+
/**
* Try to gather treasure
* @return 'true' if treasure is successfully gathered, otherwise 'false'
Index: binaries/data/mods/public/simulation/components/UnitAI.js
===================================================================
--- binaries/data/mods/public/simulation/components/UnitAI.js
+++ binaries/data/mods/public/simulation/components/UnitAI.js
@@ -4160,10 +4160,13 @@
return undefined;
let owner = cmpOwnership.GetOwner();
- // We accept resources owned by Gaia or any player
+ // We accept resources owned by any player (including Gaia).
let players = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetAllPlayers();
- let range = 64; // TODO: what's a sensible number?
+ let cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer);
+ if (!cmpResourceGatherer)
+ return undefined;
+ let range = cmpResourceGatherer.GetAutoGatherRange();
let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
@@ -4254,17 +4257,20 @@
*/
UnitAI.prototype.FindNearbyFoundation = function()
{
- var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership);
+ let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership);
if (!cmpOwnership || cmpOwnership.GetOwner() == INVALID_PLAYER)
return undefined;
- // Find buildings owned by this unit's player
- var players = [cmpOwnership.GetOwner()];
+ let players = [cmpOwnership.GetOwner()];
- var range = 64; // TODO: what's a sensible number?
+ let cmpBuilder = Engine.QueryInterface(this.entity, IID_Builder);
+ if (!cmpBuilder)
+ return undefined;
- var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
- var nearby = cmpRangeManager.ExecuteQuery(this.entity, 0, range, players, IID_Foundation);
+ let range = cmpBuilder.GetAutoBuildRange();
+
+ let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
+ let nearby = cmpRangeManager.ExecuteQuery(this.entity, 0, range, players, IID_Foundation);
// Skip foundations that are already complete. (This matters since
// we process the ConstructionFinished message before the foundation
Index: binaries/data/mods/public/simulation/templates/template_unit.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_unit.xml
+++ binaries/data/mods/public/simulation/templates/template_unit.xml
@@ -82,6 +82,7 @@
2.0
+ 64
1.0
1
Index: binaries/data/mods/public/simulation/templates/template_unit_infantry.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_unit_infantry.xml
+++ binaries/data/mods/public/simulation/templates/template_unit_infantry.xml
@@ -23,6 +23,7 @@
1.0
+ 64
structures/{civ}_house
structures/{civ}_storehouse
Index: binaries/data/mods/public/simulation/templates/template_unit_support_female_citizen.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_unit_support_female_citizen.xml
+++ binaries/data/mods/public/simulation/templates/template_unit_support_female_citizen.xml
@@ -25,6 +25,7 @@
1.0
+ 64
structures/{civ}_house
structures/{civ}_storehouse
Index: binaries/data/mods/public/simulation/templates/template_unit_support_slave.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/template_unit_support_slave.xml
+++ binaries/data/mods/public/simulation/templates/template_unit_support_slave.xml
@@ -2,6 +2,7 @@
0.5
+ 64
structures/{civ}_house
structures/{civ}_storehouse
Index: binaries/data/mods/public/simulation/templates/units/maur_support_elephant.xml
===================================================================
--- binaries/data/mods/public/simulation/templates/units/maur_support_elephant.xml
+++ binaries/data/mods/public/simulation/templates/units/maur_support_elephant.xml
@@ -7,6 +7,7 @@
2.0
+ 64