1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-04-11 11:21:54 +02:00

Merge pull request #334 from blubFisch/develop-blub

Combat rebalance + random fixes
This commit is contained in:
Gerkiz 2022-10-15 13:08:01 +02:00 committed by GitHub
commit 24c685aaa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 169 additions and 230 deletions

View File

@ -1,48 +1,166 @@
local string_sub = string.sub
local string_len = string.len
local Public = {}
-- ammo damage modifiers are static values that increase with research
-- modifier is multiplied by base damage and then added to damage, so a negative value will reduce base damage and a positive value will increase damage
local balance_functions = {
['land-mine'] = function(force_name)
-- landmines normally have a modifier of 0, so have them start at 25% of normal
if force_name ~= nil then
game.forces[force_name].set_ammo_damage_modifier('landmine', -0.75)
end
end,
['military-2'] = function(force_name)
-- grenades normally have a modifier of 0, so have them start at 50% of normal
if force_name ~= nil then
game.forces[force_name].set_ammo_damage_modifier('grenade', -0.5)
end
end,
['military-4'] = function(force_name)
-- cluster-grenades normally have a modifier of 0, so have them start at 50% of normal
if force_name ~= nil then
game.forces[force_name].set_ammo_damage_modifier('grenade', -0.5)
end
end,
['stronger-explosives'] = function(force_name)
-- landmines should never increase in damage with stronger explosives
if force_name ~= nil then
game.forces[force_name].set_ammo_damage_modifier('landmine', -0.75)
-- allow grenades to increase by 10%
game.forces[force_name].set_ammo_damage_modifier('grenade', game.forces[force_name].get_ammo_damage_modifier('grenade') + 0.1)
end
end
local player_ammo_damage_starting_modifiers = {
--['artillery-shell'] = -0.75,
--['biological'] = -0.5,
['bullet'] = 0,
['cannon-shell'] = -0.5,
['capsule'] = 0,
['beam'] = -0.5,
['laser'] = -0.5,
['electric'] = -0.5,
['flamethrower'] = 0,
['grenade'] = -0.5,
['landmine'] = -0.75,
--['melee'] = 2,
--['rocket'] = -0.75,
['shotgun-shell'] = 0
}
local player_ammo_damage_modifiers = {
--['artillery-shell'] = -0.75,
--['biological'] = -0.5,
['bullet'] = 0,
['cannon-shell'] = -0.5,
['capsule'] = 0,
['beam'] = -0.5,
['laser'] = -0.5,
['electric'] = -0.5,
['flamethrower'] = 0,
['grenade'] = -0.5,
['landmine'] = -0.5,
--['melee'] = 0,
--['rocket'] = -0.5,
['shotgun-shell'] = 0
}
local player_gun_speed_modifiers = {
--['artillery-shell'] = -0.75,
--['biological'] = -0.5,
['bullet'] = 0,
['cannon-shell'] = -0.5,
['capsule'] = -0.5,
['beam'] = -0.5,
['laser'] = 0,
['electric'] = -0.5,
['flamethrower'] = 0,
['grenade'] = -0.5,
['landmine'] = 0,
--['melee'] = 1,
--['rocket'] = -0.75,
['shotgun-shell'] = 0
}
local function on_research_finished(event)
local research_name = event.research.name
local force_name = event.research.force.name
for b = 1, string_len(research_name), 1 do
local key = string_sub(research_name, 0, b)
if balance_functions[key] then
balance_functions[key](force_name)
return
--local player_turrets_research_modifiers = {
-- ['gun-turret'] = 0,
-- ['laser-turret'] = 1.5,
-- ['flamethrower-turret'] = 0
--}
--local enemy_ammo_starting_modifiers = {
-- ['artillery-shell'] = 3,
-- ['biological'] = 3,
-- ['bullet'] = 2,
-- ['cannon-shell'] = 0,
-- ['capsule'] = 0,
-- ['beam'] = 0,
-- ['laser'] = 0,
-- ['electric'] = 0,
-- ['flamethrower'] = 0,
-- ['grenade'] = 0,
-- ['landmine'] = 0,
-- ['melee'] = 1,
-- ['rocket'] = 0,
-- ['shotgun-shell'] = 0
--}
--local enemy_ammo_evolution_modifiers = {
-- ['artillery-shell'] = 1,
-- ['biological'] = 2,
-- ['bullet'] = 1,
-- --['cannon-shell'] = 1,
-- ['capsule'] = 1,
-- ['beam'] = 1,
-- ['laser'] = 1,
-- ['electric'] = 1,
-- ['flamethrower'] = 2,
-- --['grenade'] = 1,
-- --['landmine'] = 1,
-- ['melee'] = 2
-- --['rocket'] = 1,
-- --['shotgun-shell'] = 1
--}
function Public.init_player_weapon_damage(force)
for k, v in pairs(player_ammo_damage_starting_modifiers) do
force.set_ammo_damage_modifier(k, v)
end
for k, v in pairs(player_gun_speed_modifiers) do
force.set_gun_speed_modifier(k, v)
end
force.set_turret_attack_modifier('laser-turret', 3)
end
--local function init_enemy_weapon_damage()
-- local e_force = game.forces['enemy']
--
-- for k, v in pairs(enemy_ammo_starting_modifiers) do
-- e_force.set_ammo_damage_modifier(k, v)
-- end
--end
--
--local function enemy_weapon_damage()
-- local f = game.forces.enemy
--
-- local ef = f.evolution_factor
--
-- 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
--end
-- After a research is finished and the game applied the modifier, we reduce modifiers to achieve the reduction
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_damage_modifiers[category]
if factor then
local current_m = p_force.get_ammo_damage_modifier(category)
p_force.set_ammo_damage_modifier(category, current_m + factor * e.modifier)
end
--elseif t == 'turret-attack' then -- NOTE: this doesn't trigger for laser turrets :-(
-- local category = e.turret_id
-- local factor = player_turrets_research_modifiers[category]
-- game.print("XDB cat " .. category)
-- if factor then
-- local current_m = p_force.get_turret_attack_modifier(category)
-- game.print("XDB mod " .. current_m .. " -> " .. current_m + factor * e.modifier)
-- p_force.set_turret_attack_modifier(category, current_m + factor * e.modifier)
-- end
elseif t == 'gun-speed' then
local category = e.ammo_category
local factor = player_gun_speed_modifiers[category]
if factor then
local current_m = p_force.get_gun_speed_modifier(category)
p_force.set_gun_speed_modifier(category, current_m + factor * e.modifier)
end
end
end
end
local Event = require 'utils.event'
Event.add(defines.events.on_research_finished, on_research_finished)
--Event.on_init(init_enemy_weapon_damage)
--Event.on_nth_tick(18000, enemy_weapon_damage)
Event.add(defines.events.on_research_finished, research_finished)
return Public

View File

@ -13,7 +13,8 @@ Have fun and be comfy ^.^
Changelog (10th October 2022):
Changelog (10th-15th October 2022):
- Combat balance overhaul
- Towns have an initial PvP protection shield, size and duration is scaled with the biggest town size
- Temporary PvP shield available in market for breaks / AFK
- Improved base defenses and offline survivability

View File

@ -17,7 +17,6 @@ require 'maps.scrap_towny_ffa.explosives_are_explosive'
require 'maps.scrap_towny_ffa.fluids_are_explosive'
require 'maps.scrap_towny_ffa.trap'
require 'maps.scrap_towny_ffa.turrets_drop_ammo'
require 'maps.scrap_towny_ffa.combat_balance'
require 'maps.scrap_towny_ffa.vehicles'
local Event = require 'utils.event'

View File

@ -96,6 +96,7 @@ function Public.requests(player)
i.clear()
end
player.print("Your town has fallen since you last played. Good luck next time!", {r = 1, g = 0, b = 0})
player.character.die()
end
this.requests[player.index] = nil

View File

@ -4,11 +4,13 @@ local math_random = math.random
local table_size = table.size
local string_match = string.match
local string_lower = string.lower
local math_min = math.min
local Server = require 'utils.server'
local Map = require 'maps.scrap_towny_ffa.map'
local ScenarioTable = require 'maps.scrap_towny_ffa.table'
local PvPShield = require 'maps.scrap_towny_ffa.pvp_shield'
local CombatBalance = require 'maps.scrap_towny_ffa.combat_balance'
local outlander_color = {150, 150, 150}
local outlander_chat_color = {170, 170, 170}
@ -56,11 +58,8 @@ local player_force_disabled_recipes = {
}
local all_force_enabled_recipes = {
'submachine-gun',
'small-lamp',
'shotgun',
'shotgun-shell',
'underground-belt',
'splitter',
}
local function min_slots(slots)
@ -81,7 +80,6 @@ local function update_member_limit(force)
local this = ScenarioTable.get_table()
local town_centers = this.town_centers
-- get the members of each force name into a table
local slots = {0, 0, 0}
for _, town_center in pairs(town_centers) do
local players = table_size(town_center.market.force.players)
@ -97,8 +95,8 @@ local function update_member_limit(force)
end
end
end
-- get the min of all slots
this.member_limit = min_slots(slots) + 1
-- get the min of all slots -- TODO: without the hard limit, the soft limit increases too much so it never applies
this.member_limit = math_min(min_slots(slots) + 1, 3)
end
local function can_force_accept_member(force)
@ -241,7 +239,7 @@ function Public.add_player_to_town(player, town_center)
Public.set_player_color(player)
update_member_limit(force)
game.print('>> The new member limit for all towns is now: (' .. this.member_limit .. ')', {255, 255, 0})
game.print('>> The new member limit for all towns is now ' .. this.member_limit, {255, 255, 0})
end
-- given to player upon respawn
@ -740,8 +738,7 @@ function Public.add_new_force(force_name)
end
force.research_queue_enabled = true
-- balance initial combat
force.set_ammo_damage_modifier('landmine', -0.75)
force.set_ammo_damage_modifier('grenade', -0.5)
CombatBalance.init_player_weapon_damage(force)
if (this.testing_mode == true) then
local e_force = game.forces['enemy']
e_force.set_friend(force, true) -- team force should not be attacked by turrets
@ -931,8 +928,7 @@ local function setup_player_force()
for _, recipe_name in pairs(all_force_enabled_recipes) do
recipes[recipe_name].enabled = true
end
force.set_ammo_damage_modifier('landmine', -0.75)
force.set_ammo_damage_modifier('grenade', -0.5)
CombatBalance.init_player_weapon_damage(force)
if (this.testing_mode == true) then
force.enable_all_prototypes()
end
@ -970,8 +966,7 @@ local function setup_rogue_force()
for _, recipe_name in pairs(all_force_enabled_recipes) do
recipes[recipe_name].enabled = true
end
force.set_ammo_damage_modifier('landmine', -0.75)
force.set_ammo_damage_modifier('grenade', -0.5)
CombatBalance.init_player_weapon_damage(force)
if (this.testing_mode == true) then
force.enable_all_prototypes()
end

View File

@ -1,175 +0,0 @@
--Towny balance things by Gerkiz --
--[[ local player_ammo_starting_modifiers = {
['artillery-shell'] = -0.75,
['biological'] = -0.5,
['bullet'] = -0.25,
['cannon-shell'] = -0.75,
['capsule'] = -0.5,
['combat-robot-beam'] = -0.5,
['combat-robot-laser'] = -0.5,
['electric'] = -0.5,
['flamethrower'] = -0.75,
['grenade'] = -0.5,
['landmine'] = -0.33,
['laser-turret'] = -0.75,
['melee'] = 2,
['railgun'] = 1,
['rocket'] = -0.75,
['shotgun-shell'] = -0.20
} ]]
local player_gun_speed_modifiers = {
['artillery-shell'] = -0.75,
['biological'] = -0.5,
['bullet'] = -0.5,
['cannon-shell'] = -0.5,
['capsule'] = -0.5,
['combat-robot-beam'] = -0.5,
['combat-robot-laser'] = -0.5,
['electric'] = -0.5,
['flamethrower'] = -0.75,
['grenade'] = -0.5,
['landmine'] = -0.33,
['laser-turret'] = -0.5,
['melee'] = 1,
['railgun'] = 0,
['rocket'] = -0.75,
['shotgun-shell'] = -0.5
}
local player_ammo_research_modifiers = {
['artillery-shell'] = -0.75,
['biological'] = -0.5,
['bullet'] = -0.5,
['cannon-shell'] = -0.75,
['capsule'] = -0.5,
['combat-robot-beam'] = -0.5,
['combat-robot-laser'] = -0.5,
['electric'] = -0.6,
['flamethrower'] = -0.75,
['grenade'] = -0.5,
['landmine'] = -0.5,
['laser-turret'] = -0.5,
['melee'] = -0.5,
['railgun'] = -0.5,
['rocket'] = -0.5,
['shotgun-shell'] = -0.20
}
--local player_turrets_research_modifiers = {
-- ['gun-turret'] = -0.75,
-- ['laser-turret'] = -0.75,
-- ['flamethrower-turret'] = -0.75
--}
local enemy_ammo_starting_modifiers = {
['artillery-shell'] = 0,
['biological'] = 0,
['bullet'] = 0,
['cannon-shell'] = 0,
['capsule'] = 0,
['combat-robot-beam'] = 0,
['combat-robot-laser'] = 0,
['electric'] = 0,
['flamethrower'] = 0,
['grenade'] = 0,
['landmine'] = 0,
['laser-turret'] = 0,
['melee'] = 0,
['railgun'] = 0,
['rocket'] = 0,
['shotgun-shell'] = 0
}
local enemy_ammo_evolution_modifiers = {
['artillery-shell'] = 1,
['biological'] = 2,
['bullet'] = 1,
--['cannon-shell'] = 1,
--['capsule'] = 1,
--['combat-robot-beam'] = 1,
--['combat-robot-laser'] = 1,
--['electric'] = 1,
['flamethrower'] = 2,
--['grenade'] = 1,
--['landmine'] = 1,
['laser-turret'] = 2,
['melee'] = 2
--['railgun'] = 1,
--['rocket'] = 1,
--['shotgun-shell'] = 1
}
--[[
function init_player_weapon_damage(force)
for k, v in pairs(player_ammo_starting_modifiers) do
force.set_ammo_damage_modifier(k, v)
end
for k, v in pairs(player_gun_speed_modifiers) do
force.set_gun_speed_modifier(k, v)
end
end
]]
local function init_enemy_weapon_damage()
local e_force = game.forces['enemy']
for k, v in pairs(enemy_ammo_starting_modifiers) do
e_force.set_ammo_damage_modifier(k, v)
end
end
local function enemy_weapon_damage()
local f = game.forces.enemy
local ef = f.evolution_factor
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
end
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]
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
elseif t == 'gun-speed' then
local category = e.ammo_category
local factor = player_gun_speed_modifiers[category]
if factor then
local current_m = p_force.get_gun_speed_modifier(category)
local m = e.modifier
p_force.set_gun_speed_modifier(category, current_m + factor * m)
end
end
end
end
local Event = require 'utils.event'
Event.on_init(init_enemy_weapon_damage)
Event.on_nth_tick(18000, enemy_weapon_damage)
Event.add(defines.events.on_research_finished, research_finished)