﻿# standard costs
@maa_buy_cost = 150
@maa_low_maintenance_cost = 1.0
@maa_high_maintenance_cost = 5.0
@cultural_maa_extra_ai_score = 80 # Equivalent to having 8 extra regiments beyond what the code scoring would indicate (see NEGATIVE_SCORE_PER_EXISTING_REGIMENT)

# Must be synced between files with the values located at "# Provisions Costs #".
@provisions_cost_infantry_cheap = 3
@provisions_cost_infantry_moderate = 7
@provisions_cost_infantry_expensive = 12
@provisions_cost_infantry_bankrupting = 15

@provisions_cost_cavalry_cheap = 7
@provisions_cost_cavalry_moderate = 15
@provisions_cost_cavalry_expensive = 21
@provisions_cost_cavalry_bankrupting = 30

@provisions_cost_special_cheap = 6
@provisions_cost_special_moderate = 12
@provisions_cost_special_expensive = 18
@provisions_cost_special_bankrupting = 24


emishi_horse_archers = {
	type = archer_cavalry

	damage = 28
	toughness = 12
	pursuit = 35
	screen = 30
	
	terrain_bonus = {
		forest = { damage = 12 pursuit = 12 }
		plains = { damage = 6 pursuit = 8 }
		hills = { damage = 6 pursuit = 8 }
		terraced_hills = { damage = 4 toughness = 6 }
		mountains = { damage = 4 pursuit = 6 }
	}

	counters = {
		heavy_infantry = 1
	}

	can_recruit = {
		culture = { has_cultural_parameter = unlock_emishi_horse_archers_units }
	}

	buy_cost = { gold = light_cavalry_recruitment_cost }
	low_maintenance_cost = { gold = light_cavalry_low_maint_cost }
	high_maintenance_cost = { gold = light_cavalry_high_maint_cost }
	provision_cost = @provisions_cost_cavalry_cheap
	
	stack = 100
	ai_quality = {
		value = @cultural_maa_extra_ai_score
		add = 100 #I mean... they're horse archers
	}
	icon = emishi_horse_archers
}

japanese_horse_archers = {
	type = archer_cavalry
	
	damage = 96
	toughness = 34
	pursuit = 40
	screen = 20
	
	terrain_bonus = {
		steppe = { damage = 20 }
		plains = { damage = 20 }
		drylands = { damage = 20 }
		jungle = { damage = -30 pursuit = -30 }
		desert_mountains = { damage = -30 pursuit = -30 }
		wetlands = { damage = -50 pursuit = -50 }
	}

	counters = {
		skirmishers = 1
		heavy_infantry = 1
	}

	winter_bonus = {
		harsh_winter = { damage = -10 toughness = -5 }
	}

	can_recruit = {
		valid_for_maa_trigger = { PARAMETER = unlock_mounted_samurai_units }
	}

	buy_cost = { gold = horse_archers_recruitment_cost }
	low_maintenance_cost = { gold = horse_archers_low_maint_cost }
	high_maintenance_cost = { gold = horse_archers_high_maint_cost }
	provision_cost = @provisions_cost_cavalry_moderate
	
	stack = 50
	ai_quality = {
		value = @cultural_maa_extra_ai_score
		add = 100 #I mean... they're horse archers
	}
	icon = japanese_horse_archers
}

warrior_monks = {
	type = pikemen

	damage = 22
	toughness = 26
	pursuit = 0
	screen = 20

	terrain_bonus = {
		mountains = { toughness = 8 }
		desert_mountains = { toughness = 8 }
		hills = { toughness = 8 }
		terraced_hills = { toughness = 8 }
		plains = { damage = 8 }
	}

	counters = {
		light_cavalry = 1
		heavy_cavalry = 1
		camel_cavalry = 1
		elephant_cavalry = 1
	}

	can_recruit = {
		valid_for_maa_trigger = { PARAMETER = unlock_warrior_monk_units }
	}

	buy_cost = {
		piety = warrior_monks_piety_recruitment_cost
	}
	low_maintenance_cost = {
		piety = warrior_monks_piety_low_maint_cost
	}
	high_maintenance_cost = {
		piety = warrior_monks_piety_high_maint_cost
	}
	provision_cost = @provisions_cost_infantry_moderate

	fallback_in_hired_troops_if_unlocked = yes
	allowed_in_hired_troops = yes

	stack = 100
	ai_quality = {
		value = @[cultural_maa_extra_ai_score + 20]
		add = counter_synergy_ai_weight_pikemen
	}
	icon = warrior_monks
}

fire_lancers = {
	type = gunpowder
	
	damage = 40
	toughness = 8
	pursuit = 0
	screen = 0

	can_recruit = {
		gunpowder_raise_limit_existing_gunpowder_units < gunpowder_raise_limit_existing_gunpowder_buildings	# one powder magazine must be owned to support three handgunner regiments, regardless of maa size
		culture = { has_cultural_parameter = unlock_fire_lancers_units }
	}
	
	terrain_bonus = {
		wetlands = { damage = -10 }
		floodplains = { damage = -5 }
	}

	counters = {
		heavy_infantry = 1
	}

	buy_cost = { gold = crossbowmen_recruitment_cost }
	low_maintenance_cost = { gold = crossbowmen_low_maint_cost }
	high_maintenance_cost = { gold = crossbowmen_high_maint_cost }
	provision_cost = @provisions_cost_infantry_moderate

	ai_quality = {
		value = counter_synergy_ai_weight_gunpowder
	}
	
	holy_order_fallback = yes
	
	stack = 100
	hired_stack_size = 50

	icon = fire_lance
}

gakgung_archers = {
	type = archers

	can_recruit = {
		valid_for_maa_trigger = { PARAMETER = unlock_maa_gakgung_archers }
	}
	
	damage = 25
	toughness = 8
	pursuit = 0
	screen = 0
	
	terrain_bonus = {
		hills = { damage = 10 toughness = 6 }
		terraced_hills = { damage = 10 toughness = 6 }
		mountains = { damage = 6 toughness = 10 }
		forest = { toughness = 4 screen = 4 }
		wetlands = { damage = -2 }
	}

	counters = {
		skirmishers = 1
		heavy_cavalry = 1
		gunpowder = 1
	}

	buy_cost = { gold = gakgung_archers_recruitment_cost }
	low_maintenance_cost = { gold = gakgung_archers_low_maint_cost }
	high_maintenance_cost = { gold = gakgung_archers_high_maint_cost }
	provision_cost = @provisions_cost_infantry_moderate
	
	stack = 100
	ai_quality = { value = @cultural_maa_extra_ai_score }
	icon = gakgung_archers
}

ballista_elephant = {
	type = elephant_cavalry
	
	damage = 180
	toughness = 75
	pursuit = 30
	screen = 20
	
	siege_value = 0.1

	can_recruit = {
		culture ?= { 
			has_innovation = innovation_elephantry 
			has_innovation = innovation_advanced_bowmaking
		}
		NOT = { is_landless_adventurer = yes }
	}
	
	terrain_bonus = {
		jungle = { damage = 50 }
		mountains = { damage = -50 }
		desert_mountains = { damage = -50 }
		wetlands = { damage = -50 toughness = -20 }
	}
	
	counters = {
		skirmishers = 2
		heavy_infantry = 2
	}

	winter_bonus = {
		normal_winter = { damage = -20 toughness = -5 }
		harsh_winter = { damage = -40 toughness = -10 }
	}

	buy_cost = { gold = ballista_elephant_recruitment_cost }
	low_maintenance_cost = { gold = ballista_elephant_low_maint_cost }
	high_maintenance_cost = { gold = ballista_elephant_high_maint_cost }
	provision_cost = @provisions_cost_cavalry_bankrupting
	
	stack = 25
	hired_stack_size = 10
	ai_quality = { value = culture_ai_weight_elephants }
	icon = ballista_elephant
}

pesilat_warriors = {
	type = skirmishers

	damage = 24
	toughness = 10
	pursuit = 12
	screen = 5

	can_recruit = {
		valid_for_maa_trigger = { PARAMETER = unlock_maa_pesilat }
	}

	terrain_bonus = {
		jungle = { toughness = 6 screen = 6 }
		terraced_hills = { damage = 6 toughness = 6 }
		wetlands = { toughness = 4 screen = 3 }
	}

	counters = {
		heavy_infantry = 1
	}

	buy_cost = { gold = pesilat_warriors_recruitment_cost }
	low_maintenance_cost = { gold = pesilat_warriors_low_maint_cost }
	high_maintenance_cost = { gold = pesilat_warriors_high_maint_cost }
	provision_cost = @provisions_cost_infantry_cheap

	holy_order_fallback = yes

	stack = 100
	ai_quality = { value = @cultural_maa_extra_ai_score }
	icon = pesilat_warrior
}

samurai = {
	type = heavy_infantry
	
	damage = 45
	toughness = 25
	pursuit = 12
	screen = 0
	
	can_recruit = {
		valid_for_maa_trigger = { PARAMETER = unlock_infantry_samurai_units }
		NOT = {
			culture = { has_cultural_parameter = strength_in_numbers_heavy_maa_ban }
		}
	}
	
	terrain_bonus = {
		farmlands = { damage = 6 toughness = 4 }
		plains = { damage = 6 toughness = 4 }
		terraced_hills = { damage = 6 toughness = 4 }
		mountains = { damage = 6 toughness = 4 }
	}
	
	counters = {
		pikemen = 1
		peasant_militia = 2
		heavy_cavalry = 1
	}
	
	buy_cost = { gold = samurai_recruitment_cost }
	low_maintenance_cost = { gold = samurai_low_maint_cost }
	high_maintenance_cost = { gold = samurai_high_maint_cost }
	provision_cost = @provisions_cost_infantry_expensive
	
	stack = 100
	ai_quality = { value = @cultural_maa_extra_ai_score }
	icon = samurai
}

zhanmadao_infantry = {
	type = heavy_infantry
	
	damage = 36
	toughness = 28
	pursuit = 0
	screen = 0
	
	can_recruit = {
		valid_for_maa_trigger = { PARAMETER = unlock_zhanmadao }
		OR = {
			vassal_contract_has_flag = celestial_province_military
			vassal_contract_has_flag = celestial_province_celestial
		}
		NOT = {
			culture = { has_cultural_parameter = strength_in_numbers_heavy_maa_ban }
		}
	}
	
	terrain_bonus = {
		farmlands = { damage = 6 toughness = 4 }
		plains = { damage = 6 toughness = 4 }
		terraced_hills = { damage = 6 toughness = 4 }
	}
	
	counters = {
		pikemen = 0.5
		peasant_militia = 1
		light_cavalry = 1
		heavy_cavalry = 1
		camel_cavalry = 1
	}
	
	buy_cost = { gold = zhanmadao_infantry_recruitment_cost }
	low_maintenance_cost = { gold = zhanmadao_infantry_low_maint_cost }
	high_maintenance_cost = { gold = zhanmadao_infantry_high_maint_cost }
	provision_cost = @provisions_cost_infantry_expensive
	
	stack = 100
	ai_quality = {
		value = @[cultural_maa_extra_ai_score + 60 ]
		add = counter_synergy_ai_weight_heavy_infantry
	}
	icon = zhanmadao_infantry
}

tiefutu = {
	type = heavy_cavalry
	
	damage = 110
	toughness = 35
	pursuit = 15
	screen = 10
	
	terrain_bonus = {
		plains = { damage = 30 toughness = 5 }
		drylands = { damage = 30 }
		hills = { damage = -10 }
		terraced_hills = { damage = -10 }
		mountains = { damage = -50 }
		desert_mountains = { damage = -50 }
		wetlands = { damage = -80 toughness = -15 pursuit = -10 }
		jungle = { damage = -80 toughness = -15 pursuit = -10 }
	}

	counters = {
		archers = 1
		pikemen = 1
	}

	winter_bonus = {
		normal_winter = { damage = -15 toughness = -5 }
		harsh_winter = { damage = -30 toughness = -10 }
	}
	
	can_recruit = {
		valid_for_maa_trigger = { PARAMETER = unlock_maa_tiefutu }
		NOT = {
			culture = { has_cultural_parameter = strength_in_numbers_heavy_maa_ban }
		}
	}

	buy_cost = { gold = tiefutu_recruitment_cost }
	low_maintenance_cost = { gold = tiefutu_low_maint_cost }
	high_maintenance_cost = { gold = tiefutu_high_maint_cost }
	provision_cost = @provisions_cost_cavalry_bankrupting
	
	stack = 50
	ai_quality = { value = @cultural_maa_extra_ai_score }

	icon = tiefutu_cavalry
}

burenjia = {
	type = heavy_infantry
	
	damage = 32
	toughness = 32
	pursuit = 0
	screen = 0
	
	can_recruit = {
		valid_for_maa_trigger = { PARAMETER = unlock_burenjia }
		NOT = {
			culture = { has_cultural_parameter = strength_in_numbers_heavy_maa_ban }
		}
	}
	
	terrain_bonus = {
		farmlands = { damage = 5 toughness = 6 }
		plains = { damage = 5 toughness = 6 }
		terraced_hills = { damage = 5 toughness = 6 }
		hills = { damage = 5 toughness = 6 }
	}
	
	counters = {
		pikemen = 1
		peasant_militia = 2
		archers = 1.5
	}
	
	buy_cost = { gold = burenjia_recruitment_cost }
	low_maintenance_cost = { gold = burenjia_low_maint_cost }
	high_maintenance_cost = { gold = burenjia_high_maint_cost }
	provision_cost = @provisions_cost_infantry_expensive
	
	stack = 100
	ai_quality = {
		value = @[cultural_maa_extra_ai_score + 60 ]
		add = counter_synergy_ai_weight_heavy_infantry
	}

	icon = burenjia_infantry
}

rocket_carts = {
	type = archers

	damage = 45
	toughness = 12
	pursuit = 0
	screen = 0

	siege_value = 0.1

	terrain_bonus = {
		farmlands = { damage = 8 toughness = 6 }
		plains = { damage = 8 }
		hills = { damage = 8 }
		terraced_hills = { damage = 8 }
	}

	counters = {
		pikemen = 0.5
		peasant_militia = 1
		heavy_infantry = 0.5
	}

	buy_cost = { gold = rocket_carts_recruitment_cost }
	low_maintenance_cost = { gold = rocket_carts_low_maint_cost }
	high_maintenance_cost = { gold = rocket_carts_high_maint_cost }
	provision_cost = @provisions_cost_special_moderate

	stack = 50
	ai_quality = { value = @[cultural_maa_extra_ai_score + 200] }
	icon = hwacha
}


ballista = {
	type = siege_weapon
	fights_in_main_phase = no

	damage = 0
	toughness = 12

	siege_tier = 1
	siege_value = 0.2

	can_recruit = {
		culture = {
			has_innovation = innovation_catapult
			OR = {
				has_cultural_pillar = heritage_chinese
				has_cultural_pillar = heritage_korean
				has_cultural_pillar = heritage_japonic
			}
		}
		NOR = {
			government_has_flag = government_is_nomadic
			government_has_flag = government_is_herder
		}
	}

	should_show_when_unavailable = {
		government_allows = subject_men_at_arms
	}

	buy_cost = { gold = ballista_recruitment_cost }
	low_maintenance_cost = { gold = ballista_low_maint_cost }
	high_maintenance_cost = { gold = ballista_high_maint_cost }
	provision_cost = @provisions_cost_special_cheap

	stack = 10
	allowed_in_hired_troops = no
	icon = ballista
}

cloud_ladder = {
	type = siege_weapon
	fights_in_main_phase = no

	damage = 0
	toughness = 12

	siege_tier = 2
	siege_value = 0.3

	can_recruit = {
		culture = {
			has_innovation = innovation_mangonel
			OR = {
				has_cultural_pillar = heritage_chinese
				has_cultural_pillar = heritage_korean
				has_cultural_pillar = heritage_japonic
			}	
		}
		NOR = {
			government_has_flag = government_is_nomadic
			government_has_flag = government_is_herder
		}
	}

	should_show_when_unavailable = {
		government_allows = subject_men_at_arms
		culture = { has_cultural_era_or_later = culture_era_early_medieval }
	}

	buy_cost = { gold = cloud_ladder_recruitment_cost }
	low_maintenance_cost = { gold = cloud_ladder_low_maint_cost }
	high_maintenance_cost = { gold = cloud_ladder_high_maint_cost }
	provision_cost = @provisions_cost_special_moderate

	stack = 10
	allowed_in_hired_troops = no
	icon = cloud_ladder
}

siege_tower = {
	type = siege_weapon
	fights_in_main_phase = no

	damage = 0
	toughness = 12

	siege_tier = 3
	siege_value = 0.4

	can_recruit = {
		culture = {
			has_innovation = innovation_trebuchet
			OR = {
				has_cultural_pillar = heritage_chinese
				has_cultural_pillar = heritage_korean
				has_cultural_pillar = heritage_japonic
			}
		}
		NOR = {
			government_has_flag = government_is_nomadic
			government_has_flag = government_is_herder
		}
	}

	should_show_when_unavailable = {
		government_allows = subject_men_at_arms
		culture = { has_cultural_era_or_later = culture_era_high_medieval }
	}

	buy_cost = { gold = siege_tower_recruitment_cost }
	low_maintenance_cost = { gold = siege_tower_low_maint_cost }
	high_maintenance_cost = { gold = siege_tower_high_maint_cost }
	provision_cost = @provisions_cost_special_expensive

	stack = 10
	allowed_in_hired_troops = no
	icon = siege_tower
}

cannon = {
	type = siege_weapon
	fights_in_main_phase = no

	damage = 0
	toughness = 12

	siege_tier = 4
	siege_value = 0.6

	can_recruit = {
		culture = {
			has_cultural_parameter = unlock_late_medieval_gunpowder_units
			OR = {
				has_cultural_pillar = heritage_chinese
				has_cultural_pillar = heritage_korean
				has_cultural_pillar = heritage_japonic
			}
		}
		NOR = {
			government_has_flag = government_is_nomadic
			government_has_flag = government_is_herder
		}
	}

	should_show_when_unavailable = {
		government_allows = subject_men_at_arms
		culture = { has_cultural_era_or_later = culture_era_late_medieval }
	}

	buy_cost = { gold = cannon_recruitment_cost }
	low_maintenance_cost = { gold = cannon_low_maint_cost }
	high_maintenance_cost = { gold = cannon_high_maint_cost }
	provision_cost = @provisions_cost_special_bankrupting

	stack = 10
	allowed_in_hired_troops = no
	icon = cannon
}
