﻿
#Does not add opinion if either person is NOT AI
worsen_relationship_effect = {
	if = {
		limit = { 
			NOT = { this = $TARGET$ }
		}
		#Best Friend -> Friend
		if = {
			limit = {
				has_relation_best_friend = $TARGET$
			}
			remove_relation_best_friend = $TARGET$
			hidden_effect = { 
				set_relation_friend = { 
					target = $TARGET$
					reason = $REASON$
				} 
			}
			if = {
				limit = {
					root = { is_ai = yes }
				}
				add_opinion = {
					target = $TARGET$
					modifier = unfriendly_opinion
					opinion = -15
				}
			}
			if = {
				limit = { 
					$TARGET$ = { is_ai = yes }
				}
				reverse_add_opinion = {
					target = $TARGET$
					modifier = unfriendly_opinion
					opinion = -15
				}
			}
		}
		#Friend -> Potential Friend
		else_if = {
			limit = {
				has_relation_friend = $TARGET$
			}
			remove_relation_friend = $TARGET$
			hidden_effect = { set_relation_potential_friend = $TARGET$ }
			if = {
				limit = {
					root = { is_ai = yes }
				}
				add_opinion = {
					target = $TARGET$
					modifier = unfriendly_opinion
					opinion = -15
				}
			}
			if = {
				limit = { 
					$TARGET$ = { is_ai = yes }
				}
				reverse_add_opinion = {
					target = $TARGET$
					modifier = unfriendly_opinion
					opinion = -15
				}
			}
		}
		#Potential Friend -> Potential Rival
		else_if = {
			limit = {
				has_relation_potential_friend = $TARGET$
				NOT = { has_relation_potential_rival = $TARGET$ }
			}
			remove_relation_potential_friend = $TARGET$
			set_relation_potential_rival = $TARGET$
			if = {
				limit = {
					root = { is_ai = yes }
				}
				add_opinion = {
					target = $TARGET$
					modifier = unfriendly_opinion
					opinion = -15
				}
			}
			if = {
				limit = { 
					$TARGET$ = { is_ai = yes }
				}
				reverse_add_opinion = {
					target = $TARGET$
					modifier = unfriendly_opinion
					opinion = -15
				}
			}
		}
		#Potential Rival -> Rival
		else_if = {
			limit = {
				has_relation_potential_rival = $TARGET$
			}
			set_relation_rival = {
				target = $TARGET$
				reason = $REASON$
			}
			if = {
				limit = {
					root = { is_ai = yes }
				}
				add_opinion = {
					target = $TARGET$
					modifier = unfriendly_opinion
					opinion = -30
				}
			}
			if = {
				limit = { 
					$TARGET$ = { is_ai = yes }
				}
				reverse_add_opinion = {
					target = $TARGET$
					modifier = unfriendly_opinion
					opinion = -30
				}
			}
		}
		#Rival -> Nemesis
		else_if = {
			limit = {
				has_relation_rival = $TARGET$
				can_set_relation_nemesis_trigger = { CHARACTER = $TARGET$ }
			}
			set_relation_nemesis = {
				target = $TARGET$
				reason = $REASON$
			}
			if = {
				limit = {
					root = { is_ai = yes }
				}
				add_opinion = {
					target = $TARGET$
					modifier = hate_opinion
					opinion = -50
				}
			}
			if = {
				limit = { 
					$TARGET$ = { is_ai = yes }
				}
				reverse_add_opinion = {
					target = $TARGET$
					modifier = hate_opinion
					opinion = -50
				}
			}
		}
		#Nothing -> Potential Rival
		else = {
			set_relation_potential_rival = $TARGET$
			if = {
				limit = {
					root = { is_ai = yes }
				}
				add_opinion = {
					target = $TARGET$
					modifier = unfriendly_opinion
					opinion = -15
				}
			}
			if = {
				limit = { 
					$TARGET$ = { is_ai = yes }
				}
				reverse_add_opinion = {
					target = $TARGET$
					modifier = unfriendly_opinion
					opinion = -15
				}
			}
		}
	}
}

#Does not add opinion if either person is NOT AI
improve_relationship_effect = {
	if = {
		limit = { 
			NOT = { this = $TARGET$ }
			is_alive = yes
			$TARGET$ = { is_alive = yes }
		}
		#Nemesis -> Rival
		if = {
			limit = {
				has_relation_nemesis = $TARGET$
			}
			remove_relation_nemesis = $TARGET$
			hidden_effect = {
				set_relation_rival = {
					target = $TARGET$
					reason = $REASON$
				}
			}
			if = {
				limit = {
					root = { is_ai = yes }
				}
				add_opinion = {
					target = $TARGET$
					modifier = friendliness_opinion
					opinion = 15
				}
			}
			if = {
				limit = { 
					$TARGET$ = { is_ai = yes }
				}
				reverse_add_opinion = {
					target = $TARGET$
					modifier = friendliness_opinion
					opinion = 15
				}
			}
		}
		#Rival -> Potential Rival
		else_if = {
			limit = {
				has_relation_rival = $TARGET$
			}
			remove_relation_rival = $TARGET$
			hidden_effect = { set_relation_potential_rival = $TARGET$ }
			if = {
				limit = {
					root = { is_ai = yes }
				}
				add_opinion = {
					target = $TARGET$
					modifier = friendliness_opinion
					opinion = 15
				}
			}
			if = {
				limit = { 
					$TARGET$ = { is_ai = yes }
				}
				reverse_add_opinion = {
					target = $TARGET$
					modifier = friendliness_opinion
					opinion = 15
				}
			}
		}
		#Potential Rival -> Potential Friend
		else_if = {
			limit = {
				has_relation_potential_rival = $TARGET$
			}
			remove_relation_potential_rival = $TARGET$
			hidden_effect = { set_relation_potential_friend = $TARGET$ }
			if = {
				limit = {
					root = { is_ai = yes }
				}
				add_opinion = {
					target = $TARGET$
					modifier = friendliness_opinion
					opinion = 15
				}
			}
			if = {
				limit = { 
					$TARGET$ = { is_ai = yes }
				}
				reverse_add_opinion = {
					target = $TARGET$
					modifier = friendliness_opinion
					opinion = 15
				}
			}
		}
		#Potential Friend -> Friend
		else_if = {
			limit = {
				has_relation_potential_friend = $TARGET$
			}
			set_relation_friend = { 
				target = $TARGET$
				reason = $REASON$ 
			}
			if = {
				limit = {
					root = { is_ai = yes }
				}
				add_opinion = {
					target = $TARGET$
					modifier = friendliness_opinion
					opinion = 30
				}
			}
			if = {
				limit = { 
					$TARGET$ = { is_ai = yes }
				}
				reverse_add_opinion = {
					target = $TARGET$
					modifier = friendliness_opinion
					opinion = 30
				}
			}
		}
		#Friend -> Best Friend
		else_if = {
			limit = {
				has_relation_friend = $TARGET$
				can_set_relation_best_friend_trigger = { CHARACTER = $TARGET$ }
			}
			set_relation_best_friend = { 
				target = $TARGET$
				reason = $REASON$  
			}
			if = {
				limit = {
					root = { is_ai = yes }
				}
				add_opinion = {
					target = $TARGET$
					modifier = friendliness_opinion
					opinion = 50
				}
			}
			if = {
				limit = { 
					$TARGET$ = { is_ai = yes }
				}
				reverse_add_opinion = {
					target = $TARGET$
					modifier = friendliness_opinion
					opinion = 50
				}
			}
		}
		#Nothing -> Potential Friend
		else = {
			set_relation_potential_friend = $TARGET$
			if = {
				limit = {
					root = { is_ai = yes }
				}
				add_opinion = {
					target = $TARGET$
					modifier = friendliness_opinion
					opinion = 15
				}
			}
			if = {
				limit = { 
					$TARGET$ = { is_ai = yes }
				}
				reverse_add_opinion = {
					target = $TARGET$
					modifier = friendliness_opinion
					opinion = 15
				}
			}
		}
	}
}
