Page 1 of 1
(0.18) clouds with damage = 0 don't trigger event
Posted: Thu Jan 23, 2020 1:39 pm
by ownlyme
this is my cloud action:
Code: Select all
action =
{
type = "direct",
action_delivery =
{
type = "instant",
target_effects =
{
type = "nested-result",
action =
{
type = "area",
radius = 14,
entity_flags = {"placeable-off-grid"},
action_delivery =
{
type = "instant",
target_effects =
{
type = "damage",
damage = { amount = 0, type = "poison"}
}
}
}
}
}
}
i was using it for radiation damage in realistic reactors to find trees, players and vehicles with players inside, but in 0.18 it doesn't trigger the on_entity_damaged event anymore unless i increase the damage to 0.0001, but then it would damage stones which is unimmersive.
(and i'm not even complaining about the damaged animation playing on the tank for 0.0001 damage ... oops i actually did)
Re: (0.18) clouds with damage = 0 don't trigger event
Posted: Thu Jan 23, 2020 1:42 pm
by Klonan
Not a bug
This is the perfect use-case for the new script trigger effect
https://lua-api.factorio.com/latest/eve ... ger_effect
Re: (0.18) clouds with damage = 0 don't trigger event
Posted: Thu Jan 23, 2020 1:44 pm
by ownlyme
oh okay thanks.. i'll figure out that one then
Re: (0.18) clouds with damage = 0 don't trigger event
Posted: Thu Jan 23, 2020 1:46 pm
by Klonan
ownlyme wrote: ↑Thu Jan 23, 2020 1:44 pm
oh okay thanks.. i'll figure out that one then
Its super easy, just put something like this instead of the damage effect:
Code: Select all
{
type = "script",
effect_id = "radiation-damage"
}
and then in control lua:
Code: Select all
local on_script_trigger_effect = function(event)
if event.effect_id == "radiation-damage" then
do_radiation_damage(event)
end
end
Re: (0.18) clouds with damage = 0 don't trigger event
Posted: Thu Jan 23, 2020 1:49 pm
by ownlyme
thank you, very friendly
was already about to ask because it's not yet in the wiki
Re: (0.18) clouds with damage = 0 don't trigger event
Posted: Thu Jan 23, 2020 2:01 pm
by ownlyme
hmm the event doesn't contain a "target" or "target_position" variable.. am i doing it wrong?
(it does seem to trigger for every target)
Code: Select all
{
type = "direct",
action_delivery =
{
type = "instant",
target_effects =
{
type = "nested-result",
action =
{
type = "area",
radius = radius,
entity_flags = {"placeable-off-grid"},
action_delivery =
{
type = "instant",
target_effects =
{
type = "script",
effect_id = "radiation-damage"
}
}
}
}
}
}
Code: Select all
script.on_event(defines.events.on_script_trigger_effect,function(event)
game.print(event.target) --nil
if event.effect_id == "radiation-damage" and event.target then
....
Re: (0.18) clouds with damage = 0 don't trigger event
Posted: Thu Jan 23, 2020 2:11 pm
by posila
It's target_entity, the doc is wrong (also check source_entity, trigger system is super weird and sometimes source and target is not what one would expect)
EDIT: Just FYI, for "it would damage stones" there is also a system:
71657
Re: (0.18) clouds with damage = 0 don't trigger event
Posted: Thu Jan 23, 2020 2:16 pm
by ownlyme
that did the trick, thanks
source_entity always seems to be correct