1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-02-07 13:31:54 +02:00

reduce turret activation delay with tech

This commit is contained in:
grilledham 2019-06-19 20:48:05 +01:00
parent d2e9b6f7bd
commit ae3f84667b
2 changed files with 28 additions and 1 deletions

View File

@ -403,6 +403,13 @@ global.config = {
['electric-turret'] = 60 * 15,
['fluid-turret'] = 60 * 20,
['artillery-turret'] = 60 * 10
},
-- reduce delay for each level of the tech
techs = {
['weapon-shooting-speed'] = {{turret_type = 'ammo-turret', amount = 60 * 26 / 6}},
['laser-turret-speed'] = {{turret_type = 'electric-turret', amount = 60 * 12 / 7}},
['refined-flammables'] = {{turret_type = 'fluid-turret', amount = 60 * 17 / 7}},
['artillery-shell-speed'] = {{turret_type = 'artillery-turret', amount = 60 * 2}}
}
}
}

View File

@ -4,6 +4,7 @@ local Token = require 'utils.token'
local config = require 'config'
local turret_types = config.turret_active_delay.turret_types
local techs = config.turret_active_delay.techs
local tau = 2 * math.pi
local start_angle = -tau / 4
@ -63,7 +64,7 @@ local function entity_built(event)
end
local delay = turret_types[entity.type]
if not delay then
if not delay or delay <= 0 then
return
end
@ -75,5 +76,24 @@ local function entity_built(event)
)
end
local function research_finished(event)
local research = event.research
local name = research.name:gsub('%-%d', '')
local data = techs[name]
if not data then
return
end
for _, turret_data in pairs(data) do
local turret_type = turret_data.turret_type
local amount = turret_data.amount
local old = turret_types[turret_type]
turret_types[turret_type] = math.max(old - amount, 0)
end
end
Event.add(defines.events.on_built_entity, entity_built)
Event.add(defines.events.on_robot_built_entity, entity_built)
Event.add(defines.events.on_research_finished, research_finished)