
-- Army in west

SPAWN_TIME_DEFENDERS1 = 15

createArmyDefenders1 = function()

	--	set up

		armyDefenders1						= {}
	
		armyDefenders1.player 				= 5
		armyDefenders1.id					= 7
		armyDefenders1.strength				= 8
		armyDefenders1.position				= GetPosition("spawn1")
		armyDefenders1.rodeLength			= 2000
		armyDefenders1.control				= {}
		armyDefenders1.control.timer		= SPAWN_TIME_DEFENDERS1
		
		SetupArmy(armyDefenders1)
	
	--	create

		local troopDescription = {
		
			maxNumberOfSoldiers	= 8,
			minNumberOfSoldiers	= 0,
			experiencePoints 	= LOW_EXPERIENCE,
		}				


		troopDescription.leaderType = Entities.PU_LeaderSword3		
		EnlargeArmy(armyDefenders1,troopDescription)
		EnlargeArmy(armyDefenders1,troopDescription)
		EnlargeArmy(armyDefenders1,troopDescription)
		EnlargeArmy(armyDefenders1,troopDescription)
		
		troopDescription.leaderType = Entities.PU_LeaderBow3
		EnlargeArmy(armyDefenders1,troopDescription)
		EnlargeArmy(armyDefenders1,troopDescription)
		EnlargeArmy(armyDefenders1,troopDescription)
		EnlargeArmy(armyDefenders1,troopDescription)
	
	--	job		
		
		StartJob("ControlArmyDefenders1")

	end


-----------------------------------------------------------------------------------------------------------------------	
--
--	JOB: "ControlArmyDefenders1"
--
-----------------------------------------------------------------------------------------------------------------------	
	-------------------------------------------------------------------------------------------------------------------
	Condition_ControlArmyDefenders1 = function()
	-------------------------------------------------------------------------------------------------------------------
		
		return Counter.Tick2("ControlArmyDefenders1",1)
		
		end
		
	-------------------------------------------------------------------------------------------------------------------
	Action_ControlArmyDefenders1 = function()
	-------------------------------------------------------------------------------------------------------------------
		
		if IsDead("tower1a") and IsDead("tower1b") then
		return true
		end
		
		
			if GetNumberOfLeaders(armyDefenders1) <= 4 then

				armyDefenders1.control.timer = armyDefenders1.control.timer - 1
				
				if armyDefenders1.control.timer <=0 then
				
				local troopDescription = {
		
				maxNumberOfSoldiers	= 8,
				minNumberOfSoldiers	= 0,
				experiencePoints 	= LOW_EXPERIENCE,
				}			
				
				for zaehler = 1, armyDefenders1.strength - GetNumberOfLeaders(armyDefenders1), 1 do
					local randomzahl = math.random(99)
					if randomzahl >= 50 then
					troopDescription.leaderType = Entities.PU_LeaderSword3		
					EnlargeArmy(armyDefenders1,troopDescription)
					else
					troopDescription.leaderType = Entities.PU_LeaderBow3
					EnlargeArmy(armyDefenders1,troopDescription)
					end
				end
				
			
			end
		
		
		
		
		end
		
		Defend(armyDefenders1)

		return false
		end