1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-05 13:15:03 +02:00
Overall performance improvement
Added new buffs to stateful
Modified buffs for stateful
This commit is contained in:
Gerkiz 2023-11-11 23:56:42 +01:00
parent e3ee972c74
commit d43d8130a4
13 changed files with 135 additions and 146 deletions

View File

@ -280,7 +280,7 @@ function Public.mountain_market(surface, position, rarity, buy)
if #items > 0 then
table.shuffle_table(items)
end
local mrk = surface.create_entity({name = 'market', position = position, force = 'neutral'})
local mrk = surface.create_entity({name = 'market', position = position, force = 'neutral', create_build_effect_smoke = false})
for i = 1, random(5, 10), 1 do
local item = items[i]

View File

@ -1096,7 +1096,7 @@ function Public.boost_difficulty()
WD.set('next_wave', game.tick + 3600 * 15)
Public.set('spidertron_unlocked_at_zone', 10)
WD.set_normal_unit_current_health(1.2)
WD.set_unit_health_increment_per_wave(0.35)
WD.set_unit_health_increment_per_wave(0.30)
WD.set_boss_unit_current_health(2)
WD.set_boss_health_increment_per_wave(1.5)
WD.set('death_mode', false)

View File

@ -11,7 +11,7 @@ local ceil = math.ceil
local round = math.round
local queue_task = Task.queue_task
local tiles_per_call = 8
local total_calls = ceil(1024 / tiles_per_call)
local total_calls = ceil(1024 / tiles_per_call) + 5
local regen_decoratives = false
local generate_map = Public.heavy_functions
@ -39,7 +39,7 @@ local function get_position(data)
data.xv = data.xv + 1
end
data.position = {x = data.top_x + data.xv, y = data.top_y + data.yv}
data.position = {x = (data.top_x + data.xv), y = (data.top_y + data.yv)}
end
local function do_tile_inner(tiles, tile, pos)
@ -48,71 +48,6 @@ local function do_tile_inner(tiles, tile, pos)
end
end
local function do_tile(x, y, data, shape)
local pos = {x, y}
-- local coords need to be 'centered' to allow for correct rotation and scaling.
local tile = shape(data)
if type(tile) == 'table' then
do_tile_inner(data.tiles, tile.tile, pos)
local hidden_tile = tile.hidden_tile
if hidden_tile then
data.hidden_tiles[#data.hidden_tiles + 1] = {tile = hidden_tile, position = pos}
end
local entities = tile.entities
if entities then
for _, entity in ipairs(entities) do
if not entity.position then
entity.position = pos
end
data.entities[#data.entities + 1] = entity
end
end
local buildings = tile.buildings
if buildings then
for _, entity in ipairs(buildings) do
if not entity.position then
entity.position = pos
end
data.buildings[#data.buildings + 1] = entity
end
end
local decoratives = tile.decoratives
if decoratives then
for _, decorative in ipairs(decoratives) do
data.decoratives[#data.decoratives + 1] = decorative
end
end
local markets = tile.markets
if markets then
for _, t in ipairs(markets) do
if not t.position then
t.position = pos
end
data.markets[#data.markets + 1] = t
end
end
local treasure = tile.treasure
if treasure then
for _, t in ipairs(treasure) do
if not t.position then
t.position = pos
end
data.treasure[#data.treasure + 1] = t
end
end
else
do_tile_inner(data.tiles, tile, pos)
end
end
local function do_row(row, data, shape)
local y = data.top_y + row
local top_x = data.top_x
@ -240,7 +175,8 @@ local function do_place_tiles(data)
if not surface or not surface.valid then
return
end
surface.set_tiles(data.tiles, true)
surface.set_tiles(data.tiles)
end
local function do_place_hidden_tiles(data)
@ -248,7 +184,7 @@ local function do_place_hidden_tiles(data)
if not surface or not surface.valid then
return
end
surface.set_tiles(data.hidden_tiles, true)
surface.set_tiles(data.hidden_tiles)
end
local function do_place_decoratives(data)
@ -283,6 +219,7 @@ local function do_place_buildings(data)
limit = 1
} == 0
then
e.create_build_effect_smoke = false
entity = surface.create_entity(e)
if entity and entity.valid then
if e.direction then
@ -360,6 +297,7 @@ local function do_place_entities(data)
for _, e in ipairs(data.entities) do
if e.collision then
if surface.can_place_entity(e) then
e.create_build_effect_smoke = false
entity = surface.create_entity(e)
if entity then
if e.note then -- flamethrower-turret and artillery-turret are at default health, only gun-turret is modified
@ -397,6 +335,7 @@ local function do_place_entities(data)
end
end
else
e.create_build_effect_smoke = false
entity = surface.create_entity(e)
if entity then
if e.note then -- small-worm-turret, medium-worm-turret, big-worm-turret, behemoth-worm-turret
@ -480,7 +419,7 @@ local function map_gen_action(data)
repeat
count = count - 1
get_position(data)
do_tile(x, y, data, shape)
shape(data)
x = x + 1
@ -503,30 +442,33 @@ local function map_gen_action(data)
data.y = 33
return true
elseif state == 33 then
do_place_hidden_tiles(data)
data.y = 34
return true
elseif state == 34 then
do_place_entities(data)
do_place_hidden_tiles(data)
data.y = 35
return true
elseif state == 35 then
do_place_buildings(data)
do_place_entities(data)
data.y = 36
return true
elseif state == 36 then
do_place_markets(data)
do_place_buildings(data)
data.y = 37
return true
elseif state == 37 then
do_place_treasure(data)
do_place_markets(data)
data.y = 38
return true
elseif state == 38 then
do_place_decoratives(data)
do_place_treasure(data)
data.y = 39
return true
elseif state == 39 then
do_place_decoratives(data)
data.y = 40
return true
elseif state == 40 then
run_chart_update(data)
return false
end
@ -581,7 +523,7 @@ end
--- Generates a Chunk of map when called
-- @param event <table> the event table from on_chunk_generated
local function do_chunk(event)
local function force_do_chunk(event)
local surface = event.surface
local shape = generate_map
@ -641,7 +583,7 @@ local function on_chunk(event)
end
if force_chunk then
do_chunk(event)
force_do_chunk(event)
else
schedule_chunk(event)
end

View File

@ -3,47 +3,29 @@ local simplex_noise = require 'utils.simplex_noise'.d2
--add or use noise templates from here
local noises = {
['bb_biterland'] = {
{modifier = 0.0015, weight = 1.1},
{modifier = 0.009, weight = 0.34},
{modifier = 0.095, weight = 0.016}
},
['bb_ore'] = {{modifier = 0.0046, weight = 0.95}, {modifier = 0.03, weight = 0.077}, {modifier = 0.09, weight = 0.023}},
['cave_ponds'] = {{modifier = 0.011, weight = 0.74}, {modifier = 0.14, weight = 0.079}},
['smol_areas'] = {{modifier = 0.0042, weight = 0.81}, {modifier = 0.129, weight = 0.021}, {modifier = 0.119, weight = 0.03}},
['cave_worms'] = {{modifier = 0.0011, weight = 0.99}, {modifier = 0.09, weight = 0.059}},
['cave_ponds'] = {{modifier = 0.014, weight = 0.77}, {modifier = 0.18, weight = 0.085}},
['smol_areas'] = {{modifier = 0.0052, weight = 0.83}, {modifier = 0.139, weight = 0.022}, {modifier = 0.121, weight = 0.01}},
['cave_rivers'] = {
{modifier = 0.0077, weight = 0.74},
{modifier = 0.0089, weight = 0.29},
{modifier = 0.072, weight = 0.028}
{modifier = 0.0053, weight = 0.71},
{modifier = 0.0086, weight = 0.24},
{modifier = 0.070, weight = 0.025}
},
['cave_rivers_2'] = {
{modifier = 0.0033, weight = 0.99},
{modifier = 0.0099, weight = 0.2},
{modifier = 0.049, weight = 0.009}
{modifier = 0.0035, weight = 0.90},
{modifier = 0.0088, weight = 0.15},
{modifier = 0.051, weight = 0.011}
},
['cave_rivers_3'] = {
{modifier = 0.0022, weight = 0.99},
{modifier = 0.0099, weight = 0.14},
{modifier = 0.049, weight = 0.009}
},
['cave_rivers_4'] = {
{modifier = 0.0009, weight = 0.99},
{modifier = 0.0099, weight = 0.1},
{modifier = 0.049, weight = 0.009}
},
['decoratives'] = {{modifier = 0.031, weight = 1.05}, {modifier = 0.055, weight = 0.24}, {modifier = 0.11, weight = 0.055}},
['dungeons'] = {{modifier = 0.0033, weight = 1.05}, {modifier = 0.0066, weight = 0.24}},
['dungeons'] = {{modifier = 0.0028, weight = 0.99}, {modifier = 0.0059, weight = 0.21}},
['dungeon_sewer'] = {
{modifier = 0.00055, weight = 1.05},
{modifier = 0.0055, weight = 0.014},
{modifier = 0.0062, weight = 0.024},
{modifier = 0.0275, weight = 0.00135}
},
['large_caves'] = {
{modifier = 0.00363, weight = 1.05},
{modifier = 0.01, weight = 0.23},
{modifier = 0.055, weight = 0.045},
{modifier = 0.11, weight = 0.042}
{modifier = 0.11, weight = 0.042},
{modifier = 0.00363, weight = 1.05},
{modifier = 0.01, weight = 0.23}
},
['n1'] = {{modifier = 0.00011, weight = 1.1}},
['n2'] = {{modifier = 0.0011, weight = 1.1}},
@ -131,7 +113,7 @@ function Public.get_noise(name, pos, seed)
local d = 0
for i = 1, #noises[name] do
local mod = noises[name]
noise = noise + simplex_noise(pos.x * mod[i].modifier, pos.y * mod[i].modifier, seed, 0xF) * mod[i].weight
noise = noise + simplex_noise(pos.x * mod[i].modifier, pos.y * mod[i].modifier, seed) * mod[i].weight
d = d + mod[i].weight
seed = seed + seed / seed
end

View File

@ -50,7 +50,8 @@ local function create_button(player)
type = 'sprite-button',
name = main_button_name,
sprite = 'item/dummy-steel-axe',
tooltip = 'Shows statistics!'
tooltip = 'Shows statistics!',
style = Gui.button_style
}
)
b.style.minimal_height = 38
@ -71,7 +72,8 @@ local function spectate_button(player)
type = 'sprite-button',
name = spectate_button_name,
sprite = 'utility/ghost_time_to_live_modifier_icon',
tooltip = 'Spectate!\nThis will kill your character.'
tooltip = 'Spectate!\nThis will kill your character.',
style = Gui.button_style
}
b.style.maximal_height = 38

View File

@ -644,7 +644,12 @@ local function show_score(data)
t = scroll_pane.add {type = 'table', column_count = 5}
-- Score entries
local i = 0
for _, entry in pairs(score_list) do
i = i + 1
if i == 20 then
break
end
local p
if not (entry and entry.name) then
p = {color = {r = random(1, 255), g = random(1, 255), b = random(1, 255)}}

View File

@ -526,6 +526,7 @@ local function gui_opened(event)
local container = fetch_container(unit_number)
if not container then
player.opened = nil
return
end

View File

@ -285,10 +285,8 @@ local function give_passive_xp(data)
end
end
end
-- else
-- if player.character then
-- player.character_personal_logistic_requests_enabled = false
-- end
elseif player.afk_time > 200 and player.character and player.surface.index == loco_surface.index then
player.character_personal_logistic_requests_enabled = false
end
::pre_exit::
end

View File

@ -51,7 +51,7 @@ function Public.add_loot(surface, position, chest)
local slots = c.get_inventory_size(defines.inventory.chest)
local item_stacks = LootRaffle.roll(result, slots, blacklist)
local container = surface.create_entity({name = chest, position = position, force = 'neutral'})
local container = surface.create_entity({name = chest, position = position, force = 'neutral', create_build_effect_smoke = false})
for _, item_stack in pairs(item_stacks) do
container.insert(item_stack)
end
@ -103,7 +103,7 @@ function Public.add_loot_rare(surface, position, chest, magic)
local slots = c.get_inventory_size(defines.inventory.chest)
local item_stacks = LootRaffle.roll(result, slots, blacklist)
local container = surface.create_entity({name = chest, position = position, force = 'neutral'})
local container = surface.create_entity({name = chest, position = position, force = 'neutral', create_build_effect_smoke = false})
for _, item_stack in pairs(item_stacks) do
container.insert(item_stack)
end

View File

@ -16,6 +16,7 @@ require 'modules.wave_defense.main'
require 'modules.charging_station'
local Event = require 'utils.event'
local Gui = require 'utils.gui'
local Public = require 'maps.mountain_fortress_v3.core'
local Discord = require 'utils.discord'
local IC = require 'maps.mountain_fortress_v3.ic.table'
@ -57,6 +58,8 @@ local role_to_mention = Discord.role_mentions.mtn_fortress
local floor = math.floor
local remove = table.remove
RPG.disable_cooldowns_on_spells()
Gui.mod_gui_button_enabled = true
Gui.button_style = 'mod_gui_button'
local collapse_kill = {
entities = {

View File

@ -187,7 +187,8 @@ local function create_button(player)
type = 'sprite-button',
name = main_button_name,
sprite = 'utility/custom_tag_icon',
tooltip = 'Has information about all objectives that needs to be completed'
tooltip = 'Has information about all objectives that needs to be completed',
style = Gui.button_style
}
)
b.style.minimal_height = 38

View File

@ -139,17 +139,17 @@ local function get_random_buff()
{
name = 'manual_crafting_speed_modifier',
modifier = 'force',
state = 0.04
state = 0.06
},
{
name = 'xp_bonus',
modifier = 'rpg',
state = 0.02
state = 0.08
},
{
name = 'xp_level',
modifier = 'rpg',
state = 4
state = 8
},
{
name = 'supplies',
@ -169,6 +169,33 @@ local function get_random_buff()
{name = 'firearm-magazine', count = 100}
}
},
{
name = 'defense_2',
modifier = 'starting_items',
limit = nil,
items = {
{name = 'flamethrower', count = 1},
{name = 'flamethrower-ammo', count = 100}
}
},
{
name = 'defense_3',
modifier = 'starting_items',
limit = nil,
items = {
{name = 'grenade', count = 50},
{name = 'poison-capsule', count = 30}
}
},
{
name = 'defense_4',
modifier = 'starting_items',
limit = nil,
items = {
{name = 'rocket-launcher', count = 1},
{name = 'rocket', count = 100}
}
},
{
name = 'armor',
modifier = 'starting_items',
@ -177,6 +204,15 @@ local function get_random_buff()
{name = 'heavy-armor', count = 1}
}
},
{
name = 'armor_2',
modifier = 'starting_items',
limit = 1,
items = {
{name = 'modular-armor', count = 1},
{name = 'solar-panel-equipment', count = 2}
}
},
{
name = 'production',
modifier = 'starting_items',
@ -186,6 +222,15 @@ local function get_random_buff()
{name = 'coal', count = 100}
}
},
{
name = 'production_2',
modifier = 'starting_items',
limit = nil,
items = {
{name = 'stone-furnace', count = 4},
{name = 'coal', count = 100}
}
},
{
name = 'fast-startup',
modifier = 'starting_items',
@ -421,8 +466,6 @@ local function scale(setting, limit, factor)
if limit and scale_value >= limit then
return limit
end
local random_value = scale_value * 0.9
scale_value = random(random_value, scale_value)
return floor(scale_value)
end

View File

@ -26,6 +26,19 @@ local start_ground_tiles = {
'grass-4'
}
local nuclear_tiles = {
'nuclear-ground',
'nuclear-ground',
'black-refined-concrete',
'tutorial-grid',
'nuclear-ground',
'red-refined-concrete',
'tutorial-grid',
'red-refined-concrete',
'black-refined-concrete',
'red-refined-concrete'
}
local wagon_raffle = {
'cargo-wagon',
'cargo-wagon',
@ -379,7 +392,7 @@ local function wall(p, data)
tiles[#tiles + 1] = {name = 'water', position = p}
else
tiles[#tiles + 1] = {name = 'water-shallow', position = p}
if random(1, 26) == 1 then
if random(1, 20) == 1 then
entities[#entities + 1] = {
name = 'land-mine',
position = p,
@ -391,9 +404,11 @@ local function wall(p, data)
entities[#entities + 1] = {name = 'fish', position = p}
end
else
tiles[#tiles + 1] = {name = base_tile, position = p}
local noise = Public.get_noise('dungeon_sewer', p, data.seed)
local index = floor(noise * 32) % 9 + 1
tiles[#tiles + 1] = {name = nuclear_tiles[index], position = p}
if random(1, 5) ~= 1 then
if random(1, 4) ~= 1 then
entities[#entities + 1] = {name = rock_raffle[random(1, #rock_raffle)], position = p}
if random(1, 26) == 1 then
entities[#entities + 1] = {
@ -405,7 +420,9 @@ local function wall(p, data)
end
end
else
tiles[#tiles + 1] = {name = base_tile, position = p}
local noise = Public.get_noise('dungeon_sewer', p, data.seed)
local index = floor(noise * 32) % 9 + 1
tiles[#tiles + 1] = {name = nuclear_tiles[index], position = p}
if
surface.can_place_entity(
@ -423,8 +440,8 @@ local function wall(p, data)
treasure[#treasure + 1] = {position = p, chest = 'steel-chest'}
end
end
if y < 4 or y > 25 then
if y <= 23 then
if y < 4 or y > 24 then
if y <= 22 then
if random(1, y + 1) == 1 then
entities[#entities + 1] = {
name = 'stone-wall',
@ -1332,7 +1349,7 @@ local function zone_scrap_1(x, y, data, void_or_lab, adjusted_zones)
entities[#entities + 1] = {name = 'crude-oil', position = p, amount = get_oil_amount(p)}
end
tiles[#tiles + 1] = {name = 'stone-path', position = p}
tiles[#tiles + 1] = {name = 'red-refined-concrete', position = p}
if random(1, 256) == 1 then
entities[#entities + 1] = {name = 'land-mine', position = p, force = 'enemy'}
end
@ -1347,8 +1364,8 @@ local function zone_7(x, y, data, void_or_lab, adjusted_zones)
local markets = data.markets
local treasure = data.treasure
local cave_rivers_3 = Public.get_noise('cave_rivers_3', p, seed)
local cave_rivers_4 = Public.get_noise('cave_rivers_4', p, seed + seed)
local cave_rivers_3 = Public.get_noise('cave_rivers_2', p, seed)
local cave_rivers_4 = Public.get_noise('cave_rivers_2', p, seed + seed)
local no_rocks_2 = Public.get_noise('no_rocks_2', p, seed)
local smol_areas = Public.get_noise('smol_areas', p, seed + seed)
@ -2488,8 +2505,8 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
local cave_rivers = Public.get_noise('cave_rivers', p, seed)
local no_rocks = Public.get_noise('no_rocks', p, seed)
if smol_areas < 0.055 and smol_areas > -0.025 then
entities[#entities + 1] = {name = rock_raffle[random(1, size_of_rock_raffle)], position = p}
if smol_areas < 0.057 and smol_areas > -0.021 then
tiles[#tiles + 1] = {name = void_or_lab, position = p}
if random(1, 32) == 1 then
Public.spawn_random_buildings(buildings, p, zone_settings.zone_depth)
end
@ -2517,7 +2534,7 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
end
--Water Ponds
if noise_cave_ponds > 0.64 then
if noise_cave_ponds > 0.6 then
if noise_cave_ponds > 0.74 then
tiles[#tiles + 1] = {name = 'acid-refined-concrete', position = p}
if random(1, 4) == 1 then
@ -2536,7 +2553,7 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
end
--Rivers
if cave_rivers < 0.042 and cave_rivers > -0.062 then
if cave_rivers < 0.044 and cave_rivers > -0.072 then
if noise_cave_ponds > 0.1 then
tiles[#tiles + 1] = {name = 'water-shallow', position = p}
if random(1, 64) == 1 then
@ -2559,7 +2576,7 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
end
--Worm oil Zones
if no_rocks < 0.035 and no_rocks > -0.145 then
if no_rocks < 0.029 and no_rocks > -0.245 then
if small_caves > 0.081 then
tiles[#tiles + 1] = {name = 'brown-refined-concrete', position = p}
if random(1, 250) == 1 then
@ -2808,7 +2825,6 @@ function Public.heavy_functions(data)
end
local p = data.position
local get_tile = surface.get_tile(p)
local adjusted_zones = Public.get('adjusted_zones')
init_terrain(adjusted_zones)
@ -2817,10 +2833,6 @@ function Public.heavy_functions(data)
data.seed = Public.get('random_seed')
end
if get_tile.valid and get_tile.name == 'out-of-map' then
return
end
if top_y % zone_settings.zone_depth == 0 and top_y < 0 then
Public.set('left_top', data.left_top)
return wall(p, data)
@ -2887,7 +2899,7 @@ Event.add(
end
end
if left_top.y > 32 then
if left_top.y < -32 then
game.forces.player.chart(surface, {{left_top.x, left_top.y}, {left_top.x + 31, left_top.y + 31}})
end
end