mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 03:25:23 +09:00
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)
|
||||
|
||||
-- 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 entity = event.created_entity
|
||||
local surface = entity.surface
|
||||
local position = entity.position
|
||||
local strength = get_tile_strength(surface, position)
|
||||
local function on_built_entity(event)
|
||||
local entity = event.entity
|
||||
local strength = get_tile_strength(entity.surface, entity.position)
|
||||
if not strength then return end
|
||||
if get_probability(strength) * config.weakness_value > math.random() then
|
||||
degrade_entity(entity)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- Same as above but with robots
|
||||
Event.add(defines.events.on_robot_built_entity, function(event)
|
||||
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)
|
||||
Event.add(defines.events.on_built_entity, on_built_entity)
|
||||
Event.add(defines.events.on_robot_built_entity, on_built_entity)
|
||||
|
||||
Reference in New Issue
Block a user