Design discussion: Trigger target type

Place to post guides, observations, things related to modding that are not mods themselves.
posila
Factorio Staff
Factorio Staff
Posts: 5313
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Design discussion: Trigger target type

Post by posila »

Introduction
In 0.17.46, to fix "gate cannot survive spiter acid on ground" we have added prototype type "trigger-target-type" and added property "trigger_target_mask" to entity prototypes and trigger item definition (used in acid_splash_fire in demo-spitter-projectiles.lua). Additionaly, utility-constants contain default_trigger_target_mask_by_type.

Intention is to crate more flexible system for entity filtering inside of trigger. So some triggers can have some specific effects for different targets. Something like unit attributes in Starcraft - unit can be biological, mechanical or both; light/armored; ground/air; and some other units have weaker or stronger attacks towards certain attributes.

The game can load up to 64 "trigger-target-type" definitions (of which 10 are reserved for internal use at the moment), and for start there are 2 target types in the base game - "common", and "ground-unit". "common" is intrinsic and is used as default target type for entities that don't have target type defined in their prototype nor in utility-constants.
Design
The feature is intentionaly pretty basic at the moment, just to solve the bug; I didn't want to just throw random ideas into it for it to just blow back into my face, and also the more complex feature, the more bugs it will introduce, which is not great when we try to push out the first 0.17 stable. Also at the moment there is no plan to reflect this in tooltips in any way - entities won't show what their target type mask is, nor will damage-dealing things show they have different effects on different things.

What capabilities do you think would be useful?
What target types do you think should be defined in the base game and what should be default masks for individual entity types?

Here is list of my random ideas.
Data stage
  • Matching mode configuration on trigger (matches-any, matches-all, matches-exact, matches-not-all, matches-not-any, ... ?)
  • trigger_target_mask on armor item, that would override character's mask when equipped.
  • Add trigger_target_mask also to some trigger effect item ("damage", "create-sticker") to possibly replace the single purpose properties like "apply_damage_to_trees"
Control stage
  • Query trigger_target_mask of a prototype or entity (obviously). How it should work, though?
    At first, it might seem it should work as querying collision_mask. You get dictionary of collision_layer -> bool, but trigger_target_mask can have up to 4 times more entries, and I am worried about performance overhead of creating such large tables. So maybe it would be better to have function LuaEntity::matches_trigger_target_mask(matching_mode, list_of_target_types)
  • Allow to use as filter in find_entities

User avatar
Earendel
Factorio Staff
Factorio Staff
Posts: 716
Joined: Sun Nov 23, 2014 11:57 am
Contact:

Re: Design discussion: Trigger target type

Post by Earendel »

I'm starting to implement this in some of the stuff I am working on.

I'm setting a "flammable" tag on tree most tree entities, but not all tree entities are real trees so the tag can be removed from things that shouldn't catch fire.

I will also be using tags for "flying" entities, "biological" entities, and "mechanical" in the future.

It would be useful to have a nestable trigger_target_filter, so that you can combine required and excluded tags, e.g:

Code: Select all

{
  type = area,
  radius = 8,
  trigger_target_filter = { 
    type = "trigger-target-filter",
    match_mode = "matches-any",
    trigger_target_mask = {"biological"},
    trigger_target_filter = {
      type = "trigger-target-filter",
      match_mode = "matches-not-any",
      trigger_target_mask = {"flying"},
    }
  }
}
In this example it would exclude enemies that have the flying tag, then require the biological tag, i.e. only land based biological entities are affected by the puddle of infections material.

Post Reply

Return to “Modding discussion”