Skip to main content

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