# this one is called for nightly tests
ai_test_startup_effect = {
	# if = {
	# 	limit = { is_major = yes } 
	# 	#enable crypto agency in ~2.5 years
	# 	country_event = { id = generic_debug.42 days = 900 }
	# }
	# if = {
	# 	limit = { 
	# 		OR = {
	# 			tag = ENG
	# 		}
	# 	} 
	# 	#give usa access to france & england in ~4 year
	# 	country_event = { id = generic_debug.43 days = 1500 }
	# }
}

# effects that starts with name d_ will be available as console command
# use "effect_name_DESC" to define a description

d_collaboration = {
	if = {
		limit = { tag = FROM }
		log = "Error:"
		log = "  right click a country to select it for adding collaboration"
		log = "  you can specify collaboration amount to add or just use 'collaboration' to add 10%"
		log = " "
	}
	else = {
		FROM = {
			add_collaboration = { 
				target = PREV 
				value = args^0?0.1				
			}
			
			log = "Added [?args^0?0.1|H%] collaboration for [PREV.GetName]"
		}
	}
}

d_add_fake_armies = {
	if = {
		# create template if not exist
		limit = {
			not = {
				has_country_flag = fake_intel_template_created
			}
		}
		division_template = {
			name = "Fake Intel Division"
			
			is_fake_intel_division = yes
			is_locked = yes
			regiments = {
				fake_intel_unit = { x = 0 y = 0 }
			}
		}
		set_country_flag = fake_intel_template_created
	}
	
	# give it an id and store id & current date so it can be deleted later
	if = {
		limit = { NOT = { has_variable = fake_intel_id } }
		set_variable = { fake_intel_id = 1000 }
	}
	set_temp_variable = { id_to_set = fake_intel_id }
	add_to_variable = { fake_intel_id = 1 }
	add_to_array = {
		fake_intel_ids_to_delete = id_to_set
	}
	set_variable = { num_days_for_fake_intel_id@var:id_to_set = global.num_days }
	
	# minimum of 0.25 of current armies or 24
	set_temp_variable = { num_to_create = num_armies }
	multiply_temp_variable = { num_to_create = 0.25 }
	round_temp_variable = num_to_create
	add_to_temp_variable = { num_to_create = 1 }
	clamp_temp_variable = {
		var = num_to_create
		min = 24
	}
	
	# create actual units
	capital_scope = {
		create_unit = {
			division = "division_template = \"Fake Intel Division\" start_experience_factor = 0.5" 
			owner = PREV
			count = num_to_create
			id = id_to_set
		}
	}
	
	# will delete them after 90 days
	country_event = { id = lar_fake_intel_units.1 days = 90 }
	
	log = "Done"
}

#############################
### MISC CONSOLE COMMANDS ###
#############################

d_retire_country_leader = {
	random_character = {
		limit = { is_country_leader = yes }
		log = "Character [THIS.GetName] retired from [ROOT.GetNameDef]"
	}
	retire_country_leader = yes
}

d_clear_tech = {
	set_technology = { improved_infantry_weapons = 0 popup = no }
	log = "tech reset: improved_infantry_weapons"
}

d_add_tech = {
	set_technology = { improved_infantry_weapons = 1 popup = no }
	log = "tech researched: improved_infantry_weapons"
}

d_spawn_3D_models = {

	663 = {
		#Regular Infantry
		create_unit = {
			division = "division_template = \"Divisione di Fanteria\" start_experience_factor = 0.5 start_equipment_factor = 1.0"
			owner = ROOT
			count = 1
		}

		#Mountaineer
		create_unit = {
			division = "division_template = \"Divisione Alpina\" start_experience_factor = 0.5 start_equipment_factor = 1.0"
			owner = ROOT
			count = 1
		}

		#Bersaglieri
		create_unit = {
			division = "division_template = \"Bersaglieri\" start_experience_factor = 0.5 start_equipment_factor = 1.0"
			owner = ROOT
			count = 1
		}

		#Blackshirt
		create_unit = {
			division = "division_template = \"Camicie Nere\" start_experience_factor = 0.5 start_equipment_factor = 1.0"
			owner = ROOT
			count = 1
		}

		#Colonial Infantry Eritrean
		create_unit = {
			division = "division_template = \"Eritrean Ascari\" start_experience_factor = 0.5 start_equipment_factor = 1.0"
			owner = ROOT
			count = 1
		}

		#Colonial Infantry Libyan
		create_unit = {
			division = "division_template = \"Libyan Ascari\" start_experience_factor = 0.5 start_equipment_factor = 1.0"
			owner = ROOT
			count = 1
		}

		#Colonial Infantry Somali
		create_unit = {
			division = "division_template = \"Somali Ascari\" start_experience_factor = 0.5 start_equipment_factor = 1.0"
			owner = ROOT
			count = 1
		}

		#Regular Cavalry Eritrean
		create_unit = {
			division = "division_template = \"Cavalleria Coloniale\" start_experience_factor = 0.5 start_equipment_factor = 1.0"
			owner = ROOT
			count = 1
		}

		#Regular Camelry Eritrean
		create_unit = {
			division = "division_template = \"Reggimento Meharista\" start_experience_factor = 0.5 start_equipment_factor = 1.0"
			owner = ROOT
			count = 1
		}

		#Irregular Infantry Eritrean
		create_unit = {
			division = "division_template = \"Eritrean Irregulars\" start_experience_factor = 0.5 start_equipment_factor = 1.0"
			owner = ROOT
			count = 1
		}

		#Irregular Infantry Libyan
		create_unit = {
			division = "division_template = \"Libyan Irregulars\" start_experience_factor = 0.5 start_equipment_factor = 1.0"
			owner = ROOT
			count = 1
		}

		#Irregular Cavalry Eritrean
		create_unit = {
			division = "name = \"Gruppo Bande Amhara\" division_template = \"Eritrean Irregular Cavalry\" start_experience_factor = 0.5 start_equipment_factor = 1.0"
			owner = ROOT
			count = 1
		}

		#Irregular Camelry Eritrean
		create_unit = {
			division = "division_template = \"Truppe Irregolari di Cammelli\" start_experience_factor = 0.5 start_equipment_factor = 1.0"
			owner = ROOT
			count = 1
		}
	}
}