So, you want to get on that sweet sweet targeted action, don't you? Have little flags next to the icons, code that's easier to write and maintain, dynamic targets… The whole jazz. But, just after you write one, you get that dreaded feeling, that pit in the stomach… Oh no. I can feel the game slowing down!. Well, no more! Just follow these simple practices to have your targeted decisions run as fast as possible!
Please note that this short guide focuses only on the performance aspect.
This part is the most important. You know how target_trigger
works - it checks countries/states, and those that match the trigger become decision targets. However, unless you limit the possible targets, every country or state in the game will be checked, every day! If you put in expensive triggers in there, it can really slow everything down. How can we limit targets, then, so that only a certain subset of entities is checked?
First way is to use targets = {}
. You simply put in the country tags, state IDs (depending on the type of your decision) or variables inside, and target_trigger
will run only on those. Common use cases:
You can also have it target dynamic countries with targets_dynamic = yes
in addition.
Very similar to targets
, but instead of predefining the possible values in the file, you can just use an array - again, built-in, or one you've set up yourself. If you use multiple target_array
s, they will be merged into one. Common use cases:
Make sure to use allowed
and target_root_trigger
to ensure that the target checking stage is only reached when really necessary. allowed
is only checked on game start and when a country spawns, therefore you should only put in tag
, original_tag
and has_dlc
triggers in it. target_root_trigger
is checked daily, and is similar to visible
- however, visible
is checked after targets have been selected 9and thus allows the use of FROM
), but target_root_trigger
is checked before that (and thus only has ROOT
). If target_root_trigger
fails, target_trigger
won't be ran at all. Compare the following:
Once a country/state meets the triggers in target_trigger
, it is added to possible targets. That means target_trigger
will not be ran for that particular country/state again. Make sure that you put in all checks (such as exists = yes
) in visible
instead.
This section applies to not only targeted decisions, but anything. Below are some common mistakes and how to fix them.
Questions? DM on Discord.
Yard