Aoe damage from fluid turret
Posted: Sat Apr 25, 2020 11:04 am
Hi I'm trying to make a fluid turret "spray" acid all around itself for aoe damage to biters. I am modding a fluid turret to do this and have thought of two approaches to get it to work:
1) All biters within range will be attacked rapidly in a round-robin fashion to simulate area damage. I cannot figure out a way to do this with stream damage type.
2) The turret attacks itself (0,0) with enemy-only damage. Unfortunately I also cannot figure out how to do this, as all ammo types seem to auto select enemies?
How can I gain more control over what my turret attacks? Alternatively is there another approach that would work for this turret? Something like exploding a poison capsule at the turret position?
EDIT: I've kinda got this working using an onTick event handler and just overriding damage using code. No idea if this is the best approach, it seems slightly inefficient, but perhaps not if the game entity lookups are highly efficient.
1) All biters within range will be attacked rapidly in a round-robin fashion to simulate area damage. I cannot figure out a way to do this with stream damage type.
2) The turret attacks itself (0,0) with enemy-only damage. Unfortunately I also cannot figure out how to do this, as all ammo types seem to auto select enemies?
How can I gain more control over what my turret attacks? Alternatively is there another approach that would work for this turret? Something like exploding a poison capsule at the turret position?
EDIT: I've kinda got this working using an onTick event handler and just overriding damage using code. No idea if this is the best approach, it seems slightly inefficient, but perhaps not if the game entity lookups are highly efficient.
Code: Select all
local Public = {}
function Public.onTick(e)
-- AOE damage
if e.tick % 20 == 0 then
for _, turret in pairs(game.surfaces[1].find_entities_filtered{name="acidturret"}) do
local enemiesInRange = turret.surface.find_entities_filtered{
position = turret.position,
radius = turret.prototype.attack_parameters.range,
direction = turret.direction,
force = "enemy"
}
for _, target in pairs(enemiesInRange) do
target.damage(2, "enemy", "acid")
end
end
end
end
return Public