mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-25 21:29:06 +02:00
Raffle bandaid fix + added cave island to rotation
Changes: - Made quest structures return random requirement item when raffle returns nil. This happens because some items have negative weights in lambda raffle. - Added Cave island to B and D island categories.
This commit is contained in:
parent
8542a783cf
commit
077df6c208
@ -115,6 +115,8 @@ function Public.try_ore_spawn(surface, realp, source_name, density_bonus)
|
||||
ret = true
|
||||
end
|
||||
else
|
||||
if not choice then return false end
|
||||
|
||||
local real_amount = Math.max(Common.minimum_ore_placed_per_tile, Common.ore_abstract_to_real(choices[choice]))
|
||||
|
||||
local density = (density_bonus + 17 + 4 * Math.random()) -- not too big, and not too much variation; it makes players have to stay longer
|
||||
|
@ -45,9 +45,9 @@ local HORSESHOE = Surfaces.Island.enum.HORSESHOE
|
||||
local STANDARD_VARIANT = Surfaces.Island.enum.STANDARD_VARIANT
|
||||
local CAVE = Surfaces.Island.enum.CAVE
|
||||
|
||||
local A = {STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS, CAVE}
|
||||
local A = {STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS}
|
||||
local B = {NIL, NIL, NIL, STANDARD, STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS, CAVE}
|
||||
local C = {STANDARD, STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS, CAVE}
|
||||
local C = {STANDARD, STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS}
|
||||
local D = {NIL, NIL, NIL, STANDARD, STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS, SWAMP, CAVE}
|
||||
|
||||
local destinationScheme = {
|
||||
@ -124,8 +124,7 @@ function Public.generate_destination_type_and_subtype(overworld_position)
|
||||
type2 = Surfaces.enum.ISLAND
|
||||
end
|
||||
|
||||
return {type = Surfaces.enum.ISLAND, subtype = Surfaces.Island.enum.CAVE}
|
||||
--return {type = type2, subtype = subtype}
|
||||
return {type = type2, subtype = subtype}
|
||||
end
|
||||
|
||||
|
||||
|
@ -147,26 +147,27 @@ function Public.initialise_nodamage_quest()
|
||||
end
|
||||
|
||||
|
||||
function Public.initialise_resourceflow_quest()
|
||||
local destination = Common.current_destination()
|
||||
-- @UNUSED
|
||||
-- function Public.initialise_resourceflow_quest()
|
||||
-- local destination = Common.current_destination()
|
||||
|
||||
if not destination and destination.dynamic_data and destination.dynamic_data.rocketsilomaxhp then return false end
|
||||
-- if not destination and destination.dynamic_data and destination.dynamic_data.rocketsilomaxhp then return false end
|
||||
|
||||
destination.dynamic_data.quest_type = enum.RESOURCEFLOW
|
||||
destination.dynamic_data.quest_reward = Public.quest_reward()
|
||||
destination.dynamic_data.quest_progress = 0
|
||||
-- destination.dynamic_data.quest_type = enum.RESOURCEFLOW
|
||||
-- destination.dynamic_data.quest_reward = Public.quest_reward()
|
||||
-- destination.dynamic_data.quest_progress = 0
|
||||
|
||||
local generated_flow_quest = Public.generate_flow_quest()
|
||||
if not generated_flow_quest then return false end
|
||||
-- local generated_flow_quest = Public.generate_flow_quest()
|
||||
-- if not generated_flow_quest then return false end
|
||||
|
||||
destination.dynamic_data.quest_params = {item = generated_flow_quest.item}
|
||||
-- destination.dynamic_data.quest_params = {item = generated_flow_quest.item}
|
||||
|
||||
local progressneeded_before_rounding = generated_flow_quest.base_rate * Balance.resource_quest_multiplier()
|
||||
-- local progressneeded_before_rounding = generated_flow_quest.base_rate * Balance.resource_quest_multiplier()
|
||||
|
||||
destination.dynamic_data.quest_progressneeded = Math.ceil(progressneeded_before_rounding/10) * 10
|
||||
-- destination.dynamic_data.quest_progressneeded = Math.ceil(progressneeded_before_rounding/10) * 10
|
||||
|
||||
return true
|
||||
end
|
||||
-- return true
|
||||
-- end
|
||||
|
||||
|
||||
function Public.initialise_resourcecount_quest()
|
||||
|
@ -4,6 +4,7 @@ local Math = require 'maps.pirates.math'
|
||||
|
||||
local Public = {}
|
||||
|
||||
-- @NOTE: Beware this function may return nil when there is at least 1 negative weight and guaranteed to return nil with all negative weights
|
||||
function Public.raffle(values, weights) --arguments of the form {[a] = A, [b] = B, ...} and {[a] = a_weight, [b] = b_weight, ...} or just {a,b,c,...} and {1,2,3...}
|
||||
|
||||
local total_weight = 0
|
||||
@ -27,6 +28,7 @@ function Public.raffle(values, weights) --arguments of the form {[a] = A, [b] =
|
||||
end
|
||||
end
|
||||
|
||||
-- @NOTE: Beware this function may return nil when there is at least 1 negative weight and guaranteed to return nil with all negative weights
|
||||
function Public.raffle2(table) --arguments of the form {v1 = w1, v2 = w2, ...}
|
||||
|
||||
local total_weight = 0
|
||||
|
@ -277,6 +277,10 @@ function Public.entry_price()
|
||||
|
||||
local item = Raffle.LambdaRaffle(Public.entry_price_data_raw, lambda)
|
||||
|
||||
if not item then
|
||||
item = table.get_random_dictionary_entry(Public.entry_price_data_raw, true)
|
||||
end
|
||||
|
||||
local batchSize = Public.entry_price_data_raw[item].itemBatchSize
|
||||
|
||||
return {
|
||||
|
@ -276,6 +276,10 @@ function Public.entry_price()
|
||||
|
||||
local item = Raffle.LambdaRaffle(Public.entry_price_data_raw, lambda)
|
||||
|
||||
if not item then
|
||||
item = table.get_random_dictionary_entry(Public.entry_price_data_raw, true)
|
||||
end
|
||||
|
||||
local raw_materials = Public.entry_price_data_raw[item].raw_materials
|
||||
|
||||
return {
|
||||
|
Loading…
x
Reference in New Issue
Block a user