#####################################################################
############################ INDEX ##################################
#####################################################################
### ANYONE ADDING UPGRADES(features): Keep this updated, please!
###
### Template:
###
###		upgrade_example_name
###			picture = GFX_upgrade_icon_crates
###			show_in_history = yes
###			allow = { }
###			potential = { }
###			active = { }
###			flags = { }
###			build_time = 20
###			gold_cost_flat = 450
###			gold_cost_ticking = 1
###			local_modifier = { }
###			owner_modifier = { }
###		}
###

# Note: Names are reference points, but likely displayed differently in game
# Upgrades are referred to as "features" in game
# Scopes: ROOT is the character, FROM is the upgrade, FROMFROM the wonder, and FROMFROMFROM the province.

################### Available Upgrades ###########################

#### COW UPGRADES ####                     
## Cathedral upgrades ##                   
# Gargoyles ............................... upgrade_cow_gargoyles
# Bells ................................... upgrade_cow_bells
# Stained Glass Window .................... upgrade_cow_stained_glass_window
# Relic Tomb .............................. upgrade_cow_relic_tomb
# Grand Basilica .......................... upgrade_cow_grand_basilica
# Catacombs ............................... upgrade_cow_catacombs
# Lophus Kiramaikos ....................... upgrade_cow_necropolis_alex
# Giant Cross ............................. upgrade_cow_giant_cross
# Golden Bells ............................ upgrade_cow_bells_golden

## Mosque upgrades ##
# Minaret ................................. upgrade_cow_minaret
# Sahn .................................... upgrade_cow_open_courtyard
# Qubba ................................... upgrade_cow_dome
# Magnificent Hanging Lamps ............... upgrade_cow_lamps_hanging
# Soup Kitchen ............................ upgrade_cow_soup_kitchen
# School .................................. upgrade_cow_school_mosque
# Caravanserai ............................ upgrade_cow_hostel
# Custodian of the Mosque ................. upgrade_cow_custodian_of_the_mosque

## Synagogue upgrades ##
# Tallest Building ........................ upgrade_cow_tallest_building
# Outer Wall and Open Garden .............. upgrade_cow_garden_outer
# Holy Ark ................................ upgrade_cow_holy_ark
# Elaborate Decorations ................... upgrade_cow_decorations
# Choir Rooms ............................. upgrade_cow_choir_rooms
# School .................................. upgrade_cow_school_synagogue

## Pagan temple upgrades ##
# Statue of a God ......................... upgrade_cow_statue_god
# Temple Guards ........................... upgrade_cow_temple_guards
# Sacrificial Altar ....................... upgrade_cow_sacrificial_altar
# Sacred Grove ............................ upgrade_cow_sacred_grove
# Prophecy Rooms .......................... upgrade_cow_prophecy_rooms
# Temple Precinct ......................... upgrade_cow_temple_precinct
# Inner Sanctuary ......................... upgrade_cow_inner_sanctuary
# Custodian of the Temple ................. upgrade_cow_custodian_of_temple

## Buddhist temple upgrades ##
# Chaitya-Grihas .......................... upgrade_cow_chaitya-grihas
# Gompa ................................... upgrade_cow_gompa
# Bodhi Tree .............................. upgrade_cow_bodhi_tree
# Cave Complex ............................ upgrade_cow_cave_complex
# Vihara .................................. upgrade_cow_vihara
# Buddhist School ......................... upgrade_cow_school_buddhist
# Relic Stupa ............................. upgrade_cow_relic_stupa
# Commerative Stupa ....................... upgrade_cow_commerative_stupa
# Symbolic Stupa .......................... upgrade_cow_symbolic_stupa
# Votive Stupa ............................ upgrade_cow_votive_stupa

## Hindu temple upgrades ##
# Gopuram ................................. upgrade_cow_high_gopura
# Shikhara ................................ upgrade_cow_shikhara
# Maha Mandapa ............................ upgrade_cow_mandapa
# Temple Complex .......................... upgrade_cow_temple_complex
# Calai ................................... upgrade_cow_school_hindu
# Hospital ................................ upgrade_cow_hospital_hindu

## Statue upgrades ##
# Gold Plating ............................ upgrade_cow_plating_gold
# Silver Plating .......................... upgrade_cow_plating_silver
# Bronze Plating .......................... upgrade_cow_plating_bronze
# Additional Statues ...................... upgrade_cow_statues_family
# Golden Crown ............................ upgrade_cow_golden_crown
# Watcher of Giants ....................... upgrade_cow_watcher_of_giants
## Horse Statue upgrades ##
# Grand Stable ............................ upgrade_cow_stable
# Additional Animal Statues ............... upgrade_cow_statues_animals

## Walls upgrades ##
# Sea Walls ............................... upgrade_cow_walls_sea
# Studded Bastions ........................ upgrade_cow_studded_bastions
# Strategic Exclaves ...................... upgrade_cow_strategic_exclaves
# Soaring Fortresses ...................... upgrade_cow_soaring_fortresses
# Hidden Gates ............................ upgrade_cow_hidden_gates
# Gatehouse Forts ......................... upgrade_cow_gatehouse_forts
# Staged Killing Fields ................... upgrade_cow_killing_fields
# Deep Defense Architecture ............... upgrade_cow_deep_defense_architecture
# Artificial Islands ...................... upgrade_cow_artificial_islands
# Mirror Towers of Syrakousai ............. upgrade_cow_mirror_towers # Unique - Siracusa
# Claw of Archimedes ...................... upgrade_cow_archimedes_claw # Unique - Siracusa
# Gastraphetes Makers ..................... upgrade_cow_gastraphetes_makers # Unique - Siracusa
# Walker of the Wall ...................... upgrade_cow_wall_walker

## Fortress upgrades ##
# Armory .................................. upgrade_cow_armory
# Watch Tower ............................. upgrade_cow_watch_tower
# Vault ................................... upgrade_cow_vault
# Pit Moat ................................ upgrade_cow_moat_pit
# Spike Moat .............................. upgrade_cow_moat_spike
# Water Moat .............................. upgrade_cow_moat_water
# Moat of Bones ........................... upgrade_cow_moat_bones
# Hidden Passageways ...................... upgrade_cow_hidden_passageways
# Inner Garden ............................ upgrade_cow_garden_inner

## Underground City upgrades ##
# Dungeon ................................. upgrade_cow_dungeon
# Natural Caves ........................... upgrade_cow_caves_natural
# Travel Tunnels .......................... upgrade_cow_tunnels_travel
# Precious Metal Mines .................... upgrade_cow_metal_mine_precious
# Guardian of the Deep .................... upgrade_cow_guardian_of_the_deep

## Great Harbor upgrades ##
# Cothon .................................. upgrade_cow_cothon
# Piers ................................... upgrade_cow_piers
# Harbor Office ........................... upgrade_cow_office_harbor
# Lighthouse .............................. upgrade_cow_lighthouse
# Military Wharf .......................... upgrade_cow_military_wharf
# Master of the Tides ..................... upgrade_cow_master_of_tides

## Great Lighthouse upgrades ##
# Treasure Chamber ........................ upgrade_cow_treasure_chamber
# Giant Banners ........................... upgrade_cow_giant_banners
# Royal Apartments ........................ upgrade_cow_royal_apartments
# Historical Mural ........................ upgrade_cow_historical_mural
# Custodian of the Lighthouse ............. upgrade_cow_lighthouse_custodian

## Royal Palace upgrades ##
# Fancy Throne Room ....................... upgrade_cow_throne_fancy
# Trap Door ............................... upgrade_cow_trap_door
# Royal Bedchamber ........................ upgrade_cow_royal_bedchamber
# Throne of Skulls ........................ upgrade_cow_skull_throne
# Golden Throne ........................... upgrade_cow_golden_throne
# Automata Throne ......................... upgrade_cow_automata_throne
# Torture Chamber ......................... upgrade_cow_torture_chamber
# Brewery ................................. upgrade_cow_brewery
# Dueling Room ............................ upgrade_cow_dueling_room
# Royal Custodian ......................... upgrade_cow_royal_custodian

## Amphitheatre upgrades ##
# Naval Spectacle ......................... upgrade_cow_naval_spectacle
# Animal Cages ............................ upgrade_cow_animal_cages
# Hippodrome .............................. upgrade_cow_hippodrome
# Amphitheatron ........................... upgrade_cow_amphitheatron_byz # Unique - Byzantion
# Circus Maximus .......................... upgrade_cow_circus_maximus # Unique - Roma
# Training Academy ........................ upgrade_cow_training_academy
# Theater Stage ........................... upgrade_cow_theater_stage
# Master of the Games ..................... upgrade_cow_master_of_the_games

## Garden upgrades ##
# Fountains ............................... upgrade_cow_fountains
# Fountain of Youth ....................... upgrade_cow_fountain_of_youth
# Hanging Gardens ......................... upgrade_cow_hanging_gardens
# Secluded Groves ......................... upgrade_cow_secluded_groves
# Hidden Burial Spot ...................... upgrade_cow_hidden_burial
# Poisonous Flowers ....................... upgrade_cow_poisonous_flowers
# Herb Garden ............................. upgrade_cow_herb_garden
# Garden Statues .......................... upgrade_cow_statues_garden
# Vineyard ................................ upgrade_cow_vineyard
# Pet Graveyard ........................... upgrade_cow_pet_graveyard

## Library upgrades ##
# Poetry and Drama Collection ............. upgrade_cow_collection_drama
# Architecture Collection ................. upgrade_cow_collection_architecture
# Math and Philosophy Collection .......... upgrade_cow_collection_math
# History Collection ...................... upgrade_cow_collection_history
# Natural Sciences Collection ............. upgrade_cow_collection_science
# Scribe Room ............................. upgrade_cow_scribe_room
# Keeper of the Tomes ..................... upgrade_cow_keeper_of_tomes

## University upgrades ##
# Great Seminars .......................... upgrade_cow_great_seminars
# Wing of Diplomacy ....................... upgrade_cow_wing_of_diplomacy
# Wing of Strategy ........................ upgrade_cow_wing_of_martial
# Wing of Finance ......................... upgrade_cow_wing_of_stewardship
# Wing of Secrets ......................... upgrade_cow_wing_of_intrigue
# Wing of Theology ........................ upgrade_cow_wing_of_learning
# Guardian of Knowledge ................... upgrade_cow_guardian_of_knowledge

## Mausoleum upgrades ##
# Statues of the Dead ..................... upgrade_cow_statues_dead
# Eternal Flame ........................... upgrade_cow_eternal_flame
# Unmarked Tombs .......................... upgrade_cow_unmarked_tombs
# Quadriga Statue ......................... upgrade_cow_quadriga_statue
# Keeper of the Dead ...................... upgrade_cow_keeper_of_the_dead
# Horse Graveyard ......................... upgrade_cow_horse_graveyard

## Pagan Stones upgrades ##
# Rune Stones ............................. upgrade_cow_runestones
# More Stones ............................. upgrade_cow_more_stones
# Custodian of the Stone .................. upgrade_cow_stone_custodian

## Pyramids upgrades ##
# Extra Pyramids .......................... upgrade_cow_extra_pyramids
# Mythological Beast ...................... upgrade_cow_mythological_beast
# Hidden Room ............................. upgrade_cow_hidden_room
# Necropolis .............................. upgrade_cow_necropolis
# Traps ................................... upgrade_cow_traps
# Lime Stone Casing ....................... upgrade_cow_lime_stone_casing
# Overseer of the Rites ................... upgrade_cow_overseer_of_rites

## Cordoba upgrades ##
# Street Lamps of Cordoba ................. upgrade_cow_street_lamps_cord
# Sewers of Cordoba ....................... upgrade_cow_sewers_cord

### COW UPGRADES ###
# Cathedral upgrades:
upgrade_cow_gargoyles = { # Gargoyles
	picture = GFX_upgrade_icon_skulls

	potential = { 
		religion_group = christian 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = christian } }
			religion_group = christian
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { 
		OR = { 
			religion_group = christian
			religion_openly_hellenic_or_reformed_trigger = yes
		}
	}

	flags = {
		scary
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		cruel_opinion = 5
		custom_modifier_text = execution_possible_modifier_tt
		custom_modifier_text = intimidation_possible_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_bells = { # Bells
	picture = GFX_upgrade_icon_ingots_silver

	potential = { 
		religion_group = christian 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = christian } }
			religion_group = christian
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		defensive
		decorative
		is_plural
		bells
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		siege_defence = 0.1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_stained_glass_window = { # Stained Glass Window
	picture = GFX_upgrade_icon_roses_red

	potential = { 
		religion_group = christian 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = christian } }
			religion_group = christian
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { 
		OR = { 
			religion_group = christian
			religion_openly_hellenic_or_reformed_trigger = yes
		}
	}

	flags = {
		decorative
		is_singular
		contemplative
	}
	build_time = 20
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		church_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_relic_tomb = { # Relic Tomb
	picture = GFX_upgrade_icon_key
	
	potential = { 
		religion_group = christian 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = christian } }
			religion_group = christian
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { 
		OR = { 
			religion_group = christian
			religion_openly_hellenic_or_reformed_trigger = yes
		}
		custom_tooltip = {
			text = must_be_storing_a_relic_TT
			hidden_tooltip = {
				FROM = { has_wonder_upgrade_flag = is_storing_relic }
			}
		}
	}

	flags = {
		valuable
		is_singular
		holy
		stores_relic
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_piety = 0.25
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_grand_basilica = { # Grand Basilica
	picture = GFX_upgrade_icon_crates

	potential = { 
		religion_group = christian 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = christian } }
			religion_group = christian
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { 
		OR = { 
			religion_group = christian
			religion_openly_hellenic_or_reformed_trigger = yes
		}
	}

	flags = {
		decorative
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		town_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_catacombs = { # Catacombs
	picture = GFX_upgrade_icon_skulls

	potential = { 
		religion_group = christian 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = christian } }
			religion_group = christian
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { 
		OR = { 
			religion_group = christian
			religion_openly_hellenic_or_reformed_trigger = yes
		}
	}

	flags = {
		decorative
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_piety = 0.05
	}
	local_modifier = {
		siege_defence = 0.1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_necropolis_alex = { # Lophus Kiramaikos
	picture = GFX_upgrade_icon_skulls

	potential = { 
		OR = { 
			religion_group = christian
			religion_openly_hellenic_or_reformed_trigger = yes
			culture = coptic
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = christian } }
			religion_group = christian
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { 
		OR = { 
			religion_group = christian
			religion_openly_hellenic_or_reformed_trigger = yes
			culture = coptic
		}
	}

	flags = {
		decorative
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_piety = 0.05
	}
	local_modifier = {
		siege_defence = 0.1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_giant_cross = { # Giant Cross
	picture = GFX_upgrade_icon_crates
	
	potential = { 
		religion_group = christian 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = christian } }
			religion_group = christian
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { 
		religion_group = christian
		# OR = { 
			# religion_group = christian
			# religion = hellenic_pagan
			# religion = hellenic_pagan_reformed
		# }
	}

	flags = {
		decorative
		is_singular
		contemplative
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		same_religion_opinion = 2
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_bells_golden = { # Golden Bells
	picture = GFX_upgrade_icon_ingots_gold

	potential = { 
		religion_group = christian 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_cathedral
				has_cow_unique_cathedral_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = christian } }
			religion_group = christian
		}
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_bells }
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { 
		OR = { 
			religion_group = christian
			religion_openly_hellenic_or_reformed_trigger = yes
		}
	}

	flags = {
		defensive
		decorative
		is_plural
		golden
		bells
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		proud_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Mosque upgrades:
upgrade_cow_minaret = {  # Minaret
	picture = GFX_upgrade_icon_tower

	potential = { 
		religion_group = muslim 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = muslim } }
			religion_group = muslim
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = muslim }

	flags = {
		towering
		religion_conversion_faster
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		same_religion_opinion = 2
		custom_modifier_text = religious_spread_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_open_courtyard = { # Sahn
	picture = GFX_upgrade_icon_tower

	potential = { 
		religion_group = muslim 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = muslim } }
			religion_group = muslim
		}
		num_of_wonder_upgrades = 2
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = muslim }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		disease_defence = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_dome = { # Qubba
	picture = GFX_upgrade_icon_crates

	potential = { 
		religion_group = muslim 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = muslim } }
			religion_group = muslim
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = muslim }

	flags = {
		towering
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		same_religion_opinion = 4
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_lamps_hanging = { # Magnificent Hanging Lamps
	picture = GFX_upgrade_icon_crates # Arc?

	potential = { 
		religion_group = muslim 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = muslim } }
			religion_group = muslim
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = muslim }

	flags = {
		decorative
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		same_religion_opinion = 2
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_soup_kitchen = { # Soup Kitchen
	# Not only for prayer, the mosque is a civic center, caring for the needy.
	picture = GFX_upgrade_icon_door# House?

	potential = { 
		religion_group = muslim 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = muslim } }
			religion_group = muslim
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = {  } # Should be active even if the owner is not Muslim?

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_revolt_risk = -0.02
		disease_defence = 0.025
	}
	owner_modifier = {
		kind_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_school_mosque = { # School
	picture = GFX_upgrade_icon_book_red

	potential = { 
		religion_group = muslim 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = muslim } }
			religion_group = muslim
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = muslim }

	flags = {
		culture_conversion_faster
		inspires_learning
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_revolt_risk = -0.01
	}
	owner_modifier = {
		scholar_opinion = 5
		custom_modifier_text = culture_convertion_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_hostel = { # Caravanserai (Hostel for travelers)
	picture = GFX_upgrade_icon_house
	potential = { 
		religion_group = muslim 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = muslim } }
			religion_group = muslim
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = muslim }

	flags = {
		air_bnb
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_piety = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_custodian_of_the_mosque = { # Custodian of the Mosque
	picture = GFX_upgrade_icon_key
	potential = { 
		religion_group = muslim 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = muslim } }
			religion_group = muslim
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_mosque
				has_cow_unique_mosque_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = muslim }

	flags = {
		is_singular
		unlocks_minor_title
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		custom_modifier_text = custodian_of_mosque_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Synagogue upgrades:
upgrade_cow_tallest_building = { # Tallest Building
	picture = GFX_upgrade_icon_stones

	potential = { 
		religion_group = jewish_group 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_synagogue
				has_cow_unique_synagogue_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = jewish_group } }
			religion_group = jewish_group
		}
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_synagogue
				has_cow_unique_synagogue_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = jewish_group }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_prestige = 0.05
		land_morale = 0.01
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_garden_outer = { #Outer Wall and Open Garden
	picture = GFX_upgrade_icon_roses_yellow

	potential = { 
		religion_group = jewish_group 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_synagogue
				has_cow_unique_synagogue_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = jewish_group } }
			religion_group = jewish_group
		}
		num_of_wonder_upgrades = 2
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_synagogue
				has_cow_unique_synagogue_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = jewish_group }

	flags = {
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		land_organisation = 0.1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_holy_ark = { # Holy Ark (aka the "Torah Ark")
	picture = GFX_upgrade_icon_door # Arc?

	potential = { 
		religion_group = jewish_group 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_synagogue
				has_cow_unique_synagogue_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = jewish_group } }
			religion_group = jewish_group
		}
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_synagogue
				has_cow_unique_synagogue_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = jewish_group }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		church_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_decorations = { # Elaborate Decorations
	# Elaborate decorations will help elevate the spirit of the faithful to the heavens.
	picture = GFX_upgrade_icon_door # Arc? Gold details?

	potential = { 
		religion_group = jewish_group 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_synagogue
				has_cow_unique_synagogue_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = jewish_group } }
			religion_group = jewish_group
		}
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_synagogue
				has_cow_unique_synagogue_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = jewish_group }

	flags = {
		is_plural
		decorative
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		same_religion_opinion = 2
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_choir_rooms = { # Choir Rooms
	picture = GFX_upgrade_icon_door # Arc? Gold details?

	potential = { 
		religion_group = jewish_group 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_synagogue
				has_cow_unique_synagogue_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = jewish_group } }
			religion_group = jewish_group
		}
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_synagogue
				has_cow_unique_synagogue_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = jewish_group }

	flags = {
		room
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_piety = 0.05
		monthly_character_prestige = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_school_synagogue = { # School
	picture = GFX_upgrade_icon_book_red

	potential = { 
		religion_group = jewish_group 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_synagogue
				has_cow_unique_synagogue_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = jewish_group } }
			religion_group = jewish_group
		}
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_synagogue
				has_cow_unique_synagogue_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = jewish_group }

	flags = {
		culture_conversion_faster
		inspires_learning
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_revolt_risk = -0.01
	}
	owner_modifier = {
		scholar_opinion = 5
		custom_modifier_text = culture_convertion_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Pagan temple upgrades:
upgrade_cow_statue_god = { # Statue of a God
	picture = GFX_upgrade_icon_statue

	potential = { 
		religion_group = pagan_group 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = pagan_group } }
			religion_group = pagan_group
		}
		NOT = { religion = iconoclast }
		trigger_if = {
			limit = {
				religion_group = muslim
			}
			NOT = { trait = zealous }
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = pagan_group }

	flags = {
		decorative
		holy
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_piety = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_temple_guards = { # Temple Guards
	picture = GFX_upgrade_icon_guard
	
	potential = { 
		religion_group = pagan_group 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = pagan_group } }
			religion_group = pagan_group
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = pagan_group }

	flags = {
		defensive
		#unit
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_revolt_risk = -0.1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_sacrificial_altar = { # Sacrificial Altar
	picture = GFX_upgrade_icon_skulls

	potential = { 
		has_religion_feature = religion_ritual_sacrifice 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_pagan_stones
				has_cow_unique_pagan_stones_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_aztec_pyramid
			}
		}	
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_pagan_stones
				has_cow_unique_pagan_stones_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_aztec_pyramid
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { has_religion_feature = religion_ritual_sacrifice }

	flags = {
		is_singular
		sacrificial_altar
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_revolt_risk = -0.05
	}
	owner_modifier = {
		zealous_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_sacred_grove = { # Sacred Grove
	picture = GFX_upgrade_icon_roses_white

	potential = { 
		religion_group = pagan_group 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_pagan_stones
				has_cow_unique_pagan_stones_district_trigger = yes
			}
		}	
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = pagan_group } }
			religion_group = pagan_group
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_pagan_stones
				has_cow_unique_pagan_stones_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = pagan_group }

	flags = {
		holy
		decorative
		nature
		is_singular
		secluded
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_revolt_risk = -0.04
	}
	owner_modifier = {
		custom_modifier_text = private_talk_possible_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_prophecy_rooms = { # Prophecy Rooms
	picture = GFX_upgrade_icon_crates

	potential = { 
		religion_group = pagan_group 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
			}
		}	
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = pagan_group } }
			religion_group = pagan_group
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}		
	}
	active = { religion_group = pagan_group }

	flags = {
		room
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		zealous_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_temple_precinct = { # Temple Precinct
	picture = GFX_upgrade_icon_crates

	potential = { 
		religion_group = pagan_group 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
			}
		}	
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = pagan_group } }
			religion_group = pagan_group
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = pagan_group }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		same_religion_opinion = 2
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_inner_sanctuary = { # Inner Sanctuary
	picture = GFX_upgrade_icon_crates

	potential = { 
		religion_group = pagan_group 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = pagan_group } }
			religion_group = pagan_group
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}		
	}
	active = { religion_group = pagan_group }

	flags = {
		room
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		diligent_opinion = 5
	}
	local_modifier = {
		local_revolt_risk = -0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_custodian_of_temple = { # Custodian of the Temple
	picture = GFX_upgrade_icon_key
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion_group = pagan_group } }
			religion_group = pagan_group
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_temple_pagan
				has_wonder_upgrade = upgrade_cow_district_temple_hellenic
				has_cow_unique_hellenic_temple_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_group = pagan_group }

	flags = {
		is_singular
		unlocks_minor_title
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		custom_modifier_text = custodian_of_temple_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Buddhist temple upgrades:
upgrade_cow_chaitya-grihas = { # Chaitya-Grihas
	picture = GFX_upgrade_icon_crates
	
	potential = { 
		religion = buddhist 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }	
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = buddhist } }
			religion = buddhist
		}
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}		
	}
	active = { religion = buddhist }

	flags = {
		is_plural
		contemplative
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_revolt_risk = -0.04
	}
	owner_modifier = {

	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}

}

upgrade_cow_gompa = { # Gompa
	picture = GFX_upgrade_icon_crates
	
	potential = { 
		religion = buddhist 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }	
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = buddhist } }
			religion = buddhist
		}
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = {  } #active even if owner not of the same religion

	flags = {
		is_singular
		defensive
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		siege_defence = 0.10
	}
	owner_modifier = {
	
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_bodhi_tree = { # Bodhi Tree
	picture = GFX_upgrade_icon_crates
	
	potential = { 
		religion = buddhist 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }	
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = buddhist } }
			religion = buddhist
		}
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}		
	}
	active = { religion = buddhist }

	flags = {
		is_singular
		contemplative
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		same_religion_opinion = 2
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_cave_complex = { # Cave Complex
	picture = GFX_upgrade_icon_crates
	
	potential = { 
		religion = buddhist 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }	
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = buddhist } }
			religion = buddhist
		}
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { } # active even if owner is not a Budhist?

	flags = {
		is_singular
		defensive
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		siege_defence = 0.10
	}
	owner_modifier = {
	
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_vihara = { # Vihara
	picture = GFX_upgrade_icon_crates
	
	potential = { 
		religion = buddhist 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }	
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = buddhist } }
			religion = buddhist
		}
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion = buddhist }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		disease_defence = 0.05
	}
	owner_modifier = {
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_school_buddhist = { # Buddhist School
	picture = GFX_upgrade_icon_crates
	
	potential = { 
		religion = buddhist 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }	
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = buddhist } }
			religion = buddhist
		}
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion = buddhist }

	flags = {
		culture_conversion_faster
		inspires_learning
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_revolt_risk = -0.02
	}
	owner_modifier = {
		scholar_opinion = 5
		custom_modifier_text = culture_convertion_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_relic_stupa = { # Relic Stupa
	picture = GFX_upgrade_icon_crates
	
	potential = { 
		religion = buddhist 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }	
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = buddhist } }
			religion = buddhist
		}
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { 
		religion = buddhist
		custom_tooltip = {
			text = must_be_storing_a_relic_TT
			hidden_tooltip = {
				FROM = { has_wonder_upgrade_flag = is_storing_relic }
			}
		}
	}

	flags = {
		valuable
		is_singular
		holy
		stores_relic
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		monthly_character_piety = 0.25
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_commerative_stupa = { # Commerative Stupa
	picture = GFX_upgrade_icon_crates
	
	potential = { 
		religion = buddhist 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }	
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = buddhist } }
			religion = buddhist
		}
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion = buddhist }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		indian_group_opinion = 2
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}

}

upgrade_cow_symbolic_stupa = { # Symbolic Stupa
	picture = GFX_upgrade_icon_crates
	
	potential = { 
		religion = buddhist 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }	
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = buddhist } }
			religion = buddhist
		}
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion = buddhist }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		buddhist_opinion = 3
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_votive_stupa = { # Votive Stupa
	picture = GFX_upgrade_icon_crates
	
	potential = { 
		religion = buddhist 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }	
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = buddhist } }
			religion = buddhist
		}
		num_of_wonder_upgrades = 6
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_temple_buddhist }
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion = buddhist }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_tax_modifier = 0.10
	}
	owner_modifier = {
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Hindu temple upgrades:
upgrade_cow_high_gopura = { # Gopuram
	picture = GFX_upgrade_icon_crates

	potential = { 
		religion = hindu 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_temple_hindu
				has_cow_unique_hindu_temple_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = hindu } }
			religion = hindu
		}
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_temple_hindu
				has_cow_unique_hindu_temple_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion = hindu }

	flags = {
		towering
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		siege_defence = 0.10
	}
	owner_modifier = {
		same_religion_opinion = 2
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_shikhara = { # Shikhara
	picture = GFX_upgrade_icon_crates

	potential = { 
		religion = hindu 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_temple_hindu
				has_cow_unique_hindu_temple_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = hindu } }
			religion = hindu
		}
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_temple_hindu
				has_cow_unique_hindu_temple_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion = hindu }

	flags = {
		towering
		is_singular
		religion_conversion_faster
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_revolt_risk = -0.02
	}
	owner_modifier = {
		church_opinion = 3
		custom_modifier_text = religious_spread_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_mandapa = {  # Maha Mandapa
	picture = GFX_upgrade_icon_crates

	potential = { 
		religion = hindu 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_temple_hindu
				has_cow_unique_hindu_temple_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = hindu } }
			religion = hindu
		}
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_temple_hindu
				has_cow_unique_hindu_temple_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion = hindu }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_revolt_risk = -0.02
	}
	owner_modifier = {
		land_organisation = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_temple_complex = { # Temple Complex
	picture = GFX_upgrade_icon_crates

	potential = { 
		religion = hindu 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_temple_hindu
				has_cow_unique_hindu_temple_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = hindu } }
			religion = hindu
		}
		num_of_wonder_upgrades = 4
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_temple_hindu
				has_cow_unique_hindu_temple_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion = hindu }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_revolt_risk = -0.02
	}
	owner_modifier = {
		dynasty_opinion = 3
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_school_hindu = { # Calai
	picture = GFX_upgrade_icon_book_red

	potential = { 
		religion = hindu 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_temple_hindu
				has_cow_unique_hindu_temple_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = hindu } }
			religion = hindu
		}
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_temple_hindu
				has_cow_unique_hindu_temple_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion = hindu }

	flags = {
		culture_conversion_faster
		inspires_learning
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_revolt_risk = -0.02
	}
	owner_modifier = {
		scholar_opinion = 5
		custom_modifier_text = culture_convertion_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_hospital_hindu = { # Hospital
	picture = GFX_upgrade_icon_house

	potential = { 
		religion = hindu 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_temple_hindu
				has_cow_unique_hindu_temple_district_trigger = yes
			}
		}
	}
	allow = {
		trigger_if = {
			limit = { NOT = { religion = hindu } }
			religion = hindu
		}
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_temple_hindu
				has_cow_unique_hindu_temple_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = {  }  #active even if owner is not of same religion

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		disease_defence = 0.05
	}
	owner_modifier = {
		monthly_character_piety = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Statue upgrades:
upgrade_cow_plating_gold = { # Gold Plating 
	picture = GFX_upgrade_icon_ingots_gold

	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_statue_ruler
				has_cow_unique_statue_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_horse_statue
				has_cow_unique_horse_statue_district_trigger = yes
			}
		}
	}
	allow = {
		custom_tooltip = {
			text = no_other_plating_tt
			hidden_trigger = {
				NOT = {
					FROMFROM = { has_wonder_upgrade_flag = plating }
				}
			}
		}
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_statue_ruler
				has_cow_unique_statue_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_horse_statue
				has_cow_unique_horse_statue_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		plating
		is_singular
		golden
	}
	build_time = 24
	gold_cost_flat = 700
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_prestige = 0.3
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_plating_silver = { # Silver Plating
	picture = GFX_upgrade_icon_ingots_silver
	
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_statue_ruler
				has_cow_unique_statue_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_horse_statue
				has_cow_unique_horse_statue_district_trigger = yes
			}
		}
	}
	allow = {
		custom_tooltip = {
			text = no_other_plating_tt
			hidden_trigger = {
				NOT = {
					FROMFROM = { has_wonder_upgrade_flag = plating }
				}
			}
		}
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_statue_ruler
				has_cow_unique_statue_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_horse_statue
				has_cow_unique_horse_statue_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		plating
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_prestige = 0.2
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_plating_bronze = { # Bronze Plating
	#....
	picture = GFX_upgrade_icon_ingots_bronze

	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_statue_ruler
				has_cow_unique_statue_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_horse_statue
				has_cow_unique_horse_statue_district_trigger = yes
			}
		}
	}
	allow = {
		custom_tooltip = {
			text = no_other_plating_tt
			hidden_trigger = {
				NOT = {
					FROMFROM = { has_wonder_upgrade_flag = plating }
				}
			}
		}
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_statue_ruler
				has_cow_unique_statue_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_horse_statue
				has_cow_unique_horse_statue_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		plating
		is_singular
	}
	build_time = 24
	gold_cost_flat = 350
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_prestige = 0.1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_statues_family = { # Additional Statues
	#....
	picture = GFX_upgrade_icon_stones

	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_statue_ruler
				has_cow_unique_statue_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_horse_statue
				has_cow_unique_horse_statue_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_statue_ruler
				has_cow_unique_statue_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_horse_statue
				has_cow_unique_horse_statue_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		statues
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		dynasty_opinion = 3
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_golden_crown = { # Golden Crown
	#....
	picture = GFX_upgrade_icon_statue

	potential = { 
		FROMFROM = { wonder_stage = 4 }
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_statue_ruler
				has_cow_unique_statue_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_statue_ruler
				has_cow_unique_statue_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		statues
		is_plural
	}
	build_time = 575
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		vassal_opinion = 3
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_watcher_of_giants = { # Watcher of Giants
	picture = GFX_upgrade_icon_key
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_statue_ruler
				has_cow_unique_statue_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_statue_ruler
				has_cow_unique_statue_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		unlocks_minor_title
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		custom_modifier_text = watcher_of_giants_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Horse Statue upgrades:
upgrade_cow_stable = { # Grand Stable
	# A stable containing horses descending from your trusty steed
	picture = GFX_upgrade_icon_crates

	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_horse_statue
				has_cow_unique_horse_statue_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_horse_statue
				has_cow_unique_horse_statue_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		command_modifier = {
			cavalry = 0.05
			archers = 0.05
		}
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_statues_animals = { # Additional Animal Statues (Statues of other animals)
	#....
	picture = GFX_upgrade_icon_statue
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_horse_statue
				has_cow_unique_horse_statue_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_horse_statue
				has_cow_unique_horse_statue_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		statues
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		kind_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Walls upgrades:
upgrade_cow_walls_sea = { # Sea Walls
	#Attack from the sea is often the last thing a city considers. Not so for this wealthy settlement, which has poured money and men into a thick blanket of interconnected walls, defending them from all but the most savage of ocean-going assaults.
	#Technical: Extra layers of walls around the harbor to protect from the sea.
	picture = GFX_upgrade_icon_anchor

	potential = {		
		FROMFROMFROM = {
			is_coastal = yes
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
	}
	allow = {
		FROMFROMFROM = {
			is_coastal = yes
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	build_time = 60
	gold_cost_flat = 500
	gold_cost_ticking = 1

	owner_modifier = {
		town_opinion = 5
	}
	
	local_modifier = {
		siege_defence = 0.20
	}
	flags = {

	}
	active = {
		#always
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_studded_bastions = { # Studded Bastions
	#The city's defenses have begun to spill out onto the land, with ropes of well-maintained walls criss-crossing the main approach to the burgh. Adding extra bastions to these will bulge the amount of walkable perimeter (and so how many troops can man them) without noticeably increasing cost.
	#Construct additional bastions along the walls, bulging the amount of walkable perimeter that can be used for defense along any given stretch.
	picture = GFX_upgrade_icon_stones

	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
	}
	allow = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	
	build_time = 60
	gold_cost_flat = 500
	gold_cost_ticking = 1

	owner_modifier = {
	}
	
	local_modifier = {
		siege_defence = 0.05
		archers = 200
	}
	
	flags = {

	}
	active = {
		#always
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_strategic_exclaves = { # Strategic Exclaves
	#A city is nothing without its countryside, and this city takes that seriously. Vital local townships are now guarded by their own fortifications, paid for and maintained by the capital-settlement, and the closest are even connected by short walls to form a single, defensible sprawl.
	#Extend the defenses to nearby local townships, forming a huge fortified complex.
	picture = GFX_upgrade_icon_stones

	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
	}
	allow = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	
	build_time = 120
	gold_cost_flat = 1000
	gold_cost_ticking = 5

	owner_modifier = {
 		town_opinion = 3
		#" * Immediately gain maximum walls & fortification buildings in all currently-built baronies in the county (irrelevant of technology or other construction concerns, because wonder).
 		custom_modifier_text = holdings_walls_upgrade_custom_modifier_tt
	}
	
	
	local_modifier = {
		local_tax_modifier = 0.05
	}
	
	flags = {
		upgrades_walls_on_build
	}
	active = {
		#always
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_soaring_fortresses = { # Soaring Fortresses
	#These dire, imposing stoneworks punch upwards like massive, artificial fists. Crowned with rows of bastions and studded with fortified towers, none may approach without being seen, and no amount of lesser walls captured will stop the enfilading from their legions of archers.
	#Construct massive individual fortresses within the wider network.
	picture = GFX_upgrade_icon_stones

	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
	}
	allow = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	
	build_time = 60
	gold_cost_flat = 500
	gold_cost_ticking = 1

	local_modifier = {
		heavy_infantry = 100
		siege_defence = 0.05
	}
	owner_modifier = {
		custom_modifier_text = castellan_custom_modifier_tt
	}
	flags = {
		towering
	}
	active = {
		#always
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_hidden_gates = { # Hidden Gates
	# Secreted behind sewer shafts, diving under the moats, cut into the side of obscuring bastions: the defenders of this city strike often and without warning from their many and varied hiding places, before vanishing back into the night.
	# Secret gates and sally ports to make easier strikes outwards.
	
	picture = GFX_upgrade_icon_key

	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
	}
	allow = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	
	build_time = 24
	gold_cost_flat = 500
	gold_cost_ticking = 1

	owner_modifier = {
		custom_modifier_text = better_chance_of_defender_siege_events_custom_modifier_tt
	}
	
	local_modifier = {
		siege_defence = 0.10
	}
	
	
	flags = {
		hidden_gates
	}
	active = {
		#always
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_gatehouse_forts = { # Gatehouse Forts
	#Turn each gatehouse into a full-scale fortress in its own right, and so turn each layer of the walls into a separate mini-siege.
	
	picture = GFX_upgrade_icon_stones

	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
	}
	allow = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	
	build_time = 24
	gold_cost_flat = 400
	gold_cost_ticking = 1

	owner_modifier = {
	}
	
	local_modifier = {
		siege_defence = 0.05
		archers = 150
	}
	
	flags = {

	}
	active = {
		#always
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_killing_fields = { # Staged Killing Fields
	#Planned routes through the defenses that are simple, clear, devoid of cover, and looked over by the maximum possible number of defenses, always with a difficult fortress guarded the next killing ground along.
	picture = GFX_upgrade_icon_skulls

	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
	}
	allow = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	
	build_time = 24
	gold_cost_flat = 400
	gold_cost_ticking = 1

	owner_modifier = {
	}
	
	local_modifier = {
		archers = 100
		siege_defence = 0.10
	}
	
	flags = {

	}
	active = {
		#always
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_deep_defense_architecture = { # Deep Defense Architecture
	picture = GFX_upgrade_icon_crates
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
	}
	allow = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	
	build_time = 60
	gold_cost_flat = 500
	gold_cost_ticking = 1

	owner_modifier = {
	}
	
	local_modifier = {
		siege_defence = 0.10
	}
	
	flags = {

	}
	active = {
		#always
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_artificial_islands = { # Artificial Islands
	#Redirect local rivers and channel defensive islands out of the sea itself, adding a naval element to any siege that few attackers are equipped to deal with.
	picture = GFX_upgrade_icon_stones

	potential = {
		FROMFROMFROM = {
			is_coastal = yes
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
	}
	allow = {
		FROMFROMFROM = {
			is_coastal = yes
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	
	build_time = 120
	gold_cost_flat = 300
	gold_cost_ticking = 1

	owner_modifier = {
	}
	
	local_modifier = {
		siege_defence = 0.10
	}
	
	flags = {

	}
	active = {
		#always
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_mirror_towers = { # Mirror Towers of Syrakousai
	picture = GFX_upgrade_cow_district_mirror_towers

	potential = {
		FROMFROMFROM = {
			is_coastal = yes
			province_id = 343 # Siracusa
		}
	}
	allow = {
		FROMFROMFROM = {
			is_coastal = yes
			province_id = 343 # Siracusa
			has_wonder_upgrade = upgrade_cow_district_grand_walls_syra
			has_wonder_upgrade = upgrade_cow_district_library_syra
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	
	build_time = 120
	gold_cost_flat = 300
	gold_cost_ticking = 1

	owner_modifier = {
	}
	
	local_modifier = {
		siege_defence = 0.25
	}
	
	flags = {

	}
	active = {
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_archimedes_claw = { # Claw of Archimedes
	picture = GFX_upgrade_cow_archimedes_claw

	potential = {
		FROMFROMFROM = {
			is_coastal = yes
			province_id = 343 # Siracusa
		}
	}
	allow = {
		FROMFROMFROM = {
			is_coastal = yes
			province_id = 343 # Siracusa
			has_wonder_upgrade = upgrade_cow_district_grand_walls_syra
			has_wonder_upgrade = upgrade_cow_district_library_syra
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	
	build_time = 120
	gold_cost_flat = 300
	gold_cost_ticking = 1

	owner_modifier = {
	}
	
	local_modifier = {
		siege_defence = 0.35
	}
	
	flags = {

	}
	active = {
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_gastraphetes_makers = { # Gastraphetes Makers
	picture = GFX_upgrade_cow_gastraphetes_makers

	potential = {
		FROMFROMFROM = {
			is_coastal = yes
			province_id = 343 # Siracusa
		}
	}
	allow = {
		FROMFROMFROM = {
			is_coastal = yes
			province_id = 343 # Siracusa
			has_wonder_upgrade = upgrade_cow_district_grand_walls_syra
			has_wonder_upgrade = upgrade_cow_district_library_syra
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	
	build_time = 120
	gold_cost_flat = 300
	gold_cost_ticking = 1

	owner_modifier = {
	}
	
	local_modifier = {
		siege_defence = 0.2
		archers = 300
	}
	
	flags = {

	}
	active = {
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_wall_walker = { # Walker of the Wall
	picture = GFX_upgrade_icon_key
	potential = {
		FROMFROMFROM = {
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = {
			OR = {
				has_wonder_upgrade = upgrade_cow_district_grand_walls
				has_cow_unique_grand_walls_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		unlocks_minor_title
	}
	build_time = 12
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		custom_modifier_text = wall_walker_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Fortress upgrades:
upgrade_cow_armory = {	# Armory
	picture = GFX_upgrade_icon_equipment	
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_fortress
				has_cow_unique_fortress_district_trigger = yes
			}
		}
	 }
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_fortress
				has_cow_unique_fortress_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		armory
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {		
	}
	local_modifier = {
		heavy_infantry = 100
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_watch_tower = {	# Watch Tower
	picture = GFX_upgrade_icon_bow_and_arrows
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_fortress
				has_cow_unique_fortress_district_trigger = yes
			}
		}
	}
	allow = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_fortress
				has_cow_unique_fortress_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		towering
	}
	build_time = 48
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		arrest_chance_modifier = 0.05
	}
	local_modifier = {
		siege_defence = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_vault = { # Vault
	picture = GFX_upgrade_icon_key
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_fortress
				has_cow_unique_fortress_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_fortress
				has_cow_unique_fortress_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		artifact_protection
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		custom_modifier_text = less_likely_to_be_looted_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_moat_pit = { # Pit Moat	
	picture = GFX_upgrade_icon_stones
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_fortress
				has_cow_unique_fortress_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_fortress
				has_cow_unique_fortress_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		custom_modifier_text = execution_possible_modifier_tt
	}
	local_modifier = {
		siege_defence = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_moat_spike = { # Spike Moat
	picture = GFX_upgrade_icon_skulls
	potential = {
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_moat_pit }
	}
	allow = { 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_moat_pit }
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_moat_pit } }

	flags = {
		is_singular
		scary
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		custom_modifier_text = execution_possible_modifier_tt
		custom_modifier_text = intimidation_possible_modifier_tt
	}
	local_modifier = {
		siege_defence = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_moat_water = { # Water Moat
	picture = GFX_upgrade_icon_anchor
	potential = { 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_moat_pit }
	}
	allow = { 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_moat_pit }
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}		
	}
	active = { FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_moat_pit } }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		custom_modifier_text = execution_possible_modifier_tt
	}
	local_modifier = {
		siege_defence = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_moat_bones = { # Moat of Bones
	picture = GFX_upgrade_icon_skulls
	potential = { 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_moat_pit }
		trait = cruel  
	}
	allow = {
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_moat_pit }
		any_kill_list_character = { # At least 50 kills
			count = 50
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = {
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_moat_pit }
		trait = cruel
	}

	flags = {
		is_singular
		scary
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		custom_modifier_text = execution_possible_modifier_tt
		custom_modifier_text = intimidation_possible_modifier_tt
	}
	local_modifier = {
		siege_defence = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_hidden_passageways = { # Hidden Passageways
	picture = GFX_upgrade_icon_key
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_fortress
				has_cow_unique_fortress_district_trigger = yes
			}
		}
	 }
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_fortress
				has_cow_unique_fortress_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_plural
		hidden_passageways
	}
	build_time = 36
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		assassinate_chance_modifier = 0.05
	}
	owner_modifier = {
		custom_modifier_text = hidden_passageways_modifier_tt
		court_size_modifier = 2
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_garden_inner = { # Inner Garden
	picture = GFX_upgrade_icon_roses_blue
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_fortress
				has_cow_unique_fortress_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_fortress
				has_cow_unique_fortress_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		secluded
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		land_organisation = 0.1
	}
	owner_modifier = {
		custom_modifier_text = private_talk_possible_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Underground City upgrades:
upgrade_cow_dungeon = { # Dungeon 
	picture = GFX_upgrade_icon_skulls
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_underground_city
				has_cow_unique_underground_city_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_underground_city
				has_cow_unique_underground_city_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		room
		is_singular
		scary
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		arrest_chance_modifier = 0.1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_caves_natural = { # Natural Caves
	picture = GFX_upgrade_icon_stones
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_underground_city
				has_cow_unique_underground_city_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_underground_city
				has_cow_unique_underground_city_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		defensive_plot_power_modifier = 0.1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_tunnels_travel = { # Travel Tunnels
	picture = GFX_upgrade_icon_key
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_underground_city
				has_cow_unique_underground_city_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_underground_city
				has_cow_unique_underground_city_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_plural
	}
	build_time = 60
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_movement_speed = 0.1
		court_size_modifier = 2
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_metal_mine_precious = {  # Precious Metal Mines
	picture = GFX_upgrade_icon_ingots_silver
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_underground_city
				has_cow_unique_underground_city_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_underground_city
				has_cow_unique_underground_city_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_plural
	}
	build_time = 36
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_tax_modifier = 0.1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_guardian_of_the_deep = { # Guardian of the Deep
	picture = GFX_upgrade_icon_key
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_underground_city
				has_cow_unique_underground_city_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_underground_city
				has_cow_unique_underground_city_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		unlocks_minor_title
	}
	build_time = 12
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		custom_modifier_text = deep_guardian_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Great Harbor upgrades:
upgrade_cow_cothon = { # Cothon
	picture = GFX_upgrade_icon_crates
	
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_harbor
				has_cow_unique_harbor_district_trigger = yes
			}
			is_coastal = yes
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_harbor
				has_cow_unique_harbor_district_trigger = yes
			}
			is_coastal = yes
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		siege_defence = 0.10
		supply_limit = 0.5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_piers = { # Piers
	picture = GFX_upgrade_icon_anchor
	
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_harbor
				has_cow_unique_harbor_district_trigger = yes
			}
			is_coastal = yes
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_harbor
				has_cow_unique_harbor_district_trigger = yes
			}
			is_coastal = yes
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		tradevalue = 30
		supply_limit = 0.25
		local_tax_modifier = 0.0025
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_office_harbor = { # Harbor Office
	picture = GFX_upgrade_icon_written_paper
	
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_harbor
				has_cow_unique_harbor_district_trigger = yes
			}
			is_coastal = yes
		}
	 }
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_harbor
				has_cow_unique_harbor_district_trigger = yes
			}
			is_coastal = yes
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_tax_modifier = 0.1
		supply_limit = 0.25
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_lighthouse = { # Lighthouse
	picture = GFX_upgrade_icon_brazier
	
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_harbor
				has_cow_unique_harbor_district_trigger = yes
			}
			is_coastal = yes
			NOR = {
				has_wonder_upgrade = upgrade_cow_district_lighthouse
				has_cow_unique_lighthouse_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_harbor
				has_cow_unique_harbor_district_trigger = yes
			}
			is_coastal = yes
			NOR = {
				has_wonder_upgrade = upgrade_cow_district_lighthouse
				has_cow_unique_lighthouse_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		tradevalue = 30
		local_tax_modifier = 0.05
		supply_limit = 0.25
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_military_wharf = { # Military Wharf
	picture = GFX_upgrade_icon_anchor
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_harbor
				has_cow_unique_harbor_district_trigger = yes
			}
			is_coastal = yes
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_harbor
				has_cow_unique_harbor_district_trigger = yes
			}
			is_coastal = yes
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		galleys_perc = 0.5
	}
	owner_modifier = {
		siege_speed = 0.15
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_master_of_tides = { # Master of the Tides
	picture = GFX_upgrade_icon_anchor
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_harbor
				has_cow_unique_harbor_district_trigger = yes
			}
			is_coastal = yes
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_harbor
				has_cow_unique_harbor_district_trigger = yes
			}
			is_coastal = yes
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		unlocks_minor_title
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		custom_modifier_text = master_of_tides_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Great Lighthouse upgrades:
upgrade_cow_treasure_chamber = { # Treasure Chamber

	picture = GFX_upgrade_icon_key
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_lighthouse
				has_cow_unique_lighthouse_district_trigger = yes
			}
			OR = { 
				is_coastal = yes
				has_wonder_upgrade = upgrade_cow_district_tower_of_babel
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_lighthouse
				has_cow_unique_lighthouse_district_trigger = yes
			}
			OR = { 
				is_coastal = yes
				has_wonder_upgrade = upgrade_cow_district_tower_of_babel
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		artifact_protection
		is_singular
		valuable
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		custom_modifier_text = less_likely_to_be_looted_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_giant_banners = { # Giant Banners

	picture = GFX_upgrade_icon_crates
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_lighthouse
				has_cow_unique_lighthouse_district_trigger = yes
			}
			OR = { 
				is_coastal = yes
				has_wonder_upgrade = upgrade_cow_district_tower_of_babel
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_lighthouse
				has_cow_unique_lighthouse_district_trigger = yes
			}
			OR = { 
				is_coastal = yes
				has_wonder_upgrade = upgrade_cow_district_tower_of_babel
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		land_morale = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_royal_apartments = { # Royal Apartments

	picture = GFX_upgrade_icon_roses_red
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_lighthouse
				has_cow_unique_lighthouse_district_trigger = yes
			}
			OR = { 
				is_coastal = yes
				has_wonder_upgrade = upgrade_cow_district_tower_of_babel
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_lighthouse
				has_cow_unique_lighthouse_district_trigger = yes
			}
			OR = { 
				is_coastal = yes
				has_wonder_upgrade = upgrade_cow_district_tower_of_babel
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_plural
		romantic
		secluded
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		sex_appeal_opinion = 3
		custom_modifier_text = private_talk_possible_modifier_tt
		court_size_modifier = 2
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_historical_mural = { # Historical Mural
	picture = GFX_upgrade_icon_decorative
	
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_lighthouse
				has_cow_unique_lighthouse_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_underground_city
				has_cow_unique_underground_city_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_lighthouse
				has_cow_unique_lighthouse_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_underground_city
				has_cow_unique_underground_city_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		decorative
		mural
	}
	build_time = 30
	gold_cost_flat = 300
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		dynasty_opinion = 3
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_lighthouse_custodian = { # Custodian of the Lighthouse

	picture = GFX_upgrade_icon_brazier
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_lighthouse
				has_cow_unique_lighthouse_district_trigger = yes
			}
			OR = { 
				is_coastal = yes
				has_wonder_upgrade = upgrade_cow_district_tower_of_babel
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_lighthouse
				has_cow_unique_lighthouse_district_trigger = yes
			}
			OR = { 
				is_coastal = yes
				has_wonder_upgrade = upgrade_cow_district_tower_of_babel
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		unlocks_minor_title
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		custom_modifier_text = lighthouse_custodian_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Royal Palace upgrades:
upgrade_cow_throne_fancy = { # Fancy Throne Room
	# ... Some rulers are happy to settle for a simple metal chair. You are not just any ruler
	picture = GFX_upgrade_icon_key
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
	}
	allow = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		room
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_prestige = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_trap_door = { # Trap Door
	# ... A trap door that opens up in front of the throne room
	picture = GFX_upgrade_icon_skull
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		scary
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		arrest_chance_modifier = 0.1
		court_size_maintenance_cost_modifier = -0.01
	}
	ai_will_do = {
		factor = 0.5
		modifier = {
			factor = 2
			has_evil_trait_trigger = yes
		}
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_royal_bedchamber = { # Royal Bedchamber
	# ... A royal bed chamber
	picture = GFX_upgrade_roses_red
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		secluded
		romantic
	}
	build_time = 24
	gold_cost_flat = 250
	gold_cost_ticking = 1
	owner_modifier = {
		fertility = 0.05
		custom_modifier_text = private_talk_possible_modifier_tt
		court_size_modifier = 2
	}
	ai_will_do = {
		factor = 1
		modifier = {
			factor = 2
			trait = lustful
		}
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_skull_throne = { # Throne of Skulls (a throne made of skulls)
	# ... A throne made of skulls and other bones
	picture = GFX_upgrade_icon_skulls
	potential = {	
		trait = cruel
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
		any_kill_list_character = { # At least 100 kills
			count = 100
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = {
		trait = cruel
	}

	flags = {
		is_singular
		scary
	}
	build_time = 10
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		cruel_opinion = 20
	}
	ai_will_do = {
		factor = 0.5
		modifier = {
			factor = 2
			has_evil_trait_trigger = yes
		}
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_golden_throne = { # Golden Throne (a throne made of gold)
	# ... A throne made of gold
	picture = GFX_upgrade_icon_ingots_gold
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
	}
	
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		golden
		valuable
	}
	build_time = 25
	gold_cost_flat = 1000
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_prestige = 1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_automata_throne = { # Automata Throne
	picture = GFX_upgrade_icon_stones
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
		OR = {
			emf_imperial_government = yes # HIP TRIGGER - DO NOT OVERWRITE!
			TECH_CONSTRUCTION = 5
		}
	}
	
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
		OR = {
			emf_imperial_government = yes # HIP TRIGGER - DO NOT OVERWRITE!
			TECH_CONSTRUCTION = 5
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		valuable
	}
	build_time = 25
	gold_cost_flat = 1000
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_prestige = 2
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_torture_chamber = { # Torture Chamber
	picture = GFX_upgrade_icon_skulls

	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_underground_city
				has_cow_unique_underground_city_district_trigger = yes
			}
		}
	 }
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_underground_city
				has_cow_unique_underground_city_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		scary
		secluded
		is_singular
	}
	build_time = 24
	gold_cost_flat = 550
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		cruel_opinion = 10
		custom_modifier_text = execution_possible_modifier_tt
		custom_modifier_text = intimidation_possible_modifier_tt
		custom_modifier_text = private_talk_possible_modifier_tt
	}
	ai_will_do = {
		factor = 0.5
		modifier = {
			factor = 2
			has_evil_trait_trigger = yes
		}
		modifier = {
			factor = 0.25
			k_papal_state = {
    			holder_scope = {
    				character = ROOT
    			}
    		}
		}
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_brewery = { # Brewery
	picture = GFX_upgrade_icon_crates
	
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		secluded
		entertainment
		produces_alcohol
	}
	build_time = 36
	gold_cost_flat = 300
	gold_cost_ticking = 1
	local_modifier = {

	}
	owner_modifier = {
		drunkard_opinion = 10
		custom_modifier_text = produces_alcohol_modifier_tt
		custom_modifier_text = private_talk_possible_modifier_tt
	}
	ai_will_do = {
		factor = 1
		modifier = {
			factor = 2
			trait = drunkard
		}
		modifier = {
			factor = 0.25
			k_papal_state = {
    			holder_scope = {
    				character = ROOT
    			}
    		}
		}
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_dueling_room = { # Dueling Room
	picture = GFX_upgrade_icon_equipment
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_fortress
				has_cow_unique_fortress_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_fortress
				has_cow_unique_fortress_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		room
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		combat_rating = 3
		brave_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_royal_custodian = { # Royal Custodian
	picture = GFX_upgrade_icon_key
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_palace
				has_cow_unique_palace_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		unlocks_minor_title
	}
	build_time = 12
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		custom_modifier_text = royal_custodian_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Amphitheatre upgrades:
upgrade_cow_naval_spectacle = { # Naval Spectacle
	picture = GFX_upgrade_icon_anchor
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_amphitheatre 
				has_cow_unique_amphitheatre_district_trigger = yes
			}
		}
	 }
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_amphitheatre
				has_cow_unique_amphitheatre_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		entertainment
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_tax_modifier = 0.025
	}
	owner_modifier = {
		monthly_character_prestige = 0.1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_animal_cages = { # Animal Cages
	picture = GFX_upgrade_icon_crates
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_amphitheatre
				has_cow_unique_amphitheatre_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_amphitheatre
				has_cow_unique_amphitheatre_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		animal_cages
		is_plural
		entertainment
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_prestige = 0.1
		hunter_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_hippodrome = { # Hippodrome/Circus
	picture = GFX_upgrade_icon_crates
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_amphitheatre
				has_cow_unique_amphitheatre_district_trigger = yes
			}
			NOR = {
				has_wonder_upgrade = upgrade_cow_district_hippodromos_byz # Is already a Hippodrome/Circus
				has_wonder_upgrade = upgrade_cow_district_circus_anti # Is already a Hippodrome/Circus
				has_wonder_upgrade = upgrade_cow_district_colosseum # Has Circus Maximus
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_amphitheatre
				has_cow_unique_amphitheatre_district_trigger = yes
			}
			NOR = {
				has_wonder_upgrade = upgrade_cow_district_hippodromos_byz # Is already a Hippodrome/Circus
				has_wonder_upgrade = upgrade_cow_district_circus_anti # Is already a Hippodrome/Circus
				has_wonder_upgrade = upgrade_cow_district_colosseum # Has Circus Maximus
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		entertainment
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_tax_modifier = 0.025
		knights = 50
	}
	owner_modifier = {
		command_modifier = {
			cavalry = 0.05
		}
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_amphitheatron_byz = { # Amphitheatron
	picture = GFX_upgrade_cow_amphitheatron
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_hippodromos_byz
				has_wonder_upgrade = upgrade_cow_district_circus_anti
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_hippodromos_byz
				has_wonder_upgrade = upgrade_cow_district_circus_anti
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		entertainment
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_revolt_risk = -0.04
	}
	owner_modifier = {
		monthly_character_prestige = 0.2
		same_religion_opinion = 1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_circus_maximus = { # Circus Maximus
	picture = GFX_upgrade_cow_circus_maximus
	potential = { 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_colosseum }
	}
	allow = { 
		FROMFROMFROM = { has_wonder_upgrade = upgrade_cow_district_colosseum }
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_historical
		is_singular
		entertainment
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_tax_modifier = 0.025
		knights = 50
	}
	owner_modifier = {
		command_modifier = {
			cavalry = 0.05
		}
	}
	# ai_will_do = {
		# factor = 0.01
		# modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			# factor = 0
			# ai = yes
		# }
	# }
}

upgrade_cow_training_academy = { # Training Academy 
	picture = GFX_upgrade_icon_guards
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_amphitheatre
				has_cow_unique_amphitheatre_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_amphitheatre
				has_cow_unique_amphitheatre_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		summon_commander
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		custom_modifier_text = recruit_gladiator_modifier_tt #Allows you to summon a warrior every year or so
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_theater_stage = { # Theater Stage
	picture = GFX_upgrade_icon_crates
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_amphitheatre
				has_cow_unique_amphitheatre_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_amphitheatre
				has_cow_unique_amphitheatre_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_prestige = 0.05
		poet_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_master_of_the_games = { # Master of the Games
	picture = GFX_upgrade_icon_key
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_amphitheatre
				has_cow_unique_amphitheatre_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_amphitheatre
				has_cow_unique_amphitheatre_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		unlocks_minor_title
	}
	build_time = 12
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		custom_modifier_text = game_master_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Garden upgrades:
upgrade_cow_fountains = { # Fountains
	picture = GFX_upgrade_icon_roses_blue
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_prestige = 0.05
		poet_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_fountain_of_youth = { # Fountain of Youth
	picture = GFX_upgrade_icon_roses_yellow
	potential = {
		NOT = {
			has_game_rule = {
				name = supernatural_events
				value = off
			}
		}
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
	}
	allow = {
		trait = mystic
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		life_granting
		is_singular
	}
	build_time = 36
	gold_cost_flat = 550
	gold_cost_ticking = 1
	owner_modifier = {
		custom_modifier_text = fountain_of_youth_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_hanging_gardens = { # Hanging Gardens
	picture = GFX_upgrade_icon_roses_white
	potential = {
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
	 }
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_prestige = 0.1
		gardener_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_secluded_groves = { # Secluded Groves
	picture = GFX_upgrade_icon_roses_black
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_plural
		secluded
		romantic
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		fertility = 0.05
		custom_modifier_text = private_talk_possible_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_hidden_burial = { # Hidden Burial Area
	picture = GFX_upgrade_icon_skulls
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		body_stash
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		defensive_plot_power_modifier = 0.05
		plot_power_modifier = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_poisonous_flowers = {  # Poisonous Flowers
	picture = GFX_upgrade_icon_roses_black
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		plot_power_modifier = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_herb_garden = { # Herb Garden
	picture = GFX_upgrade_icon_roses_pink

	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
	}
	allow = { 
		society_member_of = hermetics 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { 
		society_member_of = hermetics 
	}

	flags = {
		produces_herbs
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		health = 0.1
		custom_modifier_text = herb_event_modifier_tt #Periodically gives you herbs (Hermetic artifact)
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_statues_garden = { # Garden Statues
	picture = GFX_upgrade_icon_statue
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		statues
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_prestige = 0.05
		defensive_plot_power_modifier = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_vineyard = { # Vineyard
	picture = GFX_upgrade_icon_crates
	
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		secluded
		produces_alcohol
	}
	build_time = 36
	gold_cost_flat = 500
	gold_cost_ticking = 1
	local_modifier = {
	}
	owner_modifier = {
		drunkard_opinion = 10
		custom_modifier_text = produces_alcohol_modifier_tt
		custom_modifier_text = private_talk_possible_modifier_tt
	}
	
}

upgrade_cow_pet_graveyard = { # Pet Graveyard
	picture = GFX_upgrade_icon_statue
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_garden
				has_cow_unique_garden_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		child_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Library upgrades:
upgrade_cow_collection_drama = { # Poetry and Drama Collection
	picture = GFX_upgrade_icon_book_turquoise
	potential = {
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_library
				has_cow_unique_library_district_trigger = yes
			}
		}
	 }
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_library
				has_cow_unique_library_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		poetry_and_drama
		romantic
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		tech_growth_modifier_culture = 0.1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_collection_architecture = { # Architecture Collection
	picture = GFX_upgrade_icon_written_paper
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_library
				has_cow_unique_library_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_library
				has_cow_unique_library_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		architecture
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		tech_growth_modifier_economy = 0.1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_collection_math = { # Math and Philosophy Collection
	picture = GFX_upgrade_icon_written_paper
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_library
				has_cow_unique_library_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_library
				has_cow_unique_library_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		math_and_philosophy
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		tech_growth_modifier_economy = 0.1		
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_collection_history = { # History Collection
	picture = GFX_upgrade_icon_book_beige
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_library
				has_cow_unique_library_district_trigger = yes
			}
		}	
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_library
				has_cow_unique_library_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		history_flag
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		tech_growth_modifier_military = 0.1		
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_collection_science = { # Natural Sciences Collection
	picture = GFX_upgrade_icon_book_green
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_library
				has_cow_unique_library_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_library
				has_cow_unique_library_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		natural_sciences
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		tech_growth_modifier_military = 0.1		
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_scribe_room = { # Scribe Room
	picture = GFX_upgrade_icon_written_paper
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_library
				has_cow_unique_library_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_library
				has_cow_unique_library_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		room
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		tech_growth_modifier = 0.25
		monthly_character_prestige = 0.1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_keeper_of_tomes = { # Keeper of the Tomes
	picture = GFX_upgrade_icon_key
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_library
				has_cow_unique_library_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_library
				has_cow_unique_library_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		unlocks_minor_title
	}
	build_time = 12
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		tech_growth_modifier_culture = 0.1
	}
	owner_modifier = {
		custom_modifier_text = keeper_of_tomes_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# University upgrades:
upgrade_cow_great_seminars = { # Great Seminars
	picture = GFX_upgrade_icon_written_paper

	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_university
				has_cow_unique_university_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_university
				has_cow_unique_university_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		great_lecture_decision
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		scholar_opinion = 5
		town_opinion = 3
		tech_growth_modifier = 0.35
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_wing_of_diplomacy = { # Wing of Diplomacy
	picture = GFX_upgrade_icon_written_paper

	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_university
				has_cow_unique_university_district_trigger = yes
			}
		}
	 }
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_university
				has_cow_unique_university_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		culture_techpoints = 0.05
	}
	owner_modifier = {
		diplomacy = 1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_wing_of_martial = { # Wing of Strategy
	picture = GFX_upgrade_icon_book_red
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_university
				has_cow_unique_university_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_university
				has_cow_unique_university_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		military_techpoints = 0.05
	}
	owner_modifier = {
		martial = 1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_wing_of_stewardship = { # Wing of Finance
	picture = GFX_upgrade_icon_written_paper
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_university
				has_cow_unique_university_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_university
				has_cow_unique_university_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		economy_techpoints = 0.05
	}
	owner_modifier = {
		stewardship = 1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_wing_of_intrigue = { # Wing of Secrets
	picture = GFX_upgrade_icon_key
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_university
				has_cow_unique_university_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_university
				has_cow_unique_university_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		culture_techpoints = 0.05
	}
	owner_modifier = {
		intrigue = 1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_wing_of_learning = { # Wing of Theology
	picture = GFX_upgrade_icon_book_blue
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_university
				has_cow_unique_university_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_university
				has_cow_unique_university_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		tech_growth_modifier = 0.15
	}
	owner_modifier = {
		learning = 1
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_guardian_of_knowledge = { # Guardian of Knowledge
	picture = GFX_upgrade_icon_key
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_university
				has_cow_unique_university_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_university
				has_cow_unique_university_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		unlocks_minor_title
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		custom_modifier_text = guardian_of_knowledge_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Mausoleum upgrades:
upgrade_cow_statues_dead = { # Statues of the Dead

	picture = GFX_upgrade_icon_skulls
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		statues
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		dynasty_opinion = 3
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_eternal_flame = { # Eternal Flame
	
	picture = GFX_upgrade_icon_brazier
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		local_revolt_risk = -0.05
	}
	owner_modifier = {
		zun_pagan_opinion = 5
		zun_pagan_reformed_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_unmarked_tombs = { #Unmarked Tombs
	
	picture = GFX_upgrade_icon_skulls
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_plural
		scary
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		assassinate_chance_modifier = 0.1
		custom_modifier_text = intimidation_possible_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_quadriga_statue = { # Quadriga Statue
	
	picture = GFX_upgrade_icon_stones
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		statues
		decorative
		
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_prestige = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_keeper_of_the_dead = { # Keeper of the Dead 
	picture = GFX_upgrade_icon_key
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		unlocks_minor_title
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		custom_modifier_text = kepper_of_dead_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_horse_graveyard = { # Horse Graveyard (Put your beloved horses to rest)
	
	picture = GFX_upgrade_icon_skulls
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_horse_statue
				has_cow_unique_horse_statue_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_mausoleum
				has_cow_unique_mausoleum_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_horse_statue
				has_cow_unique_horse_statue_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		horse_opinion = 5
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Pagan Stones upgrades:
upgrade_cow_runestones = { # Rune Stones
	picture = GFX_upgrade_icon_stones

	potential = {
		religion_openly_norse_or_reformed_trigger = yes
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_pagan_stones
				has_cow_unique_pagan_stones_district_trigger = yes
			}
		}
	}
	allow = { 
		religion_openly_norse_or_reformed_trigger = yes
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_pagan_stones
				has_cow_unique_pagan_stones_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { religion_openly_norse_or_reformed_trigger = yes }

	flags = {
		is_plural
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		dynasty_opinion = 3
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_more_stones = { # More Stones (Additional stones)
	picture = GFX_upgrade_icon_logistics
	potential = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_pagan_stones
				has_cow_unique_pagan_stones_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_pagan_stones
				has_cow_unique_pagan_stones_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 575
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		same_religion_opinion = 2
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_stone_custodian = { # Custodian of the Stone
	picture = GFX_upgrade_icon_bricks
	potential = {
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_pagan_stones
				has_cow_unique_pagan_stones_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = {
				has_wonder_upgrade = upgrade_cow_district_pagan_stones
				has_cow_unique_pagan_stones_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		unlocks_minor_title
	}
	build_time = 575
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		custom_modifier_text = stone_custodian_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

# Pyramids upgrades:
upgrade_cow_extra_pyramids = { # Extra Pyramids (for relatives, etc)
	picture = GFX_upgrade_icon_stones
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_plural
	}
	build_time = 120
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		dynasty_opinion = 3
		monthly_character_prestige = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_mythological_beast = { # Mythological Beast (think sphinx)
	picture = GFX_upgrade_icon_crates
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_aztec_pyramid 
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_aztec_pyramid 
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 60
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		proud_opinion = 5
		same_religion_opinion = 2
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_hidden_room = { # Hidden Room
	#A hidden room to hide loot
	picture = GFX_upgrade_icon_key
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_aztec_pyramid 
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_aztec_pyramid 
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		room
		is_singular
		artifact_protection
		secluded
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		custom_modifier_text = less_likely_to_be_looted_modifier_tt
		custom_modifier_text = private_talk_possible_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_necropolis = { # Necropolis
	picture = GFX_upgrade_icon_skulls
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_aztec_pyramid 
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_aztec_pyramid 
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		artifact_protection
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		custom_modifier_text = less_likely_to_be_looted_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_traps = { # Traps
	picture = GFX_upgrade_icon_crates
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_aztec_pyramid 
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
				has_wonder_upgrade = upgrade_cow_district_aztec_pyramid 
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_plural
		traps
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		#LT.60401 that has a high chance of killing members of the new court.
		custom_modifier_text = traps_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_lime_stone_casing = { # Lime Stone Casing (For pyramids)
	picture = GFX_upgrade_icon_stones
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
	}
	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1
	owner_modifier = {
		monthly_character_piety = 0.01
		monthly_character_prestige = 0.05
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_overseer_of_rites = { # Overseer of the Rites
	picture = GFX_upgrade_icon_key
	potential = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
			}
		}
	}
	allow = { 
		FROMFROMFROM = { 
			OR = { 
				has_wonder_upgrade = upgrade_cow_district_pyramid
				has_cow_unique_pyramid_district_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	active = { }

	flags = {
		is_singular
		unlocks_minor_title
	}
	build_time = 12
	gold_cost_flat = 450
	gold_cost_ticking = 1
	local_modifier = {
		
	}
	owner_modifier = {
		custom_modifier_text = overseer_of_rites_custom_modifier_tt
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_street_lamps_cord = { # Street Lamps of Cordoba
	picture = GFX_upgrade_cow_street_lamps_cord

	potential = {
		FROMFROMFROM = {
			province_id = 181 # Cordoba
		}
	}
	allow = {
		FROMFROMFROM = {
			province_id = 181 # Cordoba
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	
	build_time = 120
	gold_cost_flat = 300
	gold_cost_ticking = 1

	owner_modifier = {
		monthly_character_prestige = 0.5
	}
	
	local_modifier = {
		local_revolt_risk = -0.03
	}
	
	flags = {

	}
	active = {
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}

upgrade_cow_sewers_cord = { # Sewers of Cordoba
	picture = GFX_upgrade_cow_sewers_cord

	potential = {
		FROMFROMFROM = {
			province_id = 181 # Cordoba
		}
	}
	allow = {
		FROMFROMFROM = {
			province_id = 181 # Cordoba
		}
		trigger_if = {
			limit = {
				ai = yes
			}
			ai = no
		}
	}
	
	build_time = 120
	gold_cost_flat = 300
	gold_cost_ticking = 1

	owner_modifier = {
	}
	
	local_modifier = {
		disease_defence = 0.1
		tech_growth_modifier_economy = 0.2
		economy_techpoints = 0.05
	}
	
	flags = {

	}
	active = {
	}
	ai_will_do = {
		factor = 0.01
		modifier = { #Do not want AI to spam upgrades, instead it should focus on districts.
			factor = 0
			ai = yes
		}
	}
}
