Index: binaries/data/mods/public/globalscripts/Templates.js
===================================================================
--- binaries/data/mods/public/globalscripts/Templates.js
+++ binaries/data/mods/public/globalscripts/Templates.js
@@ -220,11 +220,11 @@
},
"minRange": getAttackStat("MinRange"),
"maxRange": getAttackStat("MaxRange"),
- "elevationBonus": getAttackStat("ElevationBonus")
+ "attackHeight": getAttackStat("AttackHeight")
};
ret.attack[type].elevationAdaptedRange = Math.sqrt(ret.attack[type].maxRange *
- (2 * ret.attack[type].elevationBonus + ret.attack[type].maxRange));
+ (2 * ret.attack[type].attackHeight + ret.attack[type].maxRange));
ret.attack[type].repeatTime = getAttackStat("RepeatTime");
if (template.Attack[type].Projectile)
Index: binaries/data/mods/public/gui/session/input.js
===================================================================
--- binaries/data/mods/public/gui/session/input.js
+++ binaries/data/mods/public/gui/session/input.js
@@ -163,14 +163,14 @@
if (placementSupport.attack && placementSupport.attack.Ranged)
{
- let cmd = {
+ const cmd = {
"x": placementSupport.position.x,
"z": placementSupport.position.z,
"range": placementSupport.attack.Ranged.maxRange,
- "elevationBonus": placementSupport.attack.Ranged.elevationBonus
+ "attackHeight": placementSupport.attack.Ranged.attackHeight
};
- let averageRange = Math.round(Engine.GuiInterfaceCall("GetAverageRangeForBuildings", cmd) - cmd.range);
- let range = Math.round(cmd.range);
+ const averageRange = Math.round(Engine.GuiInterfaceCall("GetAverageRangeForBuildings", cmd) - cmd.range);
+ const range = Math.round(cmd.range);
placementSupport.tooltipMessage = sprintf(translatePlural("Basic range: %(range)s meter", "Basic range: %(range)s meters", range), { "range": range }) + "\n" +
sprintf(translatePlural("Average bonus range: %(range)s meter", "Average bonus range: %(range)s meters", averageRange), { "range": averageRange });
}
Index: binaries/data/mods/public/simulation/components/Attack.js
===================================================================
--- binaries/data/mods/public/simulation/components/Attack.js
+++ binaries/data/mods/public/simulation/components/Attack.js
@@ -57,10 +57,10 @@
"" +
"44.0" +
"20.0" +
- "15.0" +
+ "15.0" +
"800" +
"1600" +
- "1000" +
+ "1000" +
"" +
"" +
"Cavalry" +
@@ -115,7 +115,7 @@
"" +
"" +
""+
- "" +
+ "" +
"" +
"" +
"" +
@@ -135,7 +135,7 @@
"" +
"" +
"" +
- "" +
+ "" +
"" +
"" +
"" +
@@ -434,10 +434,8 @@
let min = +(this.template[type].MinRange || 0);
min = ApplyValueModificationsToEntity("Attack/" + type + "/MinRange", min, this.entity);
- let elevationBonus = +(this.template[type].ElevationBonus || 0);
- elevationBonus = ApplyValueModificationsToEntity("Attack/" + type + "/ElevationBonus", elevationBonus, this.entity);
-
- return { "max": max, "min": min, "elevationBonus": elevationBonus };
+ const attackHeight = ApplyValueModificationsToEntity("Attack/" + type + "/AttackHeight", +(this.template[type].AttackHeight || 0), this.entity);
+ return { "max": max, "min": min, "attackHeight": attackHeight };
};
/**
@@ -600,7 +598,7 @@
"target": target,
};
- let delay = +(this.template[type].Delay || 0);
+ let delay = +(this.template[type].EffectDelay || 0);
if (this.template[type].Projectile)
{
@@ -729,7 +727,7 @@
let positionSelf = cmpPositionSelf.GetPosition();
let positionTarget = cmpPositionTarget.GetPosition();
- let heightDifference = positionSelf.y + range.elevationBonus - positionTarget.y;
+ let heightDifference = positionSelf.y + range.attackHeight - positionTarget.y;
range.max = Math.sqrt(Math.square(range.max) + 2 * range.max * heightDifference);
if (range.max < 0)
Index: binaries/data/mods/public/simulation/components/BuildingAI.js
===================================================================
--- binaries/data/mods/public/simulation/components/BuildingAI.js
+++ binaries/data/mods/public/simulation/components/BuildingAI.js
@@ -126,7 +126,7 @@
var range = cmpAttack.GetRange(attackType);
// This takes entity sizes into accounts, so no need to compensate for structure size.
this.enemyUnitsQuery = cmpRangeManager.CreateActiveParabolicQuery(
- this.entity, range.min, range.max, range.elevationBonus,
+ this.entity, range.min, range.max, range.attackHeight,
enemies, IID_Resistance, cmpRangeManager.GetEntityFlagMask("normal"));
cmpRangeManager.EnableActiveQuery(this.enemyUnitsQuery);
@@ -156,7 +156,7 @@
// This query is only interested in Gaia entities that can attack.
// This takes entity sizes into accounts, so no need to compensate for structure size.
this.gaiaUnitsQuery = cmpRangeManager.CreateActiveParabolicQuery(
- this.entity, range.min, range.max, range.elevationBonus,
+ this.entity, range.min, range.max, range.attackHeight,
[0], IID_Attack, cmpRangeManager.GetEntityFlagMask("normal"));
cmpRangeManager.EnableActiveQuery(this.gaiaUnitsQuery);
@@ -348,7 +348,7 @@
{
// Parabolic range compuation is the same as in UnitAI's MoveToTargetAttackRange.
// h is positive when I'm higher than the target.
- let h = s.y - targetCmpPosition.GetPosition().y + range.elevationBonus;
+ let h = s.y - targetCmpPosition.GetPosition().y + range.attackHeight;
if (h > -range.max / 2 && cmpObstructionManager.IsInTargetRange(
this.entity,
selectedTarget,
Index: binaries/data/mods/public/simulation/components/GuiInterface.js
===================================================================
--- binaries/data/mods/public/simulation/components/GuiInterface.js
+++ binaries/data/mods/public/simulation/components/GuiInterface.js
@@ -467,6 +467,7 @@
let range = cmpAttack.GetRange(type);
ret.attack[type].minRange = range.min;
ret.attack[type].maxRange = range.max;
+ ret.attack[type].attackHeight = range.attackHeight;
let timers = cmpAttack.GetTimers(type);
ret.attack[type].prepareTime = timers.prepare;
@@ -474,14 +475,10 @@
if (type != "Ranged")
{
- // Not a ranged attack, set some defaults.
- ret.attack[type].elevationBonus = 0;
ret.attack[type].elevationAdaptedRange = ret.attack.maxRange;
continue;
}
- ret.attack[type].elevationBonus = range.elevationBonus;
-
if (cmpPosition && cmpPosition.IsInWorld())
// For units, take the range in front of it, no spread, so angle = 0,
// else, take the average elevation around it: angle = 2 * pi.
@@ -608,10 +605,10 @@
"z": cmd.z
};
- let elevationBonus = cmd.elevationBonus || 0;
+ const attackHeight = cmd.attackHeight || 0;
let range = cmd.range;
- return cmpRangeManager.GetElevationAdaptedRange(pos, rot, range, elevationBonus, 2 * Math.PI);
+ return cmpRangeManager.GetElevationAdaptedRange(pos, rot, range, attackHeight, 2 * Math.PI);
};
GuiInterface.prototype.GetTemplateData = function(player, data)
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
@@ -4661,7 +4661,7 @@
// Parabolic range compuation is the same as in BuildingAI's FireArrows.
let t = targetCmpPosition.GetPosition();
// h is positive when I'm higher than the target
- let h = s.y - t.y + range.elevationBonus;
+ let h = s.y - t.y + range.attackHeight;
let parabolicMaxRange = Math.sqrt(Math.square(range.max) + 2 * range.max * h);
// No negative roots please
@@ -6130,7 +6130,7 @@
* @param {string} type - [Optional]
* @return {Object | undefined} - The range in the form
* { "min": number, "max": number }
- * Object."elevationBonus": number may be present when iid == IID_Attack.
+ * Object."attackHeight": number may be present when iid == IID_Attack.
* Returns undefined when the entity does not have the requested component.
*/
UnitAI.prototype.GetRange = function(iid, type, target)
Index: binaries/data/mods/public/simulation/components/tests/test_Damage.js
===================================================================
--- binaries/data/mods/public/simulation/components/tests/test_Damage.js
+++ binaries/data/mods/public/simulation/components/tests/test_Damage.js
@@ -44,7 +44,7 @@
},
"MaxRange": 50,
"MinRange": 0,
- "Delay": 0,
+ "EffectDelay": 0,
"Projectile": {
"Speed": 75.0,
"Spread": 0.5,