///////////////////////////////////////////////////////////////////////////////
//	Disbelieving Village
//	~~~~~~~~~~~~~~~~~~~~
//
//	Description:
//	A Settlement has been spawned near the player town.
// 	The Settlement will send Soldiers to attack the player.
//  The player can either destroy the Temple or kill all Villagers of the Settlement.
//
//	Rewards:			25000 tribute
//
//	Start date:			25.10.16			By: Boxhead
//	Update date:		27.10.16			By: Boxhead
///////////////////////////////////////////////////////////////////////////////

global DisbelievingScrollPos = 0
global TemplePos = 0
global StoragePos = 0
global ArmoryPos = 0
global Abode1Pos = 0
global Abode2Pos = 0
global Abode3Pos = 0
global Abode4Pos = 0
global Abode5Pos = 0
global Abode6Pos = 0
global DT_VillagerPos = 0
global DT_Platoon1DefPos = 0
global DT_Platoon2DefPos = 0
global DTPlatoon3Pos = 0
global DT_TempleGuyPos1 = 0
global DT_TempleGuyPos2 = 0
global DT_TempleGuyPos3 = 0
global DT_TempleGuyPos4 = 0
global DT_TempleGuyPos5 = 0
global DT_RandomPrayerPos1 = 0
global DT_RandomPrayerPos2 = 0
global DT_RandomPrayerPos3 = 0
global DT_RandomPrayerPos4 = 0
global DT_RandomPrayerPos5 = 0

global Scroll_DisbelievingVillage = 0
global DT_Temple = 0
global DT_StoragePit = 0
global DT_Armory = 0
global DT_Abode1 = 0
global DT_Abode2 = 0
global DT_Abode3 = 0
global DT_Abode4 = 0
global DT_Abode5 = 0
global DT_Abode6 = 0
global DT_Villager[17]
global DTDone = 0
global DT_TempleGuy1 = 0
global DT_TempleGuy2 = 0
global DT_TempleGuy3 = 0
global DT_TempleGuy4 = 0
global DT_TempleGuy5 = 0
global DT_RandomTempleGuy = 0
global DT_RandomTempleGuy2 = 0
global DT_VillagerCounter = 0

global DT_Platoon[3]

begin script LC10_DisbelievingVillage

	ReminderTimer = create timer for 0 seconds

start

	DisbelievingScrollPos = marker at {1106.46,207.25,594.58}
	disable migration from DisbelieverTown to PlayerTown
	
	run background script SetUpVillage
	run background script DT_CheckForConditions

	Scroll_DisbelievingVillage = create highlight SILVER name "HELP_TEXT_MULTIPLAYER_TAUNTS_GA_20" remind "HELP_TEXT_CREATURE_CURRENT_SOURCE_09" at {DisbelievingScrollPos} + {0.00,5.00,0.00}
	
	begin loop
		if camera position near {DisbelievingScrollPos} radius 150
			if get ReminderTimer time remaining <= 0
				begin dialogue
					eject good spirit
					make good spirit point at {Scroll_DisbelievingVillage}
					say "BW2T_SCRIPT_10FINAL_SMOKESIGNALS_REMINDER_10"
					wait until read
					stop good spirit pointing
					send good spirit home
				end dialogue
				set ReminderTimer time to 50 seconds
			end if
		end if
	until Scroll_DisbelievingVillage right clicked or DTDone == 1
	end loop
	
	if DTDone == 0 delete Scroll_DisbelievingVillage end if

	if DTDone == 0 run background script LC10_DisbelievingVillage_Intro end if
	
end script LC10_DisbelievingVillage

begin script SetUpVillage

start

	TemplePos = marker at {1090.03,202.13,538.91}
	StoragePos = marker at {1108.10,203.16,510.26}
	ArmoryPos = marker at {1057.45,208.56,573.60}
	Abode1Pos = marker at {1041.96,206.23,550.81}
	Abode2Pos = marker at {1064.03,200.81,540.09}
	Abode3Pos = marker at {1122.80,207.03,544.00}
	Abode4Pos = marker at {1131.26,209.53,575.23}
	Abode5Pos = marker at {1083.21,208.00,599.23}
	Abode6Pos = marker at {1074.32,211.19,624.72}
	DT_VillagerPos = marker at {1097.58,205.71,572.65}
	DT_Platoon1DefPos = marker at {1057.12,209.73,610.87}
	DT_Platoon2DefPos = marker at {1143.94,213.85,533.21}

	build all town DisbelieverTown buildings in group 0
	DT_Temple = get HOUSE ABODE_NUMBER_TEMPLE at {TemplePos} radius 15
	DT_StoragePit = get HOUSE ABODE_NUMBER_STORAGE_PIT at {StoragePos} radius 15
	DT_Armory = get HOUSE ABODE_NUMBER_MELEE_ARMOURY at {ArmoryPos} radius 15
	DT_Abode1 = get HOUSE at {Abode1Pos} radius 5
	DT_Abode2 = get HOUSE at {Abode2Pos} radius 5
	DT_Abode3 = get HOUSE at {Abode3Pos} radius 5
	DT_Abode4 = get HOUSE at {Abode4Pos} radius 5
	DT_Abode5 = get HOUSE at {Abode5Pos} radius 5
	DT_Abode6 = get HOUSE at {Abode6Pos} radius 5
	
	SCRIPT_OBJECT_PROPERTY_TYPE_BUILT_PERCENTAGE of DT_Temple = 1.0
	SCRIPT_OBJECT_PROPERTY_TYPE_BUILT_PERCENTAGE of DT_StoragePit = 1.0
	SCRIPT_OBJECT_PROPERTY_TYPE_BUILT_PERCENTAGE of DT_Armory = 1.0
	SCRIPT_OBJECT_PROPERTY_TYPE_BUILT_PERCENTAGE of DT_Abode1 = 1.0
	SCRIPT_OBJECT_PROPERTY_TYPE_BUILT_PERCENTAGE of DT_Abode2 = 1.0
	SCRIPT_OBJECT_PROPERTY_TYPE_BUILT_PERCENTAGE of DT_Abode3 = 1.0
	SCRIPT_OBJECT_PROPERTY_TYPE_BUILT_PERCENTAGE of DT_Abode4 = 1.0
	SCRIPT_OBJECT_PROPERTY_TYPE_BUILT_PERCENTAGE of DT_Abode5 = 1.0
	SCRIPT_OBJECT_PROPERTY_TYPE_BUILT_PERCENTAGE of DT_Abode6 = 1.0
	
	run background script DisbelieverTownArmies

	begin loop
		while DT_VillagerCounter != 17
			if DT_Villager[DT_VillagerCounter] not exists and DT_VillagerCounter != 17
				DT_Villager[DT_VillagerCounter] = create random villager of tribe TRIBE_TYPE_AZTEC at {DT_VillagerPos}
				attach DT_Villager[DT_VillagerCounter] to DisbelieverTown
				release DT_Villager[DT_VillagerCounter]
				DT_VillagerCounter++
			end if
		end while
		until DT_VillagerCounter == 17 or 5 seconds
	end loop
	
	add resource RESOURCE_TYPE_ORE 250 to DisbelieverTown
	add resource RESOURCE_TYPE_WOOD 1000 to DisbelieverTown
	add resource RESOURCE_TYPE_FOOD 1500 to DisbelieverTown
	
	begin loop
		wait 2 seconds

		if PLAYER of DisbelieverTown == 1
			if (get town DisbelieverTown RESOURCE_TYPE_ORE total < 671)
				add resource RESOURCE_TYPE_ORE 261 to DisbelieverTown
			elsif (get town DisbelieverTown RESOURCE_TYPE_WOOD total < 4871)
				add resource RESOURCE_TYPE_WOOD 682 to DisbelieverTown
			elsif (get town DisbelieverTown RESOURCE_TYPE_FOOD total < 7314)
				add resource RESOURCE_TYPE_FOOD 385 to DisbelieverTown
			end if
		end if
		
		until DTDone == 1
	end loop
	
end script SetUpVillage

begin script DisbelieverTownArmies

	DT_RecruitTimer1 = create timer for 15 seconds
	DT_RecruitTimer2 = create timer for 30 seconds

start

	run background script DT_Platoon1Actions
	run background script DT_Platoon2Actions
	run background script DT_Platoon3Actions

	DTPlatoon3Pos = marker at {1114.59,207.28,591.87}
	
	DT_Platoon[3] = create platoon PLATOON_INFO_AZTEC_MELEE_2 at {DTPlatoon3Pos} with 30 men and 0 women
	attach DT_Platoon[3] to DisbelieverTown
	PLAYER of DT_Platoon[3] = 1
	disable platoon DT_Platoon[3] camp
	disable platoon DT_Platoon[3] respond to local platoon attack
	set DT_Platoon[3] focus to {DT_Temple}

	
begin loop

	if DT_Platoon[1] not exists and get DT_RecruitTimer1 time remaining <= 0
		wait 60 seconds
		if DTDone == 0 DT_Platoon[1] = recruit ARMY_UNIT_TYPE_MELEE_3 town DisbelieverTown platoon of size 25 end if
	end if
	
	if DT_Platoon[2] not exists and get DT_RecruitTimer2 time remaining <= 0
		wait 45 seconds
		if DTDone == 0 DT_Platoon[2] = recruit ARMY_UNIT_TYPE_MELEE_3 town DisbelieverTown platoon of size 25 end if
	end if

end loop
	
end script DisbelieverTownArmies

begin script DT_Platoon1Actions

	oCreature = get player 0 creature
	HeTeste3 = 0
	TestCreature2 = 0
	NumPat = 0
	NumPat5 = 0
	PlayerPlatoon1 = 0
	WorrNum = 0
	oTown = get town with id 0
	oTownCentre = get building ABODE_NUMBER_TOWN_CENTRE in oTown min built 1.0
	ProPlatoonsLocation = 0
	AIPlatoon1 = 0
	Armory = 0
	Town8 = get town with id 8
	RandomActionP3 = 0
	a = 1
	Timer = create timer for 0 seconds
	GreekGateHouse1 = 0
	GreekGateHouse2 = 0
	oWall = 0
	PlayerPlatoonInRange = 0
	PlayerCatapult1 = 0
	AttackNumber = 0
	House = 0
	
start

begin loop
	a = 1
	House = 0
	AttackNumber = 0
	
	wait until DT_Platoon[1] exists
	
	AttackNumber = number from 1 to 4
	disable platoon DT_Platoon[1] camp
	begin loop
		TestCreature2 = get distance from {DT_Platoon[1]} to {oCreature}
		if TestCreature2 <= 125 and SCRIPT_OBJECT_PROPERTY_TYPE_HEALTH of oCreature > 0.00 and DT_Platoon[1] can navigate to {oCreature}
			clear DT_Platoon[1] action queue
			begin loop
				add action PLATOON_AGENDA_ACTION_MELEE_ATTACK_MOVING_OBJECT using oCreature to DT_Platoon[1] action queue
				NumPat5 = get number of villagers in platoon DT_Platoon[1]
				until NumPat5 == 0 or SCRIPT_OBJECT_PROPERTY_TYPE_HEALTH of oCreature == 0.00 or not DT_Platoon[1] can navigate to {oCreature}
			end loop
		end if
		
		PlayerPlatoon1 = get platoon of player 0 nearest {DT_Platoon[1]} radius 125
		PlayerCatapult1 = get siege weapon of player 0 nearest {DT_Platoon[1]} radius 100
		if PlayerPlatoon1 exists and DT_Platoon[1] can navigate to {PlayerPlatoon1}
			clear DT_Platoon[1] action queue
			begin loop
				add action PLATOON_AGENDA_ACTION_MELEE_ATTACK_PLATOON using PlayerPlatoon1 to DT_Platoon[1] action queue
				NumPat5 = get number of villagers in platoon DT_Platoon[1]
				HeTeste3 = get number of villagers in platoon PlayerPlatoon1
				until NumPat5 == 0 or HeTeste3 == 0
			end loop
		elsif PlayerCatapult1 exists and DT_Platoon[1] can navigate to {PlayerCatapult1}
			clear DT_Platoon[1] action queue
			begin loop
				add action PLATOON_AGENDA_ACTION_MELEE_ATTACK_THING using PlayerCatapult1 to DT_Platoon[1] action queue
				NumPat5 = get number of villagers in platoon DT_Platoon[1]
				PlayerPlatoon1 = get platoon of player 0 nearest {DT_Platoon[1]} radius 125
				if PlayerPlatoon1 exists and DT_Platoon[1] can navigate to {PlayerPlatoon1}
					PlayerPlatoonInRange = 1
				end if
				until NumPat5 == 0 or PlayerCatapult1 not exists or not DT_Platoon[1] can navigate to {PlayerCatapult1} or PlayerPlatoonInRange == 1
			end loop
			PlayerPlatoonInRange = 0
		end if
		
		if DT_Platoon[1] can navigate to object oTownCentre
			a = 1
			clear DT_Platoon[1] action queue
			begin loop
				PlayerPlatoon1 = get platoon of player 0 nearest {DT_Platoon[1]} radius 125
				TestCreature2 = get distance from {DT_Platoon[1]} to {oCreature}
				set DT_Platoon[1] attack PlayerTown with severity 0.7 for takeover
				if PlayerPlatoon1 exists or TestCreature2 <= 125 or not DT_Platoon[1] can navigate to object oTownCentre
					if PlayerPlatoon1 exists
						a = 0
					elsif TestCreature2 <= 125 and SCRIPT_OBJECT_PROPERTY_TYPE_HEALTH of oCreature > 0.00
						a = 0
					elsif not DT_Platoon[1] can navigate to object oTownCentre
						a = 0
					elsif DT_Platoon[1] not exists
						a = 0
					end if
				end if
				until a == 0 or DT_Platoon[1] not exists
			end loop
		elsif not DT_Platoon[1] can navigate to object oTownCentre and not {DT_Platoon[1]} near {DT_Platoon1DefPos} radius 5 and get size of DT_Platoon[1] action queue < 1
			clear DT_Platoon[1] action queue
			add action PLATOON_AGENDA_ACTION_DEFEND_POSITION using {DT_Platoon1DefPos} to DT_Platoon[1] action queue
		end if

		until DT_Platoon[1] not exists
	end loop
	
end loop

end script DT_Platoon1Actions

begin script DT_Platoon2Actions

	oCreature = get player 0 creature
	HeTeste3 = 0
	TestCreature2 = 0
	NumPat = 0
	NumPat5 = 0
	PlayerPlatoon1 = 0
	WorrNum = 0
	oTown = get town with id 0
	oTownCentre = get building ABODE_NUMBER_TOWN_CENTRE in oTown min built 1.0
	ProPlatoonsLocation = 0
	AIPlatoon1 = 0
	Armory = 0
	Town8 = get town with id 8
	RandomActionP3 = 0
	a = 1
	Timer = create timer for 0 seconds
	GreekGateHouse1 = 0
	GreekGateHouse2 = 0
	oWall = 0
	PlayerPlatoonInRange = 0
	PlayerCatapult1 = 0
	AttackNumber = 0
	House = 0
	
start

begin loop
	a = 1
	House = 0
	AttackNumber = 0
	
	wait until DT_Platoon[2] exists
	
	AttackNumber = number from 1 to 4
	disable platoon DT_Platoon[2] camp
	begin loop
		TestCreature2 = get distance from {DT_Platoon[2]} to {oCreature}
		if TestCreature2 <= 125 and SCRIPT_OBJECT_PROPERTY_TYPE_HEALTH of oCreature > 0.00 and DT_Platoon[2] can navigate to {oCreature}
			clear DT_Platoon[2] action queue
			begin loop
				add action PLATOON_AGENDA_ACTION_MELEE_ATTACK_MOVING_OBJECT using oCreature to DT_Platoon[2] action queue
				NumPat5 = get number of villagers in platoon DT_Platoon[2]
				until NumPat5 == 0 or SCRIPT_OBJECT_PROPERTY_TYPE_HEALTH of oCreature == 0.00 or not DT_Platoon[2] can navigate to {oCreature}
			end loop
		end if
		
		PlayerPlatoon1 = get platoon of player 0 nearest {DT_Platoon[2]} radius 125
		PlayerCatapult1 = get siege weapon of player 0 nearest {DT_Platoon[2]} radius 100
		if PlayerPlatoon1 exists and DT_Platoon[2] can navigate to {PlayerPlatoon1}
			clear DT_Platoon[2] action queue
			begin loop
				add action PLATOON_AGENDA_ACTION_MELEE_ATTACK_PLATOON using PlayerPlatoon1 to DT_Platoon[2] action queue
				NumPat5 = get number of villagers in platoon DT_Platoon[2]
				HeTeste3 = get number of villagers in platoon PlayerPlatoon1
				until NumPat5 == 0 or HeTeste3 == 0
			end loop
		elsif PlayerCatapult1 exists and DT_Platoon[2] can navigate to {PlayerCatapult1}
			clear DT_Platoon[2] action queue
			begin loop
				add action PLATOON_AGENDA_ACTION_MELEE_ATTACK_THING using PlayerCatapult1 to DT_Platoon[2] action queue
				NumPat5 = get number of villagers in platoon DT_Platoon[2]
				PlayerPlatoon1 = get platoon of player 0 nearest {DT_Platoon[2]} radius 125
				if PlayerPlatoon1 exists and DT_Platoon[2] can navigate to {PlayerPlatoon1}
					PlayerPlatoonInRange = 1
				end if
				until NumPat5 == 0 or PlayerCatapult1 not exists or not DT_Platoon[2] can navigate to {PlayerCatapult1} or PlayerPlatoonInRange == 1
			end loop
			PlayerPlatoonInRange = 0
		end if
		
		if DT_Platoon[2] can navigate to object oTownCentre
			a = 1
			clear DT_Platoon[2] action queue
			begin loop
				PlayerPlatoon1 = get platoon of player 0 nearest {DT_Platoon[2]} radius 125
				TestCreature2 = get distance from {DT_Platoon[2]} to {oCreature}
				set DT_Platoon[2] attack PlayerTown with severity 0.7 for takeover
				if PlayerPlatoon1 exists or TestCreature2 <= 125 or not DT_Platoon[2] can navigate to object oTownCentre
					if PlayerPlatoon1 exists
						a = 0
					elsif TestCreature2 <= 125 and SCRIPT_OBJECT_PROPERTY_TYPE_HEALTH of oCreature > 0.00
						a = 0
					elsif not DT_Platoon[2] can navigate to object oTownCentre
						a = 0
					elsif DT_Platoon[2] not exists
						a = 0
					end if
				end if
				until a == 0 or DT_Platoon[2] not exists
			end loop
		elsif not DT_Platoon[2] can navigate to object oTownCentre and not {DT_Platoon[2]} near {DT_Platoon2DefPos} radius 5 and get size of DT_Platoon[2] action queue < 1
			clear DT_Platoon[2] action queue
			add action PLATOON_AGENDA_ACTION_DEFEND_POSITION using {DT_Platoon2DefPos} to DT_Platoon[2] action queue
		end if

		until DT_Platoon[2] not exists
	end loop
	
end loop

end script DT_Platoon2Actions

begin script DT_Platoon3Actions

	TestPlatoonGuards = 0
	DistanceG = 0
	disvolcano = 0
	Position1 = 0
	Position2 = 0
	Position3 = 0
	Position4 = 0
	PlayerCreature = 0
    PlayerPlatoon1 = 0
    TestSiege = 0
	oCreature = get player 0 creature
	NumPat1 = 0
	HeTeste1 = 0
	WorrNum = 0
	HomeTown = get town with id 4
	Catapult = 0
	Armory = get building ABODE_NUMBER_MELEE_ARMOURY in HomeTown min built 1.0
	ArmoryRanged = get building ABODE_NUMBER_RANGED_ARMOURY in HomeTown min built 1.0
	PlayerPlatoon1Distance = 0
	PlayerCatapultDistance = 0
	a = 0
	
start

begin loop
	wait until DT_Platoon[3] exists
	begin loop	
		
		PlayerCreature = get distance from {DT_Platoon[3]} to {oCreature}
		if PlayerCreature <= 60 and SCRIPT_OBJECT_PROPERTY_TYPE_HEALTH of oCreature > 0.00
			clear DT_Platoon[3] action queue
			begin loop
				PlayerCreature = get distance from {DT_Platoon[3]} to {oCreature}
				add action PLATOON_AGENDA_ACTION_MELEE_ATTACK_MOVING_OBJECT using oCreature to DT_Platoon[3] action queue
				NumPat1 = get number of villagers in platoon DT_Platoon[3]
				until NumPat1 == 0 or SCRIPT_OBJECT_PROPERTY_TYPE_HEALTH of oCreature == 0.00 or not DT_Platoon[3] can navigate to {oCreature} or PlayerCreature > 200
			end loop
			clear DT_Platoon[3] action queue
		end if
		
		PlayerPlatoon1 = get platoon of player 0 nearest {DT_Platoon[3]} radius 50
		Catapult = get siege weapon of player 0 nearest {DT_Platoon[3]} radius 45
		if PlayerPlatoon1 exists and DT_Platoon[3] can navigate to {PlayerPlatoon1}
			clear DT_Platoon[3] action queue
			begin loop
				PlayerPlatoon1 = get platoon of player 0 nearest {DT_Platoon[3]} radius 200
				add action PLATOON_AGENDA_ACTION_MELEE_ATTACK_PLATOON using PlayerPlatoon1 to DT_Platoon[3] action queue
				NumPat1 = get number of villagers in platoon DT_Platoon[3]
				HeTeste1 = get number of villagers in platoon PlayerPlatoon1
				until NumPat1 == 0 or HeTeste1 == 0 or not DT_Platoon[3] can navigate to {PlayerPlatoon1} or PlayerPlatoon1 not exists
			end loop
			clear DT_Platoon[3] action queue
		elsif Catapult exists and DT_Platoon[3] can navigate to {Catapult}
			clear DT_Platoon[3] action queue
			a = 0
			begin loop
				Catapult = get siege weapon of player 0 nearest {DT_Platoon[3]} radius 45
				add action PLATOON_AGENDA_ACTION_MELEE_ATTACK_THING using Catapult to DT_Platoon[3] action queue
				NumPat1 = get number of villagers in platoon DT_Platoon[3]
				PlayerPlatoon1 = get platoon of player 0 nearest {DT_Platoon[3]} radius 50
				if PlayerPlatoon1 exists and DT_Platoon[3] can navigate to {PlayerPlatoon1}
					a = 1
				end if
				until NumPat1 == 0 or Catapult not exists or not DT_Platoon[3] can navigate to {Catapult} or a == 1 or Catapult not exists
			end loop
			a = 0
			clear DT_Platoon[3] action queue
		end if
		
		if get size of DT_Platoon[3] action queue < 1
			add action PLATOON_AGENDA_ACTION_DEFEND_POSITION using {PrisonPos[0]} to DT_Platoon[3] action queue
		end if
		
	end loop
	
end loop

end script DT_Platoon3Actions

begin script LC10_DisbelievingVillage_Intro

start

	CinemaIsRunning = 1

	begin cinema
		set fade red 0 green 0 blue 0 time 3
		wait 2.8 seconds
		
		run background script DT_TempleGuys
		
		wait 1 seconds
		
		disable atmos sound
		set atmos volume 0
		
		set fade in time 4
		
		reset camera path
		queue camera move with position {1112.61,207.65,570.02} focus {1099.05,208.53,537.99} time 0.0
		queue camera move with position {1100.83,207.65,575.27} focus {1087.05,208.53,542.99} time 17.0
		play camera path with easein 20 easeout 8 method SCRIPT_CAMERAPATH_EQUALDISTANCE
		
		wait 0.5 seconds
		
		start music "gregorian" loop 2
		
		wait 13.5 seconds

		set fade red 0 green 0 blue 0 time 3
		wait 3.1 seconds
		
		reset camera path
		set camera position to {1295.37,257.78,804.20}
		set camera focus to {1161.96,222.46,641.51}
		
		Scroll_DisbelievingVillage = create highlight SILVER name "HELP_TEXT_MULTIPLAYER_TAUNTS_GA_20" remind "HELP_TEXT_CREATURE_CURRENT_SOURCE_09" at {DisbelievingScrollPos} + {0.00,5.00,0.00}
		
		wait 0.5 seconds
		
		enable atmos sound
		set atmos volume 1
		
		set fade in time 6
		
	end cinema
	
	CinemaIsRunning = 0

end script LC10_DisbelievingVillage_Intro

begin script DT_TempleGuys

start

	DT_TempleGuyPos1 = marker at {1110.59,205.01,561.27}
	DT_TempleGuyPos2 = marker at {1106.77,204.52,562.74}
	DT_TempleGuyPos3 = marker at {1104.27,204.43,564.25}
	DT_TempleGuyPos4 = marker at {1099.89,204.46,566.59}
	DT_TempleGuyPos5 = marker at {1096.55,204.54,568.34}

	DT_TempleGuy1 = create random villager of tribe TRIBE_TYPE_AZTEC at {DT_TempleGuyPos1}
	attach DT_TempleGuy1 to DisbelieverTown
	set DT_TempleGuy1 focus to {DT_Temple}
	play anim "a_p_pray" on DT_TempleGuy1 loop -1
	
	DT_TempleGuy2 = create random villager of tribe TRIBE_TYPE_AZTEC at {DT_TempleGuyPos2}
	attach DT_TempleGuy2 to DisbelieverTown
	set DT_TempleGuy2 focus to {DT_Temple}
	play anim "a_p_pray" on DT_TempleGuy2 loop -1
	
	DT_TempleGuy3 = create random villager of tribe TRIBE_TYPE_AZTEC at {DT_TempleGuyPos3}
	attach DT_TempleGuy3 to DisbelieverTown
	set DT_TempleGuy3 focus to {DT_Temple}
	play anim "a_p_pray" on DT_TempleGuy3 loop -1
	
	DT_TempleGuy4 = create random villager of tribe TRIBE_TYPE_AZTEC at {DT_TempleGuyPos4}
	attach DT_TempleGuy4 to DisbelieverTown
	set DT_TempleGuy4 focus to {DT_Temple}
	play anim "a_p_pray" on DT_TempleGuy4 loop -1
	
	DT_TempleGuy5 = create random villager of tribe TRIBE_TYPE_AZTEC at {DT_TempleGuyPos5}
	attach DT_TempleGuy5 to DisbelieverTown
	set DT_TempleGuy5 focus to {DT_Temple}
	play anim "a_p_pray" on DT_TempleGuy5 loop -1

	wait 18 seconds
	
	delete DT_TempleGuy1
	delete DT_TempleGuy2
	delete DT_TempleGuy3
	delete DT_TempleGuy4
	delete DT_TempleGuy5
	
	run background script DT_RandomPrayers1
	run background script DT_RandomPrayers2
	
end script DT_TempleGuys

begin script DT_RandomPrayers1

	Number = 0
	NumberDelay = 0

start

	DT_RandomPrayerPos1 = marker at {DT_Abode1}
	DT_RandomPrayerPos2 = marker at {DT_Abode3}
	DT_RandomPrayerPos3 = marker at {DT_Abode5}

begin loop
	if DTDone == 0
		Number = number from 1 to 3
		if Number == 1
			DT_RandomTempleGuy = create random villager of tribe TRIBE_TYPE_AZTEC at {DT_RandomPrayerPos1}
			attach DT_RandomTempleGuy to DisbelieverTown
			move DT_RandomTempleGuy position to {DT_TempleGuyPos2}
			wait until {DT_RandomTempleGuy} near {DT_TempleGuyPos2} or HEALTH of DT_RandomTempleGuy == 0
			set DT_RandomTempleGuy focus to {DT_Temple}
			play anim "a_p_pray" on DT_RandomTempleGuy loop 7
			wait until DT_RandomTempleGuy played or DTDone == 1 or HEALTH of DT_RandomTempleGuy == 0
			if DTDone == 0
				move DT_RandomTempleGuy position to {DT_RandomPrayerPos1}
				wait until {DT_RandomTempleGuy} near {DT_RandomPrayerPos1} or HEALTH of DT_RandomTempleGuy == 0
				delete DT_RandomTempleGuy
			end if
		elsif Number == 2
			DT_RandomTempleGuy = create random villager of tribe TRIBE_TYPE_AZTEC at {DT_RandomPrayerPos2}
			attach DT_RandomTempleGuy to DisbelieverTown
			move DT_RandomTempleGuy position to {DT_TempleGuyPos4}
			wait until {DT_RandomTempleGuy} near {DT_TempleGuyPos4} or HEALTH of DT_RandomTempleGuy == 0
			set DT_RandomTempleGuy focus to {DT_Temple}
			play anim "a_p_pray" on DT_RandomTempleGuy loop 7
			wait until DT_RandomTempleGuy played or DTDone == 1 or HEALTH of DT_RandomTempleGuy == 0
			if DTDone == 0
				move DT_RandomTempleGuy position to {DT_RandomPrayerPos2}
				wait until {DT_RandomTempleGuy} near {DT_RandomPrayerPos2} or HEALTH of DT_RandomTempleGuy == 0
				delete DT_RandomTempleGuy
			end if
		elsif Number == 3
			DT_RandomTempleGuy = create random villager of tribe TRIBE_TYPE_AZTEC at {DT_RandomPrayerPos3}
			attach DT_RandomTempleGuy to DisbelieverTown
			move DT_RandomTempleGuy position to {DT_TempleGuyPos3}
			wait until {DT_RandomTempleGuy} near {DT_TempleGuyPos3} or HEALTH of DT_RandomTempleGuy == 0
			set DT_RandomTempleGuy focus to {DT_Temple}
			play anim "a_p_pray" on DT_RandomTempleGuy loop 7
			wait until DT_RandomTempleGuy played or DTDone == 1 or HEALTH of DT_RandomTempleGuy == 0
			if DTDone == 0
				move DT_RandomTempleGuy position to {DT_RandomPrayerPos3}
				wait until {DT_RandomTempleGuy} near {DT_RandomPrayerPos3} or HEALTH of DT_RandomTempleGuy == 0
				delete DT_RandomTempleGuy
			end if
		end if
	end if
	
	NumberDelay = number from 1 to 4
	
	if NumberDelay == 1
		wait 4 seconds
	elsif NumberDelay == 2
		wait 7 seconds
	elsif NumberDelay == 3
		wait 12 seconds
	elsif NumberDelay == 4
		wait 15 seconds
	end if
	
	until DTDone == 1
end loop

end script DT_RandomPrayers1

begin script DT_RandomPrayers2

	Number = 0
	NumberDelay = 0

start

	DT_RandomPrayerPos4 = marker at {DT_Abode2}
	DT_RandomPrayerPos5 = marker at {DT_Abode4}

begin loop
	if DTDone == 0
		Number = number from 1 to 2
		if Number == 1
			DT_RandomTempleGuy2 = create random villager of tribe TRIBE_TYPE_AZTEC at {DT_RandomPrayerPos5}
			attach DT_RandomTempleGuy2 to DisbelieverTown
			move DT_RandomTempleGuy2 position to {DT_TempleGuyPos5}
			wait until {DT_RandomTempleGuy2} near {DT_TempleGuyPos5} or HEALTH of DT_RandomTempleGuy2 == 0
			set DT_RandomTempleGuy2 focus to {DT_Temple}
			play anim "a_p_pray" on DT_RandomTempleGuy2 loop 7
			wait until DT_RandomTempleGuy2 played or DTDone == 1 or HEALTH of DT_RandomTempleGuy2 == 0
			if DTDone == 0
				move DT_RandomTempleGuy2 position to {DT_RandomPrayerPos5}
				wait until {DT_RandomTempleGuy2} near {DT_RandomPrayerPos5} or HEALTH of DT_RandomTempleGuy2 == 0
				delete DT_RandomTempleGuy2
			end if
		elsif Number == 2
			DT_RandomTempleGuy2 = create random villager of tribe TRIBE_TYPE_AZTEC at {DT_RandomPrayerPos4}
			attach DT_RandomTempleGuy2 to DisbelieverTown
			move DT_RandomTempleGuy2 position to {DT_TempleGuyPos1}
			wait until {DT_RandomTempleGuy2} near {DT_TempleGuyPos1} or HEALTH of DT_RandomTempleGuy2 == 0
			set DT_RandomTempleGuy2 focus to {DT_Temple}
			play anim "a_p_pray" on DT_RandomTempleGuy2 loop 7
			wait until DT_RandomTempleGuy2 played or DTDone == 1 or HEALTH of DT_RandomTempleGuy2 == 0
			if DTDone == 0
				move DT_RandomTempleGuy2 position to {DT_RandomPrayerPos4}
				wait until {DT_RandomTempleGuy2} near {DT_RandomPrayerPos4} or HEALTH of DT_RandomTempleGuy2 == 0
				delete DT_RandomTempleGuy2
			end if
		end if
	end if
	
	NumberDelay = number from 1 to 4
	
	if NumberDelay == 1
		wait 4 seconds
	elsif NumberDelay == 2
		wait 7 seconds
	elsif NumberDelay == 3
		wait 12 seconds
	elsif NumberDelay == 4
		wait 15 seconds
	end if
	
	until DTDone == 1
end loop

end script DT_RandomPrayers2

begin script DT_CheckForConditions

	Villager = 0

start

begin loop

	Villager = get living villager at {DT_Temple} radius 100

	if (HEALTH of DT_Temple < 0.4)
		DTDone = 1
		enable migration from DisbelieverTown to PlayerTown
		start migration from DisbelieverTown to PlayerTown
	elsif Villager not exists
		DTDone = 1
	end if
	
	until DTDone == 1
end loop

delete Scroll_DisbelievingVillage

increment tribute by 25000

end script DT_CheckForConditions

//-----------------------------------------------------------------------------
// Disbelieving Village
//-----------------------------------------------------------------------------