﻿# Safe additive extension: the vanilla pulse calls one uniquely named child
# on-action. No vanilla first_valid or event list is replaced.
yearly_playable_pulse = {
	on_actions = { cagm_activity_rumor_pulse }
}

cagm_activity_rumor_pulse = {
	trigger = {
		is_alive = yes
		is_adult = yes
		is_available = yes
	}
	effect = {
		# Save compatibility for the pre-fix A18 build. A host who completed a
		# Contest of Cooks can be identified by its still-active result reward.
		# Restore only the entry trait; historical finalist XP cannot be inferred
		# safely from the reward modifier alone. The trait guard makes this a
		# one-time repair on the next yearly playable pulse.
		if = {
			limit = {
				is_ai = no
				NOT = { has_trait = cagm_cook }
				OR = {
					has_character_modifier = cagm_cooks_signature_table
					has_character_modifier = cagm_cooks_nourishing_table
					has_character_modifier = cagm_cooks_renowned_kitchens
				}
			}
			add_trait = cagm_cook
		}

		if = {
			limit = { NOT = { has_character_flag = cagm_fishing_legendary_rumor } }
				random = {
					chance = 5
					cagm_grant_fishing_legendary_rumor_effect = yes
			}
		}

		if = {
			limit = {
				NOT = { has_character_flag = cagm_whaling_legendary_rumor }
				cagm_whaling_practice_access_trigger = yes
			}
				random = {
					chance = 3
					cagm_grant_whaling_legendary_rumor_effect = yes
			}
		}

		if = {
			limit = { NOT = { has_character_flag = cagm_stars_wonder_rumor } }
			random = {
				chance = 4
				add_character_flag = { flag = cagm_stars_wonder_rumor years = 5 }
				if = { limit = { is_ai = no } trigger_event = cagm_shared.0003 }
			}
		}

		if = {
			limit = { NOT = { has_character_flag = cagm_herbs_rare_rumor } }
			random = {
				chance = 5
				add_character_flag = { flag = cagm_herbs_rare_rumor years = 7 }
				if = { limit = { is_ai = no } trigger_event = cagm_shared.0004 }
			}
		}

		if = {
			limit = { NOT = { has_character_flag = cagm_apiary_great_swarm_rumor } }
			random = {
				chance = 4
				add_character_flag = { flag = cagm_apiary_great_swarm_rumor years = 7 }
				if = { limit = { is_ai = no } trigger_event = cagm_shared.0005 }
			}
		}
	}
}
