mirror of
https://github.com/PHIDIAS0303/factorio-mod-PHI.git
synced 2026-06-27 05:46:22 +09:00
278 lines
13 KiB
Lua
278 lines
13 KiB
Lua
local items = require('mbm-c')
|
|
|
|
|
|
|
|
local mod_tint = {
|
|
[2] = {r=140, g=142, b=200},
|
|
[3] = {r=242, g=161, b=26},
|
|
[4] = {r=255, g=254, b=42},
|
|
[5] = {r=54, g=228, b=255},
|
|
[6] = {r=253, g=0, b=97},
|
|
[7] = {r=0, g=209, b=102},
|
|
[8] = {r=233, g=63, b=233}
|
|
}
|
|
|
|
function main_entity(source, tier)
|
|
local item = table.deepcopy(data.raw[source.type][source.ref_name])
|
|
item.name = source.name .. '-' .. tier
|
|
item.minable.result = item.name
|
|
item.max_health = item.max_health * (tier - source.min + 2)
|
|
item.next_upgrade = ((tier < source.max) and source.name .. '-' .. (tier + 1)) or nil
|
|
|
|
if item['crafting_speed'] then
|
|
item['crafting_speed'] = tonumber(string.match(item['crafting_speed'], '[%d%.]+')) * (2 ^ (tier - source.min + 1))
|
|
end
|
|
|
|
for _, v in pairs({'energy_usage', 'heating_energy', 'crane_energy_usage', 'energy_per_shot'}) do
|
|
if item[v] then
|
|
item[v] = (tonumber(string.match(item[v], '[%d%.]+')) * (2 ^ (tier - source.min + 1))) .. (string.match(item[v], '%a+') or '')
|
|
end
|
|
end
|
|
|
|
if item.energy_source then
|
|
for _, v in pairs({'buffer_capacity', 'input_flow_limit', 'output_flow_limit'}) do
|
|
if item.energy_source[v] then
|
|
item.energy_source[v] = tonumber(string.match(item.energy_source[v], '[%d%.]+')) * (2 ^ (tier - source.min + 1)) .. string.match(item.energy_source[v], '%a+')
|
|
end
|
|
end
|
|
|
|
if item.energy_source.emissions_per_minute then
|
|
for k, _ in pairs(item.energy_source.emissions_per_minute) do
|
|
item.energy_source.emissions_per_minute[k] = item.energy_source.emissions_per_minute[k] * (2 ^ (tier - source.min + 1))
|
|
end
|
|
end
|
|
end
|
|
|
|
if (source.type == 'electric-turret') or (source.type == 'ammo-turret') or (source.type == 'fluid-turret') then
|
|
if item.attack_parameters then
|
|
item.attack_parameters.damage_modifier = 2 ^ (tier - source.min + 1)
|
|
item.attack_parameters.range = item.attack_parameters.range + (2 * (tier - source.min + 1))
|
|
item.attack_parameters.cooldown = (item.attack_parameters.cooldown and (item.attack_parameters.cooldown * ((24 - tier + source.min) / 25))) or nil
|
|
end
|
|
|
|
item.call_for_help_radius = (item.call_for_help_radius and (item.call_for_help_radius + (2 * (tier - source.min + 1)))) or nil
|
|
|
|
if source.type == 'electric-turret' then
|
|
item.glow_light_intensity = 1
|
|
|
|
if item.attack_parameters then
|
|
item.attack_parameters.damage_modifier = (item.attack_parameters.damage_modifier and (item.attack_parameters.damage_modifier * 2)) or nil
|
|
|
|
if item.attack_parameters.ammo_type then
|
|
item.attack_parameters.ammo_type.action.action_delivery.max_length = ((item.attack_parameters.ammo_type.action and item.attack_parameters.ammo_type.action.action_delivery and item.attack_parameters.ammo_type.action.action_delivery.max_length) and (item.attack_parameters.ammo_type.action.action_delivery.max_length + (2 * (tier - source.min + 1)))) or nil
|
|
item.attack_parameters.ammo_type.energy_consumption = (item.attack_parameters.ammo_type.energy_consumption and (tonumber(string.match(item.attack_parameters.ammo_type.energy_consumption, '[%d%.]+')) * (2 ^ (tier - source.min + 1)) .. string.match(item.attack_parameters.ammo_type.energy_consumption, '%a+'))) or nil
|
|
end
|
|
end
|
|
|
|
elseif source.type == 'fluid-turret' then
|
|
item.prepare_range = item.prepare_range + (2 * (tier - source.min + 1))
|
|
end
|
|
end
|
|
|
|
if (source.type == 'lab') then
|
|
if item['researching_speed'] then
|
|
item['researching_speed'] = tonumber(string.match(item['researching_speed'], '[%d%.]+')) * (2 ^ (tier - source.min + 1))
|
|
end
|
|
|
|
for _, c in pairs({'on_animation', 'off_animation'}) do
|
|
if item[c] and item[c].layers then
|
|
for _, l in pairs(item[c].layers) do
|
|
if not l.draw_as_shadow then
|
|
l.tint = mod_tint[tier]
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
elseif (source.type == 'mining-drill') then
|
|
if item['mining_speed'] then
|
|
item['mining_speed'] = tonumber(string.match(item['mining_speed'], '[%d%.]+')) * (2 ^ (tier - source.min + 1))
|
|
end
|
|
|
|
for _, e in pairs({'graphics_set', 'wet_mining_graphics_set'}) do
|
|
if item[e] and item[e].animation then
|
|
for _, d in pairs(item[e].animation) do
|
|
if d.layers then
|
|
for _, l in pairs(d.layers) do
|
|
if not l.draw_as_shadow then
|
|
l.tint = mod_tint[tier]
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
elseif source.type == 'radar' then
|
|
item.max_distance_of_sector_revealed = item.max_distance_of_sector_revealed + (2 * (tier - source.min + 1))
|
|
item.max_distance_of_nearby_sector_revealed = item.max_distance_of_nearby_sector_revealed + (2 * (tier - source.min + 1))
|
|
|
|
if item['pictures'] and item['pictures'].layers then
|
|
for _, l in pairs(item['pictures'].layers) do
|
|
if not l.draw_as_shadow then
|
|
l.tint = mod_tint[tier]
|
|
end
|
|
end
|
|
end
|
|
|
|
if item['integration_patch'] then
|
|
item['integration_patch'].tint = mod_tint[tier]
|
|
end
|
|
|
|
elseif source.type == 'thruster' then
|
|
for _, v in pairs({'min_performance', 'max_performance'}) do
|
|
item[v].fluid_usage = (item[v].fluid_usage and item[v].fluid_usage * (2 ^ (tier - source.min + 1))) or nil
|
|
end
|
|
|
|
if item['graphics_set'] then
|
|
if item['graphics_set']['animation'] then
|
|
item['graphics_set']['animation'].tint = mod_tint[tier]
|
|
end
|
|
|
|
if item['graphics_set']['integration_patch'] then
|
|
item['graphics_set']['integration_patch'].tint = mod_tint[tier]
|
|
end
|
|
end
|
|
|
|
elseif source.type == 'agricultural-tower' then
|
|
item.radius = item.radius + (1 * (tier - source.min + 1))
|
|
end
|
|
|
|
item.localised_name = (tier > 1 and {'phi-cl.combine', {'?', {'entity-name.' .. source.ref_name}, {'name.' .. source.ref_name}}, tostring(tier)}) or {'?', {'entity-name.' .. source.ref_name}, {'name.' .. source.ref_name}}
|
|
item.localised_description = {'?', {'entity-description.' .. source.ref_name}, {'description.' .. source.ref_name}}
|
|
|
|
data:extend({item})
|
|
end
|
|
|
|
function main_item(source, tier)
|
|
local item = table.deepcopy(data.raw.item[source.ref_name])
|
|
item.name = source.name .. ((tier > 1 and '-' .. tier) or '')
|
|
item['place_result'] = item.name
|
|
|
|
if item.icons and item.icons[1] then
|
|
item.icons[1].tint = mod_tint[tier]
|
|
|
|
elseif item.icon then
|
|
item.icons = {{icon = item.icon, icon_size = (item.icon_size and item.icon_size) or nil, tint = mod_tint[tier]}}
|
|
item.icon = nil
|
|
end
|
|
|
|
table.insert(item.icons, {icon = '__base__/graphics/icons/signal/signal_' .. tier .. '.png', icon_size = 64, scale = 0.25, shift = {12, 12}})
|
|
item.order = item.order .. tier
|
|
item.localised_name = (tier > 1 and {'phi-cl.combine', {'?', {'entity-name.' .. source.ref_name}, {'equipment-name.' .. source.ref_name}, {'item-name.' .. source.ref_name}, {'name.' .. source.ref_name}}, tostring(tier)}) or {'?', {'entity-name.' .. source.ref_name}, {'equipment-name.' .. source.ref_name}, {'item-name.' .. source.ref_name}, {'name.' .. source.ref_name}}
|
|
item.localised_description = {'?', {'entity-description.' .. source.ref_name}, {'equipment-description.' .. source.ref_name}, {'item-description.' .. source.ref_name}, {'description.' .. source.ref_name}}
|
|
|
|
data:extend({item})
|
|
end
|
|
|
|
function main_recipe(source, tier)
|
|
local result_name = source.name .. '-' .. tier
|
|
|
|
data:extend({{
|
|
type = 'recipe',
|
|
name = result_name,
|
|
icons = table.deepcopy(data.raw.item[source.ref_name].icons),
|
|
energy_required = 2,
|
|
enabled = false,
|
|
ingredients = {{type = 'item', name = (tier > source.min and (source.name .. '-' .. (tier - 1))) or source.ref_name, amount = 2}},
|
|
results = {{type = 'item', name = result_name, amount = 1}},
|
|
main_product = result_name,
|
|
localised_name = {'?', data.raw[source.type][result_name].localised_name, ''},
|
|
localised_description = {'?', data.raw[source.type][result_name].localised_description, ''}
|
|
}})
|
|
end
|
|
|
|
function main_technology(source, tier)
|
|
if not data.raw.technology[source.tech] then
|
|
return
|
|
end
|
|
|
|
if not data.raw.technology[source.tech].effects then
|
|
data.raw.technology[source.tech].effects = {}
|
|
end
|
|
|
|
table.insert(data.raw.technology[source.tech].effects, {type = 'unlock-recipe', recipe = source.name .. '-' .. tier})
|
|
end
|
|
|
|
function main_replace_group(source)
|
|
if not data.raw[source.type][source.ref_name].fast_replaceable_group then
|
|
data.raw[source.type][source.ref_name].fast_replaceable_group = source.ref_name
|
|
end
|
|
|
|
if source.max > 2 then
|
|
data.raw[source.type][source.name .. '-' .. 2].fast_replaceable_group = data.raw[source.type][source.ref_name].fast_replaceable_group
|
|
end
|
|
|
|
if source.max <= source.min then
|
|
return
|
|
end
|
|
|
|
for j=source.min + 1, source.max do
|
|
data.raw[source.type][source.name .. '-' .. j].fast_replaceable_group = data.raw[source.type][source.name .. '-' .. (j - 1)].fast_replaceable_group
|
|
end
|
|
end
|
|
|
|
-- MBE A 24 BASE ENTITY,RECIPE,RESEARCH_EFFECT
|
|
-- MBE A 24 SPACE_AGE ENTITY,RECIPE,RESEARCH_EFFECT
|
|
-- MBE A 2 QUALITY ENTITY,RECIPE,RESEARCH_EFFECT
|
|
for _, v in pairs(items) do
|
|
v.mod = v.mod or 'base'
|
|
v.min = v.min or 2
|
|
v.ref_name = v.ref_name or v.name
|
|
|
|
if (v.mod and mods[v.mod]) and (v.max >= v.min) and data.raw[v.type] and data.raw[v.type][v.ref_name] and not data.raw[v.type][v.ref_name].hidden then
|
|
v.category = v.category or 'item'
|
|
|
|
for j=v.min, v.max, 1 do
|
|
main_entity(v, j)
|
|
main_item(v, j)
|
|
main_recipe(v, j)
|
|
main_technology(v, j)
|
|
end
|
|
|
|
main_replace_group(v)
|
|
end
|
|
end
|
|
|
|
if data.raw['assembling-machine'] and data.raw['assembling-machine']['assembling-machine-1'] and settings.startup['PHI-MB-MACHINE'].value > 1 then
|
|
for i = 4, settings.startup['PHI-MB-MACHINE'].value + 2 do
|
|
if data.raw['assembling-machine']['assembling-machine-' .. i] then
|
|
data.raw['assembling-machine']['assembling-machine-' .. i].localised_name = {'phi-cl.combine', {'entity-name.assembling-machine-1'}, tostring(i)}
|
|
data.raw['item']['assembling-machine-' .. i].localised_name = {'phi-cl.combine', {'entity-name.assembling-machine-1'}, tostring(i)}
|
|
data.raw['recipe']['assembling-machine-' .. i].localised_name = {'phi-cl.combine', {'entity-name.assembling-machine-1'}, tostring(i)}
|
|
end
|
|
end
|
|
end
|
|
|
|
if data.raw['ammo-turret'] and data.raw['ammo-turret']['gun-turret'] and settings.startup['PHI-MB-MACHINE'].value > 1 then
|
|
for i = 1, 7 do
|
|
if data.raw.technology['physical-projectile-damage-' .. i] and data.raw.technology['physical-projectile-damage-' .. i].effects then
|
|
for _, j in pairs(data.raw.technology['physical-projectile-damage-' .. i].effects) do
|
|
if j.type and j.turret_id and j.type == 'turret-attack' and j.turret_id == 'gun-turret' then
|
|
for k = 2, settings.startup['PHI-MB-MACHINE'].value do
|
|
if data.raw['ammo-turret']['gun-turret-' .. k] then
|
|
table.insert(data.raw.technology['physical-projectile-damage-' .. i].effects, {type = 'turret-attack', turret_id = 'gun-turret-' .. k, modifier = j.modifier})
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
if data.raw['fluid-turret'] and data.raw['fluid-turret']['flamethrower-turret'] and settings.startup['PHI-MB-MACHINE'].value > 1 then
|
|
for i = 1, 7 do
|
|
if data.raw.technology['refined-flammables-' .. i] and data.raw.technology['refined-flammables-' .. i].effects then
|
|
for _, j in pairs(data.raw.technology['refined-flammables-' .. i].effects) do
|
|
if j.type and j.turret_id and j.type == 'turret-attack' and j.turret_id == 'flamethrower-turret' then
|
|
for k = 2, settings.startup['PHI-MB-MACHINE'].value do
|
|
if data.raw['fluid-turret']['flamethrower-turret-' .. k] then
|
|
table.insert(data.raw.technology['refined-flammables-' .. i].effects, {type = 'turret-attack', turret_id = 'flamethrower-turret-' .. k, modifier = j.modifier})
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|