Fix scorched earth on_robot_built_entity (#7)
This commit is contained in:
@@ -88,25 +88,14 @@ Event.add(defines.events.on_player_changed_position, function(event)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
-- When an entity is build there is a much higher chance that the tiles will degrade
|
-- When an entity is build there is a much higher chance that the tiles will degrade
|
||||||
Event.add(defines.events.on_built_entity, function(event)
|
local function on_built_entity(event)
|
||||||
local entity = event.created_entity
|
local entity = event.entity
|
||||||
local surface = entity.surface
|
local strength = get_tile_strength(entity.surface, entity.position)
|
||||||
local position = entity.position
|
|
||||||
local strength = get_tile_strength(surface, position)
|
|
||||||
if not strength then return end
|
if not strength then return end
|
||||||
if get_probability(strength) * config.weakness_value > math.random() then
|
if get_probability(strength) * config.weakness_value > math.random() then
|
||||||
degrade_entity(entity)
|
degrade_entity(entity)
|
||||||
end
|
end
|
||||||
end)
|
end
|
||||||
|
|
||||||
-- Same as above but with robots
|
Event.add(defines.events.on_built_entity, on_built_entity)
|
||||||
Event.add(defines.events.on_robot_built_entity, function(event)
|
Event.add(defines.events.on_robot_built_entity, on_built_entity)
|
||||||
local entity = event.created_entity
|
|
||||||
local surface = entity.surface
|
|
||||||
local position = entity.position
|
|
||||||
local strength = get_tile_strength(surface, position)
|
|
||||||
if not strength then return end
|
|
||||||
if get_probability(strength) * config.weakness_value > math.random() then
|
|
||||||
degrade_entity(entity)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user