diff --git a/binaries/data/mods/public/simulation/components/Attack.js b/binaries/data/mods/public/simulation/components/Attack.js index 8fc5dc560a..6cbc4ce5d3 100644 --- a/binaries/data/mods/public/simulation/components/Attack.js +++ b/binaries/data/mods/public/simulation/components/Attack.js @@ -345,6 +345,8 @@ Attack.prototype.GetFullAttackRange = function() Attack.prototype.GetAttackEffectsData = function(type, splash) { let template = this.template[type]; + if (!template) + return undefined; if (splash) template = template.Splash; return AttackHelper.GetAttackEffectsData("Attack/" + type + (splash ? "/Splash" : ""), template, this.entity); diff --git a/binaries/data/mods/public/simulation/components/Capturable.js b/binaries/data/mods/public/simulation/components/Capturable.js index 41ffc2e766..8a431afd4c 100644 --- a/binaries/data/mods/public/simulation/components/Capturable.js +++ b/binaries/data/mods/public/simulation/components/Capturable.js @@ -7,7 +7,7 @@ Capturable.prototype.Schema = "" + "" + "" + - "" + + "" + "" + ""; @@ -182,11 +182,22 @@ Capturable.prototype.RegisterCapturePointsChanged = function() Capturable.prototype.GetRegenRate = function() { - let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder); + const cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder); if (!cmpGarrisonHolder) return this.regenRate; - return this.regenRate + this.GetGarrisonRegenRate() * cmpGarrisonHolder.GetEntities().length; + let total = this.regenRate; + const garrisonRegenRate = this.GetGarrisonRegenRate(); + for (const entity of cmpGarrisonHolder.GetEntities()) + { + const captureStrength = Engine.QueryInterface(entity, IID_Attack)?.GetAttackEffectsData("Capture")?.Capture; + if (!captureStrength) + continue; + + total += captureStrength * garrisonRegenRate; + } + + return total; }; Capturable.prototype.TimerTick = function() diff --git a/binaries/data/mods/public/simulation/components/tests/test_Capturable.js b/binaries/data/mods/public/simulation/components/tests/test_Capturable.js index 6136292993..2912879141 100644 --- a/binaries/data/mods/public/simulation/components/tests/test_Capturable.js +++ b/binaries/data/mods/public/simulation/components/tests/test_Capturable.js @@ -14,13 +14,18 @@ var testData = { "playerID": 1, "regenRate": 2, "garrisonedEntities": [30, 31, 32, 33], - "garrisonRegenRate": 5, + "garrisonRegenRate": 2, "decay": false, "decayRate": 30, "maxCapturePoints": 3000, "neighbours": [20, 0, 20, 10] }; +const testCaptureAttacks = { + "30": 1.5, + "32": 2.0 +}; + function testCapturable(testData, test_function) { ResetState(); @@ -81,7 +86,20 @@ function testCapturable(testData, test_function) "GetConnectedNeighbours": () => testData.neighbours }); - TS_ASSERT_EQUALS(cmpCapturable.GetRegenRate(), testData.regenRate + testData.garrisonRegenRate * testData.garrisonedEntities.length); + let regenRate = testData.regenRate; + for (const entity of testData.garrisonedEntities) + { + if (testCaptureAttacks[entity] === undefined) + continue; + AddMock(entity, IID_Attack, { + "GetAttackEffectsData": (type) => { + return type === "Capture" ? { "Capture": testCaptureAttacks[entity] } : undefined; + }, + }); + regenRate += testCaptureAttacks[entity] * testData.garrisonRegenRate; + } + + TS_ASSERT_EQUALS(cmpCapturable.GetRegenRate(), regenRate); test_function(cmpCapturable); Engine.PostMessage = (ent, iid, message) => {}; } @@ -142,13 +160,13 @@ function testRegen(testData, capturePointsIn, capturePointsOut, regenerating) }); } -// With our testData, the total regen rate is 22. That should be taken from the ennemies -testRegen(testData, [12, 2950, 2, 36], [1, 2972, 2, 25], true); +// With our testData, the total regen rate is 9. That should be taken from the enemies +testRegen(testData, [12, 2950, 2, 36], [7.5, 2959, 2, 31.5], true); testRegen(testData, [0, 2994, 2, 4], [0, 2998, 2, 0], true); testRegen(testData, [0, 2998, 2, 0], [0, 2998, 2, 0], false); // If the regeneration rate becomes negative, capture points are given in favour of gaia -testData.regenRate = -32; +testData.regenRate = -19; // With our testData, the total regen rate is -12. That should be taken from all players to gaia testRegen(testData, [100, 2800, 50, 50], [112, 2796, 46, 46], true); testData.regenRate = 2; @@ -167,6 +185,8 @@ function testDecay(testData, capturePointsIn, capturePointsOut) }); } testData.decay = true; +testData.regenRate = 8; +testData.garrisonRegenRate = 4; // With our testData, the decay rate is 30, that should be given to all neighbours with weights [20/50, 0, 20/50, 10/50], then it regens. testDecay(testData, [2900, 35, 10, 55], [2901, 27, 22, 50]); testData.decay = false; diff --git a/binaries/data/mods/public/simulation/data/auras/units/heroes/hero_garrison.json b/binaries/data/mods/public/simulation/data/auras/units/heroes/hero_garrison.json index a7b124ff5c..6ec252a0a2 100644 --- a/binaries/data/mods/public/simulation/data/auras/units/heroes/hero_garrison.json +++ b/binaries/data/mods/public/simulation/data/auras/units/heroes/hero_garrison.json @@ -2,8 +2,8 @@ "type": "garrison", "affects": ["Structure"], "modifications": [ - { "value": "Capturable/GarrisonRegenRate", "add": 2 } + { "value": "Capturable/GarrisonRegenRate", "add": 1 } ], "auraName": "Inspired Defense", - "auraDescription": "When garrisoned, the Structure has +2 capture points garrison regeneration rate." + "auraDescription": "When garrisoned, the Structure has +1 capture points garrison regeneration rate." } diff --git a/binaries/data/mods/public/simulation/data/technologies/phase_city_athen.json b/binaries/data/mods/public/simulation/data/technologies/phase_city_athen.json index 7096545acb..9d3c61b3ad 100644 --- a/binaries/data/mods/public/simulation/data/technologies/phase_city_athen.json +++ b/binaries/data/mods/public/simulation/data/technologies/phase_city_athen.json @@ -19,9 +19,9 @@ "replaces": ["phase_city"], "icon": "city_phase.png", "researchTime": 60, - "tooltip": "Advance to City Phase, which unlocks more entities and technologies. Civic Centers +50% territory influence radius. Structures +9 capture points regeneration rate per garrisoned unit. Workers +10% metal gather rate.", + "tooltip": "Advance to City Phase, which unlocks more entities and technologies. Civic Centers +50% territory influence radius. Structures +1 capture points regeneration rate for garrisoned units. Workers +10% metal gather rate.", "modifications": [ - { "value": "Capturable/GarrisonRegenRate", "add": 9, "affects": "Structure" }, + { "value": "Capturable/GarrisonRegenRate", "add": 1, "affects": "Structure" }, { "value": "ResourceGatherer/Rates/metal.ore", "multiply": 1.1, "affects": "Worker" }, { "value": "TerritoryInfluence/Radius", "multiply": 1.5, "affects": "CivCentre" } ], diff --git a/binaries/data/mods/public/simulation/data/technologies/phase_city_generic.json b/binaries/data/mods/public/simulation/data/technologies/phase_city_generic.json index 430c4b08fc..cd0080c480 100644 --- a/binaries/data/mods/public/simulation/data/technologies/phase_city_generic.json +++ b/binaries/data/mods/public/simulation/data/technologies/phase_city_generic.json @@ -23,9 +23,9 @@ "replaces": ["phase_city"], "icon": "city_phase.png", "researchTime": 60, - "tooltip": "Advance to City Phase, which unlocks more entities and technologies. Civic Centers +50% territory influence radius. Structures +9 capture points regeneration rate per garrisoned unit.", + "tooltip": "Advance to City Phase, which unlocks more entities and technologies. Civic Centers +50% territory influence radius. Structures +1 capture points regeneration rate for garrisoned units.", "modifications": [ - { "value": "Capturable/GarrisonRegenRate", "add": 9, "affects": "Structure" }, + { "value": "Capturable/GarrisonRegenRate", "add": 1, "affects": "Structure" }, { "value": "TerritoryInfluence/Radius", "multiply": 1.5, "affects": "CivCentre" } ], "soundComplete": "interface/alarm/alarm_phase.xml" diff --git a/binaries/data/mods/public/simulation/data/technologies/phase_city_pers.json b/binaries/data/mods/public/simulation/data/technologies/phase_city_pers.json index 08020a749c..95927afa4e 100644 --- a/binaries/data/mods/public/simulation/data/technologies/phase_city_pers.json +++ b/binaries/data/mods/public/simulation/data/technologies/phase_city_pers.json @@ -16,9 +16,9 @@ "replaces": ["phase_city"], "icon": "city_phase.png", "researchTime": 60, - "tooltip": "Advance to City Phase, which unlocks more entities and technologies. Civic Centers +50% territory influence radius. Structures +9 capture points regeneration rate per garrisoned unit. Stable −10% batch training time.", + "tooltip": "Advance to City Phase, which unlocks more entities and technologies. Civic Centers +50% territory influence radius. Structures +1 capture points regeneration rate for garrisoned units. Stable −10% batch training time.", "modifications": [ - { "value": "Capturable/GarrisonRegenRate", "add": 9, "affects": "Structure" }, + { "value": "Capturable/GarrisonRegenRate", "add": 1, "affects": "Structure" }, { "value": "Trainer/BatchTimeModifier", "add": -0.1, "affects": "Stable" }, { "value": "TerritoryInfluence/Radius", "multiply": 1.5, "affects": "CivCentre" } ], diff --git a/binaries/data/mods/public/simulation/data/technologies/phase_town_athen.json b/binaries/data/mods/public/simulation/data/technologies/phase_town_athen.json index 8a7b4709eb..091caad371 100644 --- a/binaries/data/mods/public/simulation/data/technologies/phase_town_athen.json +++ b/binaries/data/mods/public/simulation/data/technologies/phase_town_athen.json @@ -19,9 +19,9 @@ "replaces": ["phase_town"], "icon": "town_phase.png", "researchTime": 30, - "tooltip": "Advance to Town Phase, which unlocks more entities and technologies. Civic Centers +30% territory influence radius. Structures +7 capture points regeneration rate per garrisoned unit. Workers +10% metal gather rate.", + "tooltip": "Advance to Town Phase, which unlocks more entities and technologies. Civic Centers +30% territory influence radius. Structures +0.5 capture points regeneration rate for garrisoned units. Workers +10% metal gather rate.", "modifications": [ - { "value": "Capturable/GarrisonRegenRate", "add": 7, "affects": "Structure" }, + { "value": "Capturable/GarrisonRegenRate", "add": 0.5, "affects": "Structure" }, { "value": "ResourceGatherer/Rates/metal.ore", "multiply": 1.1, "affects": "Worker" }, { "value": "TerritoryInfluence/Radius", "multiply": 1.3, "affects": "CivCentre" } ], diff --git a/binaries/data/mods/public/simulation/data/technologies/phase_town_generic.json b/binaries/data/mods/public/simulation/data/technologies/phase_town_generic.json index aaf5c7bc24..262357a650 100644 --- a/binaries/data/mods/public/simulation/data/technologies/phase_town_generic.json +++ b/binaries/data/mods/public/simulation/data/technologies/phase_town_generic.json @@ -23,9 +23,9 @@ "replaces": ["phase_town"], "icon": "town_phase.png", "researchTime": 30, - "tooltip": "Advance to Town Phase, which unlocks more entities and technologies. Civic Centers +30% territory influence radius. Structures +7 capture points regeneration rate per garrisoned unit.", + "tooltip": "Advance to Town Phase, which unlocks more entities and technologies. Civic Centers +30% territory influence radius. Structures +0.5 capture points regeneration rate for garrisoned units.", "modifications": [ - { "value": "Capturable/GarrisonRegenRate", "add": 7, "affects": "Structure" }, + { "value": "Capturable/GarrisonRegenRate", "add": 0.5, "affects": "Structure" }, { "value": "TerritoryInfluence/Radius", "multiply": 1.3, "affects": "CivCentre" } ], "soundComplete": "interface/alarm/alarm_phase.xml" diff --git a/binaries/data/mods/public/simulation/data/technologies/phase_town_pers.json b/binaries/data/mods/public/simulation/data/technologies/phase_town_pers.json index c5fe7a3173..89061dff17 100644 --- a/binaries/data/mods/public/simulation/data/technologies/phase_town_pers.json +++ b/binaries/data/mods/public/simulation/data/technologies/phase_town_pers.json @@ -16,9 +16,9 @@ "replaces": ["phase_town"], "icon": "town_phase.png", "researchTime": 30, - "tooltip": "Advance to Town Phase, which unlocks more entities and technologies. Civic Centers +30% territory influence radius. Structures +7 capture points regeneration rate per garrisoned unit. Stable −10% batch training time.", + "tooltip": "Advance to Town Phase, which unlocks more entities and technologies. Civic Centers +30% territory influence radius. Structures +0.5 capture points regeneration rate for garrisoned units. Stable −10% batch training time.", "modifications": [ - { "value": "Capturable/GarrisonRegenRate", "add": 7, "affects": "Structure" }, + { "value": "Capturable/GarrisonRegenRate", "add": 0.5, "affects": "Structure" }, { "value": "Trainer/BatchTimeModifier", "add": -0.1, "affects": "Stable" }, { "value": "TerritoryInfluence/Radius", "multiply": 1.3, "affects": "CivCentre" } ], diff --git a/binaries/data/mods/public/simulation/templates/structures/cart/super_dock.xml b/binaries/data/mods/public/simulation/templates/structures/cart/super_dock.xml index c6cb7cde2d..69817f5f80 100644 --- a/binaries/data/mods/public/simulation/templates/structures/cart/super_dock.xml +++ b/binaries/data/mods/public/simulation/templates/structures/cart/super_dock.xml @@ -10,7 +10,7 @@ 4 - 10 + 2 500 diff --git a/binaries/data/mods/public/simulation/templates/structures/rome/army_camp.xml b/binaries/data/mods/public/simulation/templates/structures/rome/army_camp.xml index 14d8d0e9f7..b12db1a931 100644 --- a/binaries/data/mods/public/simulation/templates/structures/rome/army_camp.xml +++ b/binaries/data/mods/public/simulation/templates/structures/rome/army_camp.xml @@ -41,7 +41,7 @@ 3 10.0 - 3.0 + 1 250 diff --git a/binaries/data/mods/public/simulation/templates/structures/tent_arab.xml b/binaries/data/mods/public/simulation/templates/structures/tent_arab.xml index 0c455767da..10c7476c96 100644 --- a/binaries/data/mods/public/simulation/templates/structures/tent_arab.xml +++ b/binaries/data/mods/public/simulation/templates/structures/tent_arab.xml @@ -6,7 +6,7 @@ 25 0 - 5 + 1 20 diff --git a/binaries/data/mods/public/simulation/templates/structures/tent_bedouin.xml b/binaries/data/mods/public/simulation/templates/structures/tent_bedouin.xml index c9ec53b0ef..81af123d96 100644 --- a/binaries/data/mods/public/simulation/templates/structures/tent_bedouin.xml +++ b/binaries/data/mods/public/simulation/templates/structures/tent_bedouin.xml @@ -6,7 +6,7 @@ 25 0 - 5 + 1 20 diff --git a/binaries/data/mods/public/simulation/templates/structures/tent_desert.xml b/binaries/data/mods/public/simulation/templates/structures/tent_desert.xml index 62b58a6e39..553da53a50 100644 --- a/binaries/data/mods/public/simulation/templates/structures/tent_desert.xml +++ b/binaries/data/mods/public/simulation/templates/structures/tent_desert.xml @@ -1,64 +1,64 @@ - - - - own neutral enemy - - - 25 - 0 - 5 - - - 20 - - 50 - - - - - 5.0 - - - 5 - 0.1 - Unit - Support Infantry - 0 - 2 - - - 100 - decay|rubble/rubble_stone_3x3 - - - ptol - Desert Army Tent - Tent - structures/mercenary_camp.png - Tent - A temporary shelter for soldiers. +5 population bonus. - - - - - - 5 - - - - - interface/complete/building/complete_universal.xml - attack/destruction/building_collapse_large.xml - - - - 6.0 - - - 1 - - - - structures/tent_big.xml - - + + + + own neutral enemy + + + 25 + 0 + 1 + + + 20 + + 50 + + + + + 5.0 + + + 5 + 0.1 + Unit + Support Infantry + 0 + 2 + + + 100 + decay|rubble/rubble_stone_3x3 + + + ptol + Desert Army Tent + Tent + structures/mercenary_camp.png + Tent + A temporary shelter for soldiers. +5 population bonus. + + + + + + 5 + + + + + interface/complete/building/complete_universal.xml + attack/destruction/building_collapse_large.xml + + + + 6.0 + + + 1 + + + + structures/tent_big.xml + + diff --git a/binaries/data/mods/public/simulation/templates/structures/tent_mace.xml b/binaries/data/mods/public/simulation/templates/structures/tent_mace.xml index 57f35565c6..64bae755d6 100644 --- a/binaries/data/mods/public/simulation/templates/structures/tent_mace.xml +++ b/binaries/data/mods/public/simulation/templates/structures/tent_mace.xml @@ -1,64 +1,64 @@ - - - - own neutral enemy - - - 25 - 0 - 5 - - - 20 - - 50 - - - - - 5.0 - - - 5 - 0.1 - Unit - Support Infantry - 0 - 2 - - - 100 - decay|rubble/rubble_stone_3x3 - - - mace - Macedonian Army Tent - Tent - structures/mercenary_camp.png - Tent - A temporary shelter for soldiers. +5 population bonus. - - - - - - 5 - - - - - interface/complete/building/complete_universal.xml - attack/destruction/building_collapse_large.xml - - - - 6.0 - - - 1 - - - - structures/tent_greek.xml - - + + + + own neutral enemy + + + 25 + 0 + 1 + + + 20 + + 50 + + + + + 5.0 + + + 5 + 0.1 + Unit + Support Infantry + 0 + 2 + + + 100 + decay|rubble/rubble_stone_3x3 + + + mace + Macedonian Army Tent + Tent + structures/mercenary_camp.png + Tent + A temporary shelter for soldiers. +5 population bonus. + + + + + + 5 + + + + + interface/complete/building/complete_universal.xml + attack/destruction/building_collapse_large.xml + + + + 6.0 + + + 1 + + + + structures/tent_greek.xml + + diff --git a/binaries/data/mods/public/simulation/templates/structures/tent_rome.xml b/binaries/data/mods/public/simulation/templates/structures/tent_rome.xml index c59ab5516e..3fb536f917 100644 --- a/binaries/data/mods/public/simulation/templates/structures/tent_rome.xml +++ b/binaries/data/mods/public/simulation/templates/structures/tent_rome.xml @@ -1,64 +1,64 @@ - - - - own neutral enemy - - - 25 - 0 - 5 - - - 20 - - 50 - - - - - 5.0 - - - 5 - 0.1 - Unit - Support Infantry - 0 - 2 - - - 100 - decay|rubble/rubble_stone_3x3 - - - rome - Roman Army Tent - Tent - structures/mercenary_camp.png - Tent - A temporary shelter for soldiers. +5 population bonus. - - - - - - 5 - - - - - interface/complete/building/complete_universal.xml - attack/destruction/building_collapse_large.xml - - - - 6.0 - - - 1 - - - - props/structures/romans/rome_tent.xml - - + + + + own neutral enemy + + + 25 + 0 + 1 + + + 20 + + 50 + + + + + 5.0 + + + 5 + 0.1 + Unit + Support Infantry + 0 + 2 + + + 100 + decay|rubble/rubble_stone_3x3 + + + rome + Roman Army Tent + Tent + structures/mercenary_camp.png + Tent + A temporary shelter for soldiers. +5 population bonus. + + + + + + 5 + + + + + interface/complete/building/complete_universal.xml + attack/destruction/building_collapse_large.xml + + + + 6.0 + + + 1 + + + + props/structures/romans/rome_tent.xml + + diff --git a/binaries/data/mods/public/simulation/templates/template_structure.xml b/binaries/data/mods/public/simulation/templates/template_structure.xml index 24f71517c4..3eea9cf8b3 100644 --- a/binaries/data/mods/public/simulation/templates/template_structure.xml +++ b/binaries/data/mods/public/simulation/templates/template_structure.xml @@ -9,7 +9,7 @@ 500 0.5 - 5.0 + 1.0 0