Biter Detector Sentinel Combinator deprecated

by mk-fg

Adds Sentinel Alarm and Combinator buildings that detect biters within configurable range, sending signals to connected circuit network.

Content
1 year, 9 months ago
0.18 - 1.1
1.71K
Circuit network

g Thank you!

4 years ago

You have no idea how much I have wanted this to exist.

Now I can do cool stuff with colliding turret projectiles and gates :)

4 years ago
(updated 4 years ago)

I was also thinking that maybe these can work nicely with pitch ditches from Firefly Stronghold games - https://www.youtube.com/watch?v=zITBaZ99DyE&t=13m27s - though maybe that's a bit too medievial for factorio.

4 years ago

Hm, also, for turrets/gates, maybe there should be an option to not require radar to be there, so that detector can be more compact.

Not sure if you can rely on having such detectors by every turret/wall section however - they do "surface.find_entities_filtered" on interval (scan for biters), and maybe that can be costly performance-wise, though I did not test it - can probably be done by placing 1000+ of these and using debug hotkeys to see how much cpu time mod takes on each game tick.
Linking the thing to a radar hopefully provides enough disincentive for people to use them sparingly and introduces some power cost, so that performance shouldn't be an issue, but there's really no other reason to require radar to be there.

4 years ago

maybe there should be an option to not require radar to be there, so that detector can be more compact.

Added an option for that in 0.0.2.

4 years ago

Couple of performance thoughts:

surface.count_entities_filtered() claims to be more efficient than find.

surface.find_nearest_enemy() would handle the most common use I can think of, and is probably even faster.

I'm also wondering if you could do something fancy with a zero-damage turret, and detect when it's "firing" with LuaEntity::shooting_target to be even faster than that.

4 years ago

Indeed, all these sound like great potential optimizations over simple find_entities.
Not entirely sure any of them are necessary though, as maybe find_entities is fast enough for pretty much all use-cases anyway.

Count and find_nearest_enemy can probably be used as a separate mode or with a separate detector entity, which doesn't check/count enemy types in range.
Turret idea is great for dedicated short-range detectors in particular, as it can also be used to point at a nearby biters with some custom graphics :)

4 years ago

I think any optimization can be beneficial considering the number of mods people tend to stack, especially with the larger world sizes.

4 years ago

Number of other mods shouldn't really affect performance of this one - i.e. if game will lag because of them, nothing in this one will affect it.
Don't think world size itself should be an issue either (esp. since factorio "unloads" the chunks far from players iirc), just the number of these devices you deploy and the range on them.

4 years ago

I think any optimization can be beneficial considering the number of mods people tend to stack

This can also be read as "every mod should be as optimized as possible, because it all adds up", which I missed above, and that's fair and indeed a good point.

4 years ago
(updated 4 years ago)

According to the wiki, switching find to count should be almost as simple as changing the function name.

And the main use I would personally have for these is giving me a reliable (and simple!) "are there biters about to attack this wall section" detector, so I can power up laser turrets, reconfigure gate sections, and maybe even use that forcefield mod that I've been eyeing for years.

So I'm expecting one per map-chunk of wall to be the standard quantity to expect.

4 years ago
(updated 4 years ago)

According to the wiki, switching find to count should be almost as simple as changing the function name.

I've switched to https://lua-api.factorio.com/latest/LuaSurface.html#LuaSurface.find_units which is documented as being faster than find_entities and skips nests and worms (which are kinda noise anyway), not sure how it compares against that, but any serious optmization should probably be tested either way.
(e.g. could be that some lua loop or changing parameters on combinator is 100x more expensive than all this stuff)

And the main use I would personally have for these is giving me a reliable (and simple!) "are there biters about to attack this wall section" detector

Yeah, I think it's better to have much simplier radar-less detector for just this (and more optimized for such common use-case), and more complicated one for other more general cases.

4 years ago

Thanks for being open to these changes, performance was the one concern that was keeping me from downloading. Why not use find_enemy_units, by the way?

4 years ago
(updated 4 years ago)

performance was the one concern that was keeping me from downloading

I think it generally only goes away with a lot of people using the mod in different use-cases, some of which might be similar to yours.
With most mods of less than few-kilousers, it's probably easier to test, as any simple statement about performance is very relative - mod that says that it's "heavy" might be way lighter than a random trivial one that's just made by e.g. a first-time developer.
Factorio has "show times" or somesuch checkbox in Shift-F4 debug panel, you can use that to check how much cpu-time each mod takes atm.

Why not use find_enemy_units, by the way?

It should get all enemies of the player, which are not just biters, and on any force.
Probably does exact same thing as find_units with force=player condition=enemy anyway.

4 years ago

any serious optmization should probably be tested either way.

I'll be using this in my next modded game, so I'll try to remember to let you know how it goes :-)

Yeah, I think it's better to have much simplier radar-less detector for just this (and more optimized for such common use-case), and more complicated one for other more general cases.

Absolutely.

But I think it fits in this mod, if you're willing to add and maintain it.

It should get all enemies of the player, which are not just biters, and on any force.

Just thought of a possible issue: How does this work in PvP games?

4 years ago
(updated 4 years ago)

But I think it fits in this mod, if you're willing to add and maintain it.

It does, was just looking where to steal a sprite for it... something looking like an alarm beacon with red light.
Given that it'd be a combinator enabling when enemy is detected, it can have whatever on/off light overlay, so why not make it look all menacing?
Not a pixel artist however, so mostly just browsing spriters-resource.com and such for something to "appropriate" :)

Just thought of a possible issue: How does this work in PvP games?

Yeah, that's what I picked find_units{force=enemy, condition=same} over find_enemy_units(force=player) - latter should detect all units hostile to player, not just biters, and that's not what I want.

4 years ago

Krastorio2 is under GPL, maybe ask Krastor if you can use the Sentinel graphic from that?

It's a little rotating camera on a stand, and what it does in krastorio2 is pretty useless. You'd probably want to change the colour away from industrial yellow though.

4 years ago

I've actually looked at that one, but problem is that it A) can't be rotating in constant combinator and B) needs wire connection points.
And without rotation that thing looks either like a box or a bit broken.

Here's my current idea: https://e.var.nz/shot-2020-08-11_20-26-20.jpg
It's a base of turret from fallout tactics, top of air alarm siren from there, and leads/wires from constant combinator sprite.
Looks a bit dull, but I like the idea of it having just one rotation, given that it should just be a small vertical tower.

4 years ago

That doesn't look bad.

4 years ago
(updated 4 years ago)

Added these "Sentinel Alarm" towers in 0.0.6.

They use find_nearest_enemy() and only need red/green wire to function, sending whatever signals are set on them, enabling/disabling on proximity.
That algo uses circular area, not square, unlike find_entities() and such, probably because it's same algo as turrets use.
Also it picks up any hostiles, not just biters.

R range signal should work the same on them.
T signal can be set there to trigger on player instead of biters, to test range and effects and such.
Range can probably be drawn too, as 0.17 added that api, but there're plenty of mods with "measuring tape" around, shouldn't be necessary.

New response