Allow trigger_target_mask to be an empty table
Posted: Wed Dec 15, 2021 4:18 pm
What?
Every entity prototype has a trigger_target_mask. If it is not specified, or if it is set to nil, it will default to {"common"}. If empty lists could be used, modders would be able to create entity prototypes that can't be attacked, without wasting valuable resources. However, currently assigning an empty list will crash the game on loading.Why?
The trigger_target_mask of an entity prototype is an array of TriggerTargetType. Given two prototypes A and B, if A.trigger_target_mask and B.attack_target_mask have at least one TriggerTargetType in common, entities based on A may be attacked by entities based on B unless A.trigger_target_mask and B.ignore_target_mask share a TriggerTargetType as well.A mod can define a new TriggerTargetType and add it to the trigger_target_mask of one entity prototype as well as the ignore_target_mask of other entity prototypes to prevent attacks. However, TriggerTargetTypes are a rare asset, as only 56 instances may be defined. There may be different mods that want to protect their entity prototypes by creating a new TriggerTargetType. It's likely that each mod would use its own TriggerTargetType. As only so few of these can be created, using multiple TriggerTargetTypes to the same end seems like a waste of valuable resources.
Solution
If entity prototype were allowed to have an empty trigger_target_mask (i.e. "{ }"), there would be nothing in it that could match a TriggerTargetType from any attack_target_mask. Thus, entities based on such a prototype could never be attacked, while no new TriggerTargetType would have to be created. Even better: As no new TriggerTargetType has been defined, it would also be unnecessary to change any ignore_target_mask!In most cases, the default trigger_target_mask -- i.e. {"common"} -- is what should be used, so I'm not arguing for changing the default value. But if somebody intentionally changes the trigger_target_mask to an empty list, it's likely done for a reason and should not break the game.