mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-24 03:47:58 +02:00
threat farming nerf
This commit is contained in:
parent
12c3cf8d34
commit
779fabfefd
@ -176,6 +176,7 @@ event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
|
||||
require "maps.biter_battles_v2.on_tick"
|
||||
require "maps.biter_battles_v2.terrain"
|
||||
require "maps.biter_battles_v2.no_turret_creep"
|
||||
require "maps.biter_battles_v2.chat"
|
||||
require "maps.biter_battles_v2.bb_map_intro"
|
||||
require "modules.custom_death_messages"
|
51
maps/biter_battles_v2/no_turret_creep.lua
Normal file
51
maps/biter_battles_v2/no_turret_creep.lua
Normal file
@ -0,0 +1,51 @@
|
||||
local event = require 'utils.event'
|
||||
|
||||
local type_blacklist = {
|
||||
["ammo-turret"] = true,
|
||||
["artillery-turret"] = true,
|
||||
["electric-turret"] = true,
|
||||
["fluid-turret"] = true
|
||||
}
|
||||
|
||||
local function on_built_entity(event)
|
||||
local entity = event.created_entity
|
||||
if not entity.valid then return end
|
||||
if not type_blacklist[event.created_entity.type] then return end
|
||||
local surface = event.created_entity.surface
|
||||
local spawners = surface.find_entities_filtered({type = "unit-spawner", area = {{entity.position.x - 70, entity.position.y - 70}, {entity.position.x + 70, entity.position.y + 70}}})
|
||||
if #spawners == 0 then return end
|
||||
|
||||
local allowed_to_build = true
|
||||
|
||||
for _, e in pairs(spawners) do
|
||||
if (e.position.x - entity.position.x)^2 + (e.position.y - entity.position.y)^2 < 4096 then
|
||||
allowed_to_build = false
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if allowed_to_build then return end
|
||||
|
||||
if event.player_index then
|
||||
game.players[event.player_index].insert({name = entity.name, count = 1})
|
||||
else
|
||||
local inventory = event.robot.get_inventory(defines.inventory.robot_cargo)
|
||||
inventory.insert({name = entity.name, count = 1})
|
||||
end
|
||||
|
||||
surface.create_entity({
|
||||
name = "flying-text",
|
||||
position = entity.position,
|
||||
text = "Turret is too close to spawner!",
|
||||
color = {r=0.98, g=0.66, b=0.22}
|
||||
})
|
||||
|
||||
entity.destroy()
|
||||
end
|
||||
|
||||
local function on_robot_built_entity(event)
|
||||
on_built_entity(event)
|
||||
end
|
||||
|
||||
event.add(defines.events.on_robot_built_entity, on_robot_built_entity)
|
||||
event.add(defines.events.on_built_entity, on_built_entity)
|
Loading…
x
Reference in New Issue
Block a user