--- /home/albert/VirtualBox VMs/0ad/mods/ProductionQueueOld.js
+++ /home/albert/VirtualBox VMs/0ad/mods/asd
@@ -29,7 +29,20 @@
 			"</attribute>" +
 			"<text/>" +
 		"</element>" +
-	"</optional>";
+	"</optional>" +
+	"<optional>" +
+		"<element name='DirectDeployUnit'>" +
+			"<attribute name='datatype'>" +
+				"<value>tokens</value>" +
+			"</attribute>" +
+			"<text/>" +
+		"</element>" +
+	"</optional>" +
+	"<optional>" +
+		"<element name='DirectDeployCount'>" +
+			"<data type='nonNegativeInteger'/>" +
+		"</element>" +
+	"</optional>";;
 
 ProductionQueue.prototype.Init = function()
 {
@@ -67,6 +80,41 @@
 	this.spawnNotified = false;
 };
 
+ProductionQueue.prototype.OnOwnershipChanged = function(msg)
+{
+	if (msg.from == -1)
+	{
+		//Deploy units once the structure is built
+		if (this.template.DirectDeployUnit && this.template.DirectDeployCount)
+		{
+			var directDeployCount = +this.template.DirectDeployCount;
+			var directDeployUnit = this.template.DirectDeployUnit._string;
+            
+			// Replace the "{civ}" codes with this entity's civ ID
+			var cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity);
+			if (cmpIdentity)
+				directDeployUnit = directDeployUnit.replace(/\{civ\}/g, cmpIdentity.GetCiv())
+            
+			//Deploy the units
+			this.AddBatch(directDeployUnit, "directDeploy", directDeployCount, "");
+		}
+	}
+    else
+    {
+        // Unset flag that previous owner's training may be blocked
+		var cmpPlayer = QueryPlayerIDInterface(msg.from, IID_Player);
+		if (cmpPlayer && this.queue.length > 0)
+			cmpPlayer.UnBlockTraining();
+        
+        // Reset the production queue whenever the owner changes.
+        // (This should prevent players getting surprised when they capture
+        // an enemy building, and then loads of the enemy's civ's soldiers get
+        // created from it. Also it means we don't have to worry about
+        // updating the reserved pop slots.)
+        this.ResetQueue();
+    }
+};
+
 /*
  * Returns list of entities that can be trained by this building.
  */
@@ -185,7 +233,7 @@
 	if (this.queue.length < MAX_QUEUE_SIZE)
 	{
 		
-		if (type == "unit")
+		if (type == "unit" || type == "directDeploy")
 		{
 			// Find the template data so we can determine the build costs
 			var cmpTempMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
@@ -211,10 +259,6 @@
 
 			var population = +template.Cost.Population;
 
-			// TrySubtractResources should report error to player (they ran out of resources)
-			if (!cmpPlayer.TrySubtractResources(totalCosts))
-				return;
-
 			// Update entity count in the EntityLimits component
 			if (template.TrainingRestrictions)
 			{
@@ -222,19 +266,41 @@
 				var cmpPlayerEntityLimits = QueryOwnerInterface(this.entity, IID_EntityLimits);
 				cmpPlayerEntityLimits.IncreaseCount(unitCategory, count);
 			}
-
-			this.queue.push({
-				"id": this.nextID++,
-				"player": cmpPlayer.GetPlayerID(),
-				"unitTemplate": templateName,
-				"count": count,
-				"metadata": metadata,
-				"resources": costs,
-				"population": population,
-				"productionStarted": false,
-				"timeTotal": time*1000,
-				"timeRemaining": time*1000,
-			});
+            
+            if (type == "unit")
+            {
+                // TrySubtractResources should report error to player (they ran out of resources)
+                if (!cmpPlayer.TrySubtractResources(totalCosts))
+                    return;
+                
+                this.queue.push({
+				    "id": this.nextID++,
+				    "player": cmpPlayer.GetPlayerID(),
+				    "unitTemplate": templateName,
+				    "count": count,
+				    "metadata": metadata,
+				    "resources": costs,
+				    "population": population,
+				    "productionStarted": false,
+				    "timeTotal": time*1000,
+				    "timeRemaining": time*1000,
+                });
+            }
+            else if (type == "directDeploy")
+            {
+                this.queue.push({
+				    "id": this.nextID++,
+				    "player": cmpPlayer.GetPlayerID(),
+				    "unitTemplate": templateName,
+				    "count": count,
+				    "metadata": metadata,
+				    "resources": [],
+				    "population": 0,
+				    "productionStarted": false,
+				    "timeTotal": 1000,
+				    "timeRemaining": 1000,
+                });
+            }
 		}
 		else if (type == "technology")
 		{
@@ -411,24 +477,6 @@
 	return Math.pow(batchSize, batchTimeModifier) * cmpPlayer.GetCheatTimeMultiplier();
 };
 
-ProductionQueue.prototype.OnOwnershipChanged = function(msg)
-{
-	if (msg.from != -1)
-	{
-		// Unset flag that previous owner's training may be blocked
-		var cmpPlayer = QueryPlayerIDInterface(msg.from, IID_Player);
-		if (cmpPlayer && this.queue.length > 0)
-			cmpPlayer.UnBlockTraining();
-	}
-
-	// Reset the production queue whenever the owner changes.
-	// (This should prevent players getting surprised when they capture
-	// an enemy building, and then loads of the enemy's civ's soldiers get
-	// created from it. Also it means we don't have to worry about
-	// updating the reserved pop slots.)
-	this.ResetQueue();
-};
-
 ProductionQueue.prototype.OnDestroy = function()
 {
 	// Reset the queue to refund any resources
