
-- At west ironmines

SPAWN_TIME_RESOURCE1 = 20

createArmyResources1 = function()

	--	set up

		armyResources1						= {}
	
		armyResources1.player 				= 5
		armyResources1.id					= 3
		armyResources1.strength				= 8
		armyResources1.position				= GetPosition("defend1")
		armyResources1.rodeLength			= 4500
		armyResources1.beAgressive			= true
		armyResources1.control				= {}
		armyResources1.control.timer		= 0
		
		SetupArmy(armyResources1)
	
	--	create

		local troopDescription = {
		
			maxNumberOfSoldiers	= 8,
			minNumberOfSoldiers	= 0,
			experiencePoints 	= LOW_EXPERIENCE,
		}				
	
--		troopDescription.leaderType = Entities.PU_LeaderSword1				
--		EnlargeArmy(armyResources1,troopDescription)

		troopDescription.leaderType = Entities.CU_BanditLeaderSword1				
		EnlargeArmy(armyResources1,troopDescription)
		EnlargeArmy(armyResources1,troopDescription)
		EnlargeArmy(armyResources1,troopDescription)
		EnlargeArmy(armyResources1,troopDescription)

		troopDescription.leaderType = Entities.PU_LeaderBow2
		EnlargeArmy(armyResources1,troopDescription)
		EnlargeArmy(armyResources1,troopDescription)
		EnlargeArmy(armyResources1,troopDescription)
		EnlargeArmy(armyResources1,troopDescription)
	
	--	job		
		
		StartJob("ControlArmyResources1")

	end

-----------------------------------------------------------------------------------------------------------------------	
--
--	JOB: "ControlArmyResources1"
--
-----------------------------------------------------------------------------------------------------------------------	
	-------------------------------------------------------------------------------------------------------------------
	Condition_ControlArmyResources1 = function()
	-------------------------------------------------------------------------------------------------------------------

		if armyResources1.control.timer > 0 then
		
			armyResources1.control.timer = armyResources1.control.timer -1

			return false

			end
		
		return Counter.Tick2("ControlArmyResources1",3)	
		
		end
		
	-------------------------------------------------------------------------------------------------------------------
	Action_ControlArmyResources1 = function()
	-------------------------------------------------------------------------------------------------------------------
		
		if IsDead("tower1a") and IsDead("tower1b") then
		return true
		end
		
		
		if GetNumberOfLeaders(armyResources1) <= 4 then

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

		
		end
		Defend(armyResources1)
		return false
		end