#### FORTRESS
# Armory .......................... upgrade_armory
# Watch Tower ..................... upgrade_watch_tower
# Vault  .......................... upgrade_vault
# Pit Moat ........................ upgrade_moat_pit
# Spike Moat ...................... upgrade_moat_spike
# Water Moat ...................... upgrade_moat_water
# Moat of Bones ................... upgrade_moat_bones
# Hidden Passageways .............. upgrade_hidden_passageways
# Inner Garden .................... upgrade_garden_inner
# Dueling Room .................... upgrade_dueling_room

#### UNDERGROUND CITY
# Dungeon ......................... upgrade_dungeon
# Natural Caves ................... upgrade_caves_natural
# Travel Tunnels .................. upgrade_tunnels_travel
# Precious metal mine ............. upgrade_metal_mine_precious
# Guardian of the Deep............. upgrade_guardian_of_the_deep

#### Mercantile Walls
# Sea Walls ....................... upgrade_walls_sea
# Studded Bastions ................ upgrade_studded_bastions
# Strategic Exclaves .............. upgrade_strategic_exclaves
# Soaring Fortresses .............. upgrade_soaring_fortresses
# Hidden Gates .................... upgrade_hidden_gates
# Gatehouse-Forts ................. upgrade_gatehouse_forts
# Staged Killing Fields ........... upgrade_killing_fields
# Deep Defense Architecture ....... upgrade_deep_defense_architecture
# Artificial Islands .............. upgrade_artificial_islands
# Wall Walker ..................... upgrade_wall_walker

#### GREAT HARBOR
# Cothon .......................... upgrade_cothon
# Piers ........................... upgrade_piers
# Harbor Office ................... upgrade_office_harbor
# Lighthouse ...................... upgrade_lighthouse
# Military Wharf .................. upgrade_military_wharf
# Master of the Tides ............. upgrade_master_of_tides

#### GREAT LIGHTHOUSE
# Treasure Chamber ................ upgrade_treasure_chamber
# Giant Banners ................... upgrade_giant_banners
# Custodian of the Lighthouse ..... upgrade_lighthouse_custodian
# Royal Apartments ................ upgrade_royal_apartments

##########################################
################ Fortress ################
##########################################

upgrade_armory = {
	picture = GFX_upgrade_icon_equipment

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_singular
		armory
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
		heavy_infantry = 100
	}

	owner_modifier = {
	}
}

upgrade_watch_tower = {
	picture = GFX_upgrade_icon_bow_and_arrows

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_singular
		towering
		watch_tower
	}

	build_time = 48
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
		siege_defence = 0.05
	}

	owner_modifier = {
		arrest_chance_modifier = 0.05
	}
}

upgrade_vault = {
	picture = GFX_upgrade_icon_key

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_singular
		artifact_protection
		vault
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
	}

	owner_modifier = {
		custom_modifier_text = less_likely_to_be_looted_modifier_tt
	}
}

upgrade_moat_pit = { # Pit Moat
	picture = GFX_upgrade_icon_stones

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_singular
		moat_pit
		moat
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
		siege_defence = 0.05
	}

	owner_modifier = {
		custom_modifier_text = execution_possible_modifier_tt
	}
}

upgrade_moat_spike = { # Spike Moat
	picture = GFX_upgrade_icon_skulls

	potential = {
	}

	allow = {
		FROMFROM = { has_wonder_upgrade = upgrade_moat_pit }
	}

	active = {
		FROMFROM = { has_wonder_upgrade = upgrade_moat_pit }
	}

	flags = {
		is_singular
		scary
		moat_spike
		moat
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
		siege_defence = 0.05
	}

	owner_modifier = {
		custom_modifier_text = execution_possible_modifier_tt
		custom_modifier_text = intimidation_possible_modifier_tt
	}
}

upgrade_moat_water = { # Water Moat
	picture = GFX_upgrade_icon_anchor

	potential = {
	}

	allow = {
		FROMFROM = { has_wonder_upgrade = upgrade_moat_pit }
	}

	active = {
		FROMFROM = { has_wonder_upgrade = upgrade_moat_pit }
	}

	flags = {
		is_singular
		moat_water
		moat
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
		siege_defence = 0.05
	}

	owner_modifier = {
		custom_modifier_text = execution_possible_modifier_tt
	}
}

upgrade_moat_bones = { # Moat of Bones
	picture = GFX_upgrade_icon_skulls

	potential = {
		trait = cruel
	}

	allow = {
		FROMFROM = { has_wonder_upgrade = upgrade_moat_pit }
		num_of_kill_list_characters >= 50 # At least 50 kills
	}

	active = {
		FROMFROM = { has_wonder_upgrade = upgrade_moat_pit }
		trait = cruel
	}

	flags = {
		is_singular
		scary
		moat_bones
		moat
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
		siege_defence = 0.05
	}

	owner_modifier = {
		custom_modifier_text = execution_possible_modifier_tt
		custom_modifier_text = intimidation_possible_modifier_tt
	}
}

upgrade_hidden_passageways = { # Hidden Passageways
	picture = GFX_upgrade_icon_key

	potential = {
	}

	allow = {
	}

	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
	}
}

upgrade_garden_inner = { # Inner Garden
	picture = GFX_upgrade_icon_roses_blue

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_singular
		secluded
		garden_inner
	}

	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
	}
}

upgrade_dueling_room = { # Dueling Room
	picture = GFX_upgrade_icon_equipment

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		room
		is_singular
		dueling_room
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
	}

	owner_modifier = {
		combat_rating = 3
		brave_opinion = 5
	}
}

##########################################
############ Underground City ############
##########################################

upgrade_dungeon = { # Dungeon
	picture = GFX_upgrade_icon_skulls

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		room
		is_singular
		scary
		dungeon
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
	}

	owner_modifier = {
		arrest_chance_modifier = 0.1
	}
}

upgrade_caves_natural = { # Natural Caves
	picture = GFX_upgrade_icon_stones

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_plural
		caves_natural
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
	}

	owner_modifier = {
		defensive_plot_power_modifier = 0.1
	}
}

upgrade_tunnels_travel = { # Travel Tunnels
	picture = GFX_upgrade_icon_key

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_plural
		tunnels_travel
	}

	build_time = 60
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
		local_movement_speed = 0.1
		court_size_modifier = 2
	}

	owner_modifier = {
	}
}

upgrade_metal_mine_precious = { # Precious metal mine
	picture = GFX_upgrade_icon_ingots_silver

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_plural
		metal_mine_precious
	}

	build_time = 36
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
		local_tax_modifier = 0.1
	}

	owner_modifier = {
	}
}

upgrade_guardian_of_the_deep = {
	picture = GFX_upgrade_icon_key

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_singular
		unlocks_minor_title
		guardian_of_the_deep
	}

	build_time = 12
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
	}

	owner_modifier = {
		custom_modifier_text = deep_guardian_custom_modifier_tt
	}
}

##########################################
############## Great Walls ###############
##########################################

upgrade_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
		}
	}

	allow = {
	}

	active = {
	}

	flags = {
		walls_sea
	}

	build_time = 60
	gold_cost_flat = 500
	gold_cost_ticking = 1

	local_modifier = {
		siege_defence = 0.20
	}

	owner_modifier = {
		town_opinion = 5
	}
}

upgrade_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 = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		studded_bastions
	}

	build_time = 60
	gold_cost_flat = 500
	gold_cost_ticking = 1

	local_modifier = {
		siege_defence = 0.05
		archers = 200
	}

	owner_modifier = {
	}
}

upgrade_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 = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		strategic_exclaves
	}

	build_time = 120
	gold_cost_flat = 1000
	gold_cost_ticking = 5

	local_modifier = {
		local_tax_modifier = 0.05
	}

	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
	}
}

upgrade_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 = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		towering
		soaring_fortresses
	}

	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
	}
}

upgrade_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 = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		hidden_gates
	}

	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
	}
}

upgrade_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 = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		gatehouse_forts
	}

	build_time = 24
	gold_cost_flat = 400
	gold_cost_ticking = 1

	local_modifier = {
		siege_defence = 0.05
		archers = 150
	}

	owner_modifier = {
	}
}

upgrade_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 = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		killing_fields
	}

	build_time = 24
	gold_cost_flat = 400
	gold_cost_ticking = 1

	local_modifier = {
		archers = 100
		siege_defence = 0.10
	}

	owner_modifier = {
	}
}

upgrade_deep_defense_architecture = { # Deep Defense Architecture
	picture = GFX_upgrade_icon_crates

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		deep_defense_architecture
	}

	build_time = 60
	gold_cost_flat = 500
	gold_cost_ticking = 1

	local_modifier = {
		siege_defence = 0.10
	}

	owner_modifier = {
	}
}

upgrade_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 }
	}

	allow = {
	}

	active = {
	}

	flags = {
		artificial_islands
	}

	build_time = 120
	gold_cost_flat = 300
	gold_cost_ticking = 1

	local_modifier = {
		siege_defence = 0.10
	}

	owner_modifier = {
	}
}

upgrade_wall_walker = {
	picture = GFX_upgrade_icon_key
	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_singular
		unlocks_minor_title
		wall_walker
	}

	build_time = 12
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
	}

	owner_modifier = {
		custom_modifier_text = wall_walker_custom_modifier_tt
	}
}

##########################################
############## Great Harbor ##############
##########################################

upgrade_cothon = { # Cothon
	picture = GFX_upgrade_icon_crates

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_singular
		cothon
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
		siege_defence = 0.10
		supply_limit = 0.5
	}

	owner_modifier = {
	}
}

upgrade_piers = { # Piers
	picture = GFX_upgrade_icon_anchor

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_plural
		piers
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
		tradevalue = 30
		supply_limit = 0.25
		local_tax_modifier = 0.0025
	}

	owner_modifier = {
	}
}

upgrade_office_harbor = { # Harbor Office
	picture = GFX_upgrade_icon_written_paper

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_singular
		office_harbor
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
		local_tax_modifier = 0.1
		supply_limit = 0.25
	}

	owner_modifier = {
	}
}

upgrade_lighthouse = { # Lighthouse
	#....
	picture = GFX_upgrade_icon_brazier

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_singular
		lighthouse
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
		tradevalue = 30
		local_tax_modifier = 0.05
		supply_limit = 0.25
	}

	owner_modifier = {
	}
}

upgrade_military_wharf = {
	picture = GFX_upgrade_icon_anchor

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_singular
		military_wharf
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
		galleys_perc = 0.5
	}

	owner_modifier = {
		siege_speed = 0.15
	}
}

upgrade_master_of_tides = { # master of the Tides
	picture = GFX_upgrade_icon_anchor

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_singular
		unlocks_minor_title
		master_of_tides
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
	}

	owner_modifier = {
		custom_modifier_text = master_of_tides_custom_modifier_tt
	}
}

##########################################
########### Great Lighthouse #############
##########################################

upgrade_treasure_chamber = { # Treasure Chamber
	#....
	picture = GFX_upgrade_icon_key

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		artifact_protection
		is_singular
		valuable
		treasure_chamber
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
	}

	owner_modifier = {
		custom_modifier_text = less_likely_to_be_looted_modifier_tt
	}
}

upgrade_giant_banners = { # Giant Banners
	#....
	picture = GFX_upgrade_icon_crates

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_plural
		giant_banners
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
	}

	owner_modifier = {
		land_morale = 0.05
	}
}

upgrade_lighthouse_custodian = { # Custodian of the Lighthouse
	#....
	picture = GFX_upgrade_icon_brazier

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_singular
		unlocks_minor_title
		lighthouse_custodian
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
	}

	owner_modifier = {
		custom_modifier_text = lighthouse_custodian_custom_modifier_tt
	}
}

upgrade_royal_apartments = { # Royal Apartments
	#....
	picture = GFX_upgrade_icon_roses_red

	potential = {
	}

	allow = {
	}

	active = {
	}

	flags = {
		is_plural
		romantic
		secluded
		royal_apartments
	}

	build_time = 24
	gold_cost_flat = 450
	gold_cost_ticking = 1

	local_modifier = {
	}

	owner_modifier = {
		sex_appeal_opinion = 3
		custom_modifier_text = private_talk_possible_modifier_tt
		court_size_modifier = 2
	}
}
