mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-03 22:52:13 +02:00
Added improved hydra scaling (#795)
* Added improved hydra scaling Added min, max and trigger to config Added online_player_scale to config Made hail hydra chances a variable of: - number of online players (toggleable) - evolution based on a custom formula that has a slow scaling until evolution 0.8 * Removed debug game.prints * Backwards compatibility Added conversion from old config to new * Updated config to show -1 for unused * Added locking chance * Added improved hydra scaling Added min, max and trigger to config Added online_player_scale to config Made hail hydra chances a variable of: - number of online players (toggleable) - evolution based on a custom formula that has a slow scaling until evolution 0.8 * Removed debug game.prints * Backwards compatibility Added conversion from old config to new * Updated config to show -1 for unused * Added locking chance * Added behemoth-worm-turret * Removed old behemoth-biter * Added new default configuration
This commit is contained in:
parent
3b07204f98
commit
bad47f37ff
55
config.lua
55
config.lua
@ -196,27 +196,52 @@ global.config = {
|
||||
-- spawns more units when one dies
|
||||
hail_hydra = {
|
||||
enabled = false,
|
||||
-- at which scale the evolution will increase the additional hydra spawns
|
||||
-- to disable scaling with evolution, set to 0.
|
||||
-- the formula: chance = hydra_chance + (evolution_factor * evolution_scale)
|
||||
-- example: small spitter has 0.2, which is 20% at 0% and 120% at an evolution_factor of 1
|
||||
evolution_scale = 1,
|
||||
-- enables difficulty scaling with number of online players
|
||||
-- if enabled you can disable it for individual spawns by setting {locked = true}
|
||||
online_player_scale_enabled = true,
|
||||
-- the number of players required for regular values.
|
||||
-- less online players than this number decreases the spawn chances
|
||||
-- more online players than this number increases the spawn chances
|
||||
-- the spawn chance is increased or decreased with 0.01 * (#connected_players - online_player_scale)
|
||||
online_player_scale = 20,
|
||||
-- any non-rounded number will turn into a chance to spawn an additional alien
|
||||
-- example: 2.5 would spawn 2 for sure and 50% chance to spawn one additionally
|
||||
-- min defines the lowest chance, max defines the max chance at evolution 1.
|
||||
-- trigger defines when the chance is active
|
||||
-- setting max to less than min or nil will ignore set the max = min
|
||||
-- Hail Hydra scales between min and max with a custom formula.
|
||||
-- Key values shown in evolution = (percentage of max):
|
||||
-- | 0.25 evolution = 10% | 0.50 evolution = 29% | 0.60 evolution = 45% | 0.75 evolution = 58% |
|
||||
-- | 0.80 evolution = 65% | 0.90 evolution = 81% | 1.00 evolution = 100% |
|
||||
-- eg. {min = 0.2, max = 2, trigger = 0.3} means that after evolution 0.3 this hydra spawns with a chance of at least 0.2
|
||||
-- and at evolution = 1.00 it spawns with a chance of 2.
|
||||
-- At evolution 0.60 it would spawn with a chance of min + max * (percentage of max) = 1.1
|
||||
-- Example of all available options (only min is required):
|
||||
-- ['behemoth-biter'] = {min = 0.1, max = 0.5, trigger = 0.90, locked = true}}
|
||||
hydras = {
|
||||
-- spitters
|
||||
['small-spitter'] = {['small-worm-turret'] = 0.2},
|
||||
['medium-spitter'] = {['medium-worm-turret'] = 0.2},
|
||||
['big-spitter'] = {['big-worm-turret'] = 0.2},
|
||||
['behemoth-spitter'] = {['big-worm-turret'] = 0.4},
|
||||
['small-spitter'] = {['small-worm-turret'] = {min = 0.2, max = 1}},
|
||||
['medium-spitter'] = {['medium-worm-turret'] = {min = 0.2, max = 1}},
|
||||
['big-spitter'] = {['big-worm-turret'] = {min = 0.2, max = 1}},
|
||||
['behemoth-spitter'] = {['behemoth-worm-turret'] = {min = 0.2, max = 1}},
|
||||
-- biters
|
||||
['medium-biter'] = {['small-biter'] = 1.2},
|
||||
['big-biter'] = {['medium-biter'] = 1.2},
|
||||
['behemoth-biter'] = {['big-biter'] = 1.2},
|
||||
['medium-biter'] = {['small-biter'] = {min = 1, max = 2}},
|
||||
['big-biter'] = {['medium-biter'] = {min = 1, max = 2}},
|
||||
['behemoth-biter'] = {['big-biter'] = {min = 1, max = 2}},
|
||||
-- worms
|
||||
['small-worm-turret'] = {['small-biter'] = 2.5},
|
||||
['medium-worm-turret'] = {['small-biter'] = 2.5, ['medium-biter'] = 0.6},
|
||||
['big-worm-turret'] = {['small-biter'] = 3.8, ['medium-biter'] = 1.3, ['big-biter'] = 1.1}
|
||||
['small-worm-turret'] = {['small-biter'] = {min = 1.5, max = 2.5}},
|
||||
['medium-worm-turret'] = {['small-biter'] = {min = 2.5, max = 3.5}, ['medium-biter'] = {min = 1.0, max = 2}},
|
||||
['big-worm-turret'] = {
|
||||
['small-biter'] = {min = 2.5, max = 4},
|
||||
['medium-biter'] = {min = 1.5, max = 2.2},
|
||||
['big-biter'] = {min = 0.7, max = 1.5}
|
||||
},
|
||||
['behemoth-worm-turret'] = {
|
||||
['small-biter'] = {min = 4, max = 5.2},
|
||||
['medium-biter'] = {min = 2.5, max = 3.8},
|
||||
['big-biter'] = {min = 1.2, max = 2.4},
|
||||
['behemoth-biter'] = {min = 0.8, max = -1}
|
||||
}
|
||||
}
|
||||
},
|
||||
-- grants reward coins for certain actions
|
||||
|
@ -14,14 +14,24 @@ local compound = defines.command.compound
|
||||
local logical_or = defines.compound_command.logical_or
|
||||
local attack = defines.command.attack
|
||||
local attack_area = defines.command.attack_area
|
||||
local hail_hydra_conf = global.config.hail_hydra
|
||||
|
||||
local spawn_table = {}
|
||||
for k, v in pairs(global.config.hail_hydra.hydras) do
|
||||
spawn_table[k] = v
|
||||
end
|
||||
|
||||
local function formula(evo)
|
||||
evo = evo * 100
|
||||
local value = (0.00003 * evo ^ 3 + 0.004 * evo ^ 2 + 0.3 * evo) * 0.01
|
||||
return value <= 1 and value or 1
|
||||
end
|
||||
|
||||
local primitives = {
|
||||
evolution_scale = global.config.hail_hydra.evolution_scale,
|
||||
evolution_scale = (hail_hydra_conf.evolution_scale ~= nil) and hail_hydra_conf.evolution_scale or 1,
|
||||
evolution_scale_formula = formula,
|
||||
online_player_scale_enabled = hail_hydra_conf.online_player_scale_enabled,
|
||||
online_player_scale = hail_hydra_conf.online_player_scale,
|
||||
enabled = nil
|
||||
}
|
||||
|
||||
@ -38,6 +48,10 @@ Global.register(
|
||||
|
||||
local Public = {}
|
||||
|
||||
local function backwards_compatibility(amount)
|
||||
return {min = amount, max = amount + primitives.evolution_scale}
|
||||
end
|
||||
|
||||
local function create_attack_command(position, target)
|
||||
local command = {type = attack_area, destination = position, radius = 10}
|
||||
if target then
|
||||
@ -67,9 +81,17 @@ local on_died =
|
||||
|
||||
local position = entity.position
|
||||
local force = entity.force
|
||||
local evolution_factor = force.evolution_factor * primitives.evolution_scale
|
||||
local cause = event.cause
|
||||
|
||||
local num_online_players = #game.connected_players
|
||||
local player_scale = 0
|
||||
if primitives.online_player_scale_enabled then
|
||||
player_scale = (num_online_players - primitives.online_player_scale) * 0.01
|
||||
end
|
||||
|
||||
local evolution_scaled = primitives.evolution_scale_formula(force.evolution_factor)
|
||||
local evolution_factor = evolution_scaled + evolution_scaled * player_scale
|
||||
|
||||
local cause = event.cause
|
||||
local surface = entity.surface
|
||||
local create_entity = surface.create_entity
|
||||
local find_non_colliding_position = surface.find_non_colliding_position
|
||||
@ -77,7 +99,26 @@ local on_died =
|
||||
local command = create_attack_command(position, cause)
|
||||
|
||||
for hydra_spawn, amount in pairs(hydra) do
|
||||
amount = amount + evolution_factor
|
||||
if (type(amount) == 'number') then
|
||||
amount = backwards_compatibility(amount)
|
||||
end
|
||||
local trigger = amount.trigger
|
||||
if trigger == nil or trigger < force.evolution_factor then
|
||||
if amount.locked then
|
||||
evolution_factor = evolution_scaled
|
||||
end
|
||||
local min = amount.min
|
||||
local max = amount.max
|
||||
max = (max ~= nil and max >= min) and max or min
|
||||
if max ~= min then
|
||||
amount = (max - min) * (evolution_factor / primitives.evolution_scale_formula(1)) + min
|
||||
else
|
||||
amount = min
|
||||
end
|
||||
else
|
||||
amount = 0
|
||||
end
|
||||
amount = (amount > 0) and amount or 0
|
||||
|
||||
local extra_chance = amount % 1
|
||||
if extra_chance > 0 then
|
||||
@ -136,6 +177,18 @@ function Public.set_evolution_scale(scale)
|
||||
primitives.evolution_scale = scale
|
||||
end
|
||||
|
||||
--- Sets the online player scale
|
||||
-- @param scale <number>
|
||||
function Public.set_evolution_scale(scale)
|
||||
primitives.online_player_scale = scale
|
||||
end
|
||||
|
||||
--- Toggles the online player scale feature
|
||||
-- @param enable <boolean>
|
||||
function Public.set_evolution_scale(enabled)
|
||||
primitives.online_player_scale_enabled = enabled
|
||||
end
|
||||
|
||||
--- Sets the hydra spawning table
|
||||
-- @param hydras <table> see config.lua's hail_hydra section for example
|
||||
function Public.set_hydras(hydras)
|
||||
|
Loading…
Reference in New Issue
Block a user