Page 1 of 1

[Bilka] Allow optional "night only" and darkness threshold for spawners and units

Posted: Fri May 12, 2017 1:13 pm
by kyranzor
A tag on spawner type entities that spawn a variety of units having a tag for enabling a simple 'night only' spawn behaviour, and associated parameter (double data type, or whatever makes most sense for referring to the surface's 'darkness' value) as a threshold.

For example, a spitter spawner that spawns special varieties of spitters when darkness is above 0.5 (out of 1.0 being full night time).

Additionally, a unit entity tag for vulnerability to day time with specified threshold and 'effect' result (which may be damage, or slowness, or explosions etc).

Re: Allow optional "night only" and darkness threshold for spawners and units

Posted: Fri May 12, 2017 8:30 pm
by Aeternus
... and then mod them into zombies to turn Factorio into a sciency survival horror game? :D

Re: Allow optional "night only" and darkness threshold for spawners and units

Posted: Fri May 12, 2017 9:02 pm
by kyranzor
yeah that's the plan. why is that so funny? should be horrifying!

Re: Allow optional "night only" and darkness threshold for spawners and units

Posted: Sat May 13, 2017 1:17 pm
by 321freddy
You do already have the means to simlate this behaviour. The darkness of a surface can be read with LuaSurface->darkness. When this value reaches a specified limit (check in on_tick) do two things:
  • 1) Loop through every spawner on the surface and set it to active = false
    2) And either one of these:
    • Create a giant invisible poison cloud at the center of the map that has a custom damage type which every entity other than your special spitter has a 100% resistance for.
    • Or loop through every special spitter and "fast replace" it with a similar entity what has a negative healing_per_tick parameter. (See create_entity fast_replace)
After the night you can reverse the changes again. If you encounter performance issues spread the loops out over multiple ticks (or even minutes for a gradual effect).

Re: Allow optional "night only" and darkness threshold for spawners and units

Posted: Mon May 15, 2017 4:30 pm
by kyranzor
This is true, great points there 321freddy.

Re: [Bilka] Allow optional "night only" and darkness threshold for spawners and units

Posted: Thu Oct 04, 2018 5:30 am
by Bilka
Okay, I added EnemySpawnerPrototype::min_darkness_to_spawn and max_darkness_to_spawn for 0.17.