Index: binaries/data/mods/public/simulation/components/Builder.js
===================================================================
--- binaries/data/mods/public/simulation/components/Builder.js	(revision 15407)
+++ binaries/data/mods/public/simulation/components/Builder.js	(working copy)
@@ -3,7 +3,7 @@
 Builder.prototype.Schema =
 	"<a:help>Allows the unit to construct and repair buildings.</a:help>" +
 	"<a:example>" +
-		"<Rate>1.0</Rate>" +
+		"<BuildRate>1.0</BuildRate>" +
 		"<Entities datatype='tokens'>" +
 			"\n    structures/{civ}_barracks\n    structures/{civ}_civil_centre\n    structures/celt_sb1\n  " +
 		"</Entities>" +
@@ -11,6 +11,12 @@
 	"<element name='Rate' a:help='Construction speed multiplier (1.0 is normal speed, higher values are faster)'>" +
 		"<ref name='positiveDecimal'/>" +
 	"</element>" +
+	"<optional>" +
+		"<element name='RepairRate' a:help='Repairing speed multiplier (1.0 is normal speed, higher values are faster), by default the same as the normal rate.'>" +
+			"<ref name='positiveDecimal'/>" +
+		"</element>" +
+	"</optional>" +
+
 	"<element name='Entities' a:help='Space-separated list of entity template names that this unit can build. The special string \"{civ}\" will be automatically replaced by the unit&apos;s four-character civ code. This element can also be empty, in which case no new foundations may be placed by the unit, but they can still repair existing buildings'>" +
 		"<attribute name='datatype'>" +
 			"<value>tokens</value>" +
@@ -56,12 +62,12 @@
  */
 Builder.prototype.PerformBuilding = function(target)
 {
-	var rate = ApplyValueModificationsToEntity("Builder/Rate", +this.template.Rate, this.entity);
 
 	// If it's a foundation, then build it
 	var cmpFoundation = Engine.QueryInterface(target, IID_Foundation);
 	if (cmpFoundation)
 	{
+		var rate = ApplyValueModificationsToEntity("Builder/Rate", +this.template.Rate, this.entity);
 		cmpFoundation.Build(this.entity, rate);
 		return;
 	}
@@ -68,11 +74,15 @@
 
 	// Otherwise try to repair it
 	var cmpHealth = Engine.QueryInterface(target, IID_Health);
-	if (cmpHealth)
-	{
-		cmpHealth.Repair(this.entity, rate);
+	if (!cmpHealth)
 		return;
-	}
+
+	if (this.template.RepairRate)
+		var rate = ApplyValueModificationsToEntity("Builder/RepairRate", +this.template.RepairRate, this.entity);
+	else
+		var rate = ApplyValueModificationsToEntity("Builder/Rate", +this.template.Rate, this.entity);
+
+	cmpHealth.Repair(this.entity, rate);
 };
 
 Engine.RegisterComponentType(IID_Builder, "Builder", Builder);
Index: binaries/data/mods/public/simulation/components/Cost.js
===================================================================
--- binaries/data/mods/public/simulation/components/Cost.js	(revision 15407)
+++ binaries/data/mods/public/simulation/components/Cost.js	(working copy)
@@ -22,6 +22,11 @@
 	"<element name='BuildTime' a:help='Time taken to construct/train this unit (in seconds)'>" +
 		"<ref name='nonNegativeDecimal'/>" +
 	"</element>" +
+	"<optional>" +
+		"<element name='RepairTime' a:help='Time taken to repair this unit (in seconds). By default, the max health of an entity (so it repairs at 1 HP/s)'>" +
+			"<ref name='nonNegativeDecimal'/>" +
+		"</element>" +
+	"</optional>" +
 	"<element name='Resources' a:help='Resource costs to construct/train this unit'>" +
 		"<interleave>" +
 			"<element name='food'><data type='nonNegativeInteger'/></element>" +
@@ -48,11 +53,22 @@
 
 Cost.prototype.GetBuildTime = function()
 {
+	if (!this.template.RepairTime)
+		return null;
 	var cmpPlayer = QueryOwnerInterface(this.entity, IID_Player);
 	var buildTime = (+this.template.BuildTime) * cmpPlayer.cheatTimeMultiplier;
 	return ApplyValueModificationsToEntity("Cost/BuildTime", buildTime, this.entity);
 }
 
+Cost.prototype.GetRepairTime = function()
+{
+	if (!this.template.RepairTime)
+		return null;
+	var cmpPlayer = QueryOwnerInterface(this.entity, IID_Player);
+	var repairTime = (+this.template.RepairTime) * cmpPlayer.cheatTimeMultiplier;
+	return ApplyValueModificationsToEntity("Cost/RepairTime", repairTime, this.entity);
+}
+
 Cost.prototype.GetResourceCosts = function()
 {
 	var costs = {};
Index: binaries/data/mods/public/simulation/components/Health.js
===================================================================
--- binaries/data/mods/public/simulation/components/Health.js	(revision 15407)
+++ binaries/data/mods/public/simulation/components/Health.js	(working copy)
@@ -300,7 +300,7 @@
 	return spawnedEntity;
 };
 
-Health.prototype.Repair = function(builderEnt, work)
+Health.prototype.Repair = function(builderEnt, rate)
 {
 	var damage = this.GetMaxHitpoints() - this.GetHitpoints();
 
@@ -309,6 +309,13 @@
 		return;
 
 	// Calculate the amount of hitpoints that will be added
+	var repairTime = this.GetMaxHitpoints();
+	var cmpCost = Engine.QueryInterface(this.entity, IID_Cost);
+	if (cmpCost && cmpCost.GetRepairTime())
+		repairTime = cmpCost.GetRepairTime();
+
+	var work = rate / repairTime * this.GetMaxHitpoints();
+
 	// TODO: what computation should we use?
 	// TODO: should we do some diminishing returns thing? (see Foundation.Build)
 	var amount = Math.min(damage, work);
