-
Notifications
You must be signed in to change notification settings - Fork 0
Home
https://github.com/Refactorio/RedMew/issues/283 - Increase biter aggression
Purpose: Increase biter threat level over time Every chunk has a chance of attack Threat buildup is based on evolution Lights reduce rate of threat buildup in a chunk
pseudo:
chunkIndex [x][y] = index in chunkIndex
chunks = [
chunk{
lamps: #
threat: #
power: %
lamps[
entity, entity, ...
]
}..
]
chunks_count = #chunks
chunk_scan_index = 0
scan_start = 0
next_chunk_to_attack = chunk
chunk_to_attack = chunk
next_attack_tick = 0
attackers = 0
min_attack_minutes 1
max_attack_minutes 10
max_attackers_per_minute 10
chunk_rescan_cooldown_minutes = 2
on tick {
scan_chunk
if game tick > next_attack_tick
do_attack
}
do_attack {
if game tick = next_attack_tick + 1
attackers = max_attackers_per_minute * attackers * evo (10 * 10 min * .1 = 10)
spawners = attackers/10
find somewhere for spawners
if game tick % 6
find somewhere for attacker
attackers -= 1
if attackers < 1
next_attack_tick = next attack in 1 to 10 minutes
attackers = # of minutes
}
scan_chunk{
if scan_start < tick
return
chunk_scan_index ++
if chunk_scan_index >= chunks_count
chunk_scan_index = 1
scan_start += chunk_rescan_cooldown_minutes*3600
chunk = chunks[chunk_scan_index]
check power on a lamp, use to adjust chunk power
chunk.threat += evo / (lamps / power)
set next_chunk_to_attack if higher than current
}
on lamp created{
lamps++ for the chunk
}
on lamp destroyed{
lamps-- for the chunk
}
Cave miner snip: https://github.com/M3wM3w/ComfyFactorio/blob/master/maps/cave_miner.lua#L1040-L1054
wishlist:
- Put a decoration there, to show that it will happen
- Slowly start creating spawners
- Keep increasing until found by a player (player enters chunk?)
- Weapons in a chunk decrease threat by x% every scan?
https://lua-api.factorio.com/latest/LuaSurface.html#LuaSurface.get_random_chunk
https://lua-api.factorio.com/latest/LuaSurface.html#LuaSurface.find_non_colliding_position
https://lua-api.factorio.com/latest/LuaSurface.html#LuaSurface.get_closest
https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.darkness_for_all_lamps_on https://lua-api.factorio.com/latest/LuaEntityPrototype.html#LuaEntityPrototype.min_darkness_to_spawn
https://lua-api.factorio.com/latest/LuaRendering.html#LuaRendering.draw_light
https://lua-api.factorio.com/latest/LuaRendering.html#LuaRendering.get_players
https://lua-api.factorio.com/latest/LuaPlayer.html#LuaPlayer.add_custom_alert https://lua-api.factorio.com/latest/LuaControl.html#LuaControl.position