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.
Add LuaEntity::pollute
-
- Filter Inserter
- Posts: 304
- Joined: Fri Sep 09, 2022 4:33 pm
- Contact:
Re: Add LuaEntity::pollute
+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.
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.
Re: Add LuaEntity::pollute
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 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.
Re: Add LuaEntity::pollute
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)