#
# This file is to store the upkeep / production of objects that are not otherwise scripted
# right now it ignores the "cost" part of it
# subjects upkeep/production is not stored here, but in the subject type
#

once = {
	# this is applied only once per country
	federation = {
		trigger = {
			has_federation = yes
		}
		resources = {
			category = federation
			upkeep = {
				influence = 1
			}
		}
	}
}

per_relation = {
	# this is applied for each such relation with another country
	# scope: this = current country, FROM : other country in the relation
	rivalry = {
		trigger = {
			has_rival = FROM
		}
		resources = {
			category = rivalries
			produces = {
				influence = 0.5
			}
		}
	}
	
	rivalry = {
		trigger = {
			has_active_tradition = tr_enmity_eclipse
			has_rival = FROM
		}
		resources = {
			category = rivalries
			produces = {
				trade = 5
				society_research = 5
				engineering_research = 5
				physics_research = 5
			}
		}
	}

	non_aggression_pact = {
		trigger = {
			has_non_aggression_pact = FROM
		}
		resources = {
			category = non_aggression_pacts
			upkeep = {
				influence = 0.25
			}
		}
	}

	migration_pact = {
		trigger = {
			has_diplo_migration_treaty = FROM
			NOT = {
				AND = {
					has_federation = yes
					federation = { has_federation_perk = diplomacy_upkeep_1 }
					federation = { any_member = { is_same_value = FROM } }
				}
			}
			NOT = {
				AND = {
					has_federation = yes
					federation = { has_federation_law = free_migration_yes }
					federation = { any_member = { is_same_value = FROM } }
				}
			}
		}
		resources = {
			category = migration_pacts
			upkeep = {
				influence = 0.25
			}
		}
	}
	
	migration_pact = {
		trigger = {
			has_ascension_perk = ap_shared_destiny 
			has_migration_access = from
		}
		resources = {
			category = migration_pacts
			produces = {
				trade = 3
				unity = 3
				society_research = 3
				engineering_research = 3
				physics_research = 3
			}
		}
	}

	research_agreement = {
		trigger = {
			has_research_agreement = FROM
			NOT = {
				AND = {
					has_federation = yes
					federation = { has_federation_perk = diplomacy_upkeep_1 }
					federation = { any_member = { is_same_value = FROM } }
				}
			}
		}

		resources = {
			category = research_agreements
			upkeep = {
				influence = 0.25
			}
		}
	}

	commercial_pact = {
		trigger = {
			has_commercial_pact = FROM
			NOT = { has_ascension_perk = ap_universal_transactions }
		}

		resources = {
			category = commercial_pacts
			upkeep = {
				influence = 0.25
			}
		}
	}

	defensive_pact = {
		trigger = {
			has_defensive_pact = FROM
		}

		resources = {
			category = defensive_pacts
			upkeep = {
				influence = 1
			}
		}
	}

	guarantee = {
		trigger = {
			is_guaranteeing = FROM
		}
		resources = {
			category = guarantees
			upkeep = {
				influence = 0.5
			}
		}
	}

	improving_relations = {
		trigger = {
			is_improving_relations_with = FROM
			OR = {
				has_policy_flag = diplo_stance_isolationist
				has_policy_flag = diplo_stance_belligerent
				has_policy_flag = diplo_stance_supremacist
			}
		}
		resources = {
			category = envoy_costs
			upkeep = {
				influence = 0.25
			}
		}
	}

	improving_relations = {
		trigger = {
			is_improving_relations_with = FROM
			has_active_tradition = tr_diplomacy_eminent_diplomats
		}
		resources = {
			category = envoy_costs
			produces = {
				unity = 5
			}
		}
	}

	harming_relations = {
		trigger = {
			is_harming_relations_with = FROM
			OR = {
				has_policy_flag = diplo_stance_isolationist
				has_policy_flag = diplo_stance_cooperative
			}
		}
		resources = {
			category = envoy_costs
			upkeep = {
				influence = 0.25
			}
		}
	}

	diplo_stance_closed_borders = {
		trigger = {
			has_policy_flag = diplo_stance_mercantile

			has_closed_borders = FROM
			NOT = {
				has_rival = FROM
			}
		}
		resources = {
			category = diplo_closed_borders
			upkeep = {
				influence = 0.25
			}
		}
	}

	embassy = {
		trigger = {
			has_active_tradition = tr_diplomacy_diplomatic_networking
			has_embassy = from
		}
		resources = {
			category = diplomatic_networking
			produces = {
				trade = 3
				society_research = 3
				engineering_research = 3
				physics_research = 3
			}
		}
	}

	migration_pact = {
		trigger = {
			exists = ruler
			ruler = { has_trait = leader_trait_legendary_scientific_diplomacy }
			has_migration_access = from
		}
		resources = {
			category = diplomatic_networking
			produces = {
				society_research = @scientific_diplomacy_1_amt
				engineering_research = @scientific_diplomacy_1_amt
				physics_research = @scientific_diplomacy_1_amt
			}
		}
	}

	migration_pact = {
		trigger = {
			exists = ruler
			ruler = { has_trait = leader_trait_legendary_scientific_diplomacy_2 }
			has_migration_access = from
		}
		resources = {
			category = diplomatic_networking
			produces = {
				society_research = @scientific_diplomacy_2_amt
				engineering_research = @scientific_diplomacy_2_amt
				physics_research = @scientific_diplomacy_2_amt
			}
		}
	}

	migration_pact = {
		trigger = {
			exists = ruler
			ruler = { has_trait = leader_trait_legendary_scientific_diplomacy_3 }
			has_migration_access = from
		}
		resources = {
			category = diplomatic_networking
			produces = {
				society_research = @scientific_diplomacy_3_amt
				engineering_research = @scientific_diplomacy_3_amt
				physics_research = @scientific_diplomacy_3_amt
			}
		}
	}
	
	societal_enlightenment = {
		trigger = {
			from = {
				is_under_societal_enlightenment = root
			}
		}
		resources = {
			category = societal_enlightenment_pacts
			upkeep = {
				influence = 0.1
				unity = 5
			}
		}
	}
	
	open_technological_enlightenment = {
		trigger = {
			from = {
				is_under_open_technological_enlightenment = root
			}
		}
		resources = {
			category = open_technological_enlightenment_pacts
			upkeep = {
				influence = 0.1
				physics_research = 5
				society_research = 5
				engineering_research = 5
			}
		}
	}
	
	stratified_technological_enlightenment = {
		trigger = {
			from = {
				is_under_stratified_technological_enlightenment = root
			}
		}
		resources = {
			category = stratified_technological_enlightenment_pacts
			upkeep = {
				influence = 0.1
				physics_research = 3
				society_research = 3
				engineering_research = 3
			}
		}
	}
	
	waystation_pact = {
		trigger = {
			has_waystation_pact = FROM
			NOT = { has_ascension_perk = ap_universal_transactions }
		}
		resources = {
			category = waystation_pacts
			upkeep = {
				influence = 0.25
			}
		}
	}

	pre_ftl_trade = {
		trigger = {
			from = {
				has_pre_ftl_trade = root
			}
		}
		resources = {
			category = pre_ftl_trade_pacts
			upkeep = {
				trigger = {
					NOT = { has_ascension_perk = ap_universal_transactions }
				}
				influence = 0.1
			}
			upkeep = {
				minerals = 5
			}
		}
	}
}
