1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-03 13:12:11 +02:00

Mtn v3 - shuffle market prices around the map

This commit is contained in:
Gerkiz 2022-08-12 19:11:01 +02:00
parent ba83870374
commit 5bb04713f5
2 changed files with 199 additions and 144 deletions

View File

@ -1,6 +1,150 @@
local Global = require 'utils.global'
local this = {
market_settings = {
['weapons'] = {
['pistol'] = {value = 10, rarity = 1},
['submachine-gun'] = {value = 50, rarity = 2},
['shotgun'] = {value = 40, rarity = 2},
['combat-shotgun'] = {value = 400, rarity = 5},
['rocket-launcher'] = {value = 500, rarity = 6},
['flamethrower'] = {value = 750, rarity = 6},
['land-mine'] = {value = 3, rarity = 5}
},
['ammo'] = {
['firearm-magazine'] = {value = 3, rarity = 1},
['piercing-rounds-magazine'] = {value = 6, rarity = 4},
['uranium-rounds-magazine'] = {value = 20, rarity = 8},
['shotgun-shell'] = {value = 3, rarity = 1},
['piercing-shotgun-shell'] = {value = 8, rarity = 5},
['cannon-shell'] = {value = 8, rarity = 4},
['explosive-cannon-shell'] = {value = 12, rarity = 5},
['uranium-cannon-shell'] = {value = 16, rarity = 7},
['explosive-uranium-cannon-shell'] = {value = 20, rarity = 8},
['artillery-shell'] = {value = 1024, rarity = 7},
['rocket'] = {value = 45, rarity = 7},
['explosive-rocket'] = {value = 50, rarity = 7},
['atomic-bomb'] = {value = 11000, rarity = 10},
['flamethrower-ammo'] = {value = 20, rarity = 6},
['explosives'] = {value = 3, rarity = 1}
},
['caspules'] = {
['grenade'] = {value = 16, rarity = 2},
['cluster-grenade'] = {value = 64, rarity = 5},
['poison-capsule'] = {value = 32, rarity = 6},
['slowdown-capsule'] = {value = 8, rarity = 1},
['defender-capsule'] = {value = 18, rarity = 1},
['distractor-capsule'] = {value = 68, rarity = 5},
['destroyer-capsule'] = {value = 74, rarity = 7},
['artillery-targeting-remote'] = {value = 1024, rarity = 7},
['raw-fish'] = {value = 6, rarity = 1}
},
['armor'] = {
['light-armor'] = {value = 25, rarity = 1},
['heavy-armor'] = {value = 250, rarity = 4},
['modular-armor'] = {value = 750, rarity = 5},
['power-armor'] = {value = 2500, rarity = 6},
['power-armor-mk2'] = {value = 20000, rarity = 10}
},
['equipment'] = {
['solar-panel-equipment'] = {value = 240, rarity = 3},
['fusion-reactor-equipment'] = {value = 9000, rarity = 7},
['energy-shield-equipment'] = {value = 400, rarity = 6},
['energy-shield-mk2-equipment'] = {value = 4000, rarity = 8},
['battery-equipment'] = {value = 160, rarity = 2},
['battery-mk2-equipment'] = {value = 2000, rarity = 8},
['personal-laser-defense-equipment'] = {value = 2500, rarity = 7},
['discharge-defense-equipment'] = {value = 8444, rarity = 8},
['belt-immunity-equipment'] = {value = 200, rarity = 1},
['exoskeleton-equipment'] = {value = 800, rarity = 3},
['personal-roboport-equipment'] = {value = 500, rarity = 3},
['personal-roboport-mk2-equipment'] = {value = 5000, rarity = 8},
['night-vision-equipment'] = {value = 250, rarity = 1}
},
['defense'] = {
['stone-wall'] = {value = 4, rarity = 1},
['gate'] = {value = 8, rarity = 1},
['repair-pack'] = {value = 8, rarity = 1},
['gun-turret'] = {value = 64, rarity = 1},
['laser-turret'] = {value = 1024, rarity = 6},
['flamethrower-turret'] = {value = 2048, rarity = 6},
['artillery-turret'] = {value = 9216, rarity = 8},
['rocket-silo'] = {value = 64000, rarity = 10}
},
['logistic'] = {
['wooden-chest'] = {value = 3, rarity = 1},
['iron-chest'] = {value = 10, rarity = 2},
['steel-chest'] = {value = 24, rarity = 3},
['storage-tank'] = {value = 32, rarity = 4},
['transport-belt'] = {value = 4, rarity = 1},
['fast-transport-belt'] = {value = 8, rarity = 4},
['express-transport-belt'] = {value = 24, rarity = 7},
['underground-belt'] = {value = 8, rarity = 1},
['fast-underground-belt'] = {value = 32, rarity = 4},
['express-underground-belt'] = {value = 64, rarity = 7},
['splitter'] = {value = 16, rarity = 1},
['fast-splitter'] = {value = 48, rarity = 4},
['express-splitter'] = {value = 128, rarity = 7},
['loader'] = {value = 256, rarity = 2},
['fast-loader'] = {value = 512, rarity = 5},
['express-loader'] = {value = 768, rarity = 8},
['burner-inserter'] = {value = 4, rarity = 1},
['inserter'] = {value = 8, rarity = 1},
['long-handed-inserter'] = {value = 12, rarity = 2},
['fast-inserter'] = {value = 16, rarity = 4},
['filter-inserter'] = {value = 24, rarity = 5},
['stack-inserter'] = {value = 96, rarity = 6},
['stack-filter-inserter'] = {value = 128, rarity = 7},
['small-electric-pole'] = {value = 2, rarity = 1},
['medium-electric-pole'] = {value = 12, rarity = 4},
['big-electric-pole'] = {value = 24, rarity = 5},
['substation'] = {value = 96, rarity = 8},
['pipe'] = {value = 2, rarity = 1},
['pipe-to-ground'] = {value = 8, rarity = 1},
['pump'] = {value = 16, rarity = 4},
['logistic-robot'] = {value = 28, rarity = 5},
['construction-robot'] = {value = 28, rarity = 3},
['logistic-chest-active-provider'] = {value = 128, rarity = 7},
['logistic-chest-passive-provider'] = {value = 128, rarity = 6},
['logistic-chest-storage'] = {value = 128, rarity = 6},
['logistic-chest-buffer'] = {value = 128, rarity = 7},
['logistic-chest-requester'] = {value = 128, rarity = 7},
['roboport'] = {value = 4096, rarity = 8}
},
['vehicles'] = {
['rail'] = {value = 4, rarity = 1},
['train-stop'] = {value = 32, rarity = 3},
['rail-signal'] = {value = 8, rarity = 5},
['rail-chain-signal'] = {value = 8, rarity = 5},
['locomotive'] = {value = 400, rarity = 4},
['cargo-wagon'] = {value = 200, rarity = 4},
['fluid-wagon'] = {value = 300, rarity = 5},
['artillery-wagon'] = {value = 9216, rarity = 8},
['car'] = {value = 80, rarity = 1},
['tank'] = {value = 1800, rarity = 5}
},
['wire'] = {
['small-lamp'] = {value = 4, rarity = 1},
['red-wire'] = {value = 4, rarity = 1},
['green-wire'] = {value = 4, rarity = 1},
['arithmetic-combinator'] = {value = 16, rarity = 1},
['decider-combinator'] = {value = 16, rarity = 1},
['constant-combinator'] = {value = 16, rarity = 1},
['power-switch'] = {value = 16, rarity = 1},
['programmable-speaker'] = {value = 24, rarity = 1}
}
}
}
Global.register(
this,
function(tbl)
this = tbl
end
)
local Public = {}
local market = {}
local random = math.random
local floor = math.floor
@ -16,150 +160,9 @@ local blacklist = {
['spidertron'] = true
}
market.weapons = {
['pistol'] = {value = 10, rarity = 1},
['submachine-gun'] = {value = 50, rarity = 2},
['shotgun'] = {value = 40, rarity = 2},
['combat-shotgun'] = {value = 400, rarity = 5},
['rocket-launcher'] = {value = 500, rarity = 6},
['flamethrower'] = {value = 750, rarity = 6},
['land-mine'] = {value = 3, rarity = 5}
}
market.ammo = {
['firearm-magazine'] = {value = 3, rarity = 1},
['piercing-rounds-magazine'] = {value = 6, rarity = 4},
['uranium-rounds-magazine'] = {value = 20, rarity = 8},
['shotgun-shell'] = {value = 3, rarity = 1},
['piercing-shotgun-shell'] = {value = 8, rarity = 5},
['cannon-shell'] = {value = 8, rarity = 4},
['explosive-cannon-shell'] = {value = 12, rarity = 5},
['uranium-cannon-shell'] = {value = 16, rarity = 7},
['explosive-uranium-cannon-shell'] = {value = 20, rarity = 8},
['artillery-shell'] = {value = 1024, rarity = 7},
['rocket'] = {value = 45, rarity = 7},
['explosive-rocket'] = {value = 50, rarity = 7},
['atomic-bomb'] = {value = 11000, rarity = 10},
['flamethrower-ammo'] = {value = 20, rarity = 6},
['explosives'] = {value = 3, rarity = 1}
}
market.caspules = {
['grenade'] = {value = 16, rarity = 2},
['cluster-grenade'] = {value = 64, rarity = 5},
['poison-capsule'] = {value = 32, rarity = 6},
['slowdown-capsule'] = {value = 8, rarity = 1},
['defender-capsule'] = {value = 18, rarity = 1},
['distractor-capsule'] = {value = 68, rarity = 5},
['destroyer-capsule'] = {value = 74, rarity = 7},
['discharge-defense-remote'] = {value = 8222, rarity = 8},
['artillery-targeting-remote'] = {value = 1024, rarity = 7},
['raw-fish'] = {value = 6, rarity = 1}
}
market.armor = {
['light-armor'] = {value = 25, rarity = 1},
['heavy-armor'] = {value = 250, rarity = 4},
['modular-armor'] = {value = 750, rarity = 5},
['power-armor'] = {value = 2500, rarity = 6},
['power-armor-mk2'] = {value = 20000, rarity = 10}
}
market.equipment = {
['solar-panel-equipment'] = {value = 240, rarity = 3},
['fusion-reactor-equipment'] = {value = 9000, rarity = 7},
['energy-shield-equipment'] = {value = 400, rarity = 6},
['energy-shield-mk2-equipment'] = {value = 4000, rarity = 8},
['battery-equipment'] = {value = 160, rarity = 2},
['battery-mk2-equipment'] = {value = 2000, rarity = 8},
['personal-laser-defense-equipment'] = {value = 2500, rarity = 7},
['discharge-defense-equipment'] = {value = 8444, rarity = 8},
['belt-immunity-equipment'] = {value = 200, rarity = 1},
['exoskeleton-equipment'] = {value = 800, rarity = 3},
['personal-roboport-equipment'] = {value = 500, rarity = 3},
['personal-roboport-mk2-equipment'] = {value = 5000, rarity = 8},
['night-vision-equipment'] = {value = 250, rarity = 1}
}
market.defense = {
['stone-wall'] = {value = 4, rarity = 1},
['gate'] = {value = 8, rarity = 1},
['repair-pack'] = {value = 8, rarity = 1},
['gun-turret'] = {value = 64, rarity = 1},
['laser-turret'] = {value = 1024, rarity = 6},
['flamethrower-turret'] = {value = 2048, rarity = 6},
['artillery-turret'] = {value = 9216, rarity = 8},
['rocket-silo'] = {value = 64000, rarity = 10}
}
market.logistic = {
['wooden-chest'] = {value = 3, rarity = 1},
['iron-chest'] = {value = 10, rarity = 2},
['steel-chest'] = {value = 24, rarity = 3},
['storage-tank'] = {value = 32, rarity = 4},
['transport-belt'] = {value = 4, rarity = 1},
['fast-transport-belt'] = {value = 8, rarity = 4},
['express-transport-belt'] = {value = 24, rarity = 7},
['underground-belt'] = {value = 8, rarity = 1},
['fast-underground-belt'] = {value = 32, rarity = 4},
['express-underground-belt'] = {value = 64, rarity = 7},
['splitter'] = {value = 16, rarity = 1},
['fast-splitter'] = {value = 48, rarity = 4},
['express-splitter'] = {value = 128, rarity = 7},
['loader'] = {value = 256, rarity = 2},
['fast-loader'] = {value = 512, rarity = 5},
['express-loader'] = {value = 768, rarity = 8},
['burner-inserter'] = {value = 4, rarity = 1},
['inserter'] = {value = 8, rarity = 1},
['long-handed-inserter'] = {value = 12, rarity = 2},
['fast-inserter'] = {value = 16, rarity = 4},
['filter-inserter'] = {value = 24, rarity = 5},
['stack-inserter'] = {value = 96, rarity = 6},
['stack-filter-inserter'] = {value = 128, rarity = 7},
['small-electric-pole'] = {value = 2, rarity = 1},
['medium-electric-pole'] = {value = 12, rarity = 4},
['big-electric-pole'] = {value = 24, rarity = 5},
['substation'] = {value = 96, rarity = 8},
['pipe'] = {value = 2, rarity = 1},
['pipe-to-ground'] = {value = 8, rarity = 1},
['pump'] = {value = 16, rarity = 4},
['logistic-robot'] = {value = 28, rarity = 5},
['construction-robot'] = {value = 28, rarity = 3},
['logistic-chest-active-provider'] = {value = 128, rarity = 7},
['logistic-chest-passive-provider'] = {value = 128, rarity = 6},
['logistic-chest-storage'] = {value = 128, rarity = 6},
['logistic-chest-buffer'] = {value = 128, rarity = 7},
['logistic-chest-requester'] = {value = 128, rarity = 7},
['roboport'] = {value = 4096, rarity = 8}
}
market.vehicles = {
['rail'] = {value = 4, rarity = 1},
['train-stop'] = {value = 32, rarity = 3},
['rail-signal'] = {value = 8, rarity = 5},
['rail-chain-signal'] = {value = 8, rarity = 5},
['locomotive'] = {value = 400, rarity = 4},
['cargo-wagon'] = {value = 200, rarity = 4},
['fluid-wagon'] = {value = 300, rarity = 5},
['artillery-wagon'] = {value = 9216, rarity = 8},
['car'] = {value = 80, rarity = 1},
['tank'] = {value = 1800, rarity = 5}
}
market.wire = {
['small-lamp'] = {value = 4, rarity = 1},
['red-wire'] = {value = 4, rarity = 1},
['green-wire'] = {value = 4, rarity = 1},
['arithmetic-combinator'] = {value = 16, rarity = 1},
['decider-combinator'] = {value = 16, rarity = 1},
['constant-combinator'] = {value = 16, rarity = 1},
['power-switch'] = {value = 16, rarity = 1},
['programmable-speaker'] = {value = 24, rarity = 1}
}
local function get_types()
local types = {}
for k, _ in pairs(market) do
for k, _ in pairs(this.market_settings) do
types[#types + 1] = k
end
return types
@ -208,7 +211,7 @@ local function get_market_item_list(rarity)
local types = get_types()
local list = {}
for i = 1, 9 do
local branch = market[types[i]]
local branch = this.market_settings[types[i]]
for k, item in pairs(branch) do
--if item.rarity <= rarity and item.rarity + 7 >= rarity then
if item.rarity <= rarity then
@ -305,4 +308,54 @@ function Public.mountain_market(surface, position, rarity, buy)
return mrk
end
function Public.shuffle_prices()
if not this.market_default_settings then
this.market_default_settings = table.deepcopy(this.market_settings)
end
for _, data in pairs(this.market_settings) do
if data and type(data) == 'table' then
for _, category in pairs(data) do
local max = math.round(category.value * 1.5)
local min = math.round(category.value * 0.5)
local v = random(min, max)
if v then
category.value = v
end
end
end
end
end
function Public.get(key)
if key then
return this[key]
else
return this
end
end
function Public.set(key, value)
if key and (value or value == false) then
this[key] = value
return this[key]
elseif key then
return this[key]
else
return this
end
end
function Public.remove(key, sub_key)
if key and sub_key then
if this[key] and this[key][sub_key] then
this[key][sub_key] = nil
end
elseif key then
if this[key] then
this[key] = nil
end
end
end
return Public

View File

@ -7,6 +7,7 @@ local Event = require 'utils.event'
local Task = require 'utils.task'
local Token = require 'utils.token'
local Color = require 'utils.color_presets'
local BasicMarkets = require 'maps.mountain_fortress_v3.basic_markets'
local raise_event = script.raise_event
local floor = math.floor
@ -69,6 +70,7 @@ local first_player_to_zone =
local breached_wall = data.breached_wall
local message = ({'breached_wall.first_to_reach', player.name, breached_wall})
Alert.alert_all_players(10, message)
BasicMarkets.shuffle_prices()
end
)