CCCPaste

Wave of map Dotahammer

--Script By: BERKYT
--Links: VK: https://vk.com/b_e_r_k_y_t Discord: https://discord.gg/amMreCC YouTube: https://www.youtube.com/channel/UCaPBjmrAYO6p-ksHNaymwLg?view_as=subscriber
--The script is distributed freely, provided that the author of the script is indicated - BERKYT

import("ScarUtil.scar")
import("WXPScarUtil.scar")

function OnGameSetup()
	
	--Players
	g_Player1 = World_GetPlayerAt(0)
	g_Player_attack_1 = World_GetPlayerAt(6)
	g_Player_attack_2 = World_GetPlayerAt(7)
	g_Player3 = World_GetPlayerAt(2)
	
	Setup_Player(6, "BERKYT", "space_marine_race", 0)
	Setup_Player(7, "BERKYT", "chaos_marine_race", 1)
				
	Misc_PlayerTeamColor(g_Player_attack_1, "default_1")
	Misc_PlayerTeamColor(g_Player_attack_2, "default_5")
	--Warriors
	g_light_infantry = "guard_squad_guardsmen"
	g_base_warrior = "guard_squad_hellhound"
	g_base_warrior_2 = "guard_squad_guardsmen"
	g_support_warrior = "guard_squad_psyker"
	--g_support_warrior_2 = "guard_squad_kasrkin"
	g_support_warrior_2 = "space_marine_squad_tactical"
	g_heavy_support_warrior = "guard_squad_ogryns"
	g_heavy_warrior = "guard_squad_sentinel_advance_sp"
	--g_super_heavy_warrior = "guard_squad_ogryns"
	g_super_heavy_warrior = "space_marine_squad_assault"
	g_light_tank = "guard_squad_chimera"
	g_light_tank_2 = "guard_squad_basilisk"
	g_heavy_tank = "guard_squad_lemanruss"
	g_relic_warrior = "guard_squad_baneblade"
	g_hero = "guard_squad_command_squad"
	g_hero_2 = "guard_squad_assassin"
	
	--Reinforcement warriors
	g_reinforcement_light_warrior = "guard_squad_guardsmen"
	g_reinforcement_heavy_warrior = "guard_squad_kasrkin"
	g_reinforcement_tank = "guard_squad_lemanruss"
	
	--Interval
	g_interval = 5
	g_interval_s_s = 4 * 60
	--g_interval_s_s = 15 
	
	--Squads
	g_sg_wave_troops_team_1_1 = "sg_wave_troops_1_1"
	g_sg_wave_troops_team_1_2 = "sg_wave_troops_1_2"
	g_sg_wave_troops_team_1_3 = "sg_wave_troops_1_3"
	
	g_sg_wave_troops_team_2_1 = "sg_wave_troops_2_1"
	g_sg_wave_troops_team_2_2 = "sg_wave_troops_2_2"
	g_sg_wave_troops_team_2_3 = "sg_wave_troops_2_3"
	
	--Markers
	g_mkr_spawn_wave = "mkr_spawn_from"	
	g_mkr_attack_wave_team_1 = "mkr_Attack_wave_1_2"	
	
	--Integer
	g_timer_wave_team_1_1 = 0
	g_timer_wave_team_1_2 = 0
	g_timer_wave_team_1_3 = 0
	
	g_timer_wave_team_2_1 = 0
	g_timer_wave_team_2_2 = 0
	g_timer_wave_team_2_3 = 0
	
	g_timer_s_s_team_1_1 = 0
	g_timer_s_s_team_1_2 = 0
	g_timer_s_s_team_1_3 = 0
	
	g_timer_s_s_team_2_1 = 0
	g_timer_s_s_team_2_2 = 0
	g_timer_s_s_team_2_3 = 0
	
	g_count_waves = 20
	
	g_global_timer = 0
	--g_global_timer = 30 * 60
	
	--Boolean
	g_check_exists_wave_team_1_1 = false
	g_check_exists_wave_team_1_2 = false
	g_check_exists_wave_team_1_3 = false
	
	g_check_exists_wave_team_2_1 = false
	g_check_exists_wave_team_2_2 = false
	g_check_exists_wave_team_2_3 = false
	
	g_check_exists_wave_1 = false
	
	g_check_s_s_team_1 = false
	g_check_s_s_team_2 = false
	
	g_check_s_s_bool_team_1 = false
	g_check_s_s_bool_team_2 = false
	
	g_Check_See_Sp_1 = false
	
	
	--Varios
	g_check = 0
	
	g_check_s_s_hp_team_1_1 = nil
	g_check_s_s_hp_team_1_2 = nil
	g_check_s_s_hp_team_1_3 = nil
	
	g_check_s_s_hp_team_2_1 = nil
	g_check_s_s_hp_team_2_2 = nil
	g_check_s_s_hp_team_2_3 = nil
	
	g_check_s_s_hp_2 = nil
	g_sgroupid = nil
	
end

function OnInit()
	
	Delete_Hq()
	Rule_SetupMusicPlaylist()
	--FOW_RevealAll()
	--Player_SetAllResources(g_Player1, 250000, 250000)
	
	Fade_Start(3, true)
	
	Cpu_Enable(g_Player_attack_1, false)
	Cpu_Enable(g_Player_attack_2, false)
	
	Rule_AddInterval(Wave, 1)
	Rule_AddInterval(Timer, 1)
	Rule_AddInterval(CheckingSquadStuck, 1)
	Rule_AddInterval(Checking_Triggers, 1)
	
end

Scar_AddInit(OnInit)


function Checking_Triggers()
	if (playerHasAnySquadAtMarker(g_Player_attack_1, "mkr_Point_1")) then
		Cmd_AttackMoveMarker(g_sg_wave_troops_team_1_2, "mkr_Attack_wave_1_2")	
	end	
	
	if (playerHasAnySquadAtMarker(g_Player_attack_1, "mkr_Point_2")) then
		Cmd_AttackMoveMarker(g_sg_wave_troops_team_1_3, "mkr_Attack_wave_1_3")	
	end
	
	if (playerHasAnySquadAtMarker(g_Player_attack_2, "mkr_Point_1")) then
		Cmd_AttackMoveMarker(g_sg_wave_troops_team_2_2, "mkr_Attack_wave_2_2")	
	end	
	
	if (playerHasAnySquadAtMarker(g_Player_attack_2, "mkr_Point_2")) then
		Cmd_AttackMoveMarker(g_sg_wave_troops_team_2_3, "mkr_Attack_wave_2_3")	
	end
end

function Wave()

	if g_check_exists_wave_team_1_1 and g_timer_wave_team_1_1 == g_interval and EGroup_GetAvgHealth("Eg_Barrak_team_1") ~= 0 then
		
		g_check_s_s_team_1 = true
		g_check_s_s_bool_team_1 = true
		g_check_exists_wave_team_1_1 = false
		
		g_timer_s_s_team_1_1 = 0
		
		SGroup_CreateIfNotFound(g_sg_wave_troops_team_1_1)
		if SGroup_GetAvgHealth(g_sg_wave_troops_team_1_1) == 0 then 
		
			Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_1, g_support_warrior_2, "mkr_Spawn_wave_1",1 + g_check, 999)
			Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_1, g_super_heavy_warrior, "mkr_Spawn_wave_1", 2 + g_check, 999)
			
			if g_global_timer > 5 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_1, "space_marine_squad_dreadnought", "mkr_Spawn_wave_1",1, 999)
			end
			
			if g_global_timer > 10 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_1, "space_marine_squad_predator", "mkr_Spawn_wave_1",1, 999)
			end
			
			if g_global_timer > 30 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_1, "space_marine_squad_grey_knights", "mkr_Spawn_wave_1",1, 999)
				Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_1, "space_marine_squad_land_raider", "mkr_Spawn_wave_1",1, 999)
			end
			SGroup_AddLeaders(g_sg_wave_troops_team_1_1)
			Cmd_AttackMoveMarker(g_sg_wave_troops_team_1_1, "mkr_Attack_wave_1_1")	
		end
	end
	
	if g_check_exists_wave_team_1_2 and g_timer_wave_team_1_2 == g_interval and EGroup_GetAvgHealth("Eg_Barrak_team_1") ~= 0 then
	
		g_check_s_s_team_1 = true
		g_check_s_s_bool_team_1 = true
		g_check_exists_wave_team_1_2 = false
		
		g_timer_s_s_team_1_2 = 0
		SGroup_CreateIfNotFound(g_sg_wave_troops_team_1_2)
		if SGroup_GetAvgHealth(g_sg_wave_troops_team_1_2) == 0 then 
		
			Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_2, g_support_warrior_2, "mkr_Spawn_wave_1",1 + g_check, 999)
			Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_2, g_super_heavy_warrior, "mkr_Spawn_wave_1", 2 + g_check, 999)
			
			if g_global_timer > 5 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_2, "space_marine_squad_dreadnought", "mkr_Spawn_wave_1",1, 999)
			end
			
			if g_global_timer > 10 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_2, "space_marine_squad_predator", "mkr_Spawn_wave_1",1, 999)
			end
			
			if g_global_timer > 30 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_2, "space_marine_squad_grey_knights", "mkr_Spawn_wave_1",1, 999)
				Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_2, "space_marine_squad_land_raider", "mkr_Spawn_wave_1",1, 999)
			end
			SGroup_AddLeaders(g_sg_wave_troops_team_1_2)
			Cmd_AttackMoveMarker(g_sg_wave_troops_team_1_2, "mkr_Point_1")
		end		
	end
		
	if g_check_exists_wave_team_1_3 and g_timer_wave_team_1_3 == g_interval and EGroup_GetAvgHealth("Eg_Barrak_team_1") ~= 0  then
	
		g_check_s_s_team_1 = true
		g_check_s_s_bool_team_1 = true
		g_check_exists_wave_team_1_3 = false
		
		g_timer_s_s_team_1_3 = 0
		SGroup_CreateIfNotFound(g_sg_wave_troops_team_1_3)
		if SGroup_GetAvgHealth(g_sg_wave_troops_team_1_3) == 0 then 

			Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_3, g_support_warrior_2, "mkr_Spawn_wave_1",1 + g_check, 999)
			Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_3, g_super_heavy_warrior, "mkr_Spawn_wave_1", 2 + g_check, 999)
			
			if g_global_timer > 5 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_3, "space_marine_squad_dreadnought", "mkr_Spawn_wave_1",1, 999)
			end
					
			if g_global_timer > 10 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_3, "space_marine_squad_predator", "mkr_Spawn_wave_1",1, 999)
			end
			
			if g_global_timer > 30 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_3, "space_marine_squad_grey_knights", "mkr_Spawn_wave_1",1, 999)
				Util_CreateSquadsAtMarkerEx(g_Player_attack_1, g_sg_wave_troops_team_1_3, "space_marine_squad_land_raider", "mkr_Spawn_wave_1",1, 999)
			end
			
			SGroup_AddLeaders(g_sg_wave_troops_team_1_3)
			Cmd_AttackMoveMarker(g_sg_wave_troops_team_1_3, "mkr_Point_2")
		end
		
	end	
	
	if g_check_exists_wave_team_2_1 and g_timer_wave_team_2_1 == g_interval and EGroup_GetAvgHealth("Eg_Barrak_team_2") ~= 0 then
		
		g_check_s_s_team_2 = true
		g_check_s_s_bool_team_2 = true
		g_check_exists_wave_team_2_1 = false
		
		g_timer_s_s_team_2_1 = 0
		
		SGroup_CreateIfNotFound(g_sg_wave_troops_team_2_1)
		if SGroup_GetAvgHealth(g_sg_wave_troops_team_2_1) == 0 then 
		
			Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_1, "chaos_marine_squad", "mkr_Spawn_wave_2",1 + g_check, 999)
			Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_1, "chaos_squad_raptor", "mkr_Spawn_wave_2", 2 + g_check, 999)
			
			if g_global_timer > 5 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_1, "chaos_squad_dreadnought", "mkr_Spawn_wave_2",1, 999)
			end
			
			if g_global_timer > 10 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_1, "chaos_squad_predator", "mkr_Spawn_wave_2",1, 999)
			end
			
			if g_global_timer > 30 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_1, "chaos_squad_khorne_berserker", "mkr_Spawn_wave_2",1, 999)
				Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_1, "chaos_squad_bloodthirster", "mkr_Spawn_wave_2",1, 999)
			end
			
			SGroup_AddLeaders(g_sg_wave_troops_team_2_1)
			Cmd_AttackMoveMarker(g_sg_wave_troops_team_2_1, "mkr_Attack_wave_2_1")	
		end
	end
	
	if g_check_exists_wave_team_2_2 and g_timer_wave_team_2_2 == g_interval and EGroup_GetAvgHealth("Eg_Barrak_team_2") ~= 0  then
		
		g_check_s_s_team_2 = true
		g_check_s_s_bool_team_2 = true
		g_check_exists_wave_team_2_2 = false
		
		g_timer_s_s_team_2_2 = 0
		
		SGroup_CreateIfNotFound(g_sg_wave_troops_team_2_2)
		if SGroup_GetAvgHealth(g_sg_wave_troops_team_2_2) == 0 then 
		
			Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_2, "chaos_marine_squad", "mkr_Spawn_wave_2",1 + g_check, 999)
			Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_2, "chaos_squad_raptor", "mkr_Spawn_wave_2", 2 + g_check, 999)
			
			if g_global_timer > 5 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_2, "chaos_squad_dreadnought", "mkr_Spawn_wave_2",1, 999)
			end
				
			if g_global_timer > 10 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_2, "chaos_squad_predator", "mkr_Spawn_wave_2",1, 999)
			end
			
			if g_global_timer > 30 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_2, "chaos_squad_khorne_berserker", "mkr_Spawn_wave_2",1, 999)
				Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_2, "chaos_squad_bloodthirster", "mkr_Spawn_wave_2",1, 999)
			end
				
			SGroup_AddLeaders(g_sg_wave_troops_team_2_2)
			Cmd_AttackMoveMarker(g_sg_wave_troops_team_2_2, "mkr_Point_1")
		end		
	end 
	
	if g_check_exists_wave_team_2_3 and g_timer_wave_team_2_3 == g_interval and EGroup_GetAvgHealth("Eg_Barrak_team_2") ~= 0  then
		
		g_check_s_s_team_2 = true
		g_check_s_s_bool_team_2 = true
		g_check_exists_wave_team_2_3 = false
		
		g_timer_s_s_team_2_3 = 0
		
		SGroup_CreateIfNotFound(g_sg_wave_troops_team_2_3)
		if SGroup_GetAvgHealth(g_sg_wave_troops_team_2_3) == 0 then 
		
			Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_3, "chaos_marine_squad", "mkr_Spawn_wave_2",1 + g_check, 999)
			Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_3, "chaos_squad_raptor", "mkr_Spawn_wave_2", 2 + g_check, 999)
			
			if g_global_timer > 5 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_3, "chaos_squad_dreadnought", "mkr_Spawn_wave_2",1, 999)
			end
					
			if g_global_timer > 10 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_3, "chaos_squad_predator", "mkr_Spawn_wave_2",1, 999)
			end
			
			if g_global_timer > 30 * 60 then
				Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_3, "chaos_squad_khorne_berserker", "mkr_Spawn_wave_2",1, 999)
				Util_CreateSquadsAtMarkerEx(g_Player_attack_2, g_sg_wave_troops_team_2_3, "chaos_squad_bloodthirster", "mkr_Spawn_wave_2",1, 999)
			end
			
			SGroup_AddLeaders(g_sg_wave_troops_team_2_3)
			Cmd_AttackMoveMarker(g_sg_wave_troops_team_2_3, "mkr_Point_2")
		end
		
	end	
	
end

function Timer()

	g_global_timer = g_global_timer + 1
	
			
	if (math.mod(g_global_timer, 20 * 60) == 0) then 
		print("g_global_timer = "..g_global_timer)
		g_check = g_check + 1
	end
	
	SGroup_CreateIfNotFound(g_sg_wave_troops_team_1_1)
	
	if SGroup_GetAvgHealth(g_sg_wave_troops_team_1_1) == 0 then
		g_check_exists_wave_team_1_1 = true
		g_timer_wave_team_1_1 = g_timer_wave_team_1_1 + 1
		
		if g_timer_wave_team_1_1 > g_interval then
			g_timer_wave_team_1_1 = 0
		end
	end	
	
	SGroup_CreateIfNotFound(g_sg_wave_troops_team_1_2)
	
	if SGroup_GetAvgHealth(g_sg_wave_troops_team_1_2) == 0 then
		g_check_exists_wave_team_1_2 = true
		g_timer_wave_team_1_2 = g_timer_wave_team_1_2 + 1
		
		if g_timer_wave_team_1_2 > g_interval then
			g_timer_wave_team_1_2 = 0
		end
	end	
	
	SGroup_CreateIfNotFound(g_sg_wave_troops_team_1_3)
	
	if SGroup_GetAvgHealth(g_sg_wave_troops_team_1_3) == 0 then
		g_check_exists_wave_team_1_3 = true
		g_timer_wave_team_1_3 = g_timer_wave_team_1_3 + 1
		
		if g_timer_wave_team_1_3 > g_interval then
			g_timer_wave_team_1_3 = 0
		end
	end
	
	SGroup_CreateIfNotFound(g_sg_wave_troops_team_2_1)
	
	if SGroup_GetAvgHealth(g_sg_wave_troops_team_2_1) == 0 then
		g_check_exists_wave_team_2_1 = true
		g_timer_wave_team_2_1 = g_timer_wave_team_2_1 + 1
		
		if g_timer_wave_team_2_1 > g_interval then
			g_timer_wave_team_2_1 = 0
		end
	end
		
	SGroup_CreateIfNotFound(g_sg_wave_troops_team_2_2)
	
	if SGroup_GetAvgHealth(g_sg_wave_troops_team_2_2) == 0 then
		g_check_exists_wave_team_2_2 = true
		g_timer_wave_team_2_2 = g_timer_wave_team_2_2 + 1
		
		if g_timer_wave_team_2_2 > g_interval then
			g_timer_wave_team_2_2 = 0
		end
	end	
	
	SGroup_CreateIfNotFound(g_sg_wave_troops_team_2_3)
	
	if SGroup_GetAvgHealth(g_sg_wave_troops_team_2_3) == 0 then
		g_check_exists_wave_team_2_3 = true
		g_timer_wave_team_2_3 = g_timer_wave_team_2_3 + 1
		
		if g_timer_wave_team_2_3 > g_interval then
			g_timer_wave_team_2_3 = 0
		end
	end
end

function CheckingSquadStuck()

	if g_check_s_s_team_1 then
		SGroup_CreateIfNotFound(g_sg_wave_troops_team_1_1)
		
		if SGroup_IsUnderAttack(g_sg_wave_troops_team_1_1, false) == false then
			g_timer_s_s_team_1_1 = g_timer_s_s_team_1_1 + 1
			if g_timer_s_s_team_1_1 == g_interval_s_s then
				g_check_s_s_team_1 = false
				SGroup_DestroyAllSquads(g_sg_wave_troops_team_1_1)
			end
		else
			g_timer_s_s_team_1_1 = 0
			g_check_s_s_hp_team_1_1 = SGroup_GetAvgHealth(g_sg_wave_troops_team_1_1)
		end		
		
		SGroup_CreateIfNotFound(g_sg_wave_troops_team_1_2)
		
		if SGroup_IsUnderAttack(g_sg_wave_troops_team_1_2, false) == false then
			g_timer_s_s_team_1_2 = g_timer_s_s_team_1_2 + 1
			if g_timer_s_s_team_1_2 == g_interval_s_s then
				g_check_s_s_team_1 = false
				SGroup_DestroyAllSquads(g_sg_wave_troops_team_1_2)
			end
		else
			g_timer_s_s_team_1_2 = 0
			g_check_s_s_hp_team_1_2 = SGroup_GetAvgHealth(g_sg_wave_troops_team_1_2)
		end		
		
		SGroup_CreateIfNotFound(g_sg_wave_troops_team_1_3)
		
		if SGroup_IsUnderAttack(g_sg_wave_troops_team_1_3, false) == false then
			g_timer_s_s_team_1_3 = g_timer_s_s_team_1_3 + 1
			if g_timer_s_s_team_1_3 == g_interval_s_s then
				g_check_s_s_team_1 = false
				SGroup_DestroyAllSquads(g_sg_wave_troops_team_1_3)
			end
		else
			g_timer_s_s_team_1_3 = 0
			g_check_s_s_hp_team_1_3 = SGroup_GetAvgHealth(g_sg_wave_troops_team_1_3)
		end
		
	end
	
	if g_check_s_s_team_2 then
		SGroup_CreateIfNotFound(g_sg_wave_troops_team_2_1)
		
		if SGroup_IsUnderAttack(g_sg_wave_troops_team_2_1, false) == false then
			g_timer_s_s_team_2_1 = g_timer_s_s_team_2_1 + 1
			if g_timer_s_s_team_2_1 == g_interval_s_s then
				g_check_s_s_team_2 = false
				SGroup_DestroyAllSquads(g_sg_wave_troops_team_2_1)
			end
		else
			g_timer_s_s_team_2_1 = 0
			g_check_s_s_hp_team_2_1 = SGroup_GetAvgHealth(g_sg_wave_troops_team_2_1)
		end
		
		SGroup_CreateIfNotFound(g_sg_wave_troops_team_2_2)
		
		if SGroup_IsUnderAttack(g_sg_wave_troops_team_2_2, false) == false then
			g_timer_s_s_team_2_2 = g_timer_s_s_team_2_2 + 1
			if g_timer_s_s_team_2_2 == g_interval_s_s then
				g_check_s_s_team_2 = false
				SGroup_DestroyAllSquads(g_sg_wave_troops_team_2_2)
			end
		else
			g_timer_s_s_team_2_2 = 0
			g_check_s_s_hp_team_2_2 = SGroup_GetAvgHealth(g_sg_wave_troops_team_2_2)
		end
		SGroup_CreateIfNotFound(g_sg_wave_troops_team_2_3)
		
		if SGroup_IsUnderAttack(g_sg_wave_troops_team_2_3, false) == false then
			g_timer_s_s_team_2_3 = g_timer_s_s_team_2_3 + 1
			if g_timer_s_s_team_2_3 == g_interval_s_s then
				g_check_s_s_team_2 = false
				SGroup_DestroyAllSquads(g_sg_wave_troops_team_2_3)
			end
		else
			g_timer_s_s_team_2_3 = 0
			g_check_s_s_hp_team_2_3 = SGroup_GetAvgHealth(g_sg_wave_troops_team_2_3)
		end
	end
	
end

function Delete_Hq()

	local i1 = 0
	local eg = "rjgrfjlrefvrfgftgb"
	local sg = "brjrfgbkfgnf3243re"
	
	if (Marker_Exists("mkr_BERKYT_script_deleteEntities", "basic_marker")) then
		
		for i1 = 1, World_GetPlayerCount() do
			
			Player_GetAllEntitiesNearMarker(World_GetPlayerAt(i1 - 1), eg, "mkr_BERKYT_script_deleteEntities")
			
			EGroup_DestroyAllEntities(eg)
			EGroup_Destroy(eg)
		end
		
	else
		print(" (Error) Can't remove entities because special marker not exists!")
	end
	
	if (Marker_Exists("mkr_BERKYT_script_deleteSquads", "basic_marker")) then
		
		for i1 = 1, World_GetPlayerCount() do
			
			Player_GetAllSquadsNearMarker(World_GetPlayerAt(i1 - 1), sg, "mkr_BERKYT_script_deleteSquads")
			
			SGroup_DestroyAllSquads(sg)
			SGroup_Destroy(sg)
		end
		
	else
		print(" (Error) Can't remove squads because special marker not exists!")
	end
	
end


function Rule_SetupMusicPlaylist()

	Util_MissionTitle("By: BERKYT")
	
	t_ambient_sound = {"ambient_desert"}
	
	Playlist_Manager( PC_Ambient, t_ambient_sound, true, true , {2, 4})
	
	--Util_CreateSquadsAtMarkerEx(g_Player1, "423423234423423645rttrh", "guard_squad_baneblade", "mkr_Spawn_wave_2",5, 999)
end

function playerHasAnySquadAtMarker(playerId, mkr)
    local sgName = "sg_phasam_17684187"

    SGroup_CreateIfNotFound(sgName)
    SGroup_Clear(sgName)
    Player_GetAllSquadsNearMarker(playerId, sgName, mkr)

    if (SGroup_Count(sgName) > 0) then
        return true
    end

    return false
end