Use the any_demesne_province scope on the root character and either check the province for the flag or scope again to the individual holding in the provance and check the building, this will only work if you personally hold the province so you may want to use any_realm_province instead.
Sorry, I should have been clearer. My mod randomly adds flags to random provinces that allow either gold or silver mines to be built, which provide a large income.
What I want to do is have it so that other realms can declare war on people who have built a gold/silver mine - a greed CB
I tried some code, which is aimed at the province flags, not the actual buildings, but it doesn't seem to work
Code:
cfh_highvalue_gold_greed = {
name = CFH_HIGHVALUE_CB_NAME_GOLD_GREED_CONQUEST
war_name = CFH_HIGHVALUE_WAR_NAME_GOLD_GREED_CONQUEST
sprite = 27
truce_days = 3650
hostile_against_others = yes
full_hostility = yes
is_permanent = yes
check_all_titles = yes # if permanent, setting this to true will check against all of someones titles, including vassal held titles
can_ask_to_join_war = no
allowed_to_target_tributaries = no
infamy_modifier = 2
sort_priority = 795
can_use = {
NOT = {
has_game_rule = {
name = cfh_rule_highvalue
value = off
}
}
ROOT = {
NOT = { is_liege_or_above = FROM }
mercenary = no
clan = no
tier = count
}
}
can_use_title = {
OR = {
if = {
limit = { has_global_flag = cfh_gold_mine_1_flag }
distance = { who = event_target:cfh_gold_mine_1_target value = 1000 }
}
if = {
limit = { has_global_flag = cfh_gold_mine_2_flag }
distance = { who = event_target:cfh_gold_mine_2_target value = 1000 }
}
if = {
limit = { has_global_flag = cfh_gold_mine_3_flag }
distance = { who = event_target:cfh_gold_mine_3_target value = 1000 }
}
if = {
limit = { has_global_flag = cfh_gold_mine_4_flag }
distance = { who = event_target:cfh_gold_mine_4_target value = 1000 }
}
if = {
limit = { has_global_flag = cfh_gold_mine_5_flag }
distance = { who = event_target:cfh_gold_mine_5_target value = 1000 }
}
if = {
limit = { has_global_flag = cfh_gold_mine_6_flag }
distance = { who = event_target:cfh_gold_mine_6_target value = 1000 }
}
if = {
limit = { has_global_flag = cfh_gold_mine_7_flag }
distance = { who = event_target:cfh_gold_mine_7_target value = 1000 }
}
if = {
limit = { has_global_flag = cfh_gold_mine_8_flag }
distance = { who = event_target:cfh_gold_mine_8_target value = 1000 }
}
if = {
limit = { has_global_flag = cfh_gold_mine_9_flag }
distance = { who = event_target:cfh_gold_mine_9_target value = 1000 }
}
if = {
limit = { has_global_flag = cfh_gold_mine_10_flag }
distance = { who = event_target:cfh_gold_mine_10_target value = 1000 }
}
if = {
limit = { has_global_flag = cfh_gold_mine_11_flag }
distance = { who = event_target:cfh_gold_mine_11_target value = 1000 }
}
if = {
limit = { has_global_flag = cfh_gold_mine_12_flag }
distance = { who = event_target:cfh_gold_mine_12_target value = 1000 }
}
if = {
limit = { has_global_flag = cfh_gold_mine_13_flag }
distance = { who = event_target:cfh_gold_mine_13_target value = 1000 }
}
if = {
limit = { has_global_flag = cfh_gold_mine_14_flag }
distance = { who = event_target:cfh_gold_mine_14_target value = 1000 }
}
if = {
limit = { has_global_flag = cfh_gold_mine_15_flag }
distance = { who = event_target:cfh_gold_mine_15_target value = 1000 }
}
{
}
is_valid_title = {
OR = {
FROM = {
has_landed_title = PREV
}
holder_scope = {
is_liege_or_above = FROM
}
}
}
on_success_title = {
usurp_title_plus_barony_if_unlanded = { target = ROOT type = invasion }
any_de_jure_vassal_title = { # take all baronies under the one we're fighting for
}
on_fail_title = {
ROOT = {
prestige = -100
}
FROM = {
participation_scaled_prestige = 50
}
any_defender = {
limit = { NOT = { character = FROM } }
hidden_tooltip = { participation_scaled_prestige = 50 }
}
}
on_reverse_demand = {
ROOT = {
prestige = -100
transfer_scaled_wealth = {
to = FROM
value = 2.0
}
}
FROM = {
participation_scaled_prestige = 100
}
any_defender = {
limit = { NOT = { character = FROM } }
hidden_tooltip = { participation_scaled_prestige = 100 }
}
}
attacker_ai_victory_worth = {
factor = -1 # always accept
}
attacker_ai_defeat_worth = {
factor = 100
}
defender_ai_victory_worth = {
factor = -1 # always accept
}
defender_ai_defeat_worth = {
factor = 100
}
ai_will_do = {
factor = 1
modifier = {
factor = 0.1
ROOT = {
independent = no
same_liege = FROM
}
}
}
}
CB modding is admittedly much less straight forward than the other areas I've tried my hand at, and I'm unaware of any similar cb's I could reference