Add LuaEntity::pollute

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
DeadMG
Fast Inserter
Fast Inserter
Posts: 101
Joined: Thu Oct 22, 2020 7:56 am
Contact:

Add LuaEntity::pollute

Post 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.
protocol_1903
Filter Inserter
Filter Inserter
Posts: 304
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Re: Add LuaEntity::pollute

Post by protocol_1903 »

+1
If you need to reach me, message me on discord.

I make qol mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903
If you have a mod idea, I can look into it.
Rseding91
Factorio Staff
Factorio Staff
Posts: 16048
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Add LuaEntity::pollute

Post 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.
If you want to get ahold of me I'm almost always on Discord.
Atraps003
Fast Inserter
Fast Inserter
Posts: 117
Joined: Thu Jan 04, 2018 6:34 am
Contact:

Re: Add LuaEntity::pollute

Post 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)
Post Reply

Return to “Modding interface requests”