﻿namespace = regula_virus

# Run the Regula Infecta Virus effect
# Try to infect someone with the Magisters will
regula_virus.1000 = {
	hidden = yes

	trigger = {
		has_trait = regula_virus
	}

	immediate = {
		save_scope_as = last_patient

		# If this person is in prison, finish this event chain
		if = {
			limit = { is_imprisoned = yes }
			# Finish the event chain now
			regula_virus_end_infect_imprision = yes
		}

		# Otherwise we will try to infect either
		# In someone elses court
		# Or someone we know (which can include our court if we are a ruler)

		# Save court owner
		court_owner ?= {
			save_scope_as = contagion_court_owner
		}

		# If we in someone elses court, try and spread Regula Virus in that court
		if = {
			limit = { 
				exists = scope:contagion_court_owner
				NOT = { scope:contagion_court_owner = root }
			}

			### Court Spread
			# Add everyone in the same court (ruler, prisoners, guests) and friendly scheme targets/owners to list, plus family, friends etc etc
			create_regula_virus_court_list_effect = { INFECTA_CHARACTER = root CONTAGION_COURT_OWNER = scope:contagion_court_owner }

			regula_virus_try_infect_list_effect = yes
		}
		# Otherwise, try to infect someone the Infecta knows
		else = {
			### Default Spread
			# Add only targets this Infecta knows personaly, family,friends etc
			create_regula_virus_list_effect = { INFECTA_CHARACTER = root }

			regula_virus_try_infect_list_effect = yes
		}
	}
}