Page 1 of 1
Add LuaEntity::pollute
Posted: Tue Aug 26, 2025 1:15 pm
by DeadMG
Currently, you can add pollution to a surface, but this doesn't trigger attacks in the normal way. The modder can work around this with manually issuing attack commands, but this has a few drawbacks, like it's almost impossible to know what radius to set or how many biters to select to mirror "normal" behaviour.
I'd like to suggest a LuaEntity::pollute which adds pollution that is treated in exactly the same way as all normal pollution, and triggers normal attack behaviour towards the polluting entity. Ideally, the entity would be attacked even if it doesn't meet the normal criteria for doing so, like you could have the enemies attack the player character or a tree or something.
Re: Add LuaEntity::pollute
Posted: Tue Aug 26, 2025 3:48 pm
by protocol_1903
+1
Re: Add LuaEntity::pollute
Posted: Tue Aug 26, 2025 4:02 pm
by Rseding91
I think there might be some misunderstanding. All pollution is treated equal - created from an entity updating, or LuaSurface::pollute() - they all work the same. It's the biter logic that determines what it attacks when pollution reaches them. They specifically target *pollution emitting* entities when going to attack somewhere.
If they didn't do this, they would attack anything you've built - rails, power poles, pipes, belts - as long as it was within some pollution cloud when they decided to attack they would attack it.
We specifically don't want that to happen and so they target pollution emitting things as their first target priority.
Re: Add LuaEntity::pollute
Posted: Wed Aug 27, 2025 8:21 am
by Atraps003
I was going to recommend to use event on_unit_group_finished_gathering to issue commands to the group that form from surface.pollute but it doesn't seem to work consistently? Sometimes it works other times the attack group gathers up and forms from the pollution but when it's finished gathering it disperses and ignores any custom command given in the event. Seems like a bug but I'm not sure.
Code: Select all
script.on_event(defines.events.on_unit_group_finished_gathering, function(e)
local command = {
type = defines.command.compound,structure_type = defines.compound_command.return_last,commands ={
{type = defines.command.go_to_location,destination = {0, 0}},
{type = defines.command.attack_area,destination = {0, 0},radius = 16,distraction = defines.distraction.by_anything},
{type = defines.command.build_base,destination = {0, 0},distraction = defines.distraction.none,ignore_planner = true}}}
e.group.set_command(command)
end)