
-- Army in East

SPAWN_TIME_DEFENDERS2 = 15

createArmyDefenders2 = function()

	--	set up

		armyDefenders2						= {}
	
		armyDefenders2.player 				= 5
		armyDefenders2.id					= 8
		armyDefenders2.strength				= 8
		armyDefenders2.position				= GetPosition("spawn2")
		armyDefenders2.rodeLength			= 3500
		armyDefenders2.control				= {}
		armyDefenders2.control.timer		= SPAWN_TIME_DEFENDERS2
		
		SetupArmy(armyDefenders2)
	
	--	create

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

		
		troopDescription.leaderType = Entities.PU_LeaderSword3		
		EnlargeArmy(armyDefenders2,troopDescription)
		EnlargeArmy(armyDefenders2,troopDescription)
		EnlargeArmy(armyDefenders2,troopDescription)
		EnlargeArmy(armyDefenders2,troopDescription)
		
		troopDescription.leaderType = Entities.PU_LeaderBow3
		EnlargeArmy(armyDefenders2,troopDescription)
		EnlargeArmy(armyDefenders2,troopDescription)
		EnlargeArmy(armyDefenders2,troopDescription)
		EnlargeArmy(armyDefenders2,troopDescription)
	
	--	job		
		
		StartJob("ControlArmyDefenders2")

	end


-----------------------------------------------------------------------------------------------------------------------	
--
--	JOB: "ControlArmyDefenders2"
--
-----------------------------------------------------------------------------------------------------------------------	
	-------------------------------------------------------------------------------------------------------------------
	Condition_ControlArmyDefenders2 = function()
	-------------------------------------------------------------------------------------------------------------------
		
		return Counter.Tick2("ControlArmyDefenders2",1)
		
		end
		
	-------------------------------------------------------------------------------------------------------------------
	Action_ControlArmyDefenders2 = function()
	-------------------------------------------------------------------------------------------------------------------
		
		if IsDead("tower2a") and IsDead("tower2b") then
		return true
		end
		
		if GetNumberOfLeaders(armyDefenders2) <= 4 then

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

		end
		Defend(armyDefenders2)

		return false
		end