joint_focus = {
	id = MA_develop_inter_province_ties 
	icon = GFX_goal_generic_national_unity

	x = 31
	y = 0

	cost = 10

	text_icon = MA_focus_style

	allow_branch = {
		has_dlc = "No Compromise, No Surrender"
		OR = {
			tag = XSM
			tag = NXM
			tag = GSM
			tag = KHM
		}
		NOT = {
			has_country_flag = cast_off_ma_ties_or_became_china_flag 
		}
	}

    cancel_if_invalid = yes
    continue_if_invalid = no
    available_if_capitulated = no

	bypass = {

	}

	ai_will_do = {
		base = 15 
	}

	search_filters = { FOCUS_FILTER_POLITICAL }

	offset = {
		x = 8
		y = 0
		trigger = {
			tag = XSM
		}
	}

	offset = {
		x = 17
		y = 0
		trigger = {
			tag = KHM
		}
	}

	offset = {
		x = 4
		y = 0
		trigger = {
			OR = {
				tag = GSM
				tag = NXM
			}
		}
	}

	available = {
		OR = {
			original_tag = XSM
			original_tag = NXM
			original_tag = GSM
			original_tag = KHM
		}
		NOT = {
			has_country_flag = cast_off_ma_ties_or_became_china_flag 
		}
	}

	completion_reward_joint_originator = {

	}

	completion_reward = {
		
		custom_effect_tooltip = CHI_modify_ma_clique_collective_modifier_tt
		add_to_variable = { CHI_ma_clique_collective_political_power_factor = 0.05 tooltip = political_power_factor_tt }
		add_to_variable = { CHI_ma_clique_collective_production_speed_infrastructure_factor = 0.05 tooltip = production_speed_infrastructure_factor_tt }

		custom_effect_tooltip = generic_skip_one_line_tt

		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = XSM
				}
			}
			add_opinion_modifier = {
				target = XSM
				modifier = MA_family_ties_opm 
			}	
		}
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = NXM
				}
			}
			add_opinion_modifier = {
				target = NXM
				modifier = MA_family_ties_opm 
			}	
		}
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = GSM
				}
			}
			add_opinion_modifier = {
				target = GSM
				modifier = MA_family_ties_opm 
			}	
		}
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = KHM
				}
			}
			add_opinion_modifier = {
				target = KHM
				modifier = MA_family_ties_opm 
			}	
		}

	}

	completion_reward_joint_member = {

			

	}

}

joint_focus = {
	id = MA_unified_training_program
	icon = GFX_focus_PER_recruit_bakhtiari

	prerequisite = { focus = MA_develop_inter_province_ties }

	relative_position_id = MA_develop_inter_province_ties


	x = -1
	y = 1

	cost = 10

	text_icon = MA_focus_style

	available = {
		OR = {
			original_tag = XSM
			original_tag = NXM
			original_tag = GSM
			original_tag = KHM
		}
		NOT = {
			has_country_flag = cast_off_ma_ties_or_became_china_flag 
		}
	}

    cancel_if_invalid = yes
    continue_if_invalid = no
    available_if_capitulated = no

	bypass = {

	}

	ai_will_do = {
		base = 5
	}

	search_filters = { }

	completion_reward = {

		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					has_country_flag = cast_off_ma_ties_or_became_china_flag 
				}
			}
			army_experience = 25
		}

		custom_effect_tooltip = generic_skip_one_line_tt
		
		custom_effect_tooltip = CHI_modify_ma_clique_collective_modifier_tt
		add_to_variable = { CHI_ma_clique_collective_conscription_factor = 0.05 tooltip = conscription_factor_tt }
		add_to_variable = { CHI_ma_clique_collective_cavalry_defence_factor = 0.05 tooltip = cavalry_defence_factor_tt }
		add_to_variable = { CHI_ma_clique_collective_army_core_defence_factor = 0.05 tooltip = army_core_defence_factor_tt }

	}

}

joint_focus = {
	id = MA_strenghten_regional_trade 
	icon = GFX_focus_generic_economic_recovery

	prerequisite = { focus = MA_develop_inter_province_ties }

	relative_position_id = MA_develop_inter_province_ties


	x = 1
	y = 1

	cost = 10

	text_icon = MA_focus_style

	available = {
		OR = {
			original_tag = XSM
			original_tag = NXM
			original_tag = GSM
			original_tag = KHM
		}
		NOT = {
			has_country_flag = cast_off_ma_ties_or_became_china_flag 
		}
	}

    cancel_if_invalid = yes
    continue_if_invalid = no
    available_if_capitulated = no

	bypass = {

	}

	ai_will_do = {
		base = 10
	}

	search_filters = { }

	completion_reward_joint_originator = {
		
	}

	completion_reward = {
		
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					has_country_flag = cast_off_ma_ties_or_became_china_flag 
				}
			}
			custom_effect_tooltip = MA_strenghten_regional_trade_tt
			every_owned_state = {
				limit = {
					is_controlled_by = ROOT 
					free_building_slots = {
						building = industrial_complex
						size > 0
						include_locked = yes 
					}
					is_capital = yes 
				}
				add_extra_state_shared_building_slots = 1
				add_building_construction = {
					type = industrial_complex
					level = 1
					instant_build = yes
				}
			}
		}

	}

}

joint_focus = {
	id = MA_promises_of_mutual_defense
	icon = GFX_goal_generic_defence

	prerequisite = { focus = MA_strenghten_regional_trade }
	prerequisite = { focus = MA_unified_training_program }

	relative_position_id = MA_strenghten_regional_trade


	x = -1
	y = 1

	cost = 5

	text_icon = MA_focus_style

	available = {
		is_subject = no
		OR = {
			original_tag = XSM
			original_tag = NXM
			original_tag = GSM
			original_tag = KHM
		}
		NOT = {
			has_country_flag = cast_off_ma_ties_or_became_china_flag 
		}
	}

    cancel_if_invalid = yes
    continue_if_invalid = no
    available_if_capitulated = no

	bypass = {

	}

	ai_will_do = {
		base = 1
		modifier = {
			factor = 0 
			any_country = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
					original_tag = SIK
				}
				is_ai = no 
			}
		}
		modifier = {
			factor = 0 
			is_historical_focus_on = yes 
		}
		modifier = {
			factor = 0 
			date < 1942.1.1 
		}
	}

	search_filters = { }

	completion_reward = {

		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					has_country_flag = cast_off_ma_ties_or_became_china_flag 
				}
			}
			add_political_power = 50
		}

		custom_effect_tooltip = generic_skip_one_line_tt

		custom_effect_tooltip = MA_promises_of_mutual_defense_tt
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = XSM
				}
			}
			IF = {
				limit = {
					XSM = {
						is_subject = no
					}
				}
				give_guarantee = XSM
			}
		}
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = NXM
				}
			}
			IF = {
				limit = {
					NXM = {
						is_subject = no
					}
				}
				give_guarantee = NXM
			}
		}
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = GSM
				}
			}
			IF = {
				limit = {
					GSM = {
						is_subject = no
					}
				}
				give_guarantee = GSM
			}
		}
		IF = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				NOT = {
					original_tag = KHM
				}
			}
			IF = {
				limit = {
					KHM = {
						is_subject = no
					}
				}
				give_guarantee = KHM
			}
		}
		
	}

}

joint_focus = {
	id = MA_formalize_the_ma_clique_collective
	icon = GFX_focus_generic_treaty

	prerequisite = { focus = MA_promises_of_mutual_defense }

	relative_position_id = MA_promises_of_mutual_defense


	x = 0
	y = 1

	cost = 10

	text_icon = MA_focus_style

	available = {
		is_subject = no
		OR = {
			original_tag = XSM
			original_tag = NXM
			original_tag = GSM
			original_tag = KHM
		}
		NOT = {
			has_country_flag = cast_off_ma_ties_or_became_china_flag 
		}
	}

    cancel_if_invalid = yes
    continue_if_invalid = no
    available_if_capitulated = no

	bypass = {

	}

	ai_will_do = {
		base = 0
	}

	search_filters = { }

	completion_reward_joint_originator = {
		
		set_rule = { can_create_factions = yes }
		create_faction_from_template = {
			template = faction_template_regional_anti_communist
			name = MA_clique_collective_faction 
			icon = GFX_faction_logo_chinese_united_front
		}
		add_faction_initiative = 1

		every_other_country = {
			limit = {
				OR = {
					original_tag = XSM
					original_tag = NXM
					original_tag = GSM
					original_tag = KHM
				}
				exists = yes 
				is_subject = no
				NOT = {
					has_country_flag = cast_off_ma_ties_or_became_china_flag 
				}
			}
			hidden_effect = {
				add_ai_strategy = {
					type = befriend
					id = ROOT
					value = 100
				}
				add_opinion_modifier = {
					target = ROOT
					modifier = MA_family_ties_2_opm
				}	
				ROOT = {
					add_ai_strategy = {
						type = befriend
						id = PREV
						value = 100
					}
				}
				country_event = { id = generic.5 hours = 6 random_hours = 12 }
			}
			custom_effect_tooltip = generic_invite_to_faction_tt
		}

	}

}


