tiger_lib/imperator/tables/
effects.rs

1use std::sync::LazyLock;
2
3use crate::effect::Effect;
4use crate::effect_validation::*;
5use crate::everything::Everything;
6use crate::helpers::TigerHashMap;
7use crate::imperator::effect_validation::*;
8use crate::item::Item;
9use crate::scopes::*;
10use crate::token::Token;
11use Effect::*;
12
13pub fn scope_effect(name: &Token, _data: &Everything) -> Option<(Scopes, Effect)> {
14    let name_lc = name.as_str().to_ascii_lowercase();
15    SCOPE_EFFECT_MAP.get(&*name_lc).copied()
16}
17
18/// A hashed version of [`SCOPE_EFFECT`], for quick lookup by effect name.
19static SCOPE_EFFECT_MAP: LazyLock<TigerHashMap<&'static str, (Scopes, Effect)>> =
20    LazyLock::new(|| {
21        let mut hash = TigerHashMap::default();
22        for (from, s, effect) in SCOPE_EFFECT.iter().copied() {
23            hash.insert(s, (from, effect));
24        }
25        hash
26    });
27
28// LAST UPDATED VERSION 2.0.4
29// See `effects.log` from the game data dumps
30// Note: There are a lot of effects here that are marked as "Unchecked"
31// Most of these are actually deprecated OR have no example usage so can't really be checked properly
32const SCOPE_EFFECT: &[(Scopes, &str, Effect)] = &[
33    (Scopes::State, "add_trade_route", Vb(validate_trade_route)),
34    (Scopes::State, "remove_trade_route", Vb(validate_trade_route)),
35    (Scopes::State, "set_automated_trading", Boolean),
36    (Scopes::State, "set_governor_policy", Item(Item::GovernorPolicy)),
37    (Scopes::State, "add_state_food", ScriptValue),
38    (Scopes::State, "add_state_modifier", Vbv(validate_add_modifier)),
39    (Scopes::State, "remove_state_modifier", Item(Item::Modifier)),
40    (Scopes::State, "set_state_capital", ScopeOrItem(Scopes::Province, Item::Province)),
41    (Scopes::Character, "adapt_family_name", Boolean),
42    (Scopes::Character, "add_as_governor", Scope(Scopes::Governorship)),
43    (Scopes::Character, "add_character_experience", ScriptValue),
44    (Scopes::Character, "add_character_modifier", Vbv(validate_add_modifier)),
45    (Scopes::Character, "add_corruption", ScriptValue),
46    (Scopes::Character, "add_friend", Scope(Scopes::Character)),
47    (Scopes::Character, "add_gold", ScriptValue),
48    (Scopes::Character, "add_health", ScriptValue),
49    (Scopes::Character, "add_holding", ScopeOrItem(Scopes::Province, Item::Province)),
50    (Scopes::Character, "add_loyal_veterans", ScriptValue),
51    (Scopes::Character, "add_loyal_veterans", ScriptValue),
52    (Scopes::Character, "add_loyalty", Item(Item::Loyalty)),
53    (Scopes::Character, "add_nickname", Item(Item::Localization)),
54    (Scopes::Character, "add_party_conviction", Vb(validate_add_party_conviction_or_approval)),
55    (Scopes::Character, "add_popularity", ScriptValue),
56    (Scopes::Character, "add_prominence", ScriptValue),
57    (Scopes::Character, "add_rival", Scope(Scopes::Character)),
58    (Scopes::Character, "remove_rival", Scope(Scopes::Character)),
59    (Scopes::Character, "add_ruler_conviction", Removed("2.0", "")),
60    (Scopes::Character, "add_trait", Item(Item::CharacterTrait)),
61    (Scopes::Character, "add_triggered_character_modifier", Vbv(validate_add_modifier)),
62    (Scopes::Character, "adopt", Scope(Scopes::Character)),
63    (Scopes::Character, "banish", ScopeOrItem(Scopes::Country, Item::Localization)),
64    (
65        Scopes::Character,
66        "change_mercenary_employer",
67        ScopeOrItem(Scopes::Country, Item::Localization),
68    ),
69    (Scopes::Character, "clear_ambition", Boolean),
70    (Scopes::Character, "death", Vb(validate_death)),
71    (Scopes::Character, "deify_character", Vb(validate_deify_character)),
72    (Scopes::Character, "divorce_character", Scope(Scopes::Character)),
73    (Scopes::Character, "end_pregnancy", Boolean),
74    (Scopes::Character, "force_add_trait", Item(Item::CharacterTrait)),
75    (Scopes::Character, "give_office", Item(Item::Office)),
76    (Scopes::Character, "marry_character", Scope(Scopes::Character)),
77    (Scopes::Character, "move_country", ScopeOrItem(Scopes::Country, Item::Localization)),
78    (
79        Scopes::Character,
80        "move_country_with_message",
81        ScopeOrItem(Scopes::Country, Item::Localization),
82    ),
83    (Scopes::Character, "pay_gold", Vb(validate_pay_gold)),
84    (Scopes::Character, "remove_all_offices", Boolean),
85    (Scopes::Character, "remove_as_governor", Boolean),
86    (Scopes::Character, "remove_as_mercenary", Boolean),
87    (Scopes::Character, "remove_as_researcher", Boolean),
88    (Scopes::Character, "remove_character_modifier", Item(Item::Modifier)),
89    (Scopes::Character, "remove_command", Boolean),
90    (Scopes::Character, "remove_friend", Scope(Scopes::Character)),
91    (Scopes::Character, "remove_holding", ScopeOrItem(Scopes::Province, Item::Province)),
92    (Scopes::Character, "remove_loyalty", Item(Item::Loyalty)),
93    (Scopes::Character, "remove_office", Item(Item::Office)),
94    (Scopes::Character, "remove_trait", Item(Item::CharacterTrait)),
95    (Scopes::Character, "remove_triggered_character_modifier", Item(Item::Modifier)),
96    (Scopes::Character, "set_ambition", Item(Item::Ambition)),
97    (Scopes::Character, "set_as_minor_character", ScopeOkThis(Scopes::Character)),
98    (Scopes::Character, "set_can_inherit", Boolean),
99    (Scopes::Character, "set_can_marry", Boolean),
100    (Scopes::Character, "set_character_religion", ScopeOrItem(Scopes::Religion, Item::Religion)),
101    (Scopes::Character, "set_culture", ScopeOrItem(Scopes::Culture, Item::Culture)),
102    (Scopes::Character, "set_culture_same_as", ScopeOrItem(Scopes::Culture, Item::Culture)),
103    (Scopes::Character, "set_family", Scope(Scopes::Family)),
104    (Scopes::Character, "set_firstname", Item(Item::Localization)),
105    (Scopes::Character, "set_home_country", ScopeOrItem(Scopes::Country, Item::Localization)),
106    (Scopes::Character, "set_party_leader", Unchecked),
107    (Scopes::Character, "update_character", Boolean),
108    (
109        Scopes::Character.union(Scopes::Unit).union(Scopes::Legion),
110        "add_legion_history",
111        Vb(validate_legion_history),
112    ),
113    (Scopes::Character.union(Scopes::Unit), "add_to_legion", Scope(Scopes::Legion)),
114    (Scopes::Character, "add_charisma", ScriptValue),
115    (Scopes::Character, "add_finesse", ScriptValue),
116    (Scopes::Character, "add_martial", ScriptValue),
117    (Scopes::Character, "add_zeal", ScriptValue),
118    (Scopes::Character, "make_pregnant", Vb(validate_make_pregnant)),
119    (Scopes::Governorship, "disband_legion", Boolean),
120    (Scopes::Governorship, "raise_legion", Vbc(validate_raise_legion)),
121    (Scopes::Treasure, "destroy_treasure", Boolean),
122    (Scopes::Treasure, "transfer_treasure_to_character", Scope(Scopes::Character)),
123    (
124        Scopes::Treasure,
125        "transfer_treasure_to_country",
126        ScopeOrItem(Scopes::Country, Item::Localization),
127    ),
128    (
129        Scopes::Treasure,
130        "transfer_treasure_to_province",
131        ScopeOrItem(Scopes::Province, Item::Province),
132    ),
133    (Scopes::Country, "add_deity_to_pantheon", Vb(validate_add_deity_to_pantheon)),
134    (Scopes::Country, "play_sound_effect", Item(Item::Sound)),
135    (Scopes::Country, "set_antagonist", Boolean),
136    (Scopes::Country, "set_player_country", Scope(Scopes::Country)),
137    (Scopes::Country, "unlock_invention", Item(Item::Invention)),
138    (Scopes::Country, "add_aggressive_expansion", ScriptValue),
139    (Scopes::Country, "add_alliance", ScopeOrItem(Scopes::Country, Item::Localization)),
140    (Scopes::Country, "add_centralization", ScriptValue),
141    (Scopes::Country, "add_country_modifier", Vbv(validate_add_modifier)),
142    (Scopes::Country, "add_guarantee", ScopeOrItem(Scopes::Country, Item::Localization)),
143    (Scopes::Country, "add_innovation", ScriptValue),
144    (Scopes::Country, "add_legitimacy", ScriptValue),
145    (Scopes::Country, "add_manpower", ScriptValue),
146    (Scopes::Country, "add_military_access", ScopeOrItem(Scopes::Country, Item::Localization)),
147    (Scopes::Country, "add_military_experience", ScriptValue),
148    (Scopes::Country, "add_new_family", Item(Item::Localization)),
149    (Scopes::Country, "add_opinion", Vb(validate_change_opinion)),
150    (Scopes::Country, "add_party_approval", Vb(validate_add_party_conviction_or_approval)),
151    (Scopes::Country, "add_political_influence", ScriptValue),
152    (Scopes::Country, "add_research", Vb(validate_add_research)),
153    (Scopes::Country, "add_stability", ScriptValue),
154    (Scopes::Country, "add_to_war", Vb(validate_add_to_war)),
155    (Scopes::Country, "add_treasury", ScriptValue),
156    (Scopes::Country, "add_truce", Vb(validate_add_truce)),
157    (Scopes::Country, "add_tyranny", ScriptValue),
158    (Scopes::Country, "add_war_exhaustion", ScriptValue),
159    (Scopes::Country, "allow_trade_goods", Unchecked),
160    (Scopes::Country, "call_omen", Unchecked),
161    (Scopes::Country, "change_country_adjective", Item(Item::Localization)),
162    (Scopes::Country, "change_country_color", Item(Item::NamedColor)),
163    (Scopes::Country, "change_country_flag", Item(Item::Coa)),
164    (Scopes::Country, "change_country_name", Item(Item::Localization)),
165    (Scopes::Country, "change_country_tag", Unchecked),
166    (Scopes::Country, "change_government", Item(Item::GovernmentType)),
167    (Scopes::Country, "change_law", Item(Item::Law)),
168    (Scopes::Country, "create_character", Vbc(validate_create_character)),
169    (Scopes::Country, "create_country_treasure", Vb(validate_create_treasure)),
170    (Scopes::Country, "create_family", Scope(Scopes::Character)),
171    (Scopes::Country, "declare_war_with_wargoal", Vb(validate_declare_war)),
172    (Scopes::Country, "disallow_trade_goods", Unchecked),
173    (Scopes::Country, "end_truce", Scope(Scopes::Country)),
174    (Scopes::Country, "imprison", Vb(validate_imprison)),
175    (Scopes::Country, "integrate_country_culture", Scope(Scopes::CountryCulture)),
176    (Scopes::Country, "make_subject", Vb(validate_make_subject)),
177    (Scopes::Country, "pay_price", Item(Item::Price)),
178    (Scopes::Country, "recalc_succession", Boolean),
179    (Scopes::Country, "refund_price", Item(Item::Price)),
180    (Scopes::Country, "release_prisoner", Vbv(validate_release_prisoner)),
181    (Scopes::Country, "release_subject", ScopeOrItem(Scopes::Country, Item::Localization)),
182    (Scopes::Country, "remove_country_modifier", Item(Item::Modifier)),
183    (Scopes::Country, "remove_gurantee", ScopeOrItem(Scopes::Country, Item::Localization)),
184    (Scopes::Country, "remove_opinion", Vb(validate_change_opinion)),
185    (Scopes::Country, "remove_party_leadership", Unchecked),
186    (Scopes::Country, "reverse_add_opinion", Vb(validate_change_opinion)),
187    (Scopes::Country, "set_as_coruler", Scope(Scopes::Character)),
188    (Scopes::Country, "set_as_ruler", Scope(Scopes::Character)),
189    (Scopes::Country, "set_capital", ScopeOrItem(Scopes::Province, Item::Province)),
190    (Scopes::Country, "set_country_heritage", Item(Item::Heritage)),
191    (Scopes::Country, "set_country_religion", ScopeOrItem(Scopes::Religion, Item::Religion)),
192    (Scopes::Country, "set_gender_equality", Boolean),
193    (Scopes::Country, "set_graphical_culture", Item(Item::GraphicalCultureType)),
194    (Scopes::Country, "set_ignore_senate_approval", Boolean),
195    (Scopes::Country, "set_legion_recruitment", Choice(&["enabled", "disabled", "capital"])),
196    (Scopes::Country, "set_primary_culture", ScopeOrItem(Scopes::Culture, Item::Culture)),
197    (Scopes::Country, "start_character_interaction", Unchecked),
198    (Scopes::Country, "start_civil_war", Scope(Scopes::Character)),
199    (Scopes::Country, "update_allowed_parties", Boolean),
200    (Scopes::Country, "set_party_agenda", Unchecked),
201    (Scopes::Country, "break_alliance", ScopeOrItem(Scopes::Country, Item::Localization)),
202    (Scopes::Legion, "add_commander", Scope(Scopes::Character)),
203    (Scopes::Legion, "add_distinction", Item(Item::LegionDistinction)),
204    (Scopes::Legion, "add_legion_unit", Unchecked),
205    (Scopes::Legion, "move_legion", Scope(Scopes::Governorship)),
206    (Scopes::Legion, "remove_commander", Scope(Scopes::Character)),
207    (Scopes::Legion, "remove_distinction", Item(Item::LegionDistinction)),
208    (Scopes::Legion, "remove_legion_unit", Unchecked),
209    (Scopes::Siege, "add_breach", Integer),
210    (Scopes::Legion.union(Scopes::Country), "create_unit", Vbc(validate_create_unit)),
211    (Scopes::Unit, "add_food", ScriptValue),
212    (Scopes::Unit, "add_loyal_subunit", Item(Item::Unit)),
213    (Scopes::Unit, "add_morale", ScriptValue),
214    (Scopes::Unit, "add_subunit", Item(Item::Unit)),
215    (Scopes::Unit, "add_unit_modifier", Vbv(validate_add_modifier)),
216    (Scopes::Unit, "change_unit_owner", ScopeOrItem(Scopes::Country, Item::Localization)),
217    (Scopes::Unit, "damage_unit_morale_percent", ScriptValue),
218    (Scopes::Unit, "damage_unit_percent", ScriptValue),
219    (Scopes::Unit, "destroy_unit", Boolean),
220    (Scopes::Unit, "lock_unit", ScriptValue),
221    (Scopes::Unit, "unlock_unit", ScriptValue),
222    (Scopes::Unit, "remove_unit_loyalty", Boolean),
223    (Scopes::Unit, "remove_unit_modifier", Item(Item::Modifier)),
224    (Scopes::Unit, "set_as_commander", Scope(Scopes::Character)),
225    (Scopes::Unit, "set_unit_size", Unchecked),
226    (Scopes::Unit, "split_migrants_to", ScriptValue),
227    (Scopes::Party, "pick_random_agenda", Boolean),
228    (Scopes::Pop, "kill_pop", Boolean),
229    (Scopes::Pop, "move_pop", ScopeOrItem(Scopes::Province, Item::Province)),
230    (Scopes::Pop, "set_pop_culture", ScopeOrItem(Scopes::Culture, Item::Culture)),
231    (Scopes::Pop, "set_pop_culture_same_as", Scope(Scopes::Pop)),
232    (Scopes::Pop, "set_pop_religion", ScopeOrItem(Scopes::Religion, Item::Religion)),
233    (Scopes::Pop, "set_pop_religion_same_as", Scope(Scopes::Pop)),
234    (Scopes::Pop, "set_pop_type", Item(Item::PopType)),
235    (Scopes::SubUnit, "add_subunit_morale", ScriptValue),
236    (Scopes::SubUnit, "add_subunit_strength", ScriptValue),
237    (Scopes::SubUnit, "destroy_subunit", Boolean),
238    (Scopes::SubUnit, "remove_subunit_loyalty", Vv(validate_remove_subunit_loyalty)),
239    (Scopes::SubUnit, "set_personal_loyalty", Scope(Scopes::Character)),
240    (Scopes::Family, "add_prestige", ScriptValue),
241    (Scopes::Family, "move_family", ScopeOrItem(Scopes::Country, Item::Localization)),
242    (Scopes::Family, "remove_family", ScopeOrItem(Scopes::Country, Item::Localization)),
243    (Scopes::Country.union(Scopes::War), "force_white_peace", Scope(Scopes::War)),
244    (Scopes::War, "remove_from_war", ScopeOrItem(Scopes::Country, Item::Localization)),
245    (Scopes::War, "war_score_value", Vb(validate_war_score_value)),
246    (Scopes::Province, "add_building_level", Item(Item::Building)),
247    (Scopes::Province, "add_civilization_value", ScriptValue),
248    (Scopes::Province, "add_claim", ScopeOrItem(Scopes::Country, Item::Localization)),
249    (Scopes::Province, "add_permanent_province_modifier", Vbv(validate_add_modifier)),
250    (Scopes::Province, "add_province_modifier", Vbv(validate_add_modifier)),
251    (Scopes::Province, "add_road_towards", ScopeOrItem(Scopes::Province, Item::Province)),
252    (Scopes::Province, "add_state_loyalty", ScriptValue),
253    (Scopes::Province, "add_vfx", Unchecked),
254    (Scopes::Province, "begin_great_work_construction", Vb(validate_great_work_construction)),
255    (Scopes::Province, "cancel_building_construction", Item(Item::Building)),
256    (Scopes::Province, "change_climate", Unchecked),
257    (Scopes::Province, "change_province_name", Item(Item::Localization)),
258    (Scopes::Province, "create_country", Vbc(validate_create_country)),
259    (Scopes::Province, "create_pop", Item(Item::PopType)),
260    (Scopes::Province, "create_state_pop", Item(Item::PopType)),
261    (Scopes::Province, "define_pop", Vb(validate_define_pop)),
262    (Scopes::Province, "finish_great_work_construction", Vb(validate_great_work_construction)),
263    (Scopes::Province, "hide_model", Unchecked),
264    (Scopes::Province, "remove_building_level", Item(Item::Building)),
265    (Scopes::Province, "remove_claim", ScopeOrItem(Scopes::Country, Item::Localization)),
266    (Scopes::Province, "remove_province_deity", Boolean),
267    (Scopes::Province, "remove_province_modifier", Item(Item::Modifier)),
268    (Scopes::Province, "remove_vfx", Unchecked),
269    (Scopes::Province, "set_as_governor", Scope(Scopes::Character)),
270    (Scopes::Province, "set_city_status", Item(Item::ProvinceRank)),
271    (Scopes::Province, "set_conquered_by", ScopeOrItem(Scopes::Country, Item::Localization)),
272    (Scopes::Province, "set_controller", ScopeOrItem(Scopes::Country, Item::Localization)),
273    (Scopes::Province, "set_owned_by", ScopeOrItem(Scopes::Country, Item::Localization)),
274    (Scopes::Province, "set_province_deity", Scope(Scopes::Deity)),
275    (Scopes::Province, "set_trade_goods", Item(Item::TradeGood)),
276    (Scopes::Province, "show_animated_text", Unchecked),
277    (Scopes::Province, "show_model", Unchecked),
278    (Scopes::Province, "start_building_construction", Item(Item::Building)),
279    (Scopes::CountryCulture, "add_country_culture_modifier", Vbv(validate_add_modifier)),
280    (Scopes::CountryCulture, "add_integration_progress", ScriptValue),
281    (Scopes::CountryCulture, "remove_country_culture_modifier", Item(Item::Modifier)),
282    (Scopes::CountryCulture, "set_country_culture_right", Item(Item::PopType)),
283    (Scopes::CountryCulture, "set_levy_template", Item(Item::LevyTemplate)),
284    (Scopes::None, "reset_scoring", ScopeOrItem(Scopes::Country, Item::Localization)),
285    (Scopes::None, "add_to_global_variable_list", Vb(validate_add_to_variable_list)),
286    (Scopes::all_but_none(), "add_to_list", Vv(validate_add_to_list_imperator)),
287    (Scopes::None, "add_to_local_variable_list", Vb(validate_add_to_variable_list)),
288    (Scopes::all_but_none(), "add_to_temporary_list", Vv(validate_add_to_list_imperator)),
289    (Scopes::None, "add_to_variable_list", Vb(validate_add_to_variable_list)),
290    (Scopes::None, "assert_if", Unchecked),
291    (Scopes::None, "assert_read", Unchecked),
292    (Scopes::None, "break", Yes),
293    (Scopes::None, "break_if", Control),
294    (Scopes::None, "change_global_variable", Vb(validate_change_variable)),
295    (Scopes::None, "change_local_variable", Vb(validate_change_variable)),
296    (Scopes::None, "change_variable", Vb(validate_change_variable)),
297    (Scopes::None, "clamp_global_variable", Vb(validate_clamp_variable)),
298    (Scopes::None, "clamp_local_variable", Vb(validate_clamp_variable)),
299    (Scopes::None, "clamp_variable", Vb(validate_clamp_variable)),
300    (Scopes::None, "clear_global_variable_list", Identifier("list name")),
301    (Scopes::None, "clear_local_variable_list", Identifier("list name")),
302    (Scopes::None, "clear_saved_scope", Identifier("scope name")),
303    (Scopes::None, "clear_variable_list", Identifier("list name")),
304    (Scopes::None, "custom_label", ControlOrLabel),
305    (Scopes::None, "custom_tooltip", ControlOrLabel),
306    (Scopes::None, "debug_log", Unchecked),
307    (Scopes::None, "debug_log_scopes", Boolean),
308    (Scopes::None, "else", Control),
309    (Scopes::None, "else_if", Control),
310    (Scopes::None, "hidden_effect", Control),
311    (Scopes::None, "if", Control),
312    (Scopes::None, "random", Control),
313    (Scopes::None, "random_list", Vbc(validate_random_list)),
314    (Scopes::all_but_none(), "remove_from_list", Vv(validate_remove_from_list)),
315    (Scopes::None, "remove_global_variable", Identifier("list name")),
316    (Scopes::None, "remove_list_global_variable", Vb(validate_add_to_variable_list)),
317    (Scopes::None, "remove_list_local_variable", Vb(validate_add_to_variable_list)),
318    (Scopes::None, "remove_list_variable", Vb(validate_add_to_variable_list)),
319    (Scopes::None, "remove_local_variable", Identifier("variable name")),
320    (Scopes::None, "remove_variable", Identifier("variable name")),
321    (Scopes::None, "round_global_variable", Vb(validate_round_variable)),
322    (Scopes::None, "round_local_variable", Vb(validate_round_variable)),
323    (Scopes::None, "round_variable", Vb(validate_round_variable)),
324    (Scopes::all_but_none(), "save_scope_as", Vv(validate_save_scope)),
325    (Scopes::None, "save_scope_value_as", Vb(validate_save_scope_value)),
326    (Scopes::all_but_none(), "save_temporary_scope_as", Vv(validate_save_scope)),
327    (Scopes::None, "save_temporary_scope_value_as", Vb(validate_save_scope_value)),
328    (Scopes::None, "set_global_variable", Vbv(validate_set_variable)),
329    (Scopes::None, "set_local_variable", Vbv(validate_set_variable)),
330    (Scopes::None, "set_variable", Vbv(validate_set_variable)),
331    (Scopes::None, "show_as_tooltip", Control),
332    (Scopes::None, "switch", Vb(validate_switch)),
333    (Scopes::None, "trigger_event", Vbv(validate_trigger_event)),
334    (Scopes::None, "while", Control),
335];