tiger_lib/ck3/tables/
triggers.rs

1use std::sync::LazyLock;
2
3use crate::ck3::tables::misc::{
4    AGENT_SLOT_CONTRIBUTION_TYPE, GOVERNMENT_RULES, LEGEND_QUALITY, OUTBREAK_INTENSITIES,
5    TITLE_HISTORY_TYPES,
6};
7use crate::everything::Everything;
8use crate::helpers::TigerHashMap;
9use crate::item::Item;
10use crate::report::{ErrorKey, err};
11use crate::scopes::{ArgumentValue, Scopes};
12use crate::token::Token;
13use crate::trigger::Trigger;
14
15use Trigger::*;
16
17/// LAST UPDATED CK3 VERSION 1.18.1
18pub fn scope_trigger(name: &Token, data: &Everything) -> Option<(Scopes, Trigger)> {
19    let name_lc = name.as_str().to_ascii_lowercase();
20
21    if let result @ Some(_) = TRIGGER_MAP.get(&*name_lc).copied() {
22        return result;
23    }
24    if let Some(relation) = name_lc.strip_prefix("has_relation_") {
25        data.verify_exists_implied(Item::Relation, relation, name);
26        return Some((Scopes::Character, Trigger::Scope(Scopes::Character)));
27    }
28    if let Some(relation) = name_lc.strip_prefix("has_secret_relation_") {
29        data.verify_exists_implied(Item::Relation, relation, name);
30        return Some((Scopes::Character, Trigger::Scope(Scopes::Character)));
31    }
32    if let Some(relation) = name_lc.strip_prefix("num_of_relation_") {
33        data.verify_exists_implied(Item::Relation, relation, name);
34        return Some((Scopes::Character, Trigger::CompareValue));
35    }
36    if let Some(lifestyle) = name_lc.strip_prefix("perks_in_") {
37        data.verify_exists_implied(Item::Lifestyle, lifestyle, name);
38        return Some((Scopes::Character, Trigger::CompareValue));
39    }
40    if let Some(lifestyle) = name_lc.strip_suffix("_perk_points") {
41        data.verify_exists_implied(Item::Lifestyle, lifestyle, name);
42        return Some((Scopes::Character, Trigger::CompareValue));
43    }
44    if let Some(lifestyle) = name_lc.strip_suffix("_unlockable_perks") {
45        data.verify_exists_implied(Item::Lifestyle, lifestyle, name);
46        return Some((Scopes::Character, Trigger::CompareValue));
47    }
48    // Either $DYNASTY_LEGACY_TRACK$_perks and $LIFESTYLE$_perks
49    if let Some(part) = name_lc.strip_suffix("_perks") {
50        if data.item_exists(Item::DynastyLegacy, part) {
51            return Some((Scopes::Dynasty, Trigger::CompareValue));
52        }
53        if data.item_exists(Item::Lifestyle, part) {
54            return Some((Scopes::Character, Trigger::CompareValue));
55        }
56        let msg = format!("{part} not found as dynasty legacy or lifestyle");
57        err(ErrorKey::MissingItem).msg(msg).loc(name).push();
58        // Heuristic about which one is likely intended
59        return if part.ends_with("_track") {
60            Some((Scopes::Dynasty, Trigger::CompareValue))
61        } else {
62            Some((Scopes::Character, Trigger::CompareValue))
63        };
64    }
65    if let Some(lifestyle) = name_lc.strip_suffix("_xp") {
66        data.verify_exists_implied(Item::Lifestyle, lifestyle, name);
67        return Some((Scopes::Character, Trigger::CompareValue));
68    }
69    std::option::Option::None
70}
71
72static TRIGGER_MAP: LazyLock<TigerHashMap<&'static str, (Scopes, Trigger)>> = LazyLock::new(|| {
73    let mut hash = TigerHashMap::default();
74    for (from, s, trigger) in TRIGGER.iter().copied() {
75        hash.insert(s, (from, trigger));
76    }
77    hash
78});
79
80/// LAST UPDATED CK3 VERSION 1.18.1
81/// See `triggers.log` from the game data dumps
82/// special:
83///    `<legacy>_track_perks`
84///    `<lifestyle>_perk_points`
85///    `<lifestyle>_perks`
86///    `<lifestyle>_unlockable_perks`
87///    `<lifestyle>_xp`
88///    `has_relation_<relation>`
89///    `has_secret_relation_<relation>`
90///    `num_of_relation_<relation>`
91/// A key ends with '(' if it is the version that takes a parenthesized argument in script.
92const TRIGGER: &[(Scopes, &str, Trigger)] = &[
93    (Scopes::Accolade, "accolade_rank", CompareValue),
94    (Scopes::AccoladeType, "accolade_type_tier", Scope(Scopes::AccoladeType)),
95    (Scopes::LandedTitle, "active_de_jure_drift_progress", CompareValue),
96    // TODO: warn if this is in an any_ iterator and not at the end
97    (Scopes::all_but_none(), "add_to_temporary_list", Special),
98    (Scopes::Character, "age", CompareValue),
99    (Scopes::AgentSlot, "agent_slot_contribution", CompareValue),
100    (Scopes::AgentSlot, "agent_slot_has_contribution_type", Choice(AGENT_SLOT_CONTRIBUTION_TYPE)),
101    (Scopes::Character, "ai_boldness", CompareValue),
102    (Scopes::Character, "ai_compassion", CompareValue),
103    (
104        Scopes::Character,
105        "ai_diplomacy_stance",
106        Block(&[
107            ("target", Scope(Scopes::Character)),
108            ("stance", Choice(&["neutral", "threat", "enemy", "friend"])),
109        ]),
110    ),
111    (Scopes::Character, "ai_energy", CompareValue),
112    (Scopes::Character, "ai_greed", CompareValue),
113    (Scopes::Character, "ai_honor", CompareValue),
114    (Scopes::Character, "ai_rationality", CompareValue),
115    (Scopes::Character, "ai_sociability", CompareValue),
116    (
117        Scopes::Character,
118        "ai_values_divergence",
119        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
120    ),
121    (Scopes::Character, "ai_vengefulness", CompareValue),
122    (
123        Scopes::Character,
124        "ai_will_do_contribution",
125        Block(&[("target", Scope(Scopes::ProjectContribution)), ("+value", CompareValue)]),
126    ),
127    (Scopes::Character, "ai_zeal", CompareValue),
128    (Scopes::Character, "all_court_artifact_slots", Choice(&["empty", "full"])),
129    (Scopes::None, "all_false", Control),
130    (Scopes::Character, "all_inventory_artifact_slots", Choice(&["empty", "full"])),
131    (Scopes::CombatSide, "allow_early_retreat", Boolean),
132    (Scopes::Character, "allowed_concubines", Boolean),
133    (Scopes::Character, "allowed_more_concubines", Boolean),
134    (Scopes::Character, "allowed_more_spouses", Boolean),
135    (Scopes::None, "always", Boolean),
136    (
137        Scopes::Character,
138        "amenity_level",
139        Block(&[("target", Item(Item::Amenity)), ("+value", CompareValue)]),
140    ),
141    (Scopes::None, "and", Control),
142    (Scopes::None, "any_false", Control),
143    (
144        Scopes::Character,
145        "appointment_candidate_accumulated_score",
146        // TODO: target changed from title; verify
147        Block(&[("target", Scope(Scopes::LandedTitle)), ("+value", CompareValue)]),
148    ),
149    (
150        Scopes::Character,
151        "appointment_candidate_score",
152        // TODO: target changed from title; verify
153        Block(&[("target", Scope(Scopes::LandedTitle)), ("+value", CompareValue)]),
154    ),
155    (
156        Scopes::Character,
157        "appointment_level_for_title",
158        Block(&[("target", Scope(Scopes::LandedTitle)), ("+value", CompareValue)]),
159    ),
160    (
161        Scopes::Character,
162        "aptitude",
163        Block(&[("court_position", Item(Item::CourtPosition)), ("+value", CompareValue)]),
164    ),
165    (Scopes::Character, "appointment_timeout_days", CompareValue),
166    (Scopes::LandedTitle, "are_vassal_wars_redirected_to_holder", Removed("1.18.1", "")),
167    (Scopes::Army, "army_is_moving", Boolean),
168    (Scopes::Army, "army_max_size", CompareValue),
169    (Scopes::Army, "army_size", CompareValue),
170    (Scopes::Army, "army_supply", CompareValue),
171    (Scopes::Artifact, "artifact_durability", CompareValue),
172    (Scopes::Artifact, "artifact_max_durability", CompareValue),
173    (Scopes::Artifact, "artifact_slot_type", Item(Item::ArtifactSlotType)),
174    (Scopes::Artifact, "artifact_type", Item(Item::ArtifactType)),
175    (Scopes::None, "assert_if", Block(&[("limit", Control), ("?text", UncheckedValue)])),
176    (Scopes::None, "assert_read", UncheckedValue),
177    (Scopes::War, "attacker_war_score", CompareValue),
178    (Scopes::Character, "attraction", CompareValue),
179    (Scopes::SituationParticipantGroup, "auto_add_rulers", Boolean),
180    (Scopes::Province, "available_loot", CompareValueWarnEq),
181    (Scopes::TaxSlot, "available_taxpayer_slots", CompareValue),
182    (Scopes::Character, "average_amenity_level", CompareValue),
183    (Scopes::Faction, "average_faction_opinion", CompareValue),
184    (Scopes::Faction, "average_faction_opinion_not_powerful_vassal", CompareValue),
185    (Scopes::Faction, "average_faction_opinion_powerful_vassal", CompareValue),
186    (Scopes::Character, "barter_goods", CompareValue),
187    (Scopes::Army, "barter_loot", CompareValue),
188    (Scopes::Inspiration, "base_inspiration_gold_cost", CompareValue),
189    (Scopes::Character, "base_weight", CompareValue),
190    (Scopes::LandedTitle.union(Scopes::Province), "building_levies", CompareValue),
191    (Scopes::LandedTitle.union(Scopes::Province), "building_max_garrison", CompareValue),
192    (Scopes::Province, "building_slots", CompareValue),
193    (Scopes::None, "calc_true_if", Control),
194    (Scopes::Character, "can_accept_task_contract", Scope(Scopes::TaskContract)),
195    // TODO: the can_add_hook documentation says it can also take days/months/year but there are no examples in vanilla and it's not clear what it would mean.
196    (
197        Scopes::Character,
198        "can_add_hook",
199        Block(&[("target", Scope(Scopes::Character)), ("type", Item(Item::Hook))]),
200    ),
201    (Scopes::Character, "can_afford_enact_treasury_budget_costs", Boolean),
202    (Scopes::Character, "can_appoint_for_title", Scope(Scopes::LandedTitle)),
203    (Scopes::Character, "can_arrive_in_time_to_activity_minimum", Scope(Scopes::Activity)),
204    (Scopes::Character, "can_assign_to_tax_slot", Scope(Scopes::TaxSlot)),
205    (Scopes::Character, "can_attack_in_hierarchy", Scope(Scopes::Character)),
206    (Scopes::Character, "can_be_acclaimed", Boolean),
207    (Scopes::Character, "can_be_child_of", Scope(Scopes::Character)),
208    (Scopes::Artifact, "can_be_claimed_by", Scope(Scopes::Character)),
209    (Scopes::Character, "can_be_employed_as", Item(Item::CourtPosition)),
210    (Scopes::Secret, "can_be_exposed_by", Scope(Scopes::Character)),
211    (Scopes::LandedTitle, "can_be_leased_out", Boolean),
212    (Scopes::Character, "can_be_parent_of", Scope(Scopes::Character)),
213    (Scopes::Character, "can_be_tributary_of", Scope(Scopes::Character)),
214    (Scopes::Character, "can_become_owner_of_legend", Scope(Scopes::Legend)),
215    (Scopes::Character, "can_benefit_from_artifact", Scope(Scopes::Artifact)),
216    (Scopes::TravelPlan, "can_cancel", Boolean),
217    (Scopes::DynastyHouse, "can_change_house_aspiration", Boolean),
218    (
219        Scopes::Character,
220        "can_create_faction",
221        Block(&[("type", Item(Item::Faction)), ("target", Scope(Scopes::Character))]),
222    ),
223    (Scopes::Character, "can_create_maa", Item(Item::MenAtArms)),
224    (
225        Scopes::Character,
226        "can_create_task_contract",
227        ItemOrBlock(
228            Item::TaskContractType,
229            &[("type_name", Item(Item::TaskContractType)), ("?employer", Scope(Scopes::Character))],
230        ),
231    ),
232    (Scopes::LandedTitle, "can_create_title_maa", Item(Item::MenAtArms)),
233    (
234        Scopes::Character,
235        "can_declare_war",
236        Block(&[
237            ("defender", Scope(Scopes::Character)),
238            ("casus_belli", Item(Item::CasusBelli)),
239            ("?target_titles", ScopeList(Scopes::LandedTitle)),
240            ("?claimant", Scope(Scopes::Character)),
241        ]),
242    ),
243    (Scopes::Army, "can_disband_army", Boolean),
244    (Scopes::Character, "can_diverge", Boolean),
245    (Scopes::Character, "can_diverge_excluding_cost", Boolean),
246    (
247        Scopes::Character,
248        "can_embrace_tradition",
249        ScopeOrBlock(
250            Scopes::CultureTradition,
251            &[
252                ("tradition", Scope(Scopes::CultureTradition)),
253                ("?replace", Scope(Scopes::CultureTradition)),
254            ],
255        ),
256    ),
257    (Scopes::Character, "can_employ_court_position_type", Item(Item::CourtPosition)),
258    (Scopes::Character, "can_equip_artifact", Scope(Scopes::Artifact)),
259    (Scopes::Character, "can_execute_decision", ScopeOrItem(Scopes::Decision, Item::Decision)),
260    (Scopes::CouncilTask, "can_fire_position", Boolean),
261    (Scopes::Character, "can_fund_project_contribution", Scope(Scopes::ProjectContribution)),
262    (Scopes::Culture, "can_get_innovation_from", Scope(Scopes::Culture)),
263    (Scopes::Character, "can_have_children", Boolean),
264    (Scopes::Character, "can_host_activity", ScopeOrItem(Scopes::ActivityType, Item::ActivityType)),
265    (Scopes::Character, "can_hybridize", Scope(Scopes::Culture)),
266    (Scopes::Character, "can_hybridize_excluding_cost", Scope(Scopes::Culture)),
267    (Scopes::Character, "can_join_activity", Scope(Scopes::Activity)),
268    (Scopes::Character, "can_join_faction", Scope(Scopes::Faction)),
269    (
270        Scopes::Character,
271        "can_join_or_create_faction_against",
272        ScopeOrBlock(
273            Scopes::Character,
274            &[
275                ("who", Scope(Scopes::Character)),
276                ("?faction", Item(Item::Faction)),
277                ("?check_in_a_faction", Boolean),
278            ],
279        ),
280    ),
281    (Scopes::Character, "can_nomad_raze_holding", Scope(Scopes::Province)),
282    (Scopes::Character, "can_plan_great_project", Scope(Scopes::GreatProjectType)),
283    (
284        Scopes::Character,
285        "can_plan_great_project_in_province",
286        Block(&[
287            ("type_name", Scope(Scopes::GreatProjectType)),
288            ("province", Scope(Scopes::Province)),
289        ]),
290    ),
291    (Scopes::Character, "can_sponsor_inspiration", Scope(Scopes::Inspiration)),
292    (
293        Scopes::Character,
294        "can_start_scheme",
295        // Docs still just say "target"
296        Block(&[
297            ("type", Item(Item::Scheme)),
298            ("?target_character", Scope(Scopes::Character)),
299            ("?target_title", Scope(Scopes::LandedTitle)),
300            ("?target_culture", Scope(Scopes::Culture)),
301            ("?target_faith", Scope(Scopes::Faith)),
302        ]),
303    ),
304    (Scopes::None, "can_start_tutorial_lesson", UncheckedTodo),
305    (
306        Scopes::LandedTitle,
307        "can_title_create_faction",
308        Block(&[("type", Item(Item::Faction)), ("target", Scope(Scopes::Character))]),
309    ),
310    (Scopes::LandedTitle, "can_title_join_faction", Scope(Scopes::Faction)),
311    (Scopes::Regiment, "can_upgrade_maa", Boolean),
312    (Scopes::Character, "can_vassals_be_attacked", Boolean),
313    (Scopes::Artifact, "category", Choice(&["inventory", "court"])),
314    (Scopes::Character, "cease_tribute_payments_ai_chance", CompareValue),
315    (Scopes::Character, "character_has_commander_trait_scope_does_not", Scope(Scopes::Character)),
316    (Scopes::Character, "character_is_land_realm_neighbor", Scope(Scopes::Character)),
317    (Scopes::Character, "character_is_realm_neighbor", Scope(Scopes::Character)),
318    (Scopes::Character, "character_men_at_arms_expense_gold_relative", CompareValue),
319    (Scopes::Character, "character_men_at_arms_expense_prestige_relative", CompareValue),
320    (Scopes::Character, "character_men_at_arms_expense_treasury_relative", CompareValue),
321    (Scopes::Character, "character_treasury_budget_capacity", CompareValue),
322    (Scopes::Character, "character_treasury_new_budget_capacity", CompareValue),
323    (Scopes::Confederation, "cohesion", CompareValue),
324    (Scopes::Province, "combined_building_level", CompareValue),
325    (Scopes::Confederation, "combined_military_strength", CompareValue),
326    (Scopes::Character, "completely_controls", Scope(Scopes::LandedTitle)),
327    (
328        Scopes::Character,
329        "completely_controls_region",
330        ScopeOrItem(Scopes::GeographicalRegion, Item::Region),
331    ),
332    (Scopes::ProjectContribution, "contribution_id", Item(Item::ProjectContribution)),
333    (Scopes::ProjectContribution, "contribution_is_funded", Boolean),
334    (Scopes::ProjectContribution, "contribution_is_required", Boolean),
335    (Scopes::Faith, "controls_holy_site", Item(Item::HolySite)),
336    (Scopes::Faith, "controls_holy_site_with_flag", Item(Item::HolySiteFlag)),
337    (Scopes::Character, "council_task_monthly_progress", CompareValue),
338    (Scopes::LandedTitle, "county_control", CompareValue),
339    (
340        Scopes::LandedTitle,
341        "county_control_rate",
342        Removed("1.12", "replaced by monthly_county_control_change"),
343    ),
344    (
345        Scopes::LandedTitle,
346        "county_control_rate_modifier",
347        Removed(
348            "1.12",
349            "replaced by monthly_county_control_decline_factor and monthly_county_control_growth_factor",
350        ),
351    ),
352    (
353        Scopes::LandedTitle,
354        "county_has_province_with_terrain",
355        Block(&[("*terrain", Item(Item::Terrain))]),
356    ),
357    (Scopes::LandedTitle, "county_holder_opinion", CompareValue),
358    (Scopes::LandedTitle, "county_fertility", CompareValue),
359    (Scopes::LandedTitle, "county_opinion", CompareValue),
360    (
361        Scopes::LandedTitle,
362        "county_opinion_target",
363        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
364    ),
365    (Scopes::Character, "court_grandeur_base", CompareValue),
366    (Scopes::Character, "court_grandeur_current", CompareValue),
367    (Scopes::Character, "court_grandeur_current_level", CompareValue),
368    (Scopes::Character, "court_grandeur_minimum_expected", CompareValue),
369    (Scopes::Character, "court_grandeur_minimum_expected_level", CompareValue),
370    (Scopes::Character, "court_positions_currently_available", CompareValue),
371    (Scopes::Character, "court_positions_currently_filled", CompareValue),
372    (
373        Scopes::Character,
374        "create_faction_type_chance",
375        Block(&[
376            ("type", Item(Item::Faction)),
377            ("target", Scope(Scopes::Character)),
378            ("+value", CompareValue),
379        ]),
380    ),
381    (
382        Scopes::Culture,
383        "cultural_acceptance",
384        Block(&[("target", Scope(Scopes::Culture)), ("+value", CompareValue)]),
385    ),
386    (Scopes::Culture, "culture_age", CompareValueWarnEq),
387    (Scopes::CultureInnovation, "culture_can_know_innovation", Scope(Scopes::Culture)),
388    (Scopes::Culture, "culture_has_any_fascination", Boolean),
389    (Scopes::Culture, "culture_number_of_counties", CompareValue),
390    (
391        Scopes::Culture,
392        "culture_overlaps_geographical_region",
393        ScopeOrItem(Scopes::GeographicalRegion, Item::Region),
394    ),
395    (Scopes::None, "current_computer_date", CompareDate),
396    (Scopes::None, "current_computer_date_day", CompareValue),
397    (Scopes::None, "current_computer_date_month", CompareValue),
398    (Scopes::None, "current_computer_date_year", CompareValue),
399    (Scopes::TravelPlan, "current_danger_value", CompareValue),
400    (Scopes::None, "current_date", CompareDate),
401    (Scopes::None, "current_day", CompareValue),
402    (Scopes::Character, "current_domain_fertility", CompareValue),
403    (Scopes::Character, "current_military_strength", CompareValue),
404    (Scopes::None, "current_month", CompareValue),
405    (Scopes::Character, "current_raised_military_strength", CompareValue),
406    (Scopes::None, "current_tooltip_depth", CompareValue),
407    (Scopes::Character, "current_weight", CompareValue),
408    (Scopes::Character, "current_weight_for_portrait", CompareValue),
409    (Scopes::None, "current_year", CompareValue),
410    (Scopes::None, "custom_description", Control),
411    (Scopes::LandedTitle, "custom_title_name", Item(Item::Localization)),
412    (Scopes::None, "custom_tooltip", Special),
413    (Scopes::Character, "days_as_ruler", CompareValue),
414    (Scopes::Character, "days_in_prison", CompareValue),
415    (Scopes::Character, "days_of_continuous_peace", CompareValue),
416    (Scopes::Character, "days_of_continuous_war", CompareValue),
417    (Scopes::Inspiration, "days_since_creation", CompareValue),
418    (Scopes::Character, "days_since_death", CompareValue),
419    (Scopes::Character, "days_since_joined_court", CompareValue),
420    (Scopes::Legend, "days_since_legend_completion", CompareValue),
421    (Scopes::Legend, "days_since_legend_start_date", CompareValue),
422    (Scopes::War, "days_since_max_war_score", CompareValue),
423    (Scopes::Epidemic, "days_since_outbreak_start", CompareValue),
424    (
425        Scopes::Province,
426        "days_since_province_infection",
427        Block(&[("epidemic", Scope(Scopes::Epidemic)), ("+value", CompareValue)]),
428    ),
429    (Scopes::Inspiration, "days_since_sponsorship", CompareValue),
430    (Scopes::Character, "days_since_vassal_contract_liege_dynasty_reign_start", CompareValue),
431    (Scopes::TravelPlan, "days_travelled", CompareValue),
432    (Scopes::GreatHolyWar, "days_until_ghw_launch", CompareValue),
433    (
434        Scopes::LandedTitle,
435        "de_jure_drift_progress",
436        Block(&[("target", Scope(Scopes::LandedTitle)), ("+value", CompareValue)]),
437    ),
438    (Scopes::LandedTitle, "de_jure_drifting_towards", Scope(Scopes::LandedTitle)),
439    (Scopes::Character, "death_reason", Item(Item::DeathReason)),
440    (Scopes::Character, "debt_level", CompareValue),
441    (Scopes::None, "debug_log", UncheckedTodo),
442    (Scopes::None, "debug_log_details", UncheckedTodo),
443    (Scopes::None, "debug_only", Boolean),
444    (Scopes::War, "defender_war_score", CompareValue),
445    (Scopes::TravelPlan, "departure_date", CompareValue),
446    (Scopes::LandedTitle, "development_level", CompareValue),
447    (Scopes::LandedTitle, "development_rate", CompareValue),
448    (Scopes::LandedTitle, "development_rate_modifier", CompareValue),
449    (Scopes::LandedTitle, "development_towards_level_increase", CompareValue),
450    (Scopes::Character, "diarch_aptitude", CompareValue),
451    (Scopes::Character, "diarch_loyalty", CompareValue),
452    (Scopes::Character, "diarchy_swing", CompareValue),
453    (Scopes::Character, "diplomacy", CompareValue),
454    (
455        Scopes::Character,
456        "diplomacy_diff",
457        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue), ("?abs", Boolean)]),
458    ),
459    (Scopes::Character, "diplomacy_for_portrait", CompareValue),
460    (Scopes::CombatSide, "disallowed_retreat", Boolean),
461    (Scopes::Faction, "discontent_per_month", CompareValue),
462    (
463        Scopes::Character,
464        "does_ai_liege_in_vassal_contract_desire_admin_province_obligation_change",
465        Boolean,
466    ),
467    (Scopes::Character, "does_ai_liege_in_vassal_contract_desire_obligation_change", Boolean),
468    (
469        Scopes::Character,
470        "does_ai_subject_in_subject_contract_desire_admin_province_obligation_change",
471        Boolean,
472    ),
473    (Scopes::Character, "does_ai_subject_in_subject_contract_desire_obligation_change", Boolean),
474    (Scopes::Character, "does_ai_vassal_in_vassal_contract_desire_obligation_change", Boolean),
475    (Scopes::Character, "domain_limit", CompareValue),
476    (Scopes::Character, "domain_limit_available", CompareValue),
477    (Scopes::Character, "domain_limit_percentage", CompareValue),
478    (Scopes::Character, "domain_size", CompareValue),
479    (Scopes::Character, "domain_size_excluding_grace_period", CompareValue),
480    (Scopes::Domicile, "domicile_building_has_free_internal_slot", Item(Item::DomicileBuilding)),
481    (Scopes::Domicile, "domicile_uses_culture_and_faith", Boolean),
482    (Scopes::Domicile, "domicile_uses_provisions", Boolean),
483    // NOTE: documentation says `character` but it's `dreaded_character`
484    (Scopes::Character, "dread", CompareValue),
485    (
486        Scopes::Character,
487        "dread_modified_ai_boldness",
488        Block(&[("dreaded_character", Scope(Scopes::Character)), ("+value", CompareValue)]),
489    ),
490    (Scopes::Dynasty, "dynasty_can_unlock_relevant_perk", Boolean),
491    (Scopes::Dynasty, "dynasty_num_unlocked_perks", CompareValue),
492    (Scopes::Dynasty, "dynasty_prestige", CompareValueWarnEq),
493    (Scopes::Dynasty, "dynasty_prestige_level", CompareValue),
494    (Scopes::Character, "effective_age", CompareValue),
495    (Scopes::Character, "employs_court_position", Item(Item::CourtPosition)),
496    (Scopes::Character, "employs_tax_collector", Boolean),
497    (Scopes::Province, "epidemic_resistance", CompareValue),
498    (Scopes::Faith, "estimated_faith_strength", CompareValue),
499    (Scopes::None, "exists", Special),
500    (Scopes::Domicile, "external_domicile_building_slots", CompareValue),
501    (Scopes::Faction, "faction_can_press_demands", Boolean),
502    (Scopes::Faction, "faction_discontent", CompareValue),
503    (Scopes::Faction, "faction_is_at_war", Boolean),
504    (Scopes::Faction, "faction_is_type", Item(Item::Faction)),
505    (Scopes::Faction, "faction_power", CompareValue),
506    (Scopes::Faction, "faction_power_threshold", CompareValue),
507    (
508        Scopes::Faith,
509        "faith_hostility_level",
510        Block(&[("target", Scope(Scopes::Faith)), ("+value", CompareValue)]),
511    ),
512    (Scopes::Faith, "faith_hostility_level_comparison", ScopeCompare(Scopes::Faith)),
513    (Scopes::Character, "fertility", CompareValue),
514    (Scopes::LandedTitle, "fertility_equilibrium", CompareValue),
515    (Scopes::Faith, "fervor", CompareValue),
516    (Scopes::TravelPlan, "final_destination_arrival_date", CompareDate),
517    (Scopes::TravelPlan, "final_destination_arrival_days", CompareValue),
518    (Scopes::TravelPlan, "final_destination_progress", CompareValue),
519    (Scopes::Character, "focus_progress", CompareValue),
520    (Scopes::Province, "fort_level", CompareValue),
521    (Scopes::Province, "free_building_slots", CompareValue),
522    (Scopes::Domicile, "free_external_domicile_building_slots", CompareValue),
523    (Scopes::Culture, "free_tradition_slot", CompareValue),
524    (Scopes::None, "game_start_date", CompareDate),
525    (
526        Scopes::Province,
527        "geographical_region",
528        ScopeOrItem(Scopes::GeographicalRegion, Item::Region),
529    ),
530    (Scopes::GreatHolyWar, "ghw_attackers_strength", CompareValue),
531    (Scopes::GreatHolyWar, "ghw_defenders_strength", CompareValue),
532    (Scopes::GreatHolyWar, "ghw_war_chest_gold", CompareValueWarnEq),
533    (Scopes::GreatHolyWar, "ghw_war_chest_piety", CompareValueWarnEq),
534    (Scopes::GreatHolyWar, "ghw_war_chest_prestige", CompareValueWarnEq),
535    (
536        Scopes::None,
537        "global_variable_list_size",
538        Block(&[("name", Identifier("list name")), ("+value", CompareValue)]),
539    ),
540    (Scopes::Character, "gold", CompareValueWarnEq),
541    (Scopes::Character, "government_allows", Choice(GOVERNMENT_RULES)),
542    (Scopes::Character, "government_disallows", Choice(GOVERNMENT_RULES)),
543    (Scopes::Character, "government_has_flag", Item(Item::GovernmentFlag)),
544    (Scopes::GreatProject, "great_project_build_progress", CompareValue),
545    (
546        Scopes::GreatProject,
547        "great_project_construction_phase_is",
548        Choice(&["planned", "in_progress", "completed"]),
549    ),
550    (Scopes::GreatProject, "great_project_days_to_completion", CompareValue),
551    // There's a trigger that takes an Item and an event target of the same name that returns a Scope.
552    // Handle the name collistion by deleting the event target and making the trigger accept both.
553    (
554        Scopes::GreatProject,
555        "great_project_type",
556        ScopeOrItem(Scopes::GreatProjectType, Item::GreatProjectType),
557    ),
558    (Scopes::GreatProjectType, "great_project_type_is_important", Boolean),
559    (Scopes::Character, "has_access_to_maa", Item(Item::MenAtArms)),
560    (Scopes::Accolade, "has_accolade_category", Item(Item::AccoladeCategory)),
561    (Scopes::Accolade, "has_accolade_parameter", Item(Item::AccoladeParameter)),
562    (Scopes::Accolade, "has_accolade_type", Item(Item::AccoladeType)),
563    (Scopes::Character, "has_active_diarchy", Boolean),
564    (Scopes::Activity, "has_active_locale", Item(Item::ActivityLocale)),
565    (Scopes::Character, "has_active_mandate", Item(Item::DiarchyMandate)),
566    (Scopes::Character, "has_activity_intent", Item(Item::ActivityIntent)),
567    // TODO: check that the given ActivityOption belongs to the given ActivityOptionCategory
568    (
569        Scopes::Activity,
570        "has_activity_option",
571        Block(&[
572            ("category", Item(Item::ActivityOptionCategory)),
573            ("option", Item(Item::ActivityOption)),
574        ]),
575    ),
576    (Scopes::Character, "has_activity_state", Item(Item::ActivityState)),
577    (Scopes::Activity, "has_activity_type", ScopeOrItem(Scopes::ActivityType, Item::ActivityType)),
578    (
579        Scopes::Culture,
580        "has_all_innovations",
581        Block(&[
582            ("?with_flag", Item(Item::InnovationFlag)),
583            ("?without_flag", Item(Item::InnovationFlag)),
584            ("?culture_era", Item(Item::CultureEra)),
585        ]),
586    ),
587    (Scopes::None, "has_all_variables", Block(&[("+name", Identifier("variable name"))])),
588    (Scopes::Faith, "has_allowed_gender_for_clergy", Scope(Scopes::Character)),
589    (Scopes::Character, "has_any_artifact", Boolean),
590    (Scopes::Character, "has_any_artifact_claim", Boolean),
591    (Scopes::Character, "has_any_cb_on", Scope(Scopes::Character)),
592    (Scopes::Character, "has_any_court_position", Boolean),
593    (Scopes::Character, "has_any_display_cb_on", Scope(Scopes::Character)),
594    (Scopes::Character, "has_any_focus", Boolean),
595    (Scopes::Character, "has_any_nickname", Boolean),
596    (Scopes::Character, "has_any_opinion_with_reason", UncheckedTodo),
597    (Scopes::Character, "has_any_scripted_relation", Scope(Scopes::Character)),
598    (Scopes::Character, "has_any_secret_relation", Scope(Scopes::Character)),
599    (Scopes::Character, "has_any_secrets", Boolean),
600    (Scopes::Character, "has_any_unequipped_artifact", Boolean),
601    (
602        Scopes::Character,
603        "has_appointment_influence_level_for_title_tier",
604        Scope(Scopes::LandedTitle),
605    ),
606    (Scopes::Character, "has_appointment_invested_character", Scope(Scopes::Character)),
607    (Scopes::Character, "has_appointment_invested_title", Scope(Scopes::LandedTitle)),
608    (Scopes::Character, "has_appointment_level_for_title", Scope(Scopes::LandedTitle)),
609    (Scopes::Character, "has_appointment_merit_level_for_title_tier", Scope(Scopes::LandedTitle)),
610    (Scopes::Character, "has_appointment_piety_level_for_title_tier", Scope(Scopes::LandedTitle)),
611    (
612        Scopes::Character,
613        "has_appointment_prestige_level_for_title_tier",
614        Scope(Scopes::LandedTitle),
615    ),
616    (Scopes::Character, "has_artifact_claim", Scope(Scopes::Artifact)),
617    (Scopes::Artifact, "has_artifact_feature", Item(Item::ArtifactFeature)),
618    (Scopes::Artifact, "has_artifact_feature_group", Item(Item::ArtifactFeatureGroup)),
619    (Scopes::Artifact, "has_artifact_modifier", Item(Item::Modifier)),
620    (Scopes::Character, "has_away_hostages", Boolean),
621    (Scopes::Character, "has_bad_nickname", Boolean),
622    (Scopes::Character, "has_banish_reason", Scope(Scopes::Character)),
623    (Scopes::DynastyHouse, "has_base_name", Item(Item::Localization)),
624    (Scopes::Province, "has_building", Item(Item::Building)),
625    (Scopes::Culture, "has_building_gfx", Item(Item::BuildingGfx)),
626    (Scopes::Province, "has_building_or_higher", Item(Item::Building)),
627    (
628        Scopes::Province,
629        "has_building_with_flag",
630        ItemOrBlock(
631            Item::BuildingFlag,
632            &[("flag", Item(Item::BuildingFlag)), ("?count", CompareValue)],
633        ),
634    ),
635    (
636        Scopes::Character,
637        "has_cb_on",
638        Block(&[
639            ("target", Scope(Scopes::Character)),
640            ("?cb", Item(Item::CasusBelli)),
641            ("?casus_belli", Item(Item::CasusBelli)),
642        ]),
643    ),
644    (Scopes::Character, "has_character_flag", UncheckedValue),
645    (Scopes::Character, "has_character_modifier", Item(Item::Modifier)),
646    // TODO for all the duration_remaining items: verify if multiple comparators work. Verify if
647    // "weeks" works. If multiple comparators work, warn if they can never be satisfied.
648    (
649        Scopes::Character,
650        "has_character_modifier_duration_remaining",
651        Block(&[
652            ("modifier", Item(Item::Modifier)),
653            ("*days", CompareValue),
654            ("*weeks", CompareValue),
655            ("*months", CompareValue),
656            ("*years", CompareValue),
657        ]),
658    ),
659    (Scopes::LandedTitle, "has_character_nominiated", Scope(Scopes::Character)), // sic
660    (Scopes::Character, "has_claim_on", Scope(Scopes::LandedTitle)),
661    (Scopes::Culture, "has_clothing_gfx", Item(Item::ClothingGfx)),
662    (Scopes::Culture, "has_coa_gfx", Item(Item::CoaGfx)),
663    (Scopes::LandedTitle, "has_coastal_province", Boolean),
664    (Scopes::Confederation, "has_cohesion", Boolean),
665    (Scopes::Confederation, "has_cohesion_level_parameter", Item(Item::CohesionLevelParameter)),
666    (
667        Scopes::Character,
668        "has_completed_activity_intent",
669        ItemOrBlock(
670            Item::ActivityIntent,
671            &[("type", Item(Item::ActivityIntent)), ("?target", Scope(Scopes::Character))],
672        ),
673    ),
674    (Scopes::Character, "has_completed_inspiration", Boolean),
675    (Scopes::Province, "has_construction_with_flag", Item(Item::BuildingFlag)),
676    (Scopes::Character, "has_contact", Scope(Scopes::Character)),
677    (Scopes::Character, "has_council", Boolean),
678    (Scopes::Character, "has_council_position", Item(Item::CouncilPosition)),
679    (
680        Scopes::Character,
681        "has_councillor_for_skill",
682        Choice(&[
683            "diplomacy",
684            "intrigue",
685            "learning",
686            "martial",
687            "prowess",
688            "stewardship",
689            "general",
690        ]),
691    ),
692    (Scopes::LandedTitle, "has_county_modifier", Item(Item::Modifier)),
693    (
694        Scopes::LandedTitle,
695        "has_county_modifier_duration_remaining",
696        Block(&[
697            ("modifier", Item(Item::Modifier)),
698            ("*days", CompareValue),
699            ("*weeks", CompareValue),
700            ("*months", CompareValue),
701            ("*years", CompareValue),
702        ]),
703    ),
704    (Scopes::Character, "has_court_language", Item(Item::Language)),
705    (Scopes::Character, "has_court_language_of_culture", Scope(Scopes::Culture)),
706    (Scopes::Character, "has_court_position", Item(Item::CourtPosition)),
707    (Scopes::Character, "has_court_type", Item(Item::CourtType)),
708    (Scopes::Culture, "has_cultural_era_or_later", Item(Item::CultureEra)),
709    (Scopes::Culture, "has_cultural_parameter", Item(Item::CultureParameter)),
710    (Scopes::Culture, "has_cultural_pillar", Item(Item::CulturePillar)),
711    (
712        Scopes::Culture,
713        "has_cultural_tradition",
714        ScopeOrItem(Scopes::CultureTradition, Item::CultureTradition),
715    ),
716    (Scopes::Character, "has_culture", Scope(Scopes::Culture)),
717    (Scopes::Activity, "has_current_phase", Item(Item::ActivityPhase)),
718    (Scopes::LandedTitle, "has_custom_title_name", Boolean),
719    (Scopes::Character, "has_de_jure_claim_on", Scope(Scopes::Character)),
720    (Scopes::Character, "has_dead_character_flag", Identifier("flag name")),
721    (Scopes::Character, "has_dead_character_variable", Identifier("variable name")),
722    (Scopes::DynastyHouse, "has_default_house_aspiration", Boolean),
723    (Scopes::Character, "has_diarchy_active_parameter", Item(Item::DiarchyParameter)),
724    (Scopes::Character, "has_diarchy_parameter", Item(Item::DiarchyParameter)),
725    (Scopes::Character, "has_diarchy_type", Item(Item::DiarchyType)),
726    (Scopes::LandedTitle, "has_disabled_building", Boolean),
727    (Scopes::Character, "has_divorce_reason", Scope(Scopes::Character)),
728    (Scopes::None, "has_dlc", Item(Item::DlcName)),
729    (Scopes::None, "has_dlc_feature", Item(Item::DlcFeature)),
730    (Scopes::Faith, "has_doctrine", ScopeOrItem(Scopes::Doctrine, Item::Doctrine)),
731    (Scopes::Faith, "has_doctrine_parameter", Item(Item::DoctrineBooleanParameter)),
732    (Scopes::Character, "has_domicile", Boolean),
733    (Scopes::Domicile, "has_domicile_building", Item(Item::DomicileBuilding)),
734    (Scopes::Domicile, "has_domicile_building_or_higher", Item(Item::DomicileBuilding)),
735    (Scopes::Domicile, "has_domicile_construction", Item(Item::DomicileBuilding)),
736    (Scopes::Domicile, "has_domicile_parameter", Item(Item::DomicileParameter)),
737    (Scopes::Character, "has_domicile_temperament_high", Boolean),
738    (Scopes::Character, "has_domicile_temperament_low", Boolean),
739    (Scopes::Character, "has_domicile_temperament_neutral", Boolean),
740    (Scopes::Faith, "has_dominant_ruling_gender", Scope(Scopes::Character)),
741    (
742        Scopes::Character,
743        "has_dread_level_towards",
744        Block(&[("target", Scope(Scopes::Character)), ("level", CompareValue)]),
745    ),
746    (Scopes::Character, "has_dynasty", Boolean),
747    (Scopes::Dynasty, "has_dynasty_modifier", Item(Item::Modifier)),
748    (
749        Scopes::Dynasty,
750        "has_dynasty_modifier_duration_remaining",
751        Block(&[
752            ("modifier", Item(Item::Modifier)),
753            ("*days", CompareValue),
754            ("*weeks", CompareValue),
755            ("*months", CompareValue),
756            ("*years", CompareValue),
757        ]),
758    ),
759    (Scopes::Dynasty, "has_dynasty_perk", Item(Item::DynastyPerk)),
760    (
761        Scopes::Character,
762        "has_election_vote_of",
763        Block(&[("who", Scope(Scopes::Character)), ("title", Scope(Scopes::LandedTitle))]),
764    ),
765    (Scopes::Character, "has_employed_any_court_position", Boolean),
766    (Scopes::Character, "has_execute_reason", Scope(Scopes::Character)),
767    (Scopes::Character, "has_faith", Scope(Scopes::Faith)),
768    (Scopes::Character, "has_father", Boolean),
769    (Scopes::Character, "has_focus", Item(Item::Focus)),
770    (Scopes::GreatHolyWar, "has_forced_defender", Scope(Scopes::Character)),
771    (Scopes::Province, "has_free_building_slot", Boolean),
772    (Scopes::Character, "has_free_council_slot", Boolean),
773    (Scopes::None, "has_game_rule", Item(Item::GameRuleSetting)),
774    (Scopes::Character, "has_gene", Special),
775    (Scopes::None, "has_global_variable", Identifier("variable name")),
776    (Scopes::None, "has_global_variable_list", Identifier("list name")),
777    (Scopes::Character, "has_government", Item(Item::GovernmentType)),
778    (Scopes::Faith, "has_graphical_faith", Item(Item::GraphicalFaith)),
779    (Scopes::Province, "has_great_building", Boolean),
780    (Scopes::Province, "has_great_building_slot", Boolean),
781    (Scopes::Character, "has_had_focus_for_days", CompareValue),
782    (Scopes::Province, "has_holding", Boolean),
783    (Scopes::HoldingType, "has_holding_parameter", Item(Item::HoldingParameter)),
784    (Scopes::Province, "has_holding_type", Item(Item::HoldingType)),
785    (Scopes::LandedTitle, "has_holy_site_flag", Item(Item::HolySiteFlag)),
786    (Scopes::Character, "has_hook", Scope(Scopes::Character)),
787    (Scopes::Character, "has_hook_from_secret", Scope(Scopes::Secret)),
788    (
789        Scopes::Character,
790        "has_hook_of_type",
791        Block(&[("target", Scope(Scopes::Character)), ("type", Item(Item::Hook))]),
792    ),
793    (Scopes::DynastyHouse, "has_house_artifact_claim", Scope(Scopes::Artifact)),
794    (Scopes::DynastyHouse, "has_house_head_parameter", Item(Item::BooleanHouseHeadParameter)),
795    (Scopes::DynastyHouse, "has_house_modifier", Item(Item::Modifier)),
796    (
797        Scopes::DynastyHouse,
798        "has_house_modifier_duration_remaining",
799        Block(&[
800            ("modifier", Item(Item::Modifier)),
801            ("*days", CompareValue),
802            ("*weeks", CompareValue),
803            ("*months", CompareValue),
804            ("*years", CompareValue),
805        ]),
806    ),
807    (Scopes::DynastyHouse, "has_house_power_parameter", Item(Item::BooleanHousePowerParameter)),
808    (Scopes::HouseRelation, "has_house_relation_level", Item(Item::HouseRelationLevel)),
809    (
810        Scopes::HouseRelation,
811        "has_house_relation_parameter",
812        Item(Item::BooleanHouseRelationParameter),
813    ),
814    (Scopes::DynastyHouse, "has_house_relation_with", Scope(Scopes::DynastyHouse)),
815    (Scopes::DynastyHouse, "has_house_unity", Boolean),
816    (Scopes::DynastyHouse, "has_house_unity_modifier", Item(Item::Modifier)),
817    (
818        Scopes::DynastyHouse,
819        "has_house_unity_modifier_duration_remaining",
820        Block(&[
821            ("modifier", Item(Item::Modifier)),
822            ("*days", CompareValue),
823            ("*weeks", CompareValue),
824            ("*months", CompareValue),
825            ("*years", CompareValue),
826        ]),
827    ),
828    (Scopes::DynastyHouse, "has_house_unity_parameter", Item(Item::HouseUnityParameter)),
829    (Scopes::DynastyHouse, "has_house_unity_stage", Item(Item::HouseUnityStage)),
830    (Scopes::Faith, "has_icon", Item(Item::FaithIcon)),
831    (Scopes::Character, "has_imprisonment_reason", Scope(Scopes::Character)),
832    (Scopes::Character, "has_inactive_trait", Item(Item::Trait)),
833    (Scopes::Culture, "has_innovation", ScopeOrItem(Scopes::CultureInnovation, Item::Innovation)),
834    (Scopes::Culture, "has_innovation_flag", Item(Item::InnovationFlag)),
835    (Scopes::CultureInnovation, "has_innovation_parameter", Item(Item::InnovationParameter)),
836    (Scopes::Inspiration, "has_inspiration_type", Item(Item::Inspiration)),
837    (Scopes::Confederation, "has_leading_house", Boolean),
838    (
839        Scopes::Legend,
840        "has_legend_chapter",
841        ItemOrBlock(
842            Item::LegendChapter,
843            &[("name", Item(Item::LegendChapter)), ("?localization_key", Item(Item::Localization))],
844        ),
845    ),
846    (Scopes::Legend, "has_legend_chronicle", Item(Item::LegendChronicle)),
847    (Scopes::Legend, "has_legend_county_modifier", Item(Item::Modifier)),
848    (Scopes::Legend, "has_legend_county_modifier_duration_remaining", UncheckedTodo),
849    (Scopes::Legend, "has_legend_owner_modifier", Item(Item::Modifier)),
850    (Scopes::Legend, "has_legend_owner_modifier_duration_remaining", UncheckedTodo),
851    (Scopes::Legend, "has_legend_province_modifier", Item(Item::Modifier)),
852    (Scopes::Legend, "has_legend_province_modifier_duration_remaining", UncheckedTodo),
853    (Scopes::Character, "has_legitimacy", Boolean),
854    (Scopes::Character, "has_legitimacy_flag", Item(Item::LegitimacyFlag)),
855    (Scopes::Character, "has_lifestyle", Item(Item::Lifestyle)),
856    (Scopes::None, "has_local_player_open_court_event", Boolean),
857    (Scopes::None, "has_local_player_seen_unopened_court_event", Boolean),
858    (Scopes::None, "has_local_player_unopened_court_event", Boolean),
859    (Scopes::None, "has_local_variable", Special),
860    (Scopes::None, "has_local_variable_list", Special),
861    (Scopes::CombatSide, "has_maa_of_type", Item(Item::MenAtArms)),
862    (Scopes::None, "has_map_mode", Item(Item::MapMode)),
863    (Scopes::CharacterMemory, "has_memory_category", Item(Item::MemoryCategory)),
864    (Scopes::CharacterMemory, "has_memory_participant", Scope(Scopes::Character)),
865    (Scopes::CharacterMemory, "has_memory_type", Item(Item::MemoryType)),
866    (Scopes::Character, "has_mother", Boolean),
867    (Scopes::None, "has_multiple_players", Boolean),
868    (Scopes::Culture, "has_name_list", Item(Item::NameList)),
869    (Scopes::Character, "has_nickname", Item(Item::Nickname)),
870    (Scopes::None, "has_none_of_variables", Block(&[("+name", Identifier("variable name"))])),
871    (Scopes::Character, "has_obedience_reason", Scope(Scopes::Character)),
872    (Scopes::Province, "has_ongoing_construction", Boolean),
873    (Scopes::Domicile, "has_ongoing_domicile_construction", Boolean),
874    (
875        Scopes::Character,
876        "has_opinion_modifier",
877        Block(&[
878            ("target", Scope(Scopes::Character)),
879            ("modifier", Item(Item::OpinionModifier)),
880            ("*value", CompareValue),
881        ]),
882    ),
883    (Scopes::Character, "has_opposite_relation", Item(Item::Relation)),
884    (Scopes::LandedTitle, "has_order_of_succession", Choice(&["election", "appointment"])),
885    (Scopes::Character, "has_outstanding_artifact_claims", Boolean),
886    (Scopes::Character, "has_owned_scheme", Boolean),
887    (
888        Scopes::SituationParticipantGroup,
889        "has_participant_group_parameter",
890        Item(Item::SituationParticipantGroupParameter),
891    ),
892    (Scopes::Character, "has_pending_court_events", Boolean),
893    (Scopes::Character, "has_pending_interaction_of_type", Item(Item::CharacterInteraction)),
894    (Scopes::Character, "has_perk", Item(Item::Perk)),
895    (Scopes::Character, "has_personal_artifact_claim", Scope(Scopes::Artifact)),
896    (
897        Scopes::Character,
898        "has_personal_legend_seed",
899        ScopeOrItem(Scopes::LegendType, Item::LegendType),
900    ),
901    (
902        Scopes::Activity,
903        "has_phase",
904        ItemOrBlock(
905            Item::ActivityPhase,
906            &[("?type", Item(Item::ActivityPhase)), ("?location", Scope(Scopes::Province))],
907        ),
908    ),
909    (
910        Scopes::Activity,
911        "has_phase_future",
912        ItemOrBlock(
913            Item::ActivityPhase,
914            &[("?type", Item(Item::ActivityPhase)), ("?location", Scope(Scopes::Province))],
915        ),
916    ),
917    (
918        Scopes::Activity,
919        "has_phase_past",
920        ItemOrBlock(
921            Item::ActivityPhase,
922            &[("?type", Item(Item::ActivityPhase)), ("?location", Scope(Scopes::Province))],
923        ),
924    ),
925    (
926        Scopes::Character,
927        "has_player_court_position_automation_assign_best",
928        Scope(Scopes::CourtPositionType),
929    ),
930    (
931        Scopes::Character,
932        "has_player_court_position_automation_assign_best_or_event",
933        Scope(Scopes::CourtPositionType),
934    ),
935    (
936        Scopes::Character,
937        "has_player_court_position_automation_event",
938        Scope(Scopes::CourtPositionType),
939    ),
940    (
941        Scopes::Character,
942        "has_player_court_position_automation_none",
943        Scope(Scopes::CourtPositionType),
944    ),
945    (Scopes::GreatHolyWar, "has_pledged_attacker", Scope(Scopes::Character)),
946    (Scopes::GreatHolyWar, "has_pledged_defender", Scope(Scopes::Character)),
947    (Scopes::Character, "has_potential_acclaimed_knights", Boolean),
948    (Scopes::Accolade, "has_potential_accolade_successors", Boolean),
949    (Scopes::Faith, "has_preferred_gender_for_clergy", Scope(Scopes::Character)),
950    (Scopes::Culture, "has_primary_name_list", Item(Item::NameList)),
951    (Scopes::Character, "has_primary_title", Scope(Scopes::LandedTitle)),
952    (Scopes::Character, "has_prisoners", Boolean),
953    (Scopes::Province, "has_province_modifier", Item(Item::Modifier)),
954    (
955        Scopes::Province,
956        "has_province_modifier_duration_remaining",
957        Block(&[
958            ("modifier", Item(Item::Modifier)),
959            ("*days", CompareValue),
960            ("*weeks", CompareValue),
961            ("*months", CompareValue),
962            ("*years", CompareValue),
963        ]),
964    ),
965    // TODO: don't allow comparators for "any"
966    (
967        Scopes::LandedTitle,
968        "has_province_with_epidemic",
969        Block(&[("+intensity", CompareChoice(&["any", "minor", "major", "apocalyptic"]))]),
970    ),
971    (Scopes::Character, "has_raid_immunity_against", Scope(Scopes::Character)),
972    (Scopes::Character, "has_raised_armies", Boolean),
973    (Scopes::Character, "has_realm_law", Item(Item::Law)),
974    (Scopes::Character, "has_realm_law_flag", Item(Item::LawFlag)),
975    (Scopes::Character, "has_realm_law_in_group", Item(Item::LawGroup)),
976    (
977        Scopes::Character,
978        "has_relation_flag",
979        Block(&[
980            ("target", Scope(Scopes::Character)),
981            ("relation", Item(Item::Relation)),
982            ("flag", Item(Item::RelationFlag)),
983        ]),
984    ),
985    (Scopes::Character, "has_relation_to", Scope(Scopes::Character)),
986    (Scopes::Character, "has_religion", Scope(Scopes::Religion)),
987    (Scopes::HoldingType, "has_required_heir_governments", Boolean),
988    (Scopes::LandedTitle, "has_revokable_lease", Boolean),
989    (Scopes::Character, "has_revoke_title_reason", Scope(Scopes::Character)),
990    (Scopes::None, "has_reward_item", Item(Item::RewardItem)),
991    (Scopes::Character, "has_royal_court", Boolean),
992    (Scopes::Province, "has_ruined_great_building", Boolean),
993    (Scopes::Character, "has_ruler_objective", Boolean),
994    (Scopes::Character, "has_same_court_language", Scope(Scopes::Character)),
995    (Scopes::Character, "has_same_court_type_as", Scope(Scopes::Character)),
996    (Scopes::Character, "has_same_culture_as", Scope(Scopes::Character)),
997    (Scopes::Culture, "has_same_culture_ethos", Scope(Scopes::Culture)),
998    (Scopes::Culture, "has_same_culture_head_determination", Scope(Scopes::Culture)),
999    (Scopes::Culture, "has_same_culture_heritage", Scope(Scopes::Culture)),
1000    (Scopes::Culture, "has_same_culture_language", Scope(Scopes::Culture)),
1001    (Scopes::Culture, "has_same_culture_martial_tradition", Scope(Scopes::Culture)),
1002    (Scopes::Character, "has_same_focus_as", Scope(Scopes::Character)),
1003    (Scopes::Character, "has_same_government", Scope(Scopes::Character)),
1004    (Scopes::DynastyHouse, "has_same_house_power_as", Scope(Scopes::DynastyHouse)),
1005    (Scopes::Character, "has_same_sinful_trait", Scope(Scopes::Character)),
1006    (Scopes::Character, "has_same_virtue_trait", Scope(Scopes::Character)),
1007    (Scopes::Character, "has_scheme_countermeasure_parameter", Item(Item::CountermeasureParameter)),
1008    (Scopes::Scheme, "has_scheme_modifier", Item(Item::Modifier)),
1009    (Scopes::Character, "has_selected_mandate", Item(Item::DiarchyMandate)),
1010    (Scopes::Character, "has_sexuality", Item(Item::Sexuality)),
1011    (Scopes::Character, "has_spawned_court_events", Boolean),
1012    (Scopes::Province, "has_special_building", Boolean),
1013    (Scopes::Province, "has_special_building_slot", Boolean),
1014    (Scopes::Faction, "has_special_character", Boolean),
1015    (Scopes::Faction, "has_special_title", Boolean),
1016    (Scopes::Province, "has_stationed_regiment", Boolean),
1017    (Scopes::Province, "has_stationed_regiment_of_base_type", Item(Item::MenAtArmsBase)),
1018    (Scopes::Character, "has_strong_claim_on", Scope(Scopes::LandedTitle)),
1019    (Scopes::Character, "has_strong_hook", Scope(Scopes::Character)),
1020    (Scopes::Character, "has_strong_implicit_claim_on", Scope(Scopes::LandedTitle)),
1021    (Scopes::Character, "has_strong_usable_hook", Scope(Scopes::Character)),
1022    (Scopes::Struggle, "has_struggle_phase_parameter", Item(Item::StrugglePhaseParameter)),
1023    (
1024        Scopes::Situation,
1025        "has_situation_top_phase_parameter",
1026        Item(Item::SituationParticipantGroupParameter),
1027    ),
1028    (
1029        Scopes::SituationSubRegion,
1030        "has_sub_region_phase_parameter",
1031        Item(Item::SituationParticipantGroupParameter),
1032    ),
1033    (Scopes::Character, "has_subject_contract_group", Item(Item::SubjectContractGroup)),
1034    (Scopes::Character, "has_succession_appointment_investors", Scope(Scopes::LandedTitle)),
1035    (Scopes::Character, "has_targeting_faction", Boolean),
1036    (Scopes::TaskContract, "has_task_contract_group", Item(Item::TaskContractGroup)),
1037    (Scopes::TaskContract, "has_task_contract_type", Item(Item::TaskContractType)),
1038    (Scopes::TaxSlot, "has_tax_collector", Boolean),
1039    (Scopes::Character, "has_title", Scope(Scopes::LandedTitle)),
1040    (Scopes::LandedTitle, "has_title_law", Item(Item::Law)),
1041    (Scopes::LandedTitle, "has_title_law_flag", Item(Item::LawFlag)),
1042    (Scopes::CultureTradition, "has_tradition_category", Item(Item::CultureTraditionCategory)),
1043    (Scopes::Character, "has_trait", ScopeOrItem(Scopes::Trait, Item::Trait)),
1044    (Scopes::Trait, "has_trait_category", Item(Item::TraitCategory)),
1045    (Scopes::Trait, "has_trait_flag", Item(Item::TraitFlag)),
1046    (
1047        Scopes::Character,
1048        "has_trait_rank",
1049        Block(&[
1050            ("trait", Item(Item::Trait)),
1051            ("*rank", CompareValue),
1052            ("*character", CompareToScope(Scopes::Character)),
1053        ]),
1054    ),
1055    (Scopes::Character, "has_trait_with_flag", Item(Item::TraitFlag)),
1056    // TODO: "track name is required if the trait has multiple tracks, otherwise should not be provided."
1057    (
1058        Scopes::Character,
1059        "has_trait_xp",
1060        Block(&[
1061            ("trait", ScopeOrItem(Scopes::Trait, Item::Trait)),
1062            ("?track", Item(Item::TraitTrack)),
1063            ("+value", CompareValue),
1064        ]),
1065    ),
1066    (Scopes::TravelPlan, "has_travel_option", Item(Item::TravelOption)),
1067    (Scopes::TravelPlan, "has_travel_plan_modifier", Item(Item::Modifier)),
1068    (Scopes::TravelPlan, "has_travel_plan_modifier_duration_remaining", UncheckedTodo),
1069    (Scopes::Province, "has_travel_point_of_interest", Item(Item::PointOfInterest)),
1070    (Scopes::Character, "has_treasury", Boolean),
1071    (Scopes::Character, "has_triggered_legend_seed", Item(Item::LegendSeed)),
1072    (Scopes::Character, "has_truce", Scope(Scopes::Character)),
1073    (Scopes::Culture, "has_unit_gfx", Item(Item::UnitGfx)),
1074    (Scopes::Character, "has_usable_hook", Scope(Scopes::Character)),
1075    (Scopes::LandedTitle, "has_user_set_coa", Boolean),
1076    (Scopes::War, "has_valid_casus_belli", Boolean),
1077    (
1078        Scopes::None,
1079        "has_variable",
1080        IdentifierOrBlock("variable name", &[("+name", Identifier("variable name"))]),
1081    ),
1082    (Scopes::None, "has_variable_list", Identifier("list name")),
1083    (Scopes::Character, "has_vassal_stance", Item(Item::VassalStance)),
1084    (
1085        Scopes::None,
1086        "has_war_result_message_with_outcome",
1087        Choice(&["victory", "defeat", "white_peace", "invalidated", "any"]),
1088    ),
1089    (Scopes::Character, "has_weak_claim_on", Scope(Scopes::LandedTitle)),
1090    (Scopes::Character, "has_weak_hook", Scope(Scopes::Character)),
1091    (Scopes::Character, "has_weak_implicit_claim_on", Scope(Scopes::LandedTitle)),
1092    (Scopes::LandedTitle, "has_wrong_holding_type", Boolean),
1093    (Scopes::Character, "health", CompareValue),
1094    (Scopes::Domicile, "herd", CompareValue),
1095    (Scopes::Character, "highest_held_title_tier", CompareValue),
1096    // TODO: verify whether "prowess" is a valid argument to highest_skill
1097    (Scopes::Character, "highest_skill", Item(Item::Skill)),
1098    (Scopes::Character, "highest_skill_including_prowess", Item(Item::Skill)),
1099    (Scopes::Character, "holds_landed_title", Boolean),
1100    (Scopes::Faith, "holy_sites_controlled", CompareValue),
1101    (Scopes::Domicile, "horde", CompareValue),
1102    // TODO: verify "weeks" works here
1103    (
1104        Scopes::Character,
1105        "hostage_duration",
1106        Block(&[
1107            ("*days", CompareValue),
1108            ("*weeks", CompareValue),
1109            ("*months", CompareValue),
1110            ("*years", CompareValue),
1111        ]),
1112    ),
1113    (
1114        Scopes::DynastyHouse,
1115        "house_land_share_in_realm",
1116        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValueWarnEq)]),
1117    ),
1118    (Scopes::DynastyHouse, "house_power", CompareValueWarnEq),
1119    (Scopes::DynastyHouse, "house_unity_value", CompareValueWarnEq),
1120    (Scopes::Character, "important_action_is_valid_but_invisible", Item(Item::ImportantAction)),
1121    (Scopes::Character, "important_action_is_visible", Item(Item::ImportantAction)),
1122    (Scopes::Character, "in_diplomatic_range", Scope(Scopes::Character)),
1123    (Scopes::Character, "influence", CompareValueWarnEq),
1124    (Scopes::Character, "influence_level", CompareValue),
1125    (Scopes::CultureInnovation, "innovation_era", Item(Item::CultureEra)),
1126    (Scopes::CultureInnovation, "innovation_is_regional", Boolean),
1127    (Scopes::CultureInnovation, "innovation_key", Item(Item::Innovation)),
1128    (Scopes::Inspiration, "inspiration_gold_invested", CompareValueWarnEq),
1129    (Scopes::Inspiration, "inspiration_progress", CompareValue),
1130    (Scopes::Character, "intrigue", CompareValue),
1131    (
1132        Scopes::Character,
1133        "intrigue_diff",
1134        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue), ("?abs", Boolean)]),
1135    ),
1136    (Scopes::Character, "intrigue_for_portrait", CompareValue),
1137    (Scopes::Character, "is_a_faction_leader", Boolean),
1138    (Scopes::Character, "is_a_faction_member", Boolean),
1139    (Scopes::TravelPlan, "is_aborted", Boolean),
1140    (Scopes::Character, "is_acclaimed", Boolean),
1141    (Scopes::Accolade, "is_accolade_active", Boolean),
1142    (Scopes::Character, "is_accolade_successor", Boolean),
1143    (Scopes::TaxSlot, "is_active_obligation", Item(Item::TaxSlotObligation)),
1144    (Scopes::Activity, "is_activity_complete", Boolean),
1145    (
1146        Scopes::Character,
1147        "is_activity_type_on_cooldown",
1148        ScopeOrItem(Scopes::ActivityType, Item::ActivityType),
1149    ),
1150    (Scopes::Character, "is_adult", Boolean),
1151    (Scopes::Character, "is_agent_exposed_in_scheme", Scope(Scopes::Scheme)),
1152    (Scopes::AgentSlot, "is_agent_slot_type", Item(Item::AgentType)),
1153    (Scopes::CultureInnovation, "is_ahead_of_time_for_culture", Scope(Scopes::Culture)),
1154    (Scopes::Character, "is_ai", Boolean),
1155    (Scopes::Character, "is_alive", Boolean),
1156    (Scopes::Character, "is_allied_in_war", Scope(Scopes::Character)),
1157    (Scopes::Character, "is_allied_to", Scope(Scopes::Character)),
1158    (Scopes::Army, "is_army_in_combat", Boolean),
1159    (Scopes::Army, "is_army_in_raid", Boolean),
1160    (Scopes::Army, "is_army_in_siege", Boolean),
1161    (Scopes::Army, "is_army_in_siege_relevant_for", Scope(Scopes::Character)),
1162    (Scopes::Character, "is_at_home", Boolean),
1163    (Scopes::Character, "is_at_location", Scope(Scopes::Province)),
1164    (Scopes::Character, "is_at_same_location", Scope(Scopes::Character)),
1165    (Scopes::Character, "is_at_war", Boolean),
1166    (Scopes::Character, "is_at_war_as_attacker", Boolean),
1167    (Scopes::Character, "is_at_war_as_defender", Boolean),
1168    (Scopes::Character, "is_at_war_with", Scope(Scopes::Character)),
1169    (Scopes::Character, "is_at_war_with_liege", Boolean),
1170    (Scopes::War, "is_attacker", Scope(Scopes::Character)),
1171    (Scopes::Character, "is_attacker_in_war", Scope(Scopes::War)),
1172    (Scopes::Character, "is_attracted_to_gender_of", Scope(Scopes::Character)),
1173    (Scopes::Character, "is_attracted_to_men", Boolean),
1174    (Scopes::Character, "is_attracted_to_women", Boolean),
1175    (
1176        Scopes::Character,
1177        "is_available_quick",
1178        Block(&[
1179            ("?ai", Boolean),
1180            ("?alive", Boolean),
1181            ("?female", Boolean),
1182            ("?adult", Boolean),
1183            ("?incapable", Boolean),
1184            ("?imprisoned", Boolean),
1185            ("?hostage", Boolean),
1186            ("?travel", Boolean),
1187            ("?activity", Boolean),
1188            ("?ruler", Boolean),
1189            ("?advanced_ruler", Boolean),
1190            ("?landed", Boolean),
1191            ("?in_army", Boolean),
1192            ("?at_war", Boolean),
1193        ]),
1194    ),
1195    (Scopes::Character, "is_away_from_court", Boolean),
1196    (Scopes::None, "is_bad_nickname", Item(Item::Nickname)),
1197    (Scopes::Army, "is_barter_army", Boolean),
1198    (Scopes::Character, "is_betrothed", Boolean),
1199    (Scopes::Character, "is_bloc_leader_or_bloc_leader_heir_of", Scope(Scopes::Character)),
1200    (Scopes::TravelPlan, "is_cancelled", Boolean),
1201    (Scopes::LandedTitle, "is_capital_barony", Boolean),
1202    (Scopes::Character, "is_causing_raid_hostility_towards", Scope(Scopes::Character)),
1203    (
1204        Scopes::Character,
1205        "is_character_interaction_potentially_accepted",
1206        Block(&[
1207            ("recipient", ScopeOkThis(Scopes::Character)),
1208            ("interaction", Item(Item::CharacterInteraction)),
1209            ("?secondary_actor", ScopeOkThis(Scopes::Character)),
1210            ("?secondary_recipient", ScopeOkThis(Scopes::Character)),
1211            ("?target_title", Scope(Scopes::LandedTitle)),
1212            ("?required_response", Choice(&["yes", "maybe"])),
1213            ("?ai_accept", CompareValue),
1214        ]),
1215    ),
1216    (
1217        Scopes::Character,
1218        "is_character_interaction_shown",
1219        Block(&[
1220            ("recipient", ScopeOkThis(Scopes::Character)),
1221            ("interaction", Item(Item::CharacterInteraction)),
1222        ]),
1223    ),
1224    (
1225        Scopes::Character,
1226        "is_character_interaction_valid",
1227        Block(&[
1228            ("recipient", ScopeOkThis(Scopes::Character)),
1229            ("interaction", Item(Item::CharacterInteraction)),
1230        ]),
1231    ),
1232    (Scopes::Character, "is_character_window_main_character", Boolean),
1233    (Scopes::Character, "is_child_of", Scope(Scopes::Character)),
1234    (Scopes::War, "is_civil_war", Boolean),
1235    (Scopes::Character, "is_claimant", Boolean),
1236    (Scopes::Character, "is_clergy", Boolean),
1237    (Scopes::Character, "is_close_family_of", Scope(Scopes::Character)),
1238    (Scopes::Character, "is_close_or_extended_family_of", Scope(Scopes::Character)),
1239    (Scopes::Province, "is_coastal", Boolean),
1240    (Scopes::LandedTitle, "is_coastal_county", Boolean),
1241    (Scopes::CombatSide, "is_combat_side_attacker", Boolean),
1242    (Scopes::CombatSide, "is_combat_side_pursuing", Boolean),
1243    (Scopes::CombatSide, "is_combat_side_retreating", Boolean),
1244    (Scopes::Character, "is_commanding_army", Boolean),
1245    (Scopes::TravelPlan, "is_completed", Boolean),
1246    (Scopes::Character, "is_concubine", Boolean),
1247    (Scopes::Character, "is_concubine_of", Scope(Scopes::Character)),
1248    (Scopes::Character, "is_confederation_member", Boolean),
1249    // TODO: check that the landed titles are counties
1250    (
1251        Scopes::LandedTitle,
1252        "is_connected_to",
1253        Block(&[
1254            ("?max_naval_distance", SetValue),
1255            ("?allow_one_county_land_gap", Boolean),
1256            ("target", Scope(Scopes::LandedTitle)),
1257        ]),
1258    ),
1259    (Scopes::Character, "is_consort_of", Scope(Scopes::Character)),
1260    (Scopes::Character, "is_contact_of", Scope(Scopes::Character)),
1261    (Scopes::LandedTitle, "is_contested", Boolean),
1262    (
1263        Scopes::Character,
1264        "is_council_task_valid",
1265        Block(&[
1266            ("task_type", Item(Item::CouncilTask)),
1267            ("?target", Scope(Scopes::Character.union(Scopes::LandedTitle))),
1268        ]),
1269    ),
1270    (Scopes::Character, "is_councillor", Boolean),
1271    (Scopes::Character, "is_councillor_of", Scope(Scopes::Character)),
1272    (Scopes::Province, "is_county_capital", Boolean),
1273    (
1274        Scopes::Character,
1275        "is_court_position_employer",
1276        Block(&[("court_position", Item(Item::CourtPosition)), ("who", Scope(Scopes::Character))]),
1277    ),
1278    (Scopes::Character, "is_courtier", Boolean),
1279    (Scopes::Character, "is_courtier_of", Scope(Scopes::Character)),
1280    (Scopes::Character, "is_cousin_of", Scope(Scopes::Character)),
1281    (Scopes::TaskContract, "is_criminal", Boolean),
1282    (Scopes::Secret, "is_criminal_for", Scope(Scopes::Character)),
1283    (Scopes::Struggle, "is_culture_involved_in_struggle", Scope(Scopes::Culture)),
1284    (Scopes::Activity, "is_current_phase_active", Boolean),
1285    (Scopes::LandedTitle, "is_de_facto_liege_or_above_target", Scope(Scopes::LandedTitle)),
1286    (Scopes::LandedTitle, "is_de_jure_liege_or_above_target", Scope(Scopes::LandedTitle)),
1287    (Scopes::Character, "is_decision_on_cooldown", ScopeOrItem(Scopes::Decision, Item::Decision)),
1288    (Scopes::War, "is_defender", Scope(Scopes::Character)),
1289    (Scopes::Character, "is_defender_in_war", Scope(Scopes::War)),
1290    (Scopes::Character, "is_designated_diarch", Boolean),
1291    (Scopes::Character, "is_diarch", Boolean),
1292    (Scopes::Character, "is_diarch_of_target", Scope(Scopes::Character)),
1293    (Scopes::Character, "is_diarchy_successor", Boolean),
1294    (Scopes::GreatHolyWar, "is_directed_ghw", Boolean),
1295    (Scopes::Culture, "is_divergent_culture", Boolean),
1296    (Scopes::Domicile, "is_domicile_type", Item(Item::DomicileType)),
1297    (Scopes::DynastyHouse, "is_dominant_family", Boolean),
1298    (Scopes::None, "is_frontend_character_selected", Boolean),
1299    (Scopes::DynastyHouse, "is_powerful_family", Boolean),
1300    (Scopes::Character, "is_employer_of", Scope(Scopes::Character)),
1301    (Scopes::Artifact, "is_equipped", Boolean),
1302    (Scopes::Regiment, "is_event_maa_regiment", Boolean),
1303    (Scopes::Character, "is_extended_family_of", Scope(Scopes::Character)),
1304    (Scopes::Struggle, "is_faith_involved_in_struggle", Scope(Scopes::Faith)),
1305    (Scopes::Character, "is_favorite_child", Boolean),
1306    (Scopes::Character, "is_female", Boolean),
1307    (Scopes::LandedTitle, "is_figurehead_title", Boolean),
1308    (Scopes::AgentSlot, "is_filled", Boolean),
1309    (Scopes::Character, "is_forbidden_from_scheme", Scope(Scopes::Scheme)),
1310    (Scopes::Character, "is_forced_into_faction", Boolean),
1311    (Scopes::Character, "is_forced_into_scheme", Scope(Scopes::Scheme)),
1312    (Scopes::CombatSide, "is_forced_winner", Boolean),
1313    (Scopes::Character, "is_foreign_court_guest", Boolean),
1314    (Scopes::Character, "is_foreign_court_guest_of", Scope(Scopes::Character)),
1315    (Scopes::Character, "is_foreign_court_or_pool_guest", Boolean),
1316    (Scopes::Character, "is_foreign_court_or_pool_guest_of", Scope(Scopes::Character)),
1317    (Scopes::Character, "is_from_ruler_designer", Boolean),
1318    (Scopes::None, "is_game_view_open", UncheckedTodo),
1319    (Scopes::None, "is_gamestate_tutorial_active", Boolean),
1320    (Scopes::Character, "is_grandchild_of", Scope(Scopes::Character)),
1321    (Scopes::Character, "is_grandparent_of", Scope(Scopes::Character)),
1322    (Scopes::Character, "is_great_grandchild_of", Scope(Scopes::Character)),
1323    (Scopes::Character, "is_great_grandparent_of", Scope(Scopes::Character)),
1324    (Scopes::LandedTitle, "is_head_of_faith", Boolean),
1325    (Scopes::Character, "is_heir_of", Scope(Scopes::Character)),
1326    (Scopes::Regiment, "is_hired_maa_regiment", Boolean),
1327    (Scopes::LandedTitle, "is_holy_order", Boolean),
1328    (Scopes::LandedTitle, "is_holy_site", Boolean),
1329    (Scopes::LandedTitle, "is_holy_site_controlled_by", Scope(Scopes::Character)),
1330    (Scopes::LandedTitle, "is_holy_site_of", Scope(Scopes::Faith)),
1331    (Scopes::Character, "is_hostage", Boolean),
1332    (Scopes::Character, "is_hostage_from", Scope(Scopes::Character)),
1333    (Scopes::Character, "is_hostage_of", Scope(Scopes::Character)),
1334    (Scopes::Character, "is_hostage_warden", Boolean),
1335    (Scopes::Scheme, "is_hostile", Boolean),
1336    (Scopes::Confederation, "is_house_based", Boolean),
1337    (Scopes::Culture, "is_hybrid_culture", Boolean),
1338    (Scopes::Character, "is_immortal", Boolean),
1339    (Scopes::Character, "is_important_decision", Scope(Scopes::Decision)),
1340    (Scopes::LandedTitle, "is_important_location", Scope(Scopes::LandedTitle)),
1341    (Scopes::Character, "is_imprisoned", Boolean),
1342    (Scopes::Character, "is_imprisoned_by", Scope(Scopes::Character)),
1343    (Scopes::Character, "is_in_army", Boolean),
1344    (Scopes::Character, "is_in_civil_war", Boolean),
1345    (Scopes::Character, "is_in_debt", Boolean),
1346    (Scopes::Religion.union(Scopes::Faith), "is_in_family", Item(Item::ReligionFamily)),
1347    (
1348        Scopes::Character,
1349        "is_in_guest_subset",
1350        Block(&[("name", Item(Item::GuestSubset)), ("?phase", Item(Item::ActivityPhase))]),
1351    ),
1352    (Scopes::None, "is_in_list", Special),
1353    (Scopes::Character, "is_in_ongoing_great_holy_war", Boolean),
1354    (Scopes::Character, "is_in_pool_at", Scope(Scopes::Province)),
1355    (Scopes::Character, "is_in_prison_type", Item(Item::PrisonType)),
1356    (Scopes::Character, "is_in_the_same_court_as", Scope(Scopes::Character)),
1357    (Scopes::Character, "is_in_the_same_court_as_or_guest", Scope(Scopes::Character)),
1358    (Scopes::Character, "is_incapable", Boolean),
1359    (Scopes::Character, "is_independent_ruler", Boolean),
1360    (Scopes::Character, "is_knight", Boolean),
1361    (Scopes::Character, "is_knight_of", Scope(Scopes::Character)),
1362    (Scopes::Secret, "is_known_by", Scope(Scopes::Character)),
1363    (Scopes::CultureInnovation, "is_known_by_culture", Scope(Scopes::Culture)),
1364    (Scopes::Province, "is_lake_province", Boolean),
1365    (Scopes::LandedTitle, "is_lakeside_county", Boolean),
1366    (Scopes::Province, "is_lakeside_province", Boolean),
1367    (Scopes::Character, "is_landed", Boolean),
1368    (Scopes::Character, "is_landless_ruler", Boolean),
1369    (Scopes::LandedTitle, "is_landless_type_title", Boolean),
1370    (Scopes::Character, "is_leader_in_war", Scope(Scopes::War)),
1371    (Scopes::Character, "is_leading_faction_type", Item(Item::Faction)),
1372    (Scopes::LandedTitle, "is_leased_out", Boolean),
1373    (Scopes::Legend, "is_legend_completed", Boolean),
1374    (Scopes::Character, "is_liege_or_above_of", Scope(Scopes::Character)),
1375    (Scopes::Character, "is_local_player", Boolean),
1376    (Scopes::Character, "is_lowborn", Boolean),
1377    (Scopes::Regiment, "is_maa_in_combat", Boolean),
1378    (Scopes::Regiment, "is_maa_type", Item(Item::MenAtArms)),
1379    (Scopes::Character, "is_male", Boolean),
1380    (Scopes::Character, "is_manual_participant", Boolean),
1381    (Scopes::Character, "is_married", Boolean),
1382    (Scopes::Character, "is_member_of_confederation", Scope(Scopes::Confederation)),
1383    (Scopes::CharacterMemory, "is_memory_of_travel", Scope(Scopes::TravelPlan)),
1384    (Scopes::LandedTitle, "is_mercenary_company", Boolean),
1385    (Scopes::None, "is_mercenary_in_hire_range", Scope(Scopes::Character)),
1386    (Scopes::Character, "is_migrating", Boolean),
1387    (Scopes::LandedTitle, "is_migration_target", Boolean),
1388    (Scopes::LandedTitle, "is_neighbor_to_realm", Scope(Scopes::Character)),
1389    (Scopes::Character, "is_nibling_of", Scope(Scopes::Character)),
1390    (Scopes::Character, "is_no_men_enabled", Boolean),
1391    (Scopes::LandedTitle, "is_noble_family_title", Boolean),
1392    (Scopes::LandedTitle, "is_nomad_title", Boolean),
1393    (Scopes::Character, "is_normal_councillor", Boolean),
1394    (Scopes::Character, "is_obedient", Boolean),
1395    (Scopes::Character, "is_obedient_to", Scope(Scopes::Character)),
1396    (Scopes::Province, "is_occupied", Boolean),
1397    (Scopes::Activity, "is_open_invite_activity", Boolean),
1398    (Scopes::Trait, "is_opposite_of_trait", Scope(Scopes::Trait)),
1399    (Scopes::Character, "is_overriding_designated_winner", Boolean),
1400    (Scopes::Character, "is_parent_of", Scope(Scopes::Character)),
1401    (Scopes::War, "is_participant", Scope(Scopes::Character)),
1402    (Scopes::Character, "is_participant_in_activity", Scope(Scopes::Activity)),
1403    (Scopes::Character, "is_participant_in_war", Scope(Scopes::War)),
1404    (Scopes::TravelPlan, "is_paused", Boolean),
1405    (Scopes::Character, "is_performing_council_task", Item(Item::CouncilTask)),
1406    (Scopes::Character, "is_performing_council_task_or_clone", Item(Item::CouncilTask)),
1407    (Scopes::Regiment, "is_personal_maa_regiment", Boolean),
1408    (Scopes::Character, "is_planning_great_project", Item(Item::GreatProjectType)),
1409    (Scopes::Character, "is_player_heir_of", Scope(Scopes::Character)),
1410    (Scopes::None, "is_player_selected", Boolean),
1411    (Scopes::Character, "is_player_tutorial_character", Boolean),
1412    (Scopes::Character, "is_pledged_ghw_attacker", Boolean),
1413    (Scopes::Character, "is_pool_character", Boolean),
1414    (Scopes::Character, "is_pool_guest", Boolean),
1415    (Scopes::Character, "is_pool_guest_of", Scope(Scopes::Character)),
1416    (Scopes::Character, "is_potential_knight", Boolean),
1417    (Scopes::Character, "is_powerful_vassal", Boolean),
1418    (Scopes::Character, "is_powerful_vassal_of", Scope(Scopes::Character)),
1419    (Scopes::Character, "is_pregnant", Boolean),
1420    (Scopes::Character, "is_primary_heir_of", Scope(Scopes::Character)),
1421    (Scopes::Army, "is_raid_army", Boolean),
1422    (Scopes::Province, "is_raided", Boolean),
1423    (Scopes::Regiment, "is_raised", Boolean),
1424    (Scopes::Regiment, "is_regular_maa_regiment", Boolean),
1425    (Scopes::Activity, "is_required_special_guest", Scope(Scopes::Character)),
1426    (Scopes::Character, "is_rightful_liege_of", Scope(Scopes::Character)),
1427    (Scopes::Province, "is_river_province", Boolean),
1428    (Scopes::Province, "is_riverside_province", Boolean),
1429    (Scopes::LandedTitle, "is_riverside_county", Boolean),
1430    (Scopes::Province, "is_riverside_province", Boolean),
1431    (Scopes::Province, "is_ruined_building_being_reconstructed", Boolean),
1432    (Scopes::Character, "is_ruler", Boolean),
1433    (Scopes::LandedTitle, "is_ruler_de_jure_liege_or_above", Scope(Scopes::Character)),
1434    (Scopes::Scheme, "is_scheme_agent_exposed", Scope(Scopes::Character)),
1435    (
1436        Scopes::Scheme,
1437        "is_scheme_category",
1438        Choice(&["hostile", "contract", "personal", "political"]),
1439    ),
1440    (Scopes::Scheme, "is_scheme_exposed", Boolean),
1441    (Scopes::Scheme, "is_scheme_target_type", Choice(&["character", "title", "faith", "culture"])),
1442    // TODO: the documentation says scheme_skill but the single example in vanilla uses just skill. Should verify.
1443    (
1444        Scopes::Character,
1445        "is_scheming_against",
1446        Block(&[
1447            ("target", Scope(Scopes::Character)),
1448            ("?type", Item(Item::Scheme)),
1449            ("?scheme_skill", Item(Item::Skill)),
1450        ]),
1451    ),
1452    (Scopes::Province, "is_sea_province", Boolean),
1453    (Scopes::None, "is_set", Scope(Scopes::all_but_none())),
1454    (Scopes::Secret, "is_shunned_for", Scope(Scopes::Character)),
1455    (Scopes::Secret, "is_shunned_or_criminal_for", Scope(Scopes::Character)),
1456    (Scopes::Character, "is_sibling_of", Scope(Scopes::Character)),
1457    (Scopes::Situation, "is_situation_unique", Boolean),
1458    (
1459        Scopes::Activity,
1460        "is_special_guest",
1461        ScopeOrBlock(
1462            Scopes::Character,
1463            &[("target", Scope(Scopes::Character)), ("type", Item(Item::GuestSubset))],
1464        ),
1465    ),
1466    (Scopes::Secret, "is_spent_by", Scope(Scopes::Character)),
1467    (Scopes::Character, "is_spouse_of", Scope(Scopes::Character)),
1468    (Scopes::Character, "is_spouse_of_even_if_dead", Scope(Scopes::Character)),
1469    (Scopes::Struggle, "is_struggle_phase", Item(Item::StrugglePhase)),
1470    (Scopes::Struggle, "is_struggle_type", Item(Item::Struggle)),
1471    (Scopes::Character, "is_successor_of_accolade", Scope(Scopes::Accolade)),
1472    (Scopes::None, "is_target_in_global_variable_list", Special),
1473    (Scopes::None, "is_target_in_local_variable_list", Special),
1474    (Scopes::None, "is_target_in_variable_list", Special),
1475    (Scopes::LandedTitle, "is_target_of_council_task", Item(Item::CouncilTask)),
1476    (Scopes::LandedTitle, "is_target_of_council_task_or_clone", Item(Item::CouncilTask)),
1477    (Scopes::Character, "is_tax_collector", Boolean),
1478    (Scopes::Character, "is_tax_collector_of", Scope(Scopes::Character)),
1479    (Scopes::Character, "is_theocratic_lessee", Boolean),
1480    (Scopes::LandedTitle, "is_title_created", Boolean),
1481    (Scopes::None, "is_title_localization_key_used", Item(Item::Localization)),
1482    (Scopes::Regiment, "is_title_maa_regiment", Boolean),
1483    (Scopes::LandedTitle, "is_titular", Boolean),
1484    (Scopes::None, "is_tooltip_with_name_open", UncheckedTodo),
1485    (Scopes::Character, "is_travel_entourage_character", Boolean),
1486    (Scopes::Character, "is_travel_leader", Boolean),
1487    (Scopes::TravelPlan, "is_travel_with_domicile", Boolean),
1488    (Scopes::Character, "is_travelling", Boolean),
1489    (Scopes::Character, "is_tributary", Boolean),
1490    (Scopes::Character, "is_tributary_of", Scope(Scopes::Character)),
1491    (Scopes::Character, "is_tributary_of_suzerain_or_above", Scope(Scopes::Character)),
1492    (Scopes::None, "is_tutorial_active", Boolean),
1493    (Scopes::None, "is_tutorial_lesson_active", UncheckedTodo),
1494    (Scopes::None, "is_tutorial_lesson_chain_completed", UncheckedTodo),
1495    (Scopes::None, "is_tutorial_lesson_completed", UncheckedTodo),
1496    (Scopes::None, "is_tutorial_lesson_step_completed", UncheckedTodo),
1497    (Scopes::Character, "is_twin_of", Scope(Scopes::Character)),
1498    (Scopes::Scheme, "is_type_basic", Boolean),
1499    (Scopes::Scheme, "is_type_secret", Boolean),
1500    (Scopes::Character, "is_unborn_child_of_concubine", Boolean),
1501    (Scopes::Character, "is_unborn_known_bastard", Boolean),
1502    (Scopes::Character, "is_uncle_or_aunt_of", Scope(Scopes::Character)),
1503    (Scopes::LandedTitle, "is_under_holy_order_lease", Boolean),
1504    (Scopes::Artifact, "is_unique", Boolean),
1505    (Scopes::Regiment, "is_unit_type", Item(Item::MenAtArmsBase)),
1506    (Scopes::Character, "is_valid_agent_standard_trigger", Boolean),
1507    (Scopes::Character, "is_valid_as_agent_in_any_slot", Scope(Scopes::Scheme)),
1508    (
1509        Scopes::Character,
1510        "is_valid_as_agent_in_scheme",
1511        Removed("1.13", "replaced by is_valid_as_agent_in_any_slot"),
1512    ),
1513    (Scopes::Character, "is_valid_as_agent_in_slot", Scope(Scopes::AgentSlot)),
1514    (Scopes::Character, "is_valid_designated_heir", Scope(Scopes::Character)),
1515    (Scopes::Character, "is_valid_for_event_debug", Item(Item::Event)), // will not work in release mode
1516    (Scopes::Character, "is_valid_for_event_debug_cooldown", Item(Item::Event)), // will not work in release mode
1517    (Scopes::Character, "is_valid_successor_for_accolade", Scope(Scopes::Accolade)),
1518    (Scopes::TaskContract, "is_valid_to_keep", Boolean),
1519    (Scopes::Character, "is_valid_to_hire_court_position_type", Item(Item::CourtPosition)),
1520    (Scopes::Character, "is_vassal_of", Scope(Scopes::Character)),
1521    (Scopes::Character, "is_vassal_or_below_of", Scope(Scopes::Character)),
1522    (Scopes::Character, "is_visibly_fertile", Boolean),
1523    (Scopes::War, "is_war_leader", Scope(Scopes::Character)),
1524    (Scopes::None, "is_war_overview_tab_open", UncheckedTodo),
1525    (Scopes::War, "is_white_peace_possible", Boolean),
1526    (Scopes::None, "is_widget_open", Removed("1.13", "replaced by is_widgetid_open")),
1527    (Scopes::None, "is_widgetid_open", UncheckedTodo),
1528    (Scopes::Character, "is_yes_men_enabled", Boolean),
1529    (
1530        Scopes::Character,
1531        "join_faction_chance",
1532        Block(&[("target", Scope(Scopes::Faction)), ("+value", CompareValue)]),
1533    ),
1534    // Documentation says `target` but it's `scheme`
1535    (
1536        Scopes::Character,
1537        "join_scheme_chance",
1538        Block(&[("scheme", Scope(Scopes::Scheme)), ("max", SetValue), ("min", SetValue)]),
1539    ),
1540    (Scopes::Character, "knows_court_language_of", ScopeOkThis(Scopes::Character)),
1541    (Scopes::Character, "knows_language", Item(Item::Language)),
1542    (Scopes::Character, "knows_language_of_culture", Scope(Scopes::Culture)),
1543    (Scopes::Character, "learning", CompareValue),
1544    (
1545        Scopes::Character,
1546        "learning_diff",
1547        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue), ("?abs", Boolean)]),
1548    ),
1549    (Scopes::Character, "learning_for_portrait", CompareValue),
1550    (Scopes::Character, "levies_to_liege", CompareValueWarnEq),
1551    (
1552        Scopes::None,
1553        "list_size",
1554        Block(&[("name", Identifier("list name")), ("+value", CompareValue)]),
1555    ),
1556    (Scopes::Legend, "legend_completion_date", CompareDate),
1557    (Scopes::Legend, "legend_quality", Choice(LEGEND_QUALITY)),
1558    (Scopes::Legend, "legend_start_date", CompareDate),
1559    (Scopes::Character, "legitimacy", CompareValueWarnEq),
1560    (Scopes::Character, "legitimacy_level", CompareValue),
1561    (Scopes::Character, "levies_to_liege", CompareValue),
1562    (Scopes::Secret, "local_player_knows_this_secret", Boolean),
1563    (Scopes::None, "local_variable_list_size", Special),
1564    (Scopes::Character, "long_term_gold", CompareValueWarnEq),
1565    (Scopes::Character, "long_term_gold_maximum", CompareValueWarnEq),
1566    (Scopes::Character, "long_term_treasury", CompareValueWarnEq),
1567    (Scopes::Character, "long_term_treasury_maximum", CompareValueWarnEq),
1568    (Scopes::Character, "long_term_treasury_or_gold", CompareValueWarnEq),
1569    (Scopes::Character, "lowest_skill", CompareValue),
1570    (Scopes::Character, "lowest_skill_including_prowess", CompareValue),
1571    (Scopes::Regiment, "maa_current_troops_count", CompareValue),
1572    (Scopes::Character, "maa_regiments_count", CompareValue),
1573    (Scopes::Character, "maa_regiments_max_count", CompareValue),
1574    (Scopes::Regiment, "maa_max_troops_count", CompareValue),
1575    (Scopes::Regiment, "maa_size", CompareValue),
1576    (Scopes::Character, "main_administrative_tier", CompareValue),
1577    (
1578        Scopes::Character,
1579        "mandate_type_qualification",
1580        Block(&[("target", Item(Item::DiarchyMandate)), ("value", CompareValue)]),
1581    ),
1582    (Scopes::Character, "martial", CompareValue),
1583    (
1584        Scopes::Character,
1585        "martial_diff",
1586        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue), ("?abs", Boolean)]),
1587    ),
1588    (Scopes::Character, "martial_for_portrait", CompareValue),
1589    (Scopes::Character, "matrilinear_betrothal", Boolean),
1590    (Scopes::Character, "matrilinear_marriage", Boolean),
1591    (Scopes::Character, "max_active_accolades", CompareValue),
1592    (Scopes::Character, "max_domain_fertility", CompareValue),
1593    (Scopes::Domicile, "max_herd", CompareValue),
1594    (Scopes::Character, "max_military_strength", CompareValue),
1595    (
1596        Scopes::Character,
1597        "max_number_maa_soldiers_of_base_type",
1598        Block(&[("type", Item(Item::MenAtArmsBase)), ("+value", CompareValue)]),
1599    ),
1600    (
1601        Scopes::Character,
1602        "max_number_maa_soldiers_of_type",
1603        Block(&[("target", Item(Item::MenAtArms)), ("+value", CompareValue)]),
1604    ),
1605    (Scopes::Character, "max_number_of_concubines", CompareValue),
1606    (Scopes::Character, "max_number_of_knights", CompareValue),
1607    (Scopes::Domicile, "max_provisions", CompareValue),
1608    (Scopes::Scheme, "max_scheme_success_chance", CompareValue),
1609    (Scopes::Scheme, "maximum_scheme_breaches", CompareValue),
1610    (Scopes::Character, "meets_legitimacy_expectation_of", Scope(Scopes::Character)),
1611    (Scopes::Confederation, "member_count", CompareValue),
1612    (Scopes::CharacterMemory, "memory_age_years", CompareValueWarnEq),
1613    (Scopes::CharacterMemory, "memory_creation_date", CompareDate),
1614    (Scopes::CharacterMemory, "memory_end_date", CompareDate),
1615    (Scopes::MercenaryCompany, "mercenary_company_expiration_days", CompareValue),
1616    (Scopes::Character, "merit", CompareValueWarnEq),
1617    (Scopes::Character, "merit_level", CompareValue),
1618    (Scopes::Character, "military_power", CompareValueWarnEq),
1619    (Scopes::LandedTitle, "min_appointment_level", CompareValue),
1620    (Scopes::Character, "min_appointment_tier", CompareValue),
1621    (Scopes::Character, "min_title_maa_tier", CompareValue),
1622    (
1623        Scopes::Character,
1624        "missing_unique_ancestors",
1625        Removed("1.14", "replaced with parent_relatedness"),
1626    ),
1627    (Scopes::Character, "monthly_character_balance", CompareValueWarnEq),
1628    (Scopes::Character, "monthly_character_expenses", CompareValueWarnEq),
1629    (Scopes::Character, "monthly_character_income", CompareValueWarnEq),
1630    (Scopes::Character, "monthly_character_income_long_term", CompareValueWarnEq),
1631    (Scopes::Character, "monthly_character_income_reserved", CompareValueWarnEq),
1632    (Scopes::Character, "monthly_character_income_short_term", CompareValueWarnEq),
1633    (Scopes::Character, "monthly_character_income_war_chest", CompareValueWarnEq),
1634    (Scopes::Character, "monthly_character_men_at_arms_expense_gold", CompareValueWarnEq),
1635    (Scopes::Character, "monthly_character_men_at_arms_expense_prestige", CompareValueWarnEq),
1636    (Scopes::Character, "monthly_character_men_at_arms_expense_treasury", CompareValueWarnEq),
1637    (Scopes::Character, "monthly_character_treasury_balance", CompareValueWarnEq),
1638    (Scopes::Character, "monthly_character_treasury_income", CompareValueWarnEq),
1639    (Scopes::Character, "monthly_character_treasury_income_long_term", CompareValueWarnEq),
1640    (Scopes::Character, "monthly_character_treasury_income_reserved", CompareValueWarnEq),
1641    (Scopes::Character, "monthly_character_treasury_income_short_term", CompareValueWarnEq),
1642    (Scopes::Character, "monthly_character_treasury_income_war_chest", CompareValueWarnEq),
1643    (Scopes::Character, "monthly_character_treasury_variable_income", CompareValueWarnEq),
1644    (Scopes::LandedTitle, "monthly_county_control_change", CompareValue),
1645    (Scopes::LandedTitle, "monthly_county_control_decline", CompareValue),
1646    (Scopes::LandedTitle, "monthly_county_control_decline_factor", CompareValue),
1647    (Scopes::LandedTitle, "monthly_county_control_growth", CompareValue),
1648    (Scopes::LandedTitle, "monthly_county_control_growth_factor", CompareValue),
1649    (Scopes::Province, "monthly_income", CompareValueWarnEq),
1650    (Scopes::Character, "months_as_ruler", CompareValueWarnEq),
1651    (Scopes::None, "months_from_game_start", CompareValue),
1652    (Scopes::Faction, "months_until_max_discontent", CompareValueWarnEq),
1653    (
1654        Scopes::Character,
1655        "morph_gene_attribute",
1656        Block(&[
1657            ("category", Item(Item::GeneCategory)),
1658            ("attribute", Item(Item::GeneAttribute)),
1659            ("+value", CompareValue),
1660        ]),
1661    ),
1662    (
1663        Scopes::Character,
1664        "morph_gene_value",
1665        Block(&[("category", Item(Item::GeneCategory)), ("+value", CompareValue)]),
1666    ),
1667    (Scopes::None, "nand", Control),
1668    (Scopes::TravelPlan, "next_destination_arrival_date", CompareDate),
1669    (Scopes::TravelPlan, "next_destination_arrival_days", CompareValueWarnEq),
1670    (Scopes::TravelPlan, "next_destination_progress", CompareValue),
1671    (Scopes::None, "nor", Control),
1672    (Scopes::None, "not", Control), // TODO: warn about multiple triggers in a NOT ?
1673    (Scopes::Character, "num_active_accolades", CompareValue),
1674    (Scopes::Artifact, "num_artifact_kills", CompareValue),
1675    (Scopes::Province, "num_buildings", CompareValue),
1676    (Scopes::Faith, "num_character_followers", CompareValue),
1677    (Scopes::Faith, "num_county_followers", CompareValue),
1678    (Scopes::LandedTitle, "num_county_holdings", CompareValue),
1679    (Scopes::Culture, "num_discovered_innovations", CompareValue),
1680    (
1681        Scopes::Culture,
1682        "num_discovered_innovations_in_era",
1683        Block(&[("target", Item(Item::CultureEra)), ("+value", CompareValue)]),
1684    ),
1685    (Scopes::Domicile, "num_domicile_buildings", CompareValue),
1686    (Scopes::CombatSide, "num_enemies_killed", CompareValue),
1687    (Scopes::TravelPlan, "num_entourage_characters", CompareValue),
1688    (Scopes::Activity, "num_future_phases", CompareValue),
1689    (Scopes::Character, "num_inactive_accolades", CompareValue),
1690    (Scopes::HolyOrder, "num_leased_titles", CompareValue),
1691    (Scopes::Character, "num_of_bad_genetic_traits", CompareValue),
1692    (Scopes::Character, "num_of_good_genetic_traits", CompareValue),
1693    (Scopes::Character, "num_of_known_languages", CompareValue),
1694    (Scopes::Character, "num_offered_task_contracts", CompareValue),
1695    (Scopes::TravelPlan, "num_options", CompareValue),
1696    (Scopes::Activity, "num_past_phases", CompareValue),
1697    (Scopes::Character, "num_personal_legend_seeds", CompareValue),
1698    (Scopes::Activity, "num_phases", CompareValue),
1699    (Scopes::Character, "num_scripted_legend_seeds", CompareValue),
1700    (
1701        Scopes::Character,
1702        "num_sinful_traits",
1703        BlockOrCompareValue(&[("+value", CompareValue), ("target", Scope(Scopes::Faith))]),
1704    ),
1705    (Scopes::Character, "num_taken_task_contracts", CompareValue),
1706    (Scopes::Character, "num_task_contracts", CompareValue),
1707    (Scopes::Combat, "num_total_troops", CompareValueWarnEq),
1708    (Scopes::Character, "num_triggered_legend_seeds", CompareValue),
1709    (
1710        Scopes::Character,
1711        "num_virtuous_traits",
1712        BlockOrCompareValue(&[("+value", CompareValue), ("target", Scope(Scopes::Faith))]),
1713    ),
1714    (
1715        Scopes::Character,
1716        "number_maa_regiments_of_base_type",
1717        Block(&[("type", Item(Item::MenAtArmsBase)), ("+value", CompareValue)]),
1718    ),
1719    (
1720        Scopes::Character,
1721        "number_maa_regiments_of_type",
1722        Block(&[("target", Item(Item::MenAtArms)), ("+value", CompareValue)]),
1723    ),
1724    (
1725        Scopes::Character,
1726        "number_maa_soldiers_of_base_type",
1727        Block(&[("type", Item(Item::MenAtArmsBase)), ("+value", CompareValue)]),
1728    ),
1729    (
1730        Scopes::Character,
1731        "number_maa_soldiers_of_type",
1732        Block(&[("target", Item(Item::MenAtArms)), ("+value", CompareValue)]),
1733    ),
1734    (Scopes::Province, "number_of_characters_in_pool", CompareValue),
1735    (Scopes::Character, "number_of_commander_traits", CompareValue),
1736    (
1737        Scopes::Character,
1738        "number_of_commander_traits_in_common",
1739        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
1740    ),
1741    (Scopes::Character, "number_of_concubines", CompareValue),
1742    (Scopes::Character, "number_of_desired_concubines", CompareValue),
1743    (
1744        Scopes::Character,
1745        "number_of_election_votes",
1746        Block(&[("title", Scope(Scopes::Character)), ("+value", CompareValue)]),
1747    ),
1748    (Scopes::Faction, "number_of_faction_members_in_council", CompareValue),
1749    (Scopes::Character, "number_of_fertile_concubines", CompareValue),
1750    (Scopes::Character, "number_of_knights", CompareValue),
1751    (Scopes::Character, "number_of_lifestyle_traits", CompareValue),
1752    (Scopes::Character, "number_of_maa_regiments", CompareValue),
1753    (
1754        Scopes::Character,
1755        "number_of_opposing_personality_traits",
1756        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
1757    ),
1758    (
1759        Scopes::Character,
1760        "number_of_opposing_traits",
1761        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
1762    ),
1763    (Scopes::Character, "number_of_personality_traits", CompareValue),
1764    (
1765        Scopes::Character,
1766        "number_of_personality_traits_in_common",
1767        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
1768    ),
1769    (Scopes::Character, "number_of_powerful_vassals", CompareValue),
1770    (
1771        Scopes::Character,
1772        "number_of_sinful_traits_in_common",
1773        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
1774    ),
1775    (Scopes::Character, "number_of_stationed_maa_regiments", CompareValue),
1776    (Scopes::Character, "number_of_traits", CompareValue),
1777    (
1778        Scopes::Character,
1779        "number_of_traits_in_common",
1780        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
1781    ),
1782    (Scopes::Character, "number_of_tributaries", CompareValue),
1783    (
1784        Scopes::Character,
1785        "number_of_virtue_traits_in_common",
1786        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
1787    ),
1788    (
1789        Scopes::Character,
1790        "number_title_maa_regiments_of_type",
1791        Block(&[("target", Item(Item::MenAtArms)), ("+value", CompareValue)]),
1792    ),
1793    (Scopes::VassalObligationLevel, "obligation_level_score", CompareValue),
1794    (
1795        Scopes::Character,
1796        "opinion",
1797        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
1798    ),
1799    (Scopes::None, "or", Control),
1800    (Scopes::Epidemic, "outbreak_intensity", CompareChoice(OUTBREAK_INTENSITIES)),
1801    (Scopes::Epidemic, "outbreak_start_date", CompareDate),
1802    (Scopes::Character, "owns_a_story", Boolean),
1803    (Scopes::Character, "owns_story_of_type", Item(Item::Story)),
1804    (Scopes::Character, "parent_relatedness", CompareValue),
1805    (
1806        Scopes::SituationParticipantGroup,
1807        "participant_group_has_character",
1808        Scope(Scopes::Character),
1809    ),
1810    (
1811        Scopes::SituationParticipantGroup,
1812        "participant_group_type",
1813        Item(Item::SituationParticipantGroup),
1814    ),
1815    (Scopes::Character, "participated_wars", CompareValue),
1816    (Scopes::Character, "patrilinear_betrothal", Boolean),
1817    (Scopes::Character, "patrilinear_marriage", Boolean),
1818    (Scopes::CombatSide, "percent_enemies_killed", CompareValue),
1819    (Scopes::Character, "perk_points", CompareValue),
1820    (Scopes::Character, "perk_points_assigned", CompareValue),
1821    // perks_in_<lifestyle>
1822    (
1823        Scopes::Character,
1824        "perks_in_tree",
1825        Block(&[("tree", Item(Item::PerkTree)), ("+value", CompareValue)]),
1826    ),
1827    (Scopes::Struggle, "phase_has_catalyst", Item(Item::Catalyst)),
1828    (Scopes::SituationSubRegion, "phase_takeover_duration_days", CompareValue),
1829    (Scopes::SituationSubRegion, "phase_takeover_points", CompareValue),
1830    (Scopes::Character, "piety", CompareValueWarnEq),
1831    (Scopes::Character, "piety_level", CompareValue),
1832    (
1833        Scopes::LandedTitle,
1834        "place_in_line_of_succession",
1835        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
1836    ),
1837    // TODO: documentation says the field is `position`, but it's really `value`
1838    (
1839        Scopes::Character,
1840        "player_heir_position",
1841        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
1842    ),
1843    (Scopes::Character, "pregnancy_days", CompareValue),
1844    (Scopes::Character, "prestige", CompareValueWarnEq),
1845    (Scopes::Character, "prestige_level", CompareValue),
1846    (Scopes::Accolade, "primary_tier", CompareValue),
1847    (
1848        Scopes::Province,
1849        "province_infection_date",
1850        Block(&[("epidemic", Scope(Scopes::Epidemic)), ("+value", CompareDate)]),
1851    ),
1852    (
1853        Scopes::Province,
1854        "province_infection_rate",
1855        Block(&[("target", Scope(Scopes::Epidemic)), ("+value", CompareValueWarnEq)]),
1856    ),
1857    (Scopes::Character, "provision_cost_to_domicile", CompareValueWarnEq),
1858    (Scopes::Domicile, "provision_cost_to_owner", CompareValueWarnEq),
1859    (Scopes::Domicile, "provisions", CompareValueWarnEq),
1860    (Scopes::Character, "prowess", CompareValue),
1861    (
1862        Scopes::Character,
1863        "prowess_diff",
1864        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue), ("?abs", Boolean)]),
1865    ),
1866    (Scopes::Character, "prowess_for_portrait", CompareValue),
1867    (Scopes::Character, "prowess_no_portrait", CompareValue),
1868    (Scopes::Army, "raid_intent", Item(Item::RaidIntent)),
1869    (Scopes::Army, "raid_loot", CompareValue),
1870    (Scopes::Character, "ransom_cost", CompareValue),
1871    (Scopes::Artifact, "rarity", Item(Item::ArtifactRarity)),
1872    (Scopes::Character, "realm_size", CompareValue),
1873    (Scopes::Character, "realm_law_group_at_maximum_level", Item(Item::LawGroup)),
1874    (Scopes::Character, "realm_law_group_at_minimum_level", Item(Item::LawGroup)),
1875    (
1876        Scopes::Character,
1877        "realm_to_title_distance_squared",
1878        Block(&[("target", Scope(Scopes::LandedTitle)), ("+value", CompareValue)]),
1879    ),
1880    (
1881        Scopes::LandedTitle,
1882        "recent_history",
1883        Block(&[
1884            ("?type", Choice(TITLE_HISTORY_TYPES)),
1885            ("?days", SetValue),
1886            ("?months", SetValue),
1887            ("?years", SetValue),
1888        ]),
1889    ),
1890    (
1891        Scopes::GeographicalRegion.union(Scopes::SituationSubRegion),
1892        "region_is_adjacent",
1893        Scope(Scopes::GeographicalRegion),
1894    ),
1895    (
1896        Scopes::GeographicalRegion.union(Scopes::SituationSubRegion),
1897        "region_is_adjacent_situation_subregion",
1898        Scope(Scopes::SituationSubRegion),
1899    ),
1900    (Scopes::None, "release_only", Boolean),
1901    (Scopes::Faith, "religion_tag", Item(Item::Religion)),
1902    (Scopes::SituationParticipantGroup, "require_capital_in_sub_region", Boolean),
1903    (Scopes::SituationParticipantGroup, "require_domain_in_sub_region", Boolean),
1904    (Scopes::SituationParticipantGroup, "require_realm_in_sub_region", Boolean),
1905    (Scopes::Character, "reserved_gold", CompareValueWarnEq),
1906    (Scopes::Character, "reserved_gold_maximum", CompareValueWarnEq),
1907    (Scopes::Character, "reserved_treasury", CompareValueWarnEq),
1908    (Scopes::Character, "reserved_treasury_maximum", CompareValueWarnEq),
1909    (Scopes::Character, "reserved_treasury_or_gold", CompareValueWarnEq),
1910    (
1911        Scopes::Character,
1912        "reverse_has_opinion_modifier",
1913        Block(&[
1914            ("target", Scope(Scopes::Character)),
1915            ("modifier", Item(Item::OpinionModifier)),
1916            ("*value", CompareValue),
1917        ]),
1918    ),
1919    (
1920        Scopes::Character,
1921        "reverse_opinion",
1922        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
1923    ),
1924    (Scopes::Secret, "same_secret_type_as", Scope(Scopes::Secret)),
1925    (Scopes::Character, "save_temporary_opinion_value_as", Special),
1926    (Scopes::all_but_none(), "save_temporary_scope_as", Special),
1927    (Scopes::None, "save_temporary_scope_value_as", Special),
1928    (Scopes::Scheme, "scheme_agent_charges", CompareValue),
1929    (Scopes::Scheme, "scheme_breaches", CompareValue),
1930    (Scopes::Scheme, "scheme_duration_days", CompareValue),
1931    (Scopes::Scheme, "scheme_is_character_agent", Scope(Scopes::Character)),
1932    (Scopes::Scheme, "scheme_monthly_progress", Removed("1.13", "")),
1933    (Scopes::Scheme, "scheme_number_of_agents", Removed("1.13", "")),
1934    (Scopes::Scheme, "scheme_number_of_exposed_agents", CompareValue),
1935    (Scopes::Scheme, "scheme_number_of_filled_agent_slots", CompareValue),
1936    (Scopes::Scheme, "scheme_phase_duration", CompareValue),
1937    (Scopes::Scheme, "scheme_power", Removed("1.13", "")),
1938    (Scopes::Scheme, "scheme_power_resistance_difference", Removed("1.13", "")),
1939    (Scopes::Scheme, "scheme_power_resistance_ratio", Removed("1.13", "")),
1940    (Scopes::Scheme, "scheme_progress", CompareValue),
1941    (Scopes::Scheme, "scheme_resistance", Removed("1.13", "")),
1942    (Scopes::Scheme, "scheme_secrecy", CompareValue),
1943    (Scopes::Scheme, "scheme_skill", Item(Item::Skill)),
1944    (Scopes::Scheme, "scheme_success_chance", CompareValue),
1945    (Scopes::Scheme, "scheme_type", Item(Item::Scheme)),
1946    (Scopes::None, "scripted_tests", Boolean),
1947    (Scopes::Character, "scriptedtests_can_marry_character", Scope(Scopes::Character)),
1948    (Scopes::Character, "scriptedtests_dread_base", CompareValue),
1949    (Scopes::Character, "scriptedtests_gold_income_no_theocracy", CompareValue),
1950    (Scopes::Character, "scriptedtests_piety_income", CompareValue),
1951    (Scopes::Accolade, "secondary_tier", CompareValue),
1952    (Scopes::Secret, "secret_type", Item(Item::Secret)),
1953    (Scopes::Character, "sex_opposite_of", Scope(Scopes::Character)),
1954    (Scopes::Character, "sex_same_as", Scope(Scopes::Character)),
1955    (Scopes::Character, "short_term_gold", CompareValueWarnEq),
1956    (Scopes::Character, "short_term_gold_maximum", CompareValueWarnEq),
1957    (Scopes::Character, "short_term_treasury", CompareValueWarnEq),
1958    (Scopes::Character, "short_term_treasury_maximum", CompareValueWarnEq),
1959    (Scopes::Character, "short_term_treasury_or_gold", CompareValueWarnEq),
1960    (Scopes::Artifact, "should_decay", Boolean),
1961    (
1962        Scopes::Character,
1963        "should_decision_create_alert",
1964        ScopeOrItem(Scopes::Decision, Item::Decision),
1965    ),
1966    (
1967        Scopes::Character,
1968        "should_notify_can_host_activity",
1969        ScopeOrItem(Scopes::ActivityType, Item::ActivityType),
1970    ),
1971    (
1972        Scopes::Character,
1973        "should_notify_can_join_open_activity",
1974        Removed("1.18", "replaced with `should_notify_can_join_activity`"),
1975    ),
1976    (
1977        Scopes::Character,
1978        "should_notify_can_join_activity",
1979        ScopeOrItem(Scopes::ActivityType, Item::ActivityType),
1980    ),
1981    (Scopes::None, "should_show_disturbing_portrait_modifiers", Boolean),
1982    (Scopes::None, "should_show_nudity", Boolean),
1983    (Scopes::CombatSide, "side_army_size", CompareValue),
1984    (Scopes::CombatSide, "side_max_army_size", CompareValue),
1985    (Scopes::CombatSide, "side_soldiers", CompareValue),
1986    (Scopes::CombatSide, "side_strength", CompareValue),
1987    (Scopes::Situation, "situation_current_phase", Item(Item::SituationPhase)),
1988    (Scopes::Situation, "situation_days_since_end_date", CompareValue),
1989    (Scopes::Situation, "situation_days_since_start_date", CompareValue),
1990    (Scopes::Situation, "situation_end_date", CompareDate),
1991    (Scopes::Situation, "situation_has_catalyst", Item(Item::SituationCatalyst)),
1992    (Scopes::Situation, "situation_start_date", CompareDate),
1993    (Scopes::SituationSubRegion, "situation_sub_region_has_county", Scope(Scopes::LandedTitle)),
1994    (
1995        Scopes::SituationSubRegion,
1996        "situation_sub_region_has_geographical_region",
1997        ScopeOrItem(Scopes::GeographicalRegion, Item::Region),
1998    ),
1999    (Scopes::SituationSubRegion, "situation_sub_region_has_province", Scope(Scopes::Province)),
2000    (Scopes::Situation, "situation_top_has_catalyst", Item(Item::SituationCatalyst)),
2001    (Scopes::Situation, "situation_top_has_county", Scope(Scopes::LandedTitle)),
2002    (Scopes::Situation, "situation_top_has_province", Scope(Scopes::Province)),
2003    (Scopes::Situation, "situation_top_phase_days_since_start_date", CompareValue),
2004    (Scopes::Situation, "situation_top_phase_days_until_end_date", CompareValue),
2005    (Scopes::Situation, "situation_top_phase_end_date", CompareDate),
2006    (Scopes::Situation, "situation_top_phase_start_date", CompareDate),
2007    (Scopes::Situation, "situation_type", Item(Item::Situation)),
2008    (Scopes::CombatSide, "skip_pursuit", Boolean),
2009    (
2010        Scopes::LandedTitle.union(Scopes::Province),
2011        "squared_distance",
2012        Block(&[
2013            ("target", Scope(Scopes::LandedTitle.union(Scopes::Province))),
2014            ("+value", CompareValue),
2015        ]),
2016    ),
2017    (Scopes::Character, "starting_gold_by_income", CompareValue),
2018    (
2019        Scopes::Character,
2020        "static_group_filter",
2021        Block(&[
2022            ("?group", UncheckedValue),
2023            ("?scope", Scope(Scopes::all_but_none())),
2024            ("match", SetValue), // TODO: check range 0.0..1.0
2025        ]),
2026    ),
2027    (Scopes::Character, "stewardship", CompareValue),
2028    (
2029        Scopes::Character,
2030        "stewardship_diff",
2031        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue), ("?abs", Boolean)]),
2032    ),
2033    (Scopes::Character, "stewardship_for_portrait", CompareValue),
2034    (Scopes::StoryCycle, "story_type", Item(Item::Story)),
2035    (Scopes::Character, "stress", CompareValue),
2036    (Scopes::Character, "stress_level", CompareValue),
2037    (Scopes::Character, "strife_opinion", CompareValue),
2038    (Scopes::Character, "sub_realm_size", CompareValue),
2039    (Scopes::SituationSubRegion, "sub_region_current_phase", Item(Item::SituationPhase)),
2040    (Scopes::SituationSubRegion, "sub_region_current_phase_days_since_start_date", CompareValue),
2041    (Scopes::SituationSubRegion, "sub_region_current_phase_days_until_end_date", CompareValue),
2042    (Scopes::SituationSubRegion, "sub_region_current_phase_end_date", CompareDate),
2043    (Scopes::SituationSubRegion, "sub_region_current_phase_start_date", CompareDate),
2044    (Scopes::Character, "subject_can_break_tributary", Boolean),
2045    (Scopes::Character, "subject_contract_has_flag", Item(Item::SubjectContractFlag)),
2046    (Scopes::Character, "subject_contract_has_modifiable_obligations", Boolean),
2047    (Scopes::Character, "subject_contract_is_blocked_from_modification", Boolean),
2048    (
2049        Scopes::Character,
2050        "subject_contract_obligation_level_can_be_decreased",
2051        Item(Item::SubjectContract),
2052    ),
2053    (
2054        Scopes::Character,
2055        "subject_contract_obligation_level_can_be_increased",
2056        Item(Item::SubjectContract),
2057    ),
2058    (Scopes::Character, "subject_standing", CompareValue),
2059    (
2060        Scopes::Character,
2061        "succession_appointment_score_invested",
2062        Block(&[
2063            ("title", Scope(Scopes::LandedTitle)),
2064            ("candidate", Scope(Scopes::Character)),
2065            ("+value", CompareValue),
2066        ]),
2067    ),
2068    (Scopes::None, "switch", Special),
2069    (Scopes::LandedTitle, "target_is_de_facto_liege_or_above", Scope(Scopes::LandedTitle)),
2070    (Scopes::LandedTitle, "target_is_de_jure_liege_or_above", Scope(Scopes::LandedTitle)),
2071    (Scopes::Character, "target_is_liege_or_above", Scope(Scopes::Character)),
2072    (Scopes::Character, "target_is_same_character_or_above", Scope(Scopes::Character)),
2073    (Scopes::Character, "target_is_vassal_or_below", Scope(Scopes::Character)),
2074    (Scopes::Character, "target_weight", CompareValue),
2075    (Scopes::TaskContract, "task_contract_tier", CompareValue),
2076    (
2077        Scopes::Character,
2078        "tax_collector_aptitude",
2079        Block(&[("target", Item(Item::TaxSlotType)), ("+value", CompareValue)]),
2080    ),
2081    (Scopes::Character, "tax_to_liege", CompareValueWarnEq),
2082    (Scopes::Province, "terrain", Item(Item::Terrain)),
2083    (Scopes::LandedTitle, "tier", CompareValue), // TODO: advice if this is compared to a bare number
2084    (
2085        Scopes::Character,
2086        "tier_difference",
2087        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
2088    ),
2089    // TODO: warn if more than one of days, months, years
2090    // TODO: check if "weeks" works in these
2091    (
2092        Scopes::Character,
2093        "time_after_diarch_designated",
2094        Block(&[("?days", CompareValue), ("?months", CompareValue), ("?years", CompareValue)]),
2095    ),
2096    // TODO: "weeks" is used in vanilla but is not documented. Verify.
2097    (
2098        Scopes::Character,
2099        "time_in_prison",
2100        Block(&[
2101            ("?days", CompareValue),
2102            ("?weeks", CompareValue),
2103            ("?months", CompareValue),
2104            ("?years", CompareValue),
2105        ]),
2106    ),
2107    // TODO: "weeks" is used in vanilla but is not documented. Verify.
2108    (
2109        Scopes::Character,
2110        "time_in_prison_type",
2111        Block(&[
2112            ("?days", CompareValue),
2113            ("?weeks", CompareValue),
2114            ("?months", CompareValue),
2115            ("?years", CompareValue),
2116        ]),
2117    ),
2118    (Scopes::None, "time_of_year", Special),
2119    (Scopes::TaskContract, "time_since_contract_taken", CompareValue),
2120    (
2121        Scopes::Character,
2122        "time_since_death",
2123        Block(&[("?days", CompareValue), ("?months", CompareValue), ("?years", CompareValue)]),
2124    ),
2125    (
2126        Scopes::Character,
2127        "time_to_hook_expiry",
2128        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
2129    ),
2130    (
2131        Scopes::LandedTitle,
2132        "title_create_faction_type_chance",
2133        Block(&[
2134            ("type", Item(Item::Faction)),
2135            ("target", Scope(Scopes::Character)),
2136            ("+value", CompareValue),
2137        ]),
2138    ),
2139    (Scopes::LandedTitle, "title_held_years", CompareValueWarnEq),
2140    (Scopes::LandedTitle, "title_is_a_faction_member", Boolean),
2141    (
2142        Scopes::LandedTitle,
2143        "title_join_faction_chance",
2144        Block(&[("target", Scope(Scopes::Faction)), ("+value", CompareValue)]),
2145    ),
2146    (Scopes::Character, "title_law_group_at_maximum_level", Item(Item::LawGroup)),
2147    (Scopes::Character, "title_law_group_at_minimum_level", Item(Item::LawGroup)),
2148    (Scopes::LandedTitle, "title_will_leave_sub_realm_on_succession", Scope(Scopes::Character)),
2149    (Scopes::Army, "total_army_damage", CompareValue),
2150    (Scopes::Army, "total_army_pursuit", CompareValue),
2151    (Scopes::Army, "total_army_screen", CompareValue),
2152    (Scopes::Army, "total_army_siege_value", CompareValue),
2153    (Scopes::Army, "total_army_toughness", CompareValue),
2154    (Scopes::Epidemic, "total_infected_provinces", CompareValueWarnEq),
2155    (
2156        Scopes::Character,
2157        "trait_compatibility",
2158        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
2159    ),
2160    (Scopes::Faith, "trait_is_sin", ScopeOrItem(Scopes::Trait, Item::Trait)),
2161    (Scopes::Faith, "trait_is_virtue", ScopeOrItem(Scopes::Trait, Item::Trait)),
2162    (
2163        Scopes::Province,
2164        "travel_danger_type",
2165        Block(&[
2166            ("travel_plan", Scope(Scopes::TravelPlan)),
2167            ("?type", Item(Item::DangerType)),
2168            ("?terrain", Item(Item::Terrain)),
2169        ]),
2170    ),
2171    (
2172        Scopes::Province,
2173        "travel_danger_value",
2174        Block(&[("target", Scope(Scopes::TravelPlan)), ("+value", CompareValue)]),
2175    ),
2176    (Scopes::Character, "travel_leader_cost", CompareValue),
2177    (Scopes::Character, "travel_leader_safety", CompareValue),
2178    (Scopes::Character, "travel_leader_speed", CompareValue),
2179    (Scopes::TravelPlan, "travel_safety", CompareValue),
2180    (Scopes::TravelPlan, "travel_speed", CompareValue),
2181    (Scopes::Character, "treasury", CompareValueWarnEq),
2182    (Scopes::Character, "treasury_budget_allocation_excess", CompareValueWarnEq),
2183    (Scopes::Character, "treasury_budget_allocation_military", CompareValueWarnEq),
2184    (Scopes::Character, "treasury_budget_allocation_ministries", CompareValueWarnEq),
2185    (Scopes::Character, "treasury_budget_allocation_salaries", CompareValueWarnEq),
2186    (Scopes::Character, "treasury_budget_base_rate_military", CompareValueWarnEq),
2187    (Scopes::Character, "treasury_budget_base_rate_ministries", CompareValueWarnEq),
2188    (Scopes::Character, "treasury_budget_base_rate_salaries", CompareValueWarnEq),
2189    (Scopes::Character, "treasury_budget_enact_date", CompareDate),
2190    (Scopes::Character, "treasury_days_since_budget_enact_date", CompareValue),
2191    (Scopes::Character, "treasury_debt_level", CompareValue),
2192    (Scopes::Character, "treasury_months_since_budget_enact_date", CompareValue),
2193    (Scopes::Character, "treasury_or_gold", CompareValueWarnEq),
2194    (Scopes::Character, "treasury_years_since_budget_enact_date", CompareValue),
2195    (
2196        Scopes::Character,
2197        "tributary_contract_obligation_level_can_be_decreased",
2198        Item(Item::SubjectContract),
2199    ),
2200    (
2201        Scopes::Character,
2202        "tributary_contract_obligation_level_can_be_increased",
2203        Item(Item::SubjectContract),
2204    ),
2205    (Scopes::None, "trigger_else", Control),
2206    (Scopes::None, "trigger_else_if", Control),
2207    (Scopes::None, "trigger_if", Control),
2208    (Scopes::CombatSide, "troops_ratio", CompareValue),
2209    (Scopes::AccoladeType, "type_has_accolade_category", Item(Item::AccoladeCategory)),
2210    (Scopes::Character, "tyranny", CompareValue),
2211    (Scopes::LandedTitle, "uses_county_fertility", Boolean),
2212    (Scopes::War, "using_cb", Item(Item::CasusBelli)),
2213    (
2214        Scopes::None,
2215        "variable_list_size",
2216        Block(&[("name", Identifier("list name")), ("+value", CompareValue)]),
2217    ),
2218    (Scopes::Character, "vassal_contract_has_flag", Item(Item::SubjectContractFlag)),
2219    (Scopes::Character, "vassal_contract_has_modifiable_obligations", Boolean),
2220    (Scopes::Character, "vassal_contract_is_blocked_from_modification", Removed("1.16", "")),
2221    (Scopes::Character, "vassal_contract_liege_dynasty_reign_start_date", CompareDate),
2222    (Scopes::Character, "vassal_contract_obligation_level", UncheckedTodo), // No examples for the non-complex case
2223    (
2224        Scopes::Character,
2225        "vassal_contract_obligation_level_can_be_decreased",
2226        Item(Item::SubjectContract),
2227    ),
2228    (
2229        Scopes::Character,
2230        "vassal_contract_obligation_level_can_be_increased",
2231        Item(Item::SubjectContract),
2232    ),
2233    (Scopes::Character, "vassal_contract_obligation_level_score", UncheckedTodo), // No examples for the non-complex case
2234    (Scopes::Character, "vassal_count", CompareValue),
2235    (Scopes::Character, "vassal_limit", CompareValue),
2236    (Scopes::Character, "vassal_limit_available", CompareValue),
2237    (Scopes::Character, "vassal_limit_percentage", CompareValue),
2238    (Scopes::Character, "war_chest_gold", CompareValueWarnEq),
2239    (Scopes::Character, "war_chest_gold_maximum", CompareValueWarnEq),
2240    (Scopes::Character, "war_chest_treasury", CompareValueWarnEq),
2241    (Scopes::Character, "war_chest_treasury_maximum", CompareValueWarnEq),
2242    (Scopes::Character, "war_chest_treasury_or_gold", CompareValueWarnEq),
2243    (
2244        Scopes::War,
2245        "war_contribution",
2246        Block(&[("target", Scope(Scopes::Character)), ("+value", CompareValue)]),
2247    ),
2248    (Scopes::War, "war_days", CompareValueWarnEq),
2249    (Scopes::Combat, "warscore_value", CompareValue),
2250    (Scopes::TravelPlan, "was_activity_completed", Boolean),
2251    (Scopes::TravelPlan, "was_activity_invalidated", Boolean),
2252    (Scopes::War, "was_called", Scope(Scopes::Character)),
2253    (Scopes::Character, "was_hostage_child", Boolean),
2254    (Scopes::Character, "was_preferred_heir", Scope(Scopes::Character)),
2255    (Scopes::None, "weighted_calc_true_if", Special),
2256    (
2257        Scopes::Character,
2258        "would_be_valid_for_court_position",
2259        Block(&[
2260            ("employer", Scope(Scopes::Character)),
2261            ("court_position", Item(Item::CourtPosition)),
2262        ]),
2263    ),
2264    (Scopes::Character, "year_character_treasury_income", CompareValueWarnEq),
2265    (Scopes::Character, "year_character_treasury_variable_income", CompareValueWarnEq),
2266    (Scopes::Character, "year_of_birth", CompareValue),
2267    (Scopes::Character, "yearly_character_balance", CompareValueWarnEq),
2268    (Scopes::Character, "yearly_character_expenses", CompareValueWarnEq),
2269    (Scopes::Character, "yearly_character_income", CompareValueWarnEq),
2270    (Scopes::Character, "yearly_character_men_at_arms_expense_gold", CompareValueWarnEq),
2271    (Scopes::Character, "yearly_character_men_at_arms_expense_prestige", CompareValueWarnEq),
2272    (Scopes::Character, "yearly_character_men_at_arms_expense_treasury", CompareValueWarnEq),
2273    (Scopes::Character, "yearly_character_treasury_balance", CompareValueWarnEq),
2274    (Scopes::Character, "years_as_diarch", CompareValueWarnEq),
2275    (Scopes::Character, "years_as_ruler", CompareValueWarnEq),
2276    (Scopes::None, "years_from_game_start", CompareValueWarnEq),
2277    (Scopes::Character, "years_in_diarchy", CompareValueWarnEq),
2278    (
2279        Scopes::Character,
2280        "yields_alliance",
2281        Block(&[
2282            ("candidate", Scope(Scopes::Character)),
2283            ("target", Scope(Scopes::Character)),
2284            ("target_candidate", Scope(Scopes::Character)),
2285        ]),
2286    ),
2287];
2288
2289#[inline]
2290pub fn scope_trigger_complex(name: &str) -> Option<(Scopes, ArgumentValue, Scopes)> {
2291    TRIGGER_COMPLEX_MAP.get(name).copied()
2292}
2293
2294static TRIGGER_COMPLEX_MAP: LazyLock<TigerHashMap<&'static str, (Scopes, ArgumentValue, Scopes)>> =
2295    LazyLock::new(|| {
2296        let mut hash = TigerHashMap::default();
2297        for (from, s, trigger, outscopes) in TRIGGER_COMPLEX.iter().copied() {
2298            hash.insert(s, (from, trigger, outscopes));
2299        }
2300        hash
2301    });
2302
2303/// LAST UPDATED CK3 VERSION 1.15.0
2304/// See `triggers.log` from the game data dumps
2305/// `(inscopes, trigger name, argtype, outscopes)`
2306/// Currently only works with single argument triggers
2307// TODO Verify triggers
2308const TRIGGER_COMPLEX: &[(Scopes, &str, ArgumentValue, Scopes)] = {
2309    use crate::item::Item;
2310    use ArgumentValue::*;
2311    &[
2312        (Scopes::Character, "ai_values_divergence", Scope(Scopes::Character), Scopes::Value),
2313        (
2314            Scopes::Character,
2315            "ai_will_do_contribution",
2316            Scope(Scopes::ProjectContribution),
2317            Scopes::Value,
2318        ),
2319        (
2320            Scopes::Character,
2321            "appointment_candidate_accumulated_score",
2322            Scope(Scopes::LandedTitle),
2323            Scopes::Value,
2324        ),
2325        (
2326            Scopes::Character,
2327            "appointment_candidate_score",
2328            Scope(Scopes::LandedTitle),
2329            Scopes::Value,
2330        ),
2331        (
2332            Scopes::Character,
2333            "appointment_level_for_title",
2334            Scope(Scopes::LandedTitle),
2335            Scopes::Value,
2336        ),
2337        (Scopes::LandedTitle, "county_opinion_target", Scope(Scopes::Character), Scopes::Value),
2338        (Scopes::Culture, "cultural_acceptance", Scope(Scopes::Culture), Scopes::Value),
2339        (Scopes::Province, "days_since_province_infection", Scope(Scopes::Epidemic), Scopes::Value),
2340        (Scopes::Faith, "faith_hostility_level", Scope(Scopes::Faith), Scopes::Value),
2341        (
2342            Scopes::DynastyHouse,
2343            "house_land_share_in_realm",
2344            Scope(Scopes::Character),
2345            Scopes::Value,
2346        ),
2347        (Scopes::None, "list_size", Identifier("list name"), Scopes::Value),
2348        (Scopes::Character, "morph_gene_value", Item(Item::GeneCategory), Scopes::Value),
2349        (Scopes::Character, "opinion", Scope(Scopes::Character), Scopes::Value),
2350        (Scopes::Character, "reverse_opinion", Scope(Scopes::Character), Scopes::Value),
2351        (Scopes::Character, "trait_compatibility", Scope(Scopes::Character), Scopes::Value),
2352        (Scopes::Province, "travel_danger_value", Scope(Scopes::TravelPlan), Scopes::Value),
2353        (Scopes::Character, "amenity_level", Item(Item::Amenity), Scopes::Value),
2354        // (Scopes::Character, "create_faction_type_chance", Item(Item::Faction), Scope(Scopes::Character), Scopes::Value),
2355        // All `<lifestyle>_diff` without `abs` field
2356        (Scopes::Character, "diplomacy_diff", Scope(Scopes::Character), Scopes::Value),
2357        // Use `|` for multi-track traits, e.g. `has_trait_xp(lifestyle_traveler|danger)`
2358        (Scopes::Character, "has_trait_xp", TraitTrack, Scopes::Value),
2359        (Scopes::Character, "intrigue_diff", Scope(Scopes::Character), Scopes::Value),
2360        (Scopes::Character, "join_faction_chance", Scope(Scopes::Faction), Scopes::Value),
2361        (Scopes::Character, "learning_diff", Scope(Scopes::Character), Scopes::Value),
2362        (
2363            Scopes::Character,
2364            "mandate_type_qualification",
2365            Item(Item::DiarchyMandate),
2366            Scopes::Value,
2367        ),
2368        (Scopes::Character, "martial_diff", Scope(Scopes::Character), Scopes::Value),
2369        (
2370            Scopes::Character,
2371            "max_number_maa_soldiers_of_base_type",
2372            Item(Item::MenAtArmsBase),
2373            Scopes::Value,
2374        ),
2375        (
2376            Scopes::Character,
2377            "max_number_maa_soldiers_of_type",
2378            Item(Item::MenAtArms),
2379            Scopes::Value,
2380        ),
2381        // (Scopes::Character, "morph_gene_attribute", Item(Item::GeneCategory), Item(Item::GeneAttribute), Scopes::Value),
2382        (Scopes::Character, "morph_gene_value", Item(Item::GeneCategory), Scopes::Value),
2383        (
2384            Scopes::Culture,
2385            "num_discovered_innovations_in_era",
2386            Item(Item::CultureEra),
2387            Scopes::Value,
2388        ),
2389        (Scopes::Character, "num_sinful_traits", Scope(Scopes::Faith), Scopes::Value),
2390        (Scopes::Character, "num_virtuous_traits", Scope(Scopes::Faith), Scopes::Value),
2391        (
2392            Scopes::Character,
2393            "number_maa_regiments_of_base_type",
2394            Item(Item::MenAtArmsBase),
2395            Scopes::Value,
2396        ),
2397        (Scopes::Character, "number_maa_regiments_of_type", Item(Item::MenAtArms), Scopes::Value),
2398        (
2399            Scopes::Character,
2400            "number_maa_soldiers_of_base_type",
2401            Item(Item::MenAtArmsBase),
2402            Scopes::Value,
2403        ),
2404        (Scopes::Character, "number_maa_soldiers_of_type", Item(Item::MenAtArms), Scopes::Value),
2405        (Scopes::Character, "number_of_election_votes", Scope(Scopes::LandedTitle), Scopes::Value),
2406        (
2407            Scopes::Character,
2408            "number_of_sinful_traits_in_common",
2409            Scope(Scopes::Character),
2410            Scopes::Value,
2411        ),
2412        (Scopes::Character, "number_of_traits_in_common", Scope(Scopes::Character), Scopes::Value),
2413        (
2414            Scopes::Character,
2415            "number_of_virtue_traits_in_common",
2416            Scope(Scopes::Character),
2417            Scopes::Value,
2418        ),
2419        (Scopes::Character, "perks_in_tree", Item(Item::PerkTree), Scopes::Value),
2420        (
2421            Scopes::SituationSubRegion,
2422            "phase_takeover_duration_days",
2423            Item(Item::SituationPhase),
2424            Scopes::Value,
2425        ),
2426        (
2427            Scopes::SituationSubRegion,
2428            "phase_takeover_points",
2429            Item(Item::SituationPhase),
2430            Scopes::Value,
2431        ),
2432        (
2433            Scopes::LandedTitle,
2434            "place_in_line_of_succession",
2435            Scope(Scopes::Character),
2436            Scopes::Value,
2437        ),
2438        (Scopes::Character, "player_heir_position", Scope(Scopes::Character), Scopes::Value),
2439        (Scopes::Province, "province_infection_date", Scope(Scopes::Epidemic), Scopes::Value),
2440        (Scopes::Province, "province_infection_rate", Scope(Scopes::Epidemic), Scopes::Value),
2441        (Scopes::Character, "prowess_diff", Scope(Scopes::Character), Scopes::Value),
2442        (
2443            Scopes::Character,
2444            "realm_to_title_distance_squared",
2445            Scope(Scopes::LandedTitle),
2446            Scopes::Value,
2447        ),
2448        (Scopes::Character, "stewardship_diff", Scope(Scopes::Character), Scopes::Value),
2449        (Scopes::Character, "tax_collector_aptitude", Item(Item::TaxSlotType), Scopes::Value),
2450        (Scopes::Character, "tier_difference", Scope(Scopes::Character), Scopes::Value),
2451        (Scopes::Character, "time_to_hook_expiry", Scope(Scopes::Character), Scopes::Value),
2452        (
2453            Scopes::Character,
2454            "vassal_contract_obligation_level",
2455            Item(Item::SubjectContract),
2456            Scopes::Value,
2457        ),
2458        (
2459            Scopes::Character,
2460            "vassal_contract_obligation_level_score",
2461            ScopeOrItem(Scopes::VassalObligationLevel, Item::SubjectContract),
2462            Scopes::Value,
2463        ),
2464        // (Scopes::LandedTitle, "title_create_faction_type_chance", Item(Item::Faction), Scope(Scopes::Character), Scopes::Value),
2465        (Scopes::LandedTitle, "title_join_faction_chance", Scope(Scopes::Faction), Scopes::Value),
2466        (
2467            Scopes::LandedTitle.union(Scopes::Province),
2468            "squared_distance",
2469            Scope(Scopes::Province),
2470            Scopes::Value,
2471        ),
2472        (Scopes::War, "war_contribution", Scope(Scopes::Character), Scopes::Value),
2473    ]
2474};