tiger_lib/imperator/tables/
triggers.rs

1use std::sync::LazyLock;
2
3use crate::everything::Everything;
4use crate::helpers::TigerHashMap;
5use crate::item::Item;
6use crate::report::{ErrorKey, warn};
7use crate::scopes::Scopes;
8use crate::token::Token;
9use crate::trigger::Trigger;
10
11use Trigger::*;
12
13pub fn scope_trigger(name: &Token, data: &Everything) -> Option<(Scopes, Trigger)> {
14    let name_lc = name.as_str().to_ascii_lowercase();
15
16    if let Some((from, trigger)) = TRIGGER_MAP.get(&*name_lc) {
17        return Some((*from, *trigger));
18    }
19    if let Some(conviction) = name_lc.strip_suffix("_conviction") {
20        data.verify_exists_implied(Item::PartyType, conviction, name);
21        return Some((Scopes::Character, Trigger::CompareValue));
22    }
23    if let Some(support) = name_lc.strip_suffix("_support") {
24        data.verify_exists_implied(Item::PartyType, support, name);
25        return Some((Scopes::Country, Trigger::CompareValue));
26    }
27    if let Some(happiness) = name_lc.strip_suffix("_happiness") {
28        data.verify_exists_implied(Item::PopType, happiness, name);
29        return Some((Scopes::Province, Trigger::CompareValue));
30    }
31    if let Some(part) = name.as_str().strip_prefix("num_of_") {
32        if data.item_exists(Item::Building, part) {
33            return Some((Scopes::Province, Trigger::CompareValue));
34        }
35        if data.item_exists(Item::PopType, part) {
36            return Some((Scopes::Province.union(Scopes::Country), Trigger::CompareValue));
37        }
38        if !data.item_exists(Item::Building, part) && !data.item_exists(Item::PopType, part) {
39            let msg = format!("could not find any {part}");
40            let info = "Possible valid options would be: num_of_$POPTYPE$ or num_of_$BUILDING$";
41            warn(ErrorKey::MissingItem).msg(msg).info(info).loc(name).push();
42        }
43    }
44    // This one is weird...the trigger is just Item::TechnologyTable with no suffix or prefix.
45    if data.item_exists(Item::TechnologyTable, name.as_str()) {
46        return Some((Scopes::Country, Trigger::CompareValue));
47    }
48    None
49}
50
51static TRIGGER_MAP: LazyLock<TigerHashMap<&'static str, (Scopes, Trigger)>> = LazyLock::new(|| {
52    let mut hash = TigerHashMap::default();
53    for (from, s, trigger) in TRIGGER {
54        hash.insert(*s, (*from, *trigger));
55    }
56    hash
57});
58
59/// LAST UPDATED IMPERATOR VERSION 2.0.4
60/// See `triggers.log` from the game data dumps
61/// A key ends with '(' if it is the version that takes a parenthesized argument in script.
62const TRIGGER: &[(Scopes, &str, Trigger)] = &[
63    (
64        Scopes::State,
65        "can_create_trade_route",
66        Block(&[("target", Scope(Scopes::State)), ("goods", Item(Item::TradeGood))]),
67    ),
68    (Scopes::State, "has_capital_bonus_for_trade_good", Item(Item::TradeGood)),
69    (Scopes::State, "has_capital_surplus", Boolean),
70    (Scopes::State, "is_automated_trading", Boolean),
71    (
72        Scopes::Province,
73        "distance_from",
74        Block(&[
75            ("province", ScopeOrItem(Scopes::Province, Item::Province)),
76            ("value", CompareValue),
77        ]),
78    ),
79    (
80        Scopes::Country,
81        "can_unlock_invention",
82        Block(&[
83            ("invention", Item(Item::Invention)),
84            ("free", Boolean),
85            ("ignore_dependencies", Boolean),
86        ]),
87    ),
88    (Scopes::None, "debug_log", UncheckedValue),
89    (Scopes::None, "debug_log_details", UncheckedValue),
90    // State Triggers
91    (Scopes::State, "can_change_governor_policy", Boolean),
92    (Scopes::State, "can_import_trade_good", Boolean),
93    (Scopes::State, "has_any_great_work_state", Boolean),
94    (Scopes::State, "has_governor", Boolean),
95    (Scopes::State, "has_state_food", CompareValue),
96    (Scopes::State, "has_state_food_capacity", CompareValue),
97    (Scopes::State, "has_state_modifier", Item(Item::Modifier)),
98    (Scopes::State, "incoming_trade_routes", CompareValue),
99    (Scopes::State, "is_capital_state", Boolean),
100    (Scopes::State, "outgoing_trade_routes", CompareValue),
101    (Scopes::State, "state_commerce_income", CompareValue),
102    (Scopes::State, "state_level_loyalty", CompareValue),
103    (Scopes::State, "state_monthly_food_income", CompareValue),
104    (
105        Scopes::State,
106        "trade_good_exports",
107        Block(&[("target", Item(Item::TradeGood)), ("value", CompareValue)]),
108    ),
109    (
110        Scopes::State,
111        "trade_good_imports",
112        Block(&[("target", Item(Item::TradeGood)), ("value", CompareValue)]),
113    ),
114    (
115        Scopes::State,
116        "trade_good_surplus",
117        Block(&[("target", Item(Item::TradeGood)), ("value", CompareValue)]),
118    ),
119    (Scopes::State, "trade_routes", CompareValue),
120    (Scopes::State, "unused_trade_routes", CompareValue),
121    // Unit Triggers
122    (Scopes::Unit, "days_since_last_unit_victory", CompareValue),
123    (Scopes::Unit, "experience_percentage", CompareValue),
124    (Scopes::Unit, "food_percentage", CompareValue),
125    (Scopes::Unit, "has_reduced_roadbuilding_cost", Boolean),
126    (Scopes::Unit, "has_commander", Boolean),
127    (Scopes::Unit, "has_siege_impact", Boolean),
128    (Scopes::Unit, "has_unit_modifier", Item(Item::Modifier)),
129    (Scopes::Unit, "in_combat", Boolean),
130    (Scopes::Unit, "in_siege", Boolean),
131    (Scopes::Unit, "is_army", Boolean),
132    (Scopes::Unit, "is_carrying_troops", Boolean),
133    (Scopes::Unit, "in_siege", Boolean),
134    (Scopes::Unit, "is_dominant_unit", Boolean),
135    (Scopes::Unit, "is_exiled", Boolean),
136    (Scopes::Unit, "is_idle", Boolean),
137    (Scopes::Unit, "is_moving", Boolean),
138    (Scopes::Unit, "is_navy", Boolean),
139    (Scopes::Unit, "is_unit_ability_used", Item(Item::UnitAbility)),
140    (Scopes::Unit, "is_unit_locked", Boolean),
141    (Scopes::Unit, "morale_percentage", CompareValue),
142    (Scopes::Unit, "num_of_loyal_cohorts", CompareValue),
143    (Scopes::Unit, "num_of_migrants", CompareValue),
144    (Scopes::Unit, "strength_percentage", CompareValue),
145    (Scopes::Unit, "unit_size", CompareValue),
146    (Scopes::Unit, "unit_size_rank", CompareValue),
147    (Scopes::Unit, "unit_size_rank_percentage", CompareValue),
148    (Scopes::Unit, "unit_threat", CompareValue),
149    // Great Work Triggers
150    (Scopes::GreatWork, "great_work_any_material", Item(Item::GreatWorkMaterial)),
151    (Scopes::GreatWork, "great_work_builder", ScopeOrItem(Scopes::Country, Item::Localization)),
152    (Scopes::GreatWork, "great_work_category", Item(Item::GreatWorkCategory)),
153    (Scopes::GreatWork, "great_work_min_effect_tier", CompareValue),
154    (Scopes::GreatWork, "great_work_only_material", Item(Item::GreatWorkMaterial)),
155    (Scopes::GreatWork, "is_ancient_wonder", Boolean),
156    // Character Triggers
157    (Scopes::Character, "age", CompareValue),
158    (Scopes::Character, "can_add_entire_loyalty_bonus", Item(Item::Loyalty)),
159    (Scopes::Character, "can_get_friends", Boolean),
160    (Scopes::Character, "can_get_rivals", Boolean),
161    (Scopes::Character, "can_hold_office", Item(Item::Office)),
162    (Scopes::Character, "can_inherit", Boolean),
163    (Scopes::Character, "can_marry", Boolean),
164    (Scopes::Character, "character_experience", CompareValue),
165    (Scopes::Character, "charisma", CompareValue),
166    (Scopes::Character, "corruption", CompareValue),
167    (Scopes::Character, "current_party_conviction", CompareValue),
168    (Scopes::Character, "days_since_last_victory", CompareValue),
169    (Scopes::Character, "fertility", CompareValue),
170    (Scopes::Character, "finesse", CompareValue),
171    (Scopes::Character, "from_ruler_family", Boolean),
172    (Scopes::Character, "has_ambition", Item(Item::Ambition)),
173    (Scopes::Character, "has_any_office", Boolean),
174    (Scopes::Character, "has_character_modifier", Item(Item::Modifier)),
175    (Scopes::Character, "has_culture", ScopeOrItem(Scopes::Culture, Item::Culture)),
176    (Scopes::Character, "has_culture_group", ScopeOrItem(Scopes::CultureGroup, Item::CultureGroup)),
177    (Scopes::Character, "has_father", Boolean),
178    (Scopes::Character, "has_holding_in", ScopeOrItem(Scopes::Province, Item::Province)),
179    (Scopes::Character, "has_job", Boolean),
180    (Scopes::Character, "has_loyalty", Item(Item::Loyalty)),
181    (Scopes::Character, "has_mother", Boolean),
182    (Scopes::Character, "has_nickname", Boolean),
183    (Scopes::Character, "has_office", Item(Item::Office)),
184    (Scopes::Character, "has_religion", ScopeOrItem(Scopes::Religion, Item::Religion)),
185    (Scopes::Character, "has_same_culture_group_as", Scope(Scopes::Character)),
186    (Scopes::Character, "has_same_family", Scope(Scopes::Character)),
187    (Scopes::Character, "has_same_religion_as", Scope(Scopes::Character)),
188    (Scopes::Character, "has_tech_office", Boolean),
189    (Scopes::Character, "has_tech_office_of", Item(Item::TechnologyTable)),
190    (Scopes::Character, "has_trait", Item(Item::CharacterTrait)),
191    (Scopes::Character, "has_triggered_character_modifier", Item(Item::Modifier)),
192    (Scopes::Character, "health", CompareValue),
193    (Scopes::Character, "highest_skill", Choice(&["martial", "finesse", "charisma", "zeal"])),
194    (Scopes::Character, "in_command", Boolean),
195    (Scopes::Character, "is_admiral", Boolean),
196    (Scopes::Character, "is_adult", Boolean),
197    (Scopes::Character, "is_alive", Boolean),
198    (Scopes::Character, "is_at_location", ScopeOrItem(Scopes::Province, Item::Province)),
199    (Scopes::Character, "is_at_same_location", Scope(Scopes::Character)),
200    (Scopes::Character, "is_banished", Boolean),
201    (Scopes::Character, "is_bastard", Boolean),
202    (Scopes::Character, "is_child_of", Scope(Scopes::Character)),
203    (Scopes::Character, "is_clan_chief", Boolean),
204    (Scopes::Character, "is_close_relative", Scope(Scopes::Character)),
205    (Scopes::Character, "is_co_ruler", Boolean),
206    (Scopes::Character, "is_courtier", Boolean),
207    (Scopes::Character, "is_deified", Boolean),
208    (Scopes::Character, "is_female", Boolean),
209    (Scopes::Character, "is_friend", Scope(Scopes::Character)),
210    (Scopes::Character, "is_general", Boolean),
211    (Scopes::Character, "is_governor", Boolean),
212    (Scopes::Character, "is_head_of_family", Boolean),
213    (Scopes::Character, "is_leader_of_party", Item(Item::PartyType)),
214    (Scopes::Character, "is_leader_of_party_type", Item(Item::PartyType)),
215    (Scopes::Character, "is_male", Boolean),
216    (Scopes::Character, "is_married", Boolean),
217    (Scopes::Character, "is_mercenary", Boolean),
218    (Scopes::Character, "is_minor_character", Boolean),
219    (Scopes::Character, "is_parent_of", Scope(Scopes::Character)),
220    (Scopes::Character, "is_party_leader", Boolean),
221    (Scopes::Character, "is_pregnant", Boolean),
222    (Scopes::Character, "is_pretender", Boolean),
223    (Scopes::Character, "is_previous_ruler", Boolean),
224    (Scopes::Character, "is_primary_heir", Boolean),
225    (Scopes::Character, "is_rival", Scope(Scopes::Character)),
226    (Scopes::Character, "is_ruler", Boolean),
227    (Scopes::Character, "is_same_gender", Scope(Scopes::Character)),
228    (Scopes::Character, "is_same_party_as", Scope(Scopes::Character)),
229    (Scopes::Character, "is_sibling_of", Scope(Scopes::Character)),
230    (Scopes::Character, "is_spouse_of", Scope(Scopes::Character)),
231    (Scopes::Character, "is_successor", Boolean),
232    (Scopes::Character, "loyalty", CompareValue),
233    (Scopes::Character, "martial", CompareValue),
234    (Scopes::Character, "num_character_treasures", CompareValue),
235    (Scopes::Character, "num_holdings_owned", CompareValue),
236    (Scopes::Character, "num_loyal_cohorts", CompareValue),
237    (Scopes::Character, "num_loyal_veterans", CompareValue),
238    (Scopes::Character, "num_of_children", CompareValue),
239    (Scopes::Character, "num_of_friends", CompareValue),
240    (Scopes::Character, "num_of_rivals", CompareValue),
241    (Scopes::Character, "num_of_supporters", CompareValue),
242    (Scopes::Character, "number_of_health_traits", CompareValue),
243    (Scopes::Character, "number_of_military_traits", CompareValue),
244    (Scopes::Character, "number_of_personality_traits", CompareValue),
245    (Scopes::Character, "number_of_status_traits", CompareValue),
246    (Scopes::Character, "number_of_traits", CompareValue),
247    (Scopes::Character, "total_power_base", CompareValue),
248    (Scopes::Character, "party", Scope(Scopes::Party)),
249    (Scopes::Character, "party_type", Item(Item::PartyType)),
250    (Scopes::Character, "popularity", CompareValue),
251    (Scopes::Character, "power_base", CompareValue),
252    (Scopes::Character, "prisoner", Boolean),
253    (Scopes::Character, "prominence", CompareValue),
254    (Scopes::Character, "relative_power_base", CompareValue),
255    (Scopes::Character, "title_importance", CompareValue),
256    (Scopes::Character, "wealth", CompareValue),
257    (Scopes::Character, "zeal", CompareValue),
258    (Scopes::Character, "has_same_culture_as", Scope(Scopes::Character)),
259    // Pop Triggers
260    (Scopes::Pop, "pop_can_move", Boolean),
261    (Scopes::Pop, "pop_culture", ScopeOrItem(Scopes::Culture, Item::Culture)),
262    (Scopes::Pop, "pop_culture_group", ScopeOrItem(Scopes::CultureGroup, Item::CultureGroup)),
263    (Scopes::Pop, "pop_hapiness", CompareValue),
264    (Scopes::Pop, "pop_religion", ScopeOrItem(Scopes::Religion, Item::Religion)),
265    (Scopes::Pop, "pop_type", Item(Item::PopType)),
266    (Scopes::Pop, "is_pop_type_right", Item(Item::PopType)),
267    // Country Triggers
268    (
269        Scopes::Country.union(Scopes::Character).union(Scopes::Province),
270        "treasure_count",
271        CompareValue,
272    ),
273    (Scopes::Country, "biggest_party", ScopeOrItem(Scopes::Party, Item::PartyType)),
274    (Scopes::Country, "alliance_with", ScopeOrItem(Scopes::Country, Item::Localization)),
275    (Scopes::Country, "can_activate", Scope(Scopes::Deity)),
276    (Scopes::Country, "can_change_idea", Item(Item::Idea)),
277    (Scopes::Country, "can_pay_price", Item(Item::Price)),
278    (Scopes::Country, "centralization", CompareValue),
279    (Scopes::Country, "civil_war_with", ScopeOrItem(Scopes::Country, Item::Localization)),
280    (Scopes::Country, "country_culture_group", Item(Item::CultureGroup)),
281    (Scopes::Country, "country_population", CompareValue),
282    (
283        Scopes::Country,
284        "country_trade_good_exports",
285        Block(&[("target", Item(Item::TradeGood)), ("value", CompareValue)]),
286    ),
287    (
288        Scopes::Country,
289        "country_trade_good_imports",
290        Block(&[("target", Item(Item::TradeGood)), ("value", CompareValue)]),
291    ),
292    (Scopes::Country, "cultural_unity", CompareValue),
293    (Scopes::Country, "days_since_last_war", CompareValue),
294    (Scopes::Country, "diplomatic_stance", Item(Item::DiplomaticStance)),
295    (Scopes::Country, "distress_level", CompareValue),
296    (Scopes::Country, "exports_to", ScopeOrItem(Scopes::Country, Item::Localization)),
297    (Scopes::Country, "gender_equality", Boolean),
298    (Scopes::Country, "government", Item(Item::GovernmentType)),
299    (Scopes::Country, "has_aggressive_expansion", CompareValue),
300    (Scopes::Country, "has_any_great_work_country", Boolean),
301    (Scopes::Country, "has_any_omen", Boolean),
302    (Scopes::Country, "has_civil_war", Boolean),
303    (Scopes::Country, "has_claim", ScopeOrItem(Scopes::Province, Item::Province)),
304    (Scopes::Country, "has_co_ruler_government", Boolean),
305    (Scopes::Country, "has_coasts", Boolean),
306    (Scopes::Country, "has_completed_mission", Item(Item::Mission)),
307    (Scopes::Country, "has_completed_mission_task", Item(Item::MissionTask)),
308    (Scopes::Country, "has_country_great_work_effect", Item(Item::GreatWorkEffect)),
309    (Scopes::Country, "has_country_modifier", Item(Item::Modifier)),
310    (Scopes::Country, "has_deity_in_pantheon", Scope(Scopes::Deity)),
311    (Scopes::Country, "has_high_economic_policy", Item(Item::EconomicPolicy)),
312    (Scopes::Country, "has_land", Boolean),
313    (Scopes::Country, "has_law", Item(Item::Law)),
314    (Scopes::Country, "has_low_economic_policy", Item(Item::EconomicPolicy)),
315    (Scopes::Country, "has_mid_economic_policy", Item(Item::EconomicPolicy)),
316    (Scopes::Country, "has_military_access", ScopeOrItem(Scopes::Country, Item::Localization)),
317    (Scopes::Country, "has_military_bonus", Item(Item::MilitaryTradition)),
318    (Scopes::Country, "has_monthly_balance", CompareValue),
319    (Scopes::Country, "has_monthly_income", CompareValue),
320    (
321        Scopes::Country,
322        "has_opinion",
323        Block(&[
324            ("modifier", Item(Item::Opinion)),
325            ("target", ScopeOrItem(Scopes::Country, Item::Localization)),
326        ]),
327    ),
328    (Scopes::Country, "has_party_type", Item(Item::PartyType)),
329    (Scopes::Country, "has_primary_heir", Boolean),
330    (Scopes::Country, "has_senate_approval", CompareValue),
331    (Scopes::Country, "has_subject_loyalty", CompareValue),
332    (Scopes::Country, "has_this_omen", ScopeOrItem(Scopes::Deity, Item::Deity)),
333    (Scopes::Country, "has_truce_with", ScopeOrItem(Scopes::Country, Item::Localization)),
334    (Scopes::Country, "has_war_exhaustion", CompareValue),
335    (Scopes::Country, "has_subject_loyalty", CompareValue),
336    (Scopes::Country, "healthy_economy_percentage", CompareValue),
337    (Scopes::Country, "heritage", Item(Item::Heritage)),
338    (Scopes::Country, "idea", Item(Item::Idea)),
339    (Scopes::Country, "imports_from", ScopeOrItem(Scopes::Country, Item::Localization)),
340    (Scopes::Country, "in_diplomatic_range", ScopeOrItem(Scopes::Country, Item::Localization)),
341    (Scopes::Country, "invention", Item(Item::Invention)),
342    (Scopes::Country, "is_ai", Boolean),
343    (Scopes::Country, "is_antagonist", Boolean),
344    (Scopes::Country, "is_guaranteed_by", ScopeOrItem(Scopes::Country, Item::Localization)),
345    (Scopes::Country, "is_monarchy", Boolean),
346    (Scopes::Country, "is_monotheist_deity", Scope(Scopes::Deity)),
347    (Scopes::Country, "is_republic", Boolean),
348    (Scopes::Country, "is_subject", Boolean),
349    (Scopes::Country, "is_overlord", Boolean),
350    (Scopes::Country, "is_subject_of", ScopeOrItem(Scopes::Country, Item::Localization)),
351    (Scopes::Country, "is_subject_type", Item(Item::SubjectType)),
352    (Scopes::Country, "is_trade_goods_allowed", Item(Item::TradeGood)),
353    (Scopes::Country, "is_tradition_tree_allowed", Item(Item::MilitaryTraditionTree)),
354    (Scopes::Country, "is_tribal", Boolean),
355    (Scopes::Country, "is_tutorial_active", Boolean),
356    (Scopes::Country, "legitimacy", CompareValue),
357    (Scopes::Country, "manpower", CompareValue),
358    (Scopes::Country, "manpower_percentage", CompareValue),
359    (Scopes::Country, "max_diplomatic_relations", CompareValue),
360    (Scopes::Country, "max_manpower", CompareValue),
361    (Scopes::Country, "migration_strategy", CompareValue),
362    (Scopes::Country, "military_experience", CompareValue),
363    (Scopes::Country, "months_to_war", CompareValue),
364    (Scopes::Country, "naval_dominance", CompareValue),
365    (Scopes::Country, "non_loyal_power_base", CompareValue),
366    (Scopes::Country, "num_active_relations", CompareValue),
367    (Scopes::Country, "num_allowed_families", CompareValue),
368    (Scopes::Country, "num_of_cities", CompareValue),
369    (Scopes::Country, "num_of_civic_ideas", CompareValue),
370    (Scopes::Country, "num_of_cohorts", CompareValue),
371    (Scopes::Country, "num_of_controlled_cities", CompareValue),
372    (Scopes::Country, "num_of_deified_rulers_in_pantheon", CompareValue),
373    (Scopes::Country, "num_of_families", CompareValue),
374    (Scopes::Country, "num_of_military_ideas", CompareValue),
375    (Scopes::Country, "num_of_oratory_ideas", CompareValue),
376    (Scopes::Country, "num_of_ports", CompareValue),
377    (Scopes::Country, "num_of_provinces", CompareValue),
378    (Scopes::Country, "num_of_religious_ideas", CompareValue),
379    (Scopes::Country, "num_of_ships", CompareValue),
380    (
381        Scopes::Country,
382        "num_of_unit_type",
383        Block(&[("type", Item(Item::Unit)), ("value", CompareValue)]),
384    ),
385    (Scopes::Country, "office_is_empty", Item(Item::Office)),
386    (
387        Scopes::Country,
388        "opinion",
389        Block(&[
390            ("target", ScopeOrItem(Scopes::Country, Item::Localization)),
391            ("value", CompareValue),
392        ]),
393    ),
394    (Scopes::Country, "owns", ScopeOrItem(Scopes::Province, Item::Province)),
395    (Scopes::Country, "owns_area", ScopeOrItem(Scopes::Area, Item::Area)),
396    (Scopes::Country, "owns_or_subject_owns", ScopeOrItem(Scopes::Province, Item::Province)),
397    (Scopes::Country, "owns_or_subject_owns_area", ScopeOrItem(Scopes::Area, Item::Area)),
398    (Scopes::Country, "owns_or_subject_owns_region", ScopeOrItem(Scopes::Region, Item::Region)),
399    (Scopes::Country, "owns_region", ScopeOrItem(Scopes::Region, Item::Region)),
400    (Scopes::Country, "percentage_characters_below_max_loyalty", CompareValue),
401    (Scopes::Country, "political_influence", CompareValue),
402    (Scopes::Country, "possible_holdings", CompareValue),
403    (Scopes::Country, "primary_culture", ScopeOrItem(Scopes::Culture, Item::Culture)),
404    (Scopes::Country, "rank", CompareValue),
405    (Scopes::Country, "religion", ScopeOrItem(Scopes::Religion, Item::Religion)),
406    (Scopes::Country, "religious_unity", CompareValue),
407    (Scopes::Country, "safety", CompareValue),
408    (Scopes::Country, "stability", CompareValue),
409    (Scopes::Country, "tag", UncheckedValue),
410    (Scopes::Country, "threat_in_owned_land", CompareValue),
411    (Scopes::Country, "total_holdings", CompareValue),
412    (Scopes::Country, "towards_civil_war", Boolean),
413    (Scopes::Country, "treasury", CompareValue),
414    (Scopes::Country, "tyranny", CompareValue),
415    (Scopes::Country, "war", Boolean),
416    (Scopes::Country, "war_with", ScopeOrItem(Scopes::Country, Item::Localization)),
417    (
418        Scopes::Country,
419        "culture_pops_in_country",
420        Block(&[("target", Scope(Scopes::CountryCulture)), ("value", CompareValue)]),
421    ),
422    (Scopes::Country, "is_monotheist_religion", Boolean),
423    // Subunit triggers
424    (Scopes::SubUnit, "cohort_food_consumption", CompareValue),
425    (Scopes::SubUnit, "cohort_food_storage_capacity", CompareValue),
426    (Scopes::SubUnit, "has_personal_loyalty", Boolean),
427    (Scopes::SubUnit, "is_cohort", Boolean),
428    (Scopes::SubUnit, "is_migration", Boolean),
429    (Scopes::SubUnit, "is_ship", Boolean),
430    (Scopes::SubUnit, "ship_category", Choice(&["light", "medium", "heavy"])),
431    (Scopes::SubUnit, "sub_unit_type", Item(Item::Unit)),
432    (Scopes::SubUnit, "subunit_morale_percentage", CompareValue),
433    (Scopes::SubUnit, "subunit_strength_percentage", CompareValue),
434    // Unit triggers
435    (
436        Scopes::Unit.union(Scopes::Character).union(Scopes::Governorship),
437        "has_legion_trigger",
438        Boolean,
439    ),
440    // Party triggers
441    (Scopes::Party, "has_active_agenda", Boolean),
442    (Scopes::Party, "has_power_percentage", CompareValue),
443    (Scopes::Party, "is_party_type", Item(Item::PartyType)),
444    (Scopes::Party, "party_approval", CompareValue),
445    // Family triggers
446    (Scopes::Family, "is_grateful", Boolean),
447    (Scopes::Family, "is_scorned", Boolean),
448    (Scopes::Family, "num_of_expected_jobs", CompareValue),
449    (Scopes::Family, "num_of_jobs", CompareValue),
450    (Scopes::Family, "num_of_members", CompareValue),
451    (Scopes::Family, "prestige", CompareValue),
452    // Legion triggers
453    (Scopes::Legion, "can_add_commander", Boolean),
454    (Scopes::Legion, "commander_count", CompareValue),
455    (Scopes::Legion, "distinction_count", CompareValue),
456    (Scopes::Legion, "has_distinction", Item(Item::LegionDistinction)),
457    (Scopes::Legion, "unit_count", CompareValue),
458    // Siege triggers
459    (Scopes::Siege, "has_breach", Boolean),
460    // War triggers
461    (Scopes::War, "is_civil_war", Boolean),
462    (Scopes::War, "is_war_leader", ScopeOrItem(Scopes::Country, Item::Localization)),
463    (Scopes::War, "is_war_over", Boolean),
464    (
465        Scopes::War,
466        "war_score",
467        Block(&[
468            ("target", ScopeOrItem(Scopes::Country, Item::Localization)),
469            ("value", CompareValue),
470        ]),
471    ),
472    // Deity triggers
473    (Scopes::Deity, "deity_religion", ScopeOrItem(Scopes::Religion, Item::Religion)),
474    (Scopes::Deity, "has_holy_site", Boolean),
475    // TODO - These 2 should be country modifiers from ModifKinds::Country
476    (Scopes::Deity, "has_active_modifier", UncheckedValue),
477    (Scopes::Deity, "has_passive_modifier", UncheckedValue),
478    // Province triggers
479    (Scopes::Province, "ai_wants_road", ScopeOrItem(Scopes::Country, Item::Localization)),
480    (Scopes::Province, "can_build_building", Item(Item::Building)),
481    (Scopes::Province, "can_have_port", Boolean),
482    // TODO - This should be "Special" and only be usable in files inside common/unit_abilities
483    (Scopes::Province, "can_use_unit_ability", Item(Item::UnitAbility)),
484    (Scopes::Province, "civilization_value", CompareValue),
485    (Scopes::Province, "control_range", ScopeOrItem(Scopes::Country, Item::Localization)),
486    (Scopes::Province, "distance_to_migration_target", CompareValue),
487    (Scopes::Province, "dominant_province_culture", ScopeOrItem(Scopes::Culture, Item::Culture)),
488    (Scopes::Province, "dominant_province_religion", ScopeOrItem(Scopes::Religion, Item::Religion)),
489    (Scopes::Province, "fort_level", CompareValue),
490    (Scopes::Province, "free_building_slots", CompareValue),
491    (Scopes::Province, "governor_policy", Item(Item::GovernorPolicy)),
492    (
493        Scopes::Province,
494        "great_work_locator_is_free",
495        Choice(&["primary_great_work", "secondary_great_work", "great_work"]),
496    ),
497    // TODO - ancient wonders are defined in setup/main by great works with "ancient_wonder = yes"
498    (Scopes::Province, "has_ancient_wonder", UncheckedValue),
499    (Scopes::Province, "has_building", Item(Item::Building)),
500    (Scopes::Province, "has_city_status", Boolean),
501    (Scopes::Province, "has_construction", Boolean),
502    (Scopes::Province, "has_enemy_army", ScopeOrItem(Scopes::Country, Item::Localization)),
503    (Scopes::Province, "has_enemy_navy", ScopeOrItem(Scopes::Country, Item::Localization)),
504    (Scopes::Province, "has_great_work", Boolean),
505    (Scopes::Province, "has_minor_river", Boolean),
506    (Scopes::Province, "has_owner", Boolean),
507    (Scopes::Province, "has_province_modifier", Item(Item::Modifier)),
508    (Scopes::Province, "has_province_rank", Item(Item::ProvinceRank)),
509    (Scopes::Province, "has_road_towards", ScopeOrItem(Scopes::Province, Item::Province)),
510    (Scopes::Province, "has_siege", Boolean),
511    (Scopes::Province, "has_specific_construction", Item(Item::Building)),
512    (Scopes::Province, "has_winter", Boolean),
513    (Scopes::Province, "is_adjacent_to_major_river", Boolean),
514    (Scopes::Province, "is_capital", Boolean),
515    (Scopes::Province, "is_coastal", Boolean),
516    (Scopes::Province, "is_colonizer", ScopeOrItem(Scopes::Country, Item::Localization)),
517    (Scopes::Province, "is_core_of", ScopeOrItem(Scopes::Country, Item::Localization)),
518    (Scopes::Province, "is_holy_site", Boolean),
519    (Scopes::Province, "is_holy_site_of_deity", Scope(Scopes::Deity)),
520    (Scopes::Province, "is_holy_site_of_religion", ScopeOrItem(Scopes::Religion, Item::Religion)),
521    (Scopes::Province, "is_importing_trade_good", Item(Item::TradeGood)),
522    (Scopes::Province, "is_in_area", ScopeOrItem(Scopes::Province, Item::Area)),
523    (Scopes::Province, "is_in_region", ScopeOrItem(Scopes::Province, Item::Region)),
524    (Scopes::Province, "is_inhabitable", Boolean),
525    (Scopes::Province, "is_model_shown", UncheckedValue),
526    (Scopes::Province, "is_neighbor", ScopeOrItem(Scopes::Province, Item::Province)),
527    (Scopes::Province, "is_port", Boolean),
528    (Scopes::Province, "is_previous_controller", ScopeOrItem(Scopes::Country, Item::Localization)),
529    (Scopes::Province, "is_previous_owner", ScopeOrItem(Scopes::Country, Item::Localization)),
530    (Scopes::Province, "is_sea", Boolean),
531    (Scopes::Province, "is_state_capital", Boolean),
532    (Scopes::Province, "is_uninhabitable", Boolean),
533    (Scopes::Province, "num_goods_produced", CompareValue),
534    (Scopes::Province, "num_of_total_building_slots", CompareValue),
535    (Scopes::Province, "num_of_used_building_slots", CompareValue),
536    (Scopes::Province, "num_other_religion", CompareValue),
537    (Scopes::Province, "num_foreign_culture", CompareValue),
538    (Scopes::Province, "num_province_treasures", CompareValue),
539    (Scopes::Province, "owned_or_subject_owned", ScopeOrItem(Scopes::Country, Item::Localization)),
540    (Scopes::Province, "population_cap", CompareValue),
541    (Scopes::Province, "province_dominant_culture_group", Item(Item::CultureGroup)),
542    (Scopes::Province, "province_id", CompareValue),
543    (Scopes::Province, "province_income", CompareValue),
544    (Scopes::Province, "province_manpower_income", CompareValue),
545    (Scopes::Province, "province_tax_income", CompareValue),
546    (Scopes::Province, "province_unrest", CompareValue),
547    (Scopes::Province, "state_loyalty", CompareValue),
548    (Scopes::Province, "terrain", Item(Item::Terrain)),
549    (Scopes::Province, "total_population", CompareValue),
550    (Scopes::Province, "trade_goods", Item(Item::TradeGood)),
551    // Country Culture triggers
552    (Scopes::CountryCulture, "country_culture_pop_count", CompareValue),
553    (Scopes::CountryCulture, "has_country_culture_modifier", Item(Item::Modifier)),
554    (Scopes::CountryCulture, "has_pop_type_right", Item(Item::PopType)),
555    (Scopes::CountryCulture, "integration_progress", CompareValue),
556    (Scopes::CountryCulture, "is_integrated", Boolean),
557    (Scopes::CountryCulture, "is_culture", ScopeOrItem(Scopes::Culture, Item::Culture)),
558    // None scope triggers
559    (Scopes::all_but_none(), "add_to_temporary_list", Special),
560    (Scopes::None, "all_false", Control),
561    (Scopes::None, "always", Boolean),
562    (Scopes::None, "and", Control),
563    (Scopes::None, "assert_if", Block(&[("limit", Control), ("?text", UncheckedValue)])),
564    (Scopes::None, "assert_read", UncheckedValue),
565    (Scopes::None, "calc_true_if", Control),
566    (Scopes::None, "current_date", CompareDate),
567    (Scopes::None, "custom_tooltip", Special),
568    (Scopes::None, "debug_only", Boolean),
569    (Scopes::None, "exists", Special),
570    (Scopes::None, "game_start_date", CompareDate),
571    (Scopes::None, "gender_rules", Boolean),
572    (
573        Scopes::None,
574        "global_variable_list_size",
575        Block(&[("name", Identifier("list name")), ("value", CompareValue)]),
576    ),
577    (Scopes::None, "has_agenda", UncheckedValue),
578    (Scopes::None, "has_dlc", Item(Item::DlcName)),
579    (Scopes::None, "has_global_variable", Identifier("variable name")),
580    (Scopes::None, "has_global_variable_list", Identifier("list name")),
581    (Scopes::None, "has_local_variable", Special),
582    (Scopes::None, "has_local_variable_list", Special),
583    (Scopes::None, "has_variable", Identifier("variable name")),
584    (Scopes::None, "has_variable_list", Identifier("list name")),
585    (Scopes::None, "is_dynamic_tag", Boolean),
586    (Scopes::None, "is_in_list", Special),
587    (Scopes::None, "is_iron_man", Boolean),
588    (Scopes::None, "is_target_alive", Scope(Scopes::Character)),
589    (Scopes::None, "is_target_in_global_variable_list", Special),
590    (Scopes::None, "is_target_in_local_variable_list", Special),
591    (Scopes::None, "is_target_in_variable_list", Special),
592    (
593        Scopes::None,
594        "list_size",
595        Block(&[("name", Identifier("list name")), ("value", CompareValue)]),
596    ),
597    (Scopes::None, "local_variable_list_size", Special),
598    (Scopes::None, "nand", Control),
599    (Scopes::None, "nor", Control),
600    (Scopes::None, "not", Control),
601    (Scopes::None, "or", Control),
602    (
603        Scopes::None,
604        "religion_pops_in_country",
605        Block(&[
606            ("target", ScopeOrItem(Scopes::Religion, Item::Religion)),
607            ("value", CompareValue),
608        ]),
609    ),
610    (Scopes::all_but_none(), "save_temporary_scope_as", Special),
611    (Scopes::None, "switch", Special),
612    (Scopes::None, "target_is_valid_character", Scope(Scopes::Character)),
613    (Scopes::None, "trigger_else", Control),
614    (Scopes::None, "trigger_else_if", Control),
615    (Scopes::None, "trigger_if", Control),
616    (
617        Scopes::None,
618        "variable_list_size",
619        Block(&[("name", Identifier("list name")), ("value", CompareValue)]),
620    ),
621    (Scopes::None, "weighted_calc_true_if", Special),
622    (Scopes::None, "in_color_list", UncheckedValue),
623    (Scopes::None, "is_color", UncheckedValue),
624];