1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-28 23:06:38 +02:00

chronotrain update for current version

This commit is contained in:
hanakocz 2024-10-08 22:44:40 +02:00 committed by Gerkiz
parent 1462c07956
commit 87847f6529
10 changed files with 20 additions and 24 deletions

View File

@ -1,7 +1,8 @@
local Chrono_table = require 'maps.chronosphere.table'
local Balance = require 'maps.chronosphere.balance'
local Difficulty = require 'modules.difficulty_vote'
local Raffle = require 'maps.chronosphere.raffles'
local Raffle = require 'utils.math.raffle'
local Raffles = require 'maps.chronosphere.raffles'
local AI = require 'utils.functions.AI'
local Public = {}
@ -70,7 +71,7 @@ local function generate_side_attack_target(surface, position, area)
for index, _ in pairs(entities) do
weights[#weights + 1] = 1 + floor((#entities - index) / 2)
end
return table.get_random_weighted_t(entities, weights)
return Raffle.raffle(entities, weights)
end
local function generate_main_attack_target()
@ -102,7 +103,7 @@ local function get_random_close_spawner(surface)
for index, _ in pairs(spawners) do
weights[#weights + 1] = 1 + floor((#spawners - index) / 2)
end
return table.get_random_weighted_t(spawners, weights), area
return Raffle.raffle(spawners, weights), area
end
local function is_biter_inactive(biter)
@ -269,7 +270,7 @@ local function colonize(group)
local evo = group.force.get_evolution_factor(surface)
local nests = random(1 + floor(evo * 20), 2 + floor(evo * 20) * 2)
local commands = {}
local biters = surface.find_entities_filtered { position = group.position, radius = 30, name = Raffle.biters, force = 'enemy' }
local biters = surface.find_entities_filtered { position = group.position, radius = 30, name = Raffles.biters, force = 'enemy' }
local goodbiters = {}
if #biters > 1 then
for i = 1, #biters, 1 do
@ -298,9 +299,9 @@ local function colonize(group)
--game.print("[gps=" .. pos.x .. "," .. pos.y .."," .. surface.name .. "]")
success = true
if random(1, 5) == 1 then
surface.create_entity({ name = Raffle.worms[random(1 + floor(evo * 8), floor(1 + evo * 16))], position = pos, force = group.force })
surface.create_entity({ name = Raffles.worms[random(1 + floor(evo * 8), floor(1 + evo * 16))], position = pos, force = group.force })
else
surface.create_entity({ name = Raffle.spawners[random(1, #Raffle.spawners)], position = pos, force = group.force })
surface.create_entity({ name = Raffles.spawners[random(1, #Raffles.spawners)], position = pos, force = group.force })
end
else
commands = {

View File

@ -1,5 +1,4 @@
local Public = {}
local Rand = require 'maps.chronosphere.random'
local Chrono_table = require 'maps.chronosphere.table'
local math_floor = math.floor

View File

@ -4,7 +4,6 @@ local Score = require 'utils.gui.score'
local Difficulty = require 'modules.difficulty_vote'
local Upgrades = require 'maps.chronosphere.upgrade_list'
local List = require 'maps.chronosphere.production_list'
local Rand = require 'maps.chronosphere.random'
local Public = {}
local Server = require 'utils.server'
@ -69,7 +68,7 @@ function Public.restart_settings()
local bitertable = Chrono_table.get_biter_table()
local production = Chrono_table.get_production_table()
Difficulty.reset_difficulty_poll()
Difficulty.set_poll_closing_timeout(game.tick + 120 * 60 * 60)
Difficulty.set_poll_closing_timeout(game.tick + 240 * 60 * 60)
objective.max_health = Balance.Chronotrain_max_HP
objective.health = Balance.Chronotrain_max_HP
objective.poisontimeout = 0

View File

@ -1,7 +1,6 @@
local Chrono_table = require 'maps.chronosphere.table'
local Event = require 'utils.event'
local math_random = math.random
local Rand = require 'maps.chronosphere.random'
local Balance = require 'maps.chronosphere.balance'
local Difficulty = require 'modules.difficulty_vote'
local FT = require 'utils.functions.flying_texts'

View File

@ -503,6 +503,7 @@ end
function Public.nuclear_artillery(entity, cause)
local objective = Chrono_table.get_table()
if objective.upgrades[23] ~= 1 then return end
if objective.upgrades[24] > 0 and objective.last_artillery_event ~= game.tick then
entity.surface.create_entity({name = 'atomic-rocket', position = entity.position, force = 'player', speed = 1, max_range = 100, target = entity, source = cause})
objective.upgrades[24] = objective.upgrades[24] - 1

View File

@ -83,6 +83,7 @@ local function chronojump(choice)
local scheduletable = Chrono_table.get_schedule_table()
if objective.chronojumps == 0 then
Difficulty.set_poll_closing_timeout(game.tick)
objective.warmup = false
end
if objective.game_lost then

View File

@ -1,6 +1,7 @@
local Chrono_table = require 'maps.chronosphere.table'
local Balance = require 'maps.chronosphere.balance'
local Difficulty = require 'modules.difficulty_vote'
local Raffle = require 'utils.math.raffle'
local Public = {}
local List = require 'maps.chronosphere.production_list'
@ -15,7 +16,7 @@ local function roll_assembler()
table.insert(choices.weights, item.weight)
end
end
return table.get_random_weighted_t(choices.types, choices.weights)
return Raffle.raffle(choices.types, choices.weights)
end
function Public.calculate_factory_level(xp, whole_level)

View File

@ -1,6 +1,7 @@
local Chrono_table = require 'maps.chronosphere.table'
local Balance = require 'maps.chronosphere.balance'
local Difficulty = require 'modules.difficulty_vote'
local Raffle = require 'utils.math.raffle'
local math_random = math.random
local math_abs = math.abs
local math_max = math.max
@ -35,8 +36,6 @@ local function treasure_chest_loot(difficulty, world)
{3, 0, 1, false, 'small-lamp', 8, 32},
{2, 0, 1, false, 'electric-mining-drill', 2, 4},
{3, 0, 1, false, 'long-handed-inserter', 4, 16},
--{0.5, 0, 1, false, 'filter-inserter', 2, 12},
--{0.2, 0, 1, false, 'stack-filter-inserter', 2, 6},
{0.2, 0, 1, false, 'slowdown-capsule', 2, 4},
{0.2, 0, 1, false, 'destroyer-capsule', 2, 4},
{0.2, 0, 1, false, 'defender-capsule', 2, 4},
@ -76,7 +75,6 @@ local function treasure_chest_loot(difficulty, world)
{4, 0.4, 1.5, true, 'utility-science-pack', 16, 32},
{10, 0.5, 1.5, true, 'space-science-pack', 16, 32},
--early-game:
--{3, -0.1, 0.2, false, "railgun-dart", 2, 4},
{3, -0.1, 0.1, true, 'wooden-chest', 8, 40},
{5, -0.1, 0.1, true, 'burner-inserter', 8, 20},
{1, -0.2, 0.2, true, 'offshore-pump', 1, 3},
@ -96,7 +94,6 @@ local function treasure_chest_loot(difficulty, world)
{1, -0.3, 0.3, true, 'assembling-machine-1', 2, 4},
{5, -0.8, 0.8, true, 'transport-belt', 15, 120},
--mid-game:
--{6, 0.2, 0.5, false, "railgun-dart", 4, 8},
{5, -0.2, 0.7, true, 'pipe', 30, 50},
{1, -0.2, 0.7, true, 'pipe-to-ground', 4, 8},
{5, -0.2, 0.7, true, 'iron-gear-wheel', 40, 160},
@ -119,7 +116,6 @@ local function treasure_chest_loot(difficulty, world)
{8, 0, 1, true, 'steel-chest', 8, 16},
{3, 0.2, 1, true, 'chemical-plant', 1, 3},
--late-game:
--{9, 0.5, 0.8, false, "railgun-dart", 8, 16},
{3, 0, 1.2, true, 'rocket-launcher', 1, 1},
{5, 0, 1.2, true, 'rocket', 16, 32},
{3, 0, 1.2, true, 'land-mine', 16, 32},
@ -146,12 +142,9 @@ local function treasure_chest_loot(difficulty, world)
{4, 0.4, 1.6, true, 'processing-unit', 30, 200},
{2, 0.6, 1.4, true, 'roboport', 1, 1},
-- super late-game:
--{9, 0.8, 1.2, false, "railgun-dart", 12, 20},
{1, 0.9, 1.1, true, 'power-armor-mk2', 1, 1},
{1, 0.8, 1.2, true, 'fission-reactor-equipment', 1, 1}
--{2, 0, 1, , "computer", 1, 1},
--{1, 0.2, 1, , "railgun", 1, 1},
--{1, 0.9, 1, , "personal-roboport-mk2-equipment", 1, 1},
}
local specialised_loot_raw = {}
@ -320,7 +313,7 @@ function Public.treasure_chest(surface, position, container_name)
e.minable = false
local inv = e.get_inventory(defines.inventory.chest)
for _ = 1, math_random(2, 6), 1 do
local loot = table.get_random_weighted_t(loot_types, loot_weights)
local loot = Raffle.raffle(loot_types, loot_weights)
local difficulty_scaling = Balance.treasure_quantity_difficulty_scaling(difficulty)
if objective.chronojumps == 0 then
difficulty_scaling = 1

View File

@ -335,6 +335,7 @@ local function check_single_upgrade(index, coin_scaling)
local objective = Chrono_table.get_table()
local upgrade = Upgrades['upgrade' .. index](coin_scaling)
if objective.upgradechest[index] and objective.upgradechest[index].valid then
if not upgrade.enabled then return end
if index == 14 and (objective.upgrades[13] ~= 1 or objective.computermessage ~= 3) then
return
elseif index == 15 and (objective.upgrades[14] ~= 1 or objective.computermessage ~= 5) then

View File

@ -1,6 +1,7 @@
local Chrono_table = require 'maps.chronosphere.table'
local Balance = require 'maps.chronosphere.balance'
local Difficulty = require 'modules.difficulty_vote'
local Raffle = require 'utils.math.raffle'
local random = math.random
local Public = {}
local Worlds = {}
@ -176,8 +177,8 @@ function Public.determine_world(optional_choice)
local SA = script.active_mods['space-travel']
local chosen_id
local chosen_variant_id
local ores = table.get_random_weighted_t(ore_richness_variants, Balance.ore_richness_weights(difficulty))
local dayspeed = table.get_random_weighted_t(time_speed_variants, time_speed_weights)
local ores = ore_richness_variants[Raffle.raffle(Balance.ore_richness_weights(difficulty))]
local dayspeed = time_speed_variants[Raffle.raffle(time_speed_weights)]
local daytime = random(0, 100) / 100
local special = special_world()
if special.yes then
@ -219,7 +220,7 @@ function Public.determine_world(optional_choice)
if Worlds[tonumber(optional_choice)] then
chosen_id = tonumber(optional_choice)
else
chosen_id = table.get_random_weighted_t(choices.types, choices.weights)
chosen_id = Raffle.raffle(choices.types, choices.weights)
end
local variant_choices = {types = {}, weights = {}}
for _, variant in pairs(Worlds[chosen_id].variants) do
@ -232,7 +233,7 @@ function Public.determine_world(optional_choice)
optional_choice = nil
goto retry
end
chosen_variant_id = table.get_random_weighted_t(variant_choices.types, variant_choices.weights)
chosen_variant_id = Raffle.raffle(variant_choices.types, variant_choices.weights)
local modifiers = get_modifiers(chosen_id)
if modifiers.ores then
ores = modifiers.ores