2018-07-31 12:51:02 +02:00
|
|
|
--local Global = require 'utils.global'
|
2018-07-20 23:01:34 +02:00
|
|
|
local Event = require 'utils.event'
|
|
|
|
|
2018-07-30 17:42:14 +02:00
|
|
|
local player_ammo_starting_modifiers = {
|
|
|
|
['artillery-shell'] = -0.75,
|
|
|
|
['biological'] = -0.5,
|
2019-01-25 02:14:26 +02:00
|
|
|
['bullet'] = -0.25,
|
2018-07-30 17:42:14 +02:00
|
|
|
['cannon-shell'] = -0.75,
|
|
|
|
['capsule'] = -0.5,
|
|
|
|
['electric'] = -0.5,
|
|
|
|
['flamethrower'] = -0.75,
|
|
|
|
['grenade'] = -0.5,
|
2019-01-25 02:14:26 +02:00
|
|
|
['landmine'] = -0.33,
|
2020-11-24 19:45:07 +02:00
|
|
|
['laser'] = -0.75,
|
2019-01-25 02:14:26 +02:00
|
|
|
['melee'] = 1,
|
2018-07-30 17:42:14 +02:00
|
|
|
['rocket'] = -0.5,
|
2019-01-14 13:10:34 +02:00
|
|
|
['shotgun-shell'] = -0.20
|
2018-07-30 17:42:14 +02:00
|
|
|
}
|
|
|
|
|
2018-07-31 12:51:02 +02:00
|
|
|
local player_ammo_research_modifiers = {
|
|
|
|
['artillery-shell'] = -0.75,
|
|
|
|
['biological'] = -0.5,
|
2019-01-14 13:10:34 +02:00
|
|
|
['bullet'] = -0.20,
|
2018-07-31 12:51:02 +02:00
|
|
|
['cannon-shell'] = -0.75,
|
2020-11-24 19:45:07 +02:00
|
|
|
['capsule'] = -0.5,
|
2018-07-31 12:51:02 +02:00
|
|
|
['electric'] = -0.6,
|
|
|
|
['flamethrower'] = -0.75,
|
|
|
|
['grenade'] = -0.5,
|
|
|
|
['landmine'] = -0.5,
|
2020-11-24 19:45:07 +02:00
|
|
|
['laser'] = -0.75,
|
2018-07-31 12:51:02 +02:00
|
|
|
['melee'] = -0.5,
|
|
|
|
['rocket'] = -0.5,
|
2019-01-14 13:10:34 +02:00
|
|
|
['shotgun-shell'] = -0.20
|
2018-07-31 12:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
local player_turrets_research_modifiers = {
|
2018-08-04 00:26:44 +02:00
|
|
|
['gun-turret'] = -0.5,
|
2018-07-31 12:51:02 +02:00
|
|
|
--['laser-turret'] = -0.75,
|
|
|
|
['flamethrower-turret'] = -0.75
|
|
|
|
}
|
|
|
|
|
2018-07-30 17:42:14 +02:00
|
|
|
local enemy_ammo_starting_modifiers = {
|
|
|
|
['artillery-shell'] = 0,
|
|
|
|
['biological'] = 0,
|
|
|
|
['bullet'] = 0,
|
|
|
|
['cannon-shell'] = 0,
|
|
|
|
['capsule'] = 0,
|
|
|
|
['electric'] = 0,
|
|
|
|
['flamethrower'] = 0,
|
|
|
|
['grenade'] = 0,
|
|
|
|
['landmine'] = 0,
|
2020-11-24 19:45:07 +02:00
|
|
|
['laser'] = 0,
|
2018-07-30 17:42:14 +02:00
|
|
|
['melee'] = 0,
|
|
|
|
['rocket'] = 0,
|
|
|
|
['shotgun-shell'] = 0
|
|
|
|
}
|
|
|
|
|
|
|
|
local enemy_ammo_evolution_modifiers = {
|
|
|
|
['artillery-shell'] = 1,
|
2019-03-16 15:08:44 +02:00
|
|
|
['biological'] = 1,
|
2018-07-30 17:42:14 +02:00
|
|
|
['bullet'] = 1,
|
|
|
|
--['cannon-shell'] = 1,
|
|
|
|
--['capsule'] = 1,
|
|
|
|
--['electric'] = 1,
|
|
|
|
['flamethrower'] = 2,
|
|
|
|
--['grenade'] = 1,
|
|
|
|
--['landmine'] = 1,
|
2020-11-24 19:45:07 +02:00
|
|
|
['laser'] = 2,
|
2018-07-30 17:42:14 +02:00
|
|
|
['melee'] = 2
|
|
|
|
--['rocket'] = 1,
|
|
|
|
--['shotgun-shell'] = 1
|
|
|
|
}
|
|
|
|
|
2018-07-20 23:01:34 +02:00
|
|
|
local function init_weapon_damage()
|
|
|
|
local forces = game.forces
|
|
|
|
local p_force = forces.player
|
2018-07-30 17:42:14 +02:00
|
|
|
local e_force = forces.enemy
|
2018-07-20 23:01:34 +02:00
|
|
|
|
2018-07-30 17:42:14 +02:00
|
|
|
for k, v in pairs(player_ammo_starting_modifiers) do
|
|
|
|
p_force.set_ammo_damage_modifier(k, v)
|
2018-07-20 23:01:34 +02:00
|
|
|
end
|
|
|
|
|
2018-07-30 17:42:14 +02:00
|
|
|
for k, v in pairs(enemy_ammo_starting_modifiers) do
|
|
|
|
e_force.set_ammo_damage_modifier(k, v)
|
|
|
|
end
|
2018-07-20 23:01:34 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function enemy_weapon_damage()
|
|
|
|
local f = game.forces.enemy
|
|
|
|
|
2018-07-30 17:42:14 +02:00
|
|
|
local ef = f.evolution_factor
|
2018-07-20 23:01:34 +02:00
|
|
|
|
2018-07-30 17:42:14 +02:00
|
|
|
for k, v in pairs(enemy_ammo_evolution_modifiers) do
|
|
|
|
local base = enemy_ammo_starting_modifiers[k]
|
|
|
|
|
|
|
|
local new = base + v * ef
|
|
|
|
f.set_ammo_damage_modifier(k, new)
|
|
|
|
end
|
2018-07-20 23:01:34 +02:00
|
|
|
end
|
|
|
|
|
2018-07-30 17:42:14 +02:00
|
|
|
local function research_finished(event)
|
|
|
|
local r = event.research
|
|
|
|
local p_force = r.force
|
|
|
|
|
|
|
|
for _, e in ipairs(r.effects) do
|
|
|
|
local t = e.type
|
|
|
|
|
|
|
|
if t == 'ammo-damage' then
|
|
|
|
local category = e.ammo_category
|
|
|
|
local factor = player_ammo_research_modifiers[category]
|
2018-07-20 23:01:34 +02:00
|
|
|
|
2018-07-30 17:42:14 +02:00
|
|
|
if factor then
|
|
|
|
local current_m = p_force.get_ammo_damage_modifier(category)
|
|
|
|
local m = e.modifier
|
|
|
|
p_force.set_ammo_damage_modifier(category, current_m + factor * m)
|
|
|
|
end
|
|
|
|
elseif t == 'turret-attack' then
|
|
|
|
local category = e.turret_id
|
|
|
|
local factor = player_turrets_research_modifiers[category]
|
|
|
|
|
|
|
|
if factor then
|
|
|
|
local current_m = p_force.get_turret_attack_modifier(category)
|
|
|
|
local m = e.modifier
|
|
|
|
p_force.set_turret_attack_modifier(category, current_m + factor * m)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Event.on_init(init_weapon_damage)
|
2018-07-20 23:01:34 +02:00
|
|
|
Event.on_nth_tick(18000, enemy_weapon_damage)
|
2018-07-30 17:42:14 +02:00
|
|
|
Event.add(defines.events.on_research_finished, research_finished)
|