AlliesTrue = true
SovietsTrue = true
GDITrue = false
NODTrue = false
MonstersTrue = true
DinosTrue = false
AntsTrue = false


buildingM0 = 0
DestroyedBuildingsM0 = 0

fact0pos = CPos.New(144, 3)
weap0pos = CPos.New(139,4)
apwr0pos = CPos.New(144,10)
fix0pos = CPos.New(139,9)
dome0pos = CPos.New(135,4)

hpad0pos = CPos.New(131,4)
barr0pos = CPos.New(129,9)

afld0pos = CPos.New(133,9)
tent0pos = CPos.New(127,4)
kenn0pos = CPos.New(126,10)

weapcnc0pos = CPos.New(120,4)
pyle0pos = CPos.New(116,4)

afldcnc0pos = CPos.New(120,9)
hand0pos = CPos.New(116,9)

hpadnod0pos = CPos.New(112,4)

bio0pos = CPos.New(123,9)

monsteregg0pos = CPos.New(107,9)

anthill0pos = CPos.New(107,4)
queen0pos = CPos.New(100,4)
NukePositions = { CPos.New(135,15), CPos.New(135,70) }


RaBaseM0 = function()
--	if Difficulty ~= "easy" then
		newEnemyfact0 = Actor.Create("fact", true, { Location = fact0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyfact0, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyfact0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			factKilled0 = true end)
		newEnemyweap0 = Actor.Create("weap", true, { Location = weap0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyweap0, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyweap0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			weapKilled0 = true end)
		buildingM0 = buildingM0 + 2
--	end
	if Difficulty ~= "easy" then
		newEnemyapwr0 = Actor.Create("much.apwr", true, { Location = apwr0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyapwr0, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyapwr0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			apwrKilled0 = true end)
		newEnemyfix0 = Actor.Create("fix", true, { Location = fix0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyfix0, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyfix0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1	
			fixKilled0 = true end)
		newEnemydome0 = Actor.Create("dome", true, { Location = dome0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemydome0, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemydome0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			domeKilled0 = true end)	
		buildingM0 = buildingM0 + 3
	end

	if AlliesTrue then
	
		newEnemyhpad0 = Actor.Create("hpad", true, { Location = hpad0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyhpad0, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyhpad0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			hpadKilled0 = true end)
		newEnemybarr0 = Actor.Create("barr", true, { Location = barr0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemybarr0, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemybarr0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			barrKilled0 = true end)
		buildingM0 = buildingM0 + 2
	end
	
	if SovietsTrue then
		
		newEnemyafld0 = Actor.Create("afld", true, { Location = afld0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyafld0, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyafld0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			afldKilled0 = true end)
		newEnemytent0 = Actor.Create("tent", true, { Location = tent0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemytent0, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemytent0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			tentKilled0 = true end)
		newEnemykenn0 = Actor.Create("kenn", true, { Location = kenn0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemykenn0, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemykenn0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			kennKilled0 = true end)
		buildingM0 = buildingM0 + 3
	end
	


	if GDITrue then
		newEnemyweapcnc0 = Actor.Create("weapcnc", true, { Location = weapcnc0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyweapcnc0, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyweapcnc0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			weapcncKilled0 = true end)
		newEnemypyle0 = Actor.Create("pyle", true, { Location = pyle0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemypyle0, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemypyle0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			pyleKilled0 = true end)
		buildingM0 = buildingM0 + 2
	end
	if NODTrue then
		newEnemyafldcnc0 = Actor.Create("afldcnc", true, { Location = afldcnc0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyafldcnc0, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyafldcnc0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			afldcncKilled0 = true end)
		newEnemyhand0 = Actor.Create("hand", true, { Location = hand0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyhand0, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyhand0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			handKilled0 = true end)
		buildingM0 = buildingM0 + 2
	end

	if GDITrue or NODTrue then
		newEnemyhpadnod0 = Actor.Create("hpadnod", true, { Location = hpadnod0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyhpadnod0, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyhpadnod0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			hpadnodKilled0 = true end)
		buildingM0 = buildingM0 + 1
	end

	if MonstersTrue then
		newEnemybio0 = Actor.Create("bio", true, { Location = bio0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnKilledOrCaptured(newEnemybio0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			bioKilled0 = true
			BioCount = BioCount - 1	end)
		buildingM0 = buildingM0 + 1
		BioCount = BioCount + 1
	end

	if DinosTrue then
		newEnemymonsteregg0 = Actor.Create("monsteregg", true, { Location = monsteregg0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
	end

	if AntsTrue then
		newEnemyanthill0 = Actor.Create("anthill", true, { Location = anthill0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnKilledOrCaptured(newEnemyanthill0, function() DestroyedBuildingsM0 = DestroyedBuildingsM0 + 1
			anthillKilled0 = true end)
		buildingM0 = buildingM0 + 1
		newEnemyqueen0 = Actor.Create("queen", true, { Location = queen0pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
	end
end




EnemyDefenseMakerM0 = function()

end
buildingM1 = 0
DestroyedBuildingsM1 = 0

fact1pos = CPos.New(144,32)
weap1pos = CPos.New(139,33)
apwr1pos = CPos.New(144,40)
fix1pos = CPos.New(139,38)
dome1pos = CPos.New(135,33)

hpad1pos = CPos.New(131,33)
barr1pos = CPos.New(129,38)

afld1pos = CPos.New(133,38)
tent1pos = CPos.New(127,33)
kenn1pos = CPos.New(126,40)

weapcnc1pos = CPos.New(120,33)
pyle1pos = CPos.New(116,33)

afldcnc1pos = CPos.New(120,38)
hand1pos = CPos.New(116,38)

hpadnod1pos = CPos.New(112,33)

bio1pos = CPos.New(123,38)

monsteregg1pos = CPos.New(107,38)

anthill1pos = CPos.New(107,33)
queen1pos = CPos.New(101,33)



RaBaseM1 = function()
--	if Difficulty ~= "easy" then
		newEnemyfact1 = Actor.Create("fact", true, { Location = fact1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyfact1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyfact1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			factKilled1 = true end)
		newEnemyweap1 = Actor.Create("weap", true, { Location = weap1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyweap1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyweap1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			weapKilled1 = true end)
		buildingM1 = buildingM1 + 2
--	end
	if Difficulty ~= "easy" then
		newEnemyapwr1 = Actor.Create("much.apwr", true, { Location = apwr1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyapwr1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyapwr1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			apwrKilled1 = true end)
		newEnemyfix1 = Actor.Create("fix", true, { Location = fix1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyfix1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyfix1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1	
			fixKilled1 = true end)
		newEnemydome1 = Actor.Create("dome", true, { Location = dome1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemydome1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemydome1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			domeKilled1 = true end)
		buildingM1 = buildingM1 + 3
	end

	if AlliesTrue then
	
		newEnemyhpad1 = Actor.Create("hpad", true, { Location = hpad1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyhpad1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyhpad1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			hpadKilled1 = true end)
		newEnemybarr1 = Actor.Create("barr", true, { Location = barr1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemybarr1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemybarr1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			barrKilled1 = true end)
		buildingM1 = buildingM1 + 2
	end
	
	if SovietsTrue then
		
		newEnemyafld1 = Actor.Create("afld", true, { Location = afld1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyafld1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyafld1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			afldKilled1 = true end)
		newEnemytent1 = Actor.Create("tent", true, { Location = tent1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemytent1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemytent1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			tentKilled1 = true end)
		newEnemykenn1 = Actor.Create("kenn", true, { Location = kenn1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemykenn1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemykenn1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			kennKilled1 = true end)
		buildingM1 = buildingM1 + 3
	end
	


	if GDITrue then
		newEnemyweapcnc1 = Actor.Create("weapcnc", true, { Location = weapcnc1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyweapcnc1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyweapcnc1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			weapcncKilled1 = true end)
		newEnemypyle1 = Actor.Create("pyle", true, { Location = pyle1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemypyle1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemypyle1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			pyleKilled1 = true end)
		buildingM1 = buildingM1 + 2
	end
	if NODTrue then
		newEnemyafldcnc1 = Actor.Create("afldcnc", true, { Location = afldcnc1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyafldcnc1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyafldcnc1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			afldcncKilled1 = true end)
		newEnemyhand1 = Actor.Create("hand", true, { Location = hand1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyhand1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyhand1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			handKilled1 = true end)
		buildingM1 = buildingM1 + 2
	end

	if GDITrue or NODTrue then
		newEnemyhpadnod1 = Actor.Create("hpadnod", true, { Location = hpadnod1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyhpadnod1, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyhpadnod1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			hpadnodKilled1 = true end)
		buildingM1 = buildingM1 + 1
	end

	if MonstersTrue then
		newEnemybio1 = Actor.Create("bio", true, { Location = bio1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnKilledOrCaptured(newEnemybio1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			bioKilled1 = true
			BioCount = BioCount - 1	end)
		buildingM1 = buildingM1 + 1
		BioCount = BioCount + 1
	end

	if DinosTrue then
		newEnemymonsteregg1 = Actor.Create("monsteregg", true, { Location = monsteregg1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
	end

	if AntsTrue then
		newEnemyanthill1 = Actor.Create("anthill", true, { Location = anthill1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnKilledOrCaptured(newEnemyanthill1, function() DestroyedBuildingsM1 = DestroyedBuildingsM1 + 1
			anthillKilled1 = true end)
		buildingM1 = buildingM1 + 1
		newEnemyqueen1 = Actor.Create("queen", true, { Location = queen1pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
	end
end




EnemyDefenseMakerM1 = function()

end

buildingM2 = 0
DestroyedBuildingsM2 = 0

fact2pos = CPos.New(144, 46)
weap2pos = CPos.New(139,47)
apwr2pos = CPos.New(144,53)
fix2pos = CPos.New(139,52)
dome2pos = CPos.New(135,47)

hpad2pos = CPos.New(131,47)
barr2pos = CPos.New(129,52)

afld2pos = CPos.New(133,52)
tent2pos = CPos.New(127,47)
kenn2pos = CPos.New(126,53)

weapcnc2pos = CPos.New(120,47)
pyle2pos = CPos.New(116,47)

afldcnc2pos = CPos.New(120,52)
hand2pos = CPos.New(116,52)

hpadnod2pos = CPos.New(112,47)

bio2pos = CPos.New(123,52)

monsteregg2pos = CPos.New(107,52)

anthill2pos = CPos.New(107,47)
queen2pos = CPos.New(100,47)



RaBaseM2 = function()
--	if Difficulty ~= "easy" then
		newEnemyfact2 = Actor.Create("fact", true, { Location = fact2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyfact2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyfact2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			factKilled2 = true end)
		newEnemyweap2 = Actor.Create("weap", true, { Location = weap2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyweap2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyweap2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			weapKilled2 = true end)
		buildingM2 = buildingM2 + 2
--	end
	if Difficulty ~= "easy" then
		newEnemyapwr2 = Actor.Create("much.apwr", true, { Location = apwr2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyapwr2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyapwr2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			apwrKilled2 = true end)
		newEnemyfix2 = Actor.Create("fix", true, { Location = fix2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyfix2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyfix2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			fixKilled2 = true end)
		newEnemydome2 = Actor.Create("dome", true, { Location = dome2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemydome2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemydome2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			domeKilled2 = true end)
		buildingM2 = buildingM2 + 3
	end

	if AlliesTrue then
	
		newEnemyhpad2 = Actor.Create("hpad", true, { Location = hpad2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyhpad2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyhpad2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			hpadKilled2 = true end)
		newEnemybarr2 = Actor.Create("barr", true, { Location = barr2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemybarr2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemybarr2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			barrKilled2 = true end)
		buildingM2 = buildingM2 + 2
	end
	
	if SovietsTrue then
		
		newEnemyafld2 = Actor.Create("afld", true, { Location = afld2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyafld2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyafld2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			afldKilled2 = true end)
		newEnemytent2 = Actor.Create("tent", true, { Location = tent2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemytent2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemytent2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			tentKilled2 = true end)
		newEnemykenn2 = Actor.Create("kenn", true, { Location = kenn2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemykenn2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemykenn2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			kennKilled2 = true end)
		buildingM2 = buildingM2 + 3
	end
	


	if GDITrue then
		newEnemyweapcnc2 = Actor.Create("weapcnc", true, { Location = weapcnc2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyweapcnc2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyweapcnc2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			weapcncKilled2 = true end)
		newEnemypyle2 = Actor.Create("pyle", true, { Location = pyle2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemypyle2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemypyle2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			pyleKilled2 = true end)
		buildingM2 = buildingM2 + 2
	end
	if NODTrue then
		newEnemyafldcnc2 = Actor.Create("afldcnc", true, { Location = afldcnc2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyafldcnc2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyafldcnc2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			afldcncKilled2 = true end)
		newEnemyhand2 = Actor.Create("hand", true, { Location = hand2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyhand2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyhand2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			handKilled2 = true end)
		buildingM2 = buildingM2 + 2
	end

	if GDITrue or NODTrue then
		newEnemyhpadnod2 = Actor.Create("hpadnod", true, { Location = hpadnod2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyhpadnod2, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyhpadnod2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			hpadnodKilled2 = true end)
		buildingM2 = buildingM2 + 1
	end

	if MonstersTrue then
		newEnemybio2 = Actor.Create("bio", true, { Location = bio2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnKilledOrCaptured(newEnemybio2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			bioKilled2 = true
			BioCount = BioCount - 1	end)
		buildingM2 = buildingM2 + 1
		BioCount = BioCount + 1
	end

	if DinosTrue then
		newEnemymonsteregg2 = Actor.Create("monsteregg", true, { Location = monsteregg2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
	end

	if AntsTrue then
		newEnemyanthill2 = Actor.Create("anthill", true, { Location = anthill2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnKilledOrCaptured(newEnemyanthill2, function() DestroyedBuildingsM2 = DestroyedBuildingsM2 + 1
			anthillKilled2 = true end)
		buildingM2 = buildingM2 + 1
		newEnemyqueen2 = Actor.Create("queen", true, { Location = queen2pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
	end
end


buildingM3 = 0
DestroyedBuildingsM3 = 0

fact3pos = CPos.New(144, 60)
weap3pos = CPos.New(139,61)
apwr3pos = CPos.New(144,67)
fix3pos = CPos.New(139,66)
dome3pos = CPos.New(135,61)

hpad3pos = CPos.New(131,61)
barr3pos = CPos.New(129,66)

afld3pos = CPos.New(133,66)
tent3pos = CPos.New(127,61)
kenn3pos = CPos.New(126,67)

weapcnc3pos = CPos.New(120,61)
pyle3pos = CPos.New(116,61)

afldcnc3pos = CPos.New(120,66)
hand3pos = CPos.New(116,66)

hpadnod3pos = CPos.New(112,61)

bio3pos = CPos.New(123,66)

monsteregg3pos = CPos.New(107,66)

anthill3pos = CPos.New(107,61)
queen3pos = CPos.New(100,61)



RaBaseM3 = function()
--	if Difficulty ~= "easy" then
		newEnemyfact3 = Actor.Create("fact", true, { Location = fact3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyfact3, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyfact3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			factKilled3 = true end)
		newEnemyweap3 = Actor.Create("weap", true, { Location = weap3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyweap3, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyweap3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			weapKilled3 = true end)
		buildingM3 = buildingM3 + 2
--	end
	if Difficulty ~= "easy" then
		newEnemyapwr3 = Actor.Create("much.apwr", true, { Location = apwr3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyapwr3, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyapwr3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			apwrKilled3 = true end)
		newEnemyfix3 = Actor.Create("fix", true, { Location = fix3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyfix3, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyfix3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			fixKilled3 = true end)
		newEnemydome3 = Actor.Create("dome", true, { Location = dome3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemydome3, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemydome3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			domeKilled3 = true end)
		buildingM3 = buildingM3 + 3
	end

	if AlliesTrue then
	
		newEnemyhpad3 = Actor.Create("hpad", true, { Location = hpad3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyhpad3, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyhpad3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			hpadKilled3 = true end)
		newEnemybarr3 = Actor.Create("barr", true, { Location = barr3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemybarr3, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemybarr3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			barrKilled3 = true end)
		buildingM3 = buildingM3 + 2
	end
	
	if SovietsTrue then
		
		newEnemyafld3 = Actor.Create("afld", true, { Location = afld3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyafld3, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyafld3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			afldKilled3 = true end)
		newEnemytent3 = Actor.Create("tent", true, { Location = tent3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemytent3, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemytent3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			tentKilled3 = true end)
		newEnemykenn3 = Actor.Create("kenn", true, { Location = kenn3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemykenn3, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemykenn3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			kennKilled3 = true end)
		buildingM3 = buildingM3 + 3
	end
	


	if GDITrue then
		newEnemyweapcnc3 = Actor.Create("weapcnc", true, { Location = weapcnc3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyweapcnc3, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyweapcnc3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			weapcncKilled3 = true end)
		newEnemypyle3 = Actor.Create("pyle", true, { Location = pyle3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemypyle3, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemypyle3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			pyleKilled3 = true end)
		buildingM3 = buildingM3 + 2
	end
	if NODTrue then
		newEnemyafldcnc3 = Actor.Create("afldcnc", true, { Location = afldcnc3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyafldcnc3, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyafldcnc3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			afldcncKilled3 = true end)
		newEnemyhand3 = Actor.Create("hand", true, { Location = hand3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyhand3, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyhand3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			handKilled3 = true end)
		buildingM3 = buildingM3 + 2
	end

	if GDITrue or NODTrue then
		newEnemyhpadnod3 = Actor.Create("hpadnod", true, { Location = hpadnod3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyhpadnod3, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyhpadnod3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			hpadnodKilled3 = true end)
		buildingM3 = buildingM3 + 1
	end

	if MonstersTrue then
		newEnemybio3 = Actor.Create("bio", true, { Location = bio3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnKilledOrCaptured(newEnemybio3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			bioKilled3 = true
			BioCount = BioCount - 1	end)
		buildingM3 = buildingM3 + 1
		BioCount = BioCount + 1
	end

	if DinosTrue then
		newEnemymonsteregg3 = Actor.Create("monsteregg", true, { Location = monsteregg3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
	end

	if AntsTrue then
		newEnemyanthill3 = Actor.Create("anthill", true, { Location = anthill3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnKilledOrCaptured(newEnemyanthill3, function() DestroyedBuildingsM3 = DestroyedBuildingsM3 + 1
			anthillKilled3 = true end)
		buildingM3 = buildingM3 + 1
		newEnemyqueen3 = Actor.Create("queen", true, { Location = queen3pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
	end
end

buildingM4 = 0
DestroyedBuildingsM4 = 0

fact4pos = CPos.New(144, 89)
weap4pos = CPos.New(139,90)
apwr4pos = CPos.New(144,96)
fix4pos = CPos.New(139,95)
dome4pos = CPos.New(135,90)

hpad4pos = CPos.New(131,90)
barr4pos = CPos.New(129,95)

afld4pos = CPos.New(133,95)
tent4pos = CPos.New(127,90)
kenn4pos = CPos.New(126,96)

weapcnc4pos = CPos.New(120,90)
pyle4pos = CPos.New(116,90)

afldcnc4pos = CPos.New(120,95)
hand4pos = CPos.New(116,95)

hpadnod4pos = CPos.New(112,90)

bio4pos = CPos.New(123,95)

monsteregg4pos = CPos.New(107,95)

anthill4pos = CPos.New(107,90)
queen4pos = CPos.New(100,90)

RaBaseM4 = function()
--	if Difficulty ~= "easy" then
		newEnemyfact4 = Actor.Create("fact", true, { Location = fact4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyfact4, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyfact4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			factKilled4 = true end)
		newEnemyweap4 = Actor.Create("weap", true, { Location = weap4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyweap4, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyweap4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			weapKilled4 = true end)
		buildingM4 = buildingM4 + 2
--	end
	if Difficulty ~= "easy" then
		newEnemyapwr4 = Actor.Create("much.apwr", true, { Location = apwr4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyapwr4, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyapwr4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			apwrKilled4 = true end)
		newEnemyfix4 = Actor.Create("fix", true, { Location = fix4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyfix4, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyfix4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			fixKilled4 = true end)
		newEnemydome4 = Actor.Create("dome", true, { Location = dome4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemydome4, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemydome4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			domeKilled4 = true end)
		buildingM4 = buildingM4 + 3
	end

	if AlliesTrue then
	
		newEnemyhpad4 = Actor.Create("hpad", true, { Location = hpad4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyhpad4, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyhpad4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			hpadKilled4 = true end)
		newEnemybarr4 = Actor.Create("barr", true, { Location = barr4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemybarr4, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemybarr4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			barrKilled4 = true end)
		buildingM4 = buildingM4 + 2
	end
	
	if SovietsTrue then
		
		newEnemyafld4 = Actor.Create("afld", true, { Location = afld4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyafld4, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyafld4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			afldKilled4 = true end)
		newEnemytent4 = Actor.Create("tent", true, { Location = tent4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemytent4, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemytent4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			tentKilled4 = true end)
		newEnemykenn4 = Actor.Create("kenn", true, { Location = kenn4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemykenn4, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemykenn4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			kennKilled4 = true end)
		buildingM4 = buildingM4 + 3
	end
	


	if GDITrue then
		newEnemyweapcnc4 = Actor.Create("weapcnc", true, { Location = weapcnc4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyweapcnc4, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyweapcnc4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			weapcncKilled4 = true end)
		newEnemypyle4 = Actor.Create("pyle", true, { Location = pyle4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemypyle4, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemypyle4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			pyleKilled4 = true end)
		buildingM4 = buildingM4 + 2
	end
	if NODTrue then
		newEnemyafldcnc4 = Actor.Create("afldcnc", true, { Location = afldcnc4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyafldcnc4, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyafldcnc4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			afldcncKilled4 = true end)
		newEnemyhand4 = Actor.Create("hand", true, { Location = hand4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyhand4, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyhand4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			handKilled4 = true end)
		buildingM4 = buildingM4 + 2
	end

	if GDITrue or NODTrue then
		newEnemyhpadnod4 = Actor.Create("hpadnod", true, { Location = hpadnod4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnDamaged(newEnemyhpadnod4, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		Trigger.OnKilledOrCaptured(newEnemyhpadnod4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			dpadnodKilled4 = true end)
		buildingM4 = buildingM4 + 1
	end

	if MonstersTrue then
		newEnemybio4 = Actor.Create("bio", true, { Location = bio4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnKilledOrCaptured(newEnemybio4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			bioKilled4 = true
			BioCount = BioCount - 1	end)
		buildingM4 = buildingM4 + 1
		BioCount = BioCount + 1
	end

	if DinosTrue then
		newEnemymonsteregg4 = Actor.Create("monsteregg", true, { Location = monsteregg4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
	end

	if AntsTrue then
		newEnemyanthill4 = Actor.Create("anthill", true, { Location = anthill4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
		Trigger.OnKilledOrCaptured(newEnemyanthill4, function() DestroyedBuildingsM4 = DestroyedBuildingsM4 + 1
			anthillKilled4 = true end)
		buildingM4 = buildingM4 + 1
		newEnemyqueen4 = Actor.Create("queen", true, { Location = queen4pos + CVec.New(Utils.RandomInteger(0, 1), Utils.RandomInteger(0, 1)), Owner = Enemys })
	end
end


Actors1 = { "tsla", "pbox", "ftur", "hbox", "gun" }
Actors2 = { "sam", "agun" }

countV1 = 0
countV2 = 0

DefenseMaker = function()
	if countV1 < 98 then
		RandomActor1 = Utils.Random(Actors1)
		newactor = Actor.Create(RandomActor1, true, { Location = CPos.New(118,2) + CVec.New(0, countV1), Owner = Enemys })
		Trigger.OnDamaged(newactor, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		countV1 = countV1 + 2
		DefenseMaker()
	end
end

AAMaker = function()
	if countV2 < 98 then
		RandomActor2 = Utils.Random(Actors2)
		newactor = Actor.Create(RandomActor2, true, { Location = CPos.New(120,2) + CVec.New(0, countV2), Owner = Enemys })
		Trigger.OnDamaged(newactor, function(building)
			if building.Owner == Enemys and building.Health < building.MaxHealth * 3/4 and Difficulty ~= "easy" then
				building.StartBuildingRepairs()
			end
		end)
		countV2 = countV2 + 5
		AAMaker()
	end
end