mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-24 03:47:58 +02:00
updates and things
This commit is contained in:
parent
547dd93974
commit
dd766de60a
191
functions/basic_markets.lua
Normal file
191
functions/basic_markets.lua
Normal file
@ -0,0 +1,191 @@
|
||||
local market = {}
|
||||
|
||||
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 = 250, rarity = 4},
|
||||
["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 = 16, 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 = 64, rarity = 7},
|
||||
["rocket"] = {value = 4, rarity = 3},
|
||||
["explosive-rocket"] = {value = 12, rarity = 5},
|
||||
["atomic-bomb"] = {value = 5000, rarity = 10},
|
||||
["flamethrower-ammo"] = {value = 20, rarity = 6},
|
||||
}
|
||||
|
||||
market.caspules = {
|
||||
["grenade"] = {value = 8, rarity = 1},
|
||||
["cluster-grenade"] = {value = 24, rarity = 5},
|
||||
["poison-capsule"] = {value = 16, rarity = 6},
|
||||
["slowdown-capsule"] = {value = 8, rarity = 1},
|
||||
["defender-capsule"] = {value = 8, rarity = 1},
|
||||
["distractor-capsule"] = {value = 16, rarity = 5},
|
||||
["destroyer-capsule"] = {value = 24, rarity = 7},
|
||||
["discharge-defense-remote"] = {value = 64, rarity = 6},
|
||||
["artillery-targeting-remote"] = {value = 16, rarity = 7},
|
||||
}
|
||||
|
||||
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 = 2000, rarity = 5},
|
||||
["belt-immunity-equipment"] = {value = 500, rarity = 1},
|
||||
["exoskeleton-equipment"] = {value = 1000, rarity = 3},
|
||||
["personal-roboport-equipment"] = {value = 500, rarity = 4},
|
||||
["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 = 10, rarity = 1},
|
||||
["gun-turret"] = {value = 64, rarity = 1},
|
||||
["laser-turret"] = {value = 1024, rarity = 7},
|
||||
["flamethrower-turret"] = {value = 2048, rarity = 6},
|
||||
["artillery-turret"] = {value = 8192, 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},
|
||||
["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 = 32, rarity = 5},
|
||||
["construction-robot"] = {value = 32, rarity = 5},
|
||||
["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 = 640, rarity = 4},
|
||||
["cargo-wagon"] = {value = 320, rarity = 4},
|
||||
["fluid-wagon"] = {value = 480, rarity = 5},
|
||||
["artillery-wagon"] = {value = 8192, rarity = 9},
|
||||
["car"] = {value = 96, rarity = 1},
|
||||
["tank"] = {value = 2048, rarity = 7},
|
||||
}
|
||||
|
||||
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, v in pairs(market) do
|
||||
types[#types + 1] = k
|
||||
end
|
||||
return types
|
||||
end
|
||||
|
||||
local function get_market_item_list(market_types, rarity)
|
||||
if rarity < 1 then rarity = 1 end
|
||||
local list = {}
|
||||
for _, market_type in pairs(market_types) do
|
||||
for k, item in pairs(market[market_type]) do
|
||||
if item.rarity <= rarity then
|
||||
local price = math.random(math.floor(item.value * 0.75), math.floor(item.value * 1.25))
|
||||
if price < 1 then price = 1 end
|
||||
list[#list + 1] = {price = {{"coin", price}}, offer = {type = 'give-item', item = k}}
|
||||
end
|
||||
end
|
||||
end
|
||||
if #list == 0 then return false end
|
||||
return list
|
||||
end
|
||||
|
||||
local function get_random_market_item_list(rarity)
|
||||
local types = get_types()
|
||||
table.shuffle_table(types)
|
||||
for i = 1, #types, 1 do
|
||||
local items = get_market_item_list({types[i]}, rarity)
|
||||
if items then return items end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function random_type_market(surface, position, rarity)
|
||||
local types = get_types()
|
||||
table.shuffle_table(types)
|
||||
local types = {types[1], types[2]}
|
||||
local items = get_market_item_list({types[1], types[2]}, rarity)
|
||||
if not items then return end
|
||||
if #items > 0 then table.shuffle_table(items) end
|
||||
local market = surface.create_entity({name = "market", position = position})
|
||||
for i = 1, math.random(4, 10), 1 do
|
||||
if items[i] then
|
||||
market.add_market_item(items[i])
|
||||
end
|
||||
end
|
||||
return market
|
||||
end
|
||||
|
||||
function super_market(surface, position, rarity)
|
||||
|
||||
end
|
@ -64,7 +64,9 @@ local function process_explosion_tile(pos, explosion_index, current_radius)
|
||||
entity.damage(999999, "player", "explosion")
|
||||
else
|
||||
entity.damage(global.explosion_schedule[explosion_index].damage_remaining, "player", "explosion")
|
||||
global.explosion_schedule[explosion_index].damage_remaining = global.explosion_schedule[explosion_index].damage_remaining - entity.health
|
||||
if entity.valid then
|
||||
global.explosion_schedule[explosion_index].damage_remaining = global.explosion_schedule[explosion_index].damage_remaining - entity.health
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,16 +1,16 @@
|
||||
-- Mountain digger fortress, protect the locomotive! -- by MewMew
|
||||
|
||||
require "modules.biter_evasion_hp_increaser"
|
||||
require "modules.wave_defense"
|
||||
require "modules.wave_defense.main"
|
||||
--require "modules.dense_rocks"
|
||||
require "functions.soft_reset"
|
||||
require "functions.basic_markets"
|
||||
--require "modules.dynamic_player_spawn"
|
||||
require "modules.biters_yield_coins"
|
||||
require "modules.no_deconstruction_of_neutral_entities"
|
||||
require "modules.rocks_broken_paint_tiles"
|
||||
require "modules.rocks_heal_over_time"
|
||||
require "modules.rocks_yield_ore_veins"
|
||||
require "modules.rocks_yield_ore"
|
||||
require "modules.spawners_contain_biters"
|
||||
require "modules.map_info"
|
||||
require "modules.rpg"
|
||||
@ -111,6 +111,20 @@ local function biters_chew_rocks_faster(event)
|
||||
event.entity.health = event.entity.health - bonus_damage
|
||||
end
|
||||
|
||||
local function hidden_biter(entity)
|
||||
wave_defense_set_biter_raffle(math.floor(math.abs(entity.position.y) * 0.5) + 1)
|
||||
entity.surface.create_entity({name = wave_defense_roll_biter_name(), position = entity.position})
|
||||
end
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
if not event.entity.valid then return end
|
||||
if event.entity.force.index == 3 then
|
||||
if math.random(1,48) == 1 then
|
||||
hidden_biter(event.entity)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
if not event.entity.valid then return end
|
||||
if event.entity == global.locomotive_cargo then
|
||||
@ -122,6 +136,17 @@ local function on_entity_died(event)
|
||||
--global.wave_defense.game_lost = true
|
||||
return
|
||||
end
|
||||
|
||||
if event.cause then
|
||||
if event.cause.valid then
|
||||
if event.cause.force.index == 2 then return end
|
||||
end
|
||||
end
|
||||
if event.entity.force.index == 3 then
|
||||
if math.random(1,16) == 1 then
|
||||
hidden_biter(event.entity)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
@ -149,4 +174,7 @@ local event = require 'utils.event'
|
||||
event.on_init(on_init)
|
||||
event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
|
||||
require "modules.rocks_yield_ore"
|
@ -30,10 +30,23 @@ end
|
||||
|
||||
local function process_rock_chunk_position(p, seed, tiles, entities, markets, treasure)
|
||||
local m = get_cave_density_modifer(p.y)
|
||||
|
||||
local noise = get_noise("large_caves", p, seed)
|
||||
if noise > m * -1 and noise < m then
|
||||
local noise_cave_ponds = get_noise("cave_ponds", p, seed)
|
||||
|
||||
local noise_large_caves = get_noise("large_caves", p, seed)
|
||||
local noise_cave_ponds = get_noise("cave_ponds", p, seed)
|
||||
local small_caves = get_noise("small_caves", p, seed)
|
||||
|
||||
if noise_cave_ponds < 0.08 and noise_cave_ponds > -0.08 then
|
||||
if small_caves > 0.45 then
|
||||
tiles[#tiles + 1] = {name = "out-of-map", position = p}
|
||||
return
|
||||
end
|
||||
if small_caves < -0.45 then
|
||||
tiles[#tiles + 1] = {name = "out-of-map", position = p}
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if noise_large_caves > m * -1 and noise_large_caves < m then
|
||||
if noise_cave_ponds > 0.80 then
|
||||
tiles[#tiles + 1] = {name = "deepwater-green", position = p}
|
||||
if math_random(1,16) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
@ -45,16 +58,6 @@ local function process_rock_chunk_position(p, seed, tiles, entities, markets, tr
|
||||
if math_random(1,96) == 1 then entities[#entities + 1] = {name = "crude-oil", position = p, amount = math.abs(p.y) * 250} end
|
||||
return
|
||||
end
|
||||
if noise_cave_ponds < 0.08 and noise_cave_ponds > -0.08 then
|
||||
if noise > 0.45 then
|
||||
tiles[#tiles + 1] = {name = "out-of-map", position = p}
|
||||
return
|
||||
end
|
||||
if noise < -0.45 then
|
||||
tiles[#tiles + 1] = {name = "out-of-map", position = p}
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
tiles[#tiles + 1] = {name = "dirt-7", position = p}
|
||||
if math_random(1,3) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end
|
||||
@ -62,23 +65,22 @@ local function process_rock_chunk_position(p, seed, tiles, entities, markets, tr
|
||||
return
|
||||
end
|
||||
|
||||
if math.abs(noise) > m * 7 then
|
||||
if math.abs(noise_large_caves) > m * 7 then
|
||||
tiles[#tiles + 1] = {name = "water", position = p}
|
||||
if math_random(1,16) == 1 then entities[#entities + 1] = {name="fish", position=p} end
|
||||
return
|
||||
end
|
||||
if math.abs(noise) > m * 6.5 then
|
||||
if math.abs(noise_large_caves) > m * 6.5 then
|
||||
if math_random(1,16) == 1 then entities[#entities + 1] = {name="tree-02", position=p} end
|
||||
if math_random(1,128) == 1 then markets[#markets + 1] = p end
|
||||
end
|
||||
if math.abs(noise) > m * 5 then
|
||||
if math.abs(noise_large_caves) > m * 5 then
|
||||
tiles[#tiles + 1] = {name = "grass-2", position = p}
|
||||
--if math_random(1,128) == 1 then entities[#entities + 1] = {name=spawner_raffle[math_random(1, #spawner_raffle)], position=p} end
|
||||
return
|
||||
end
|
||||
|
||||
local noise = get_noise("small_caves", p, seed)
|
||||
if noise > (m + 0.05) * -1 and noise < m - 0.05 then
|
||||
if small_caves > (m + 0.05) * -1 and small_caves < m - 0.05 then
|
||||
tiles[#tiles + 1] = {name = "dirt-6", position = p}
|
||||
if math_random(1,5) > 1 then entities[#entities + 1] = {name = rock_raffle[math_random(1, #rock_raffle)], position = p} end
|
||||
if math_random(1, 512) == 1 then treasure[#treasure + 1] = p end
|
||||
@ -110,7 +112,13 @@ local function rock_chunk(surface, left_top)
|
||||
end
|
||||
end
|
||||
end
|
||||
if #markets > 0 then secret_shop(markets[math_random(1, #markets)], surface) end
|
||||
--if #markets > 0 then secret_shop(markets[math_random(1, #markets)], surface) end
|
||||
if #markets > 0 then
|
||||
local position = markets[math_random(1, #markets)]
|
||||
if surface.count_entities_filtered{area = {{position.x - 128, position.y - 128}, {position.x + 128, position.y + 128}}, name = "market", limit = 1} == 0 then
|
||||
local market = random_type_market(surface, position, math.abs(position.y) * 0.004)
|
||||
end
|
||||
end
|
||||
for _, p in pairs(treasure) do treasure_chest(surface, p) end
|
||||
end
|
||||
|
||||
|
@ -16,7 +16,7 @@ local function debug_print(msg)
|
||||
end
|
||||
end
|
||||
|
||||
local function roll_biter_name()
|
||||
function wave_defense_roll_biter_name()
|
||||
local max_chance = 0
|
||||
for k, v in pairs(global.wave_defense.biter_raffle) do
|
||||
max_chance = max_chance + v
|
||||
@ -29,7 +29,7 @@ local function roll_biter_name()
|
||||
end
|
||||
end
|
||||
|
||||
local function set_biter_raffle(level)
|
||||
function wave_defense_set_biter_raffle(level)
|
||||
global.wave_defense.biter_raffle = {
|
||||
["small-biter"] = 1000 - level * 2,
|
||||
["small-spitter"] = 1000 - level * 2,
|
||||
@ -128,7 +128,7 @@ end
|
||||
local function spawn_biter()
|
||||
if global.wave_defense.threat <= 0 then return false end
|
||||
if global.wave_defense.active_biter_count >= global.wave_defense.max_active_biters then return false end
|
||||
local name = roll_biter_name()
|
||||
local name = wave_defense_roll_biter_name()
|
||||
local position = global.wave_defense.surface.find_non_colliding_position(name, global.wave_defense.spawn_position, 32, 1)
|
||||
if not position then return false end
|
||||
local biter = global.wave_defense.surface.create_entity({name = name, position = position, force = "enemy"})
|
||||
@ -173,7 +173,7 @@ end
|
||||
|
||||
local function spawn_attack_groups()
|
||||
if global.wave_defense.active_biter_count >= global.wave_defense.max_active_biters then return false end
|
||||
set_biter_raffle(global.wave_defense.wave_number)
|
||||
wave_defense_set_biter_raffle(global.wave_defense.wave_number)
|
||||
for a = 1, global.wave_defense.max_active_unit_groups - global.wave_defense.active_unit_group_count, 1 do
|
||||
if not spawn_unit_group() then break end
|
||||
end
|
||||
@ -181,9 +181,9 @@ end
|
||||
|
||||
local function set_next_wave()
|
||||
global.wave_defense.wave_number = global.wave_defense.wave_number + 1
|
||||
global.wave_defense.group_size = global.wave_defense.wave_number * 3
|
||||
global.wave_defense.group_size = global.wave_defense.wave_number * 2
|
||||
if global.wave_defense.group_size > global.wave_defense.max_group_size then global.wave_defense.group_size = global.wave_defense.max_group_size end
|
||||
global.wave_defense.threat = global.wave_defense.threat + global.wave_defense.wave_number * 3
|
||||
global.wave_defense.threat = global.wave_defense.threat + global.wave_defense.wave_number * 2
|
||||
global.wave_defense.last_wave = global.wave_defense.next_wave
|
||||
global.wave_defense.next_wave = game.tick + global.wave_defense.wave_interval
|
||||
end
|
||||
@ -214,7 +214,7 @@ local function get_commmands(group)
|
||||
type = defines.command.attack_area,
|
||||
destination = {x = position.x, y = position.y},
|
||||
radius = 16,
|
||||
distraction = defines.distraction.by_enemy
|
||||
distraction = defines.distraction.by_anything
|
||||
}
|
||||
if global.wave_defense.debug then print(position) end
|
||||
end
|
||||
@ -340,7 +340,7 @@ function reset_wave_defense()
|
||||
max_active_unit_groups = 6,
|
||||
max_active_biters = 1024,
|
||||
max_group_size = 256,
|
||||
max_biter_age = 3600 * 30,
|
||||
max_biter_age = 3600 * 60,
|
||||
active_unit_group_count = 0,
|
||||
active_biter_count = 0,
|
||||
spawn_position = {x = 0, y = 48},
|
Loading…
x
Reference in New Issue
Block a user