1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00

Revert "Merge remote-tracking branch 'origin/hydra-scaling' into Quadrants"

This reverts commit 80d56c2e4a00a58bd924a4cde904c8b3f08a99a9, reversing
changes made to 92841bc13ca5b0ecd2c0346540ad10b9361273ac.
This commit is contained in:
SimonFlapse 2019-03-02 16:54:42 +01:00
parent bfa355e309
commit 277a2c599d
2 changed files with 19 additions and 88 deletions

View File

@ -196,43 +196,27 @@ global.config = {
-- spawns more units when one dies
hail_hydra = {
enabled = false,
-- 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,
-- 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,
-- 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'] = {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}},
['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},
-- biters
['medium-biter'] = {['small-biter'] = {min = 1.2, max = 2}},
['big-biter'] = {['medium-biter'] = {min = 1.2, max = 2}},
['behemoth-biter'] = {['big-biter'] = {min = 1.2, max = 2}},
['medium-biter'] = {['small-biter'] = 1.2},
['big-biter'] = {['medium-biter'] = 1.2},
['behemoth-biter'] = {['big-biter'] = 1.2},
-- worms
['small-worm-turret'] = {['small-biter'] = {min = 2.5, max = -1}},
['medium-worm-turret'] = {['small-biter'] = {min = 2.5, max = -1}, ['medium-biter'] = {min = 0.6, max = -1}},
['big-worm-turret'] = {['small-biter'] = {min = 3.8, max = -1}, ['medium-biter'] = {min = 1.3, max = -1}, ['big-biter'] = {min = 1.1, max = -1}, ['behemoth-biter'] = {min = 0.1, max = -1, trigger = 0.99, locked = true}},
['behemoth-worm-turret'] = {['small-biter'] = {min = 4.5, max = -1}, ['medium-biter'] = {min = 2.5, max = -1}, ['big-biter'] = {min = 2, max = -1}, ['behemoth-biter'] = {min = 0.8, max = -1}}
['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}
}
},
-- grants reward coins for certain actions

View File

@ -14,24 +14,14 @@ 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 = (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,
evolution_scale = global.config.hail_hydra.evolution_scale,
enabled = nil
}
@ -48,10 +38,6 @@ 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
@ -81,17 +67,9 @@ local on_died =
local position = entity.position
local force = entity.force
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 evolution_factor = force.evolution_factor * primitives.evolution_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
@ -99,26 +77,7 @@ local on_died =
local command = create_attack_command(position, cause)
for hydra_spawn, amount in pairs(hydra) do
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
amount = amount + evolution_factor
local extra_chance = amount % 1
if extra_chance > 0 then
@ -177,18 +136,6 @@ 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)