diff --git a/features/force_control.lua b/features/force_control.lua index fe1a668f..531adca6 100644 --- a/features/force_control.lua +++ b/features/force_control.lua @@ -207,10 +207,12 @@ end ---@param lua_force_or_name LuaForce|string ---@param percentage number percentage of total obtained experience to remove ---@param min_experience number minimum amount of experience to remove (optional) +---@param max_experience number maximum amount of experience to remove (optional) ---@return number the experience being removed ---@see ForceControl.remove_experience -function ForceControl.remove_experience_percentage(lua_force_or_name, percentage, min_experience) +function ForceControl.remove_experience_percentage(lua_force_or_name, percentage, min_experience, max_experience) min_experience = min_experience ~= nil and min_experience or 0 + max_experience = max_experience ~= nil and max_experience or 0 local force = get_valid_force(lua_force_or_name) if not force then return @@ -222,6 +224,7 @@ function ForceControl.remove_experience_percentage(lua_force_or_name, percentage local penalty = force_config.total_experience * percentage penalty = (penalty >= min_experience) and ceil(penalty) or ceil(min_experience) + penalty = (penalty <= max_experience or max_experience == 0) and penalty or ceil(max_experience) return ForceControl.remove_experience(lua_force_or_name, penalty) end @@ -269,10 +272,12 @@ end ---@param lua_force_or_name LuaForce|string ---@param percentage number percentage of total obtained experience to add ---@param min_experience number minimum amount of experience to add (optional) +---@param max_experience number maximum amount of experience to add (optional) ---@return number the experience being added ---@see ForceControl.add_experience -function ForceControl.add_experience_percentage(lua_force_or_name, percentage, min_experience) +function ForceControl.add_experience_percentage(lua_force_or_name, percentage, min_experience, max_experience) min_experience = min_experience ~= nil and min_experience or 0 + max_experience = max_experience ~= nil and max_experience or 0 local force = get_valid_force(lua_force_or_name) if not force then return @@ -284,6 +289,7 @@ function ForceControl.add_experience_percentage(lua_force_or_name, percentage, m local reward = force_config.total_experience * percentage reward = (reward >= min_experience) and ceil(reward) or ceil(min_experience) + reward = (reward <= max_experience or max_experience == 0) and reward or ceil(max_experience) ForceControl.add_experience(lua_force_or_name, reward) return reward end diff --git a/map_gen/maps/diggy/config.lua b/map_gen/maps/diggy/config.lua index 0fcd13ca..6c4c93d4 100644 --- a/map_gen/maps/diggy/config.lua +++ b/map_gen/maps/diggy/config.lua @@ -9,83 +9,66 @@ local Config = { -- creates a starting zone starting_zone = { enabled = true, - -- initial starting position size, higher values are not recommended starting_size = 8, - -- where the market should spawn - market_spawn_position = {x = 0, y = 3}, + market_spawn_position = {x = 0, y = 3} }, - -- controls the Daylight (Default diggy: enabled = true) night_time = { - enabled = true, -- true = No Daylight, false = Day/night circle (Solar panels work) + enabled = true -- true = No Daylight, false = Day/night circle (Solar panels work) }, - -- controls setting up the players setup_player = { enabled = true, starting_items = { {name = 'stone-wall', count = 12}, {name = 'iron-gear-wheel', count = 8}, - {name = 'iron-plate', count = 16}, + {name = 'iron-plate', count = 16} }, - - -- applied when cheat_mode is set to true. It's recommended to tweak this to your needs + -- applied when _CHEATS is set to true and _DEBUG is NOT true. It's recommended to tweak this to your needs -- when playing with cheats on (recommended for single player or LAN with limited players) + -- see config.lua -> config.player_create.cheats for available options cheats = { + enabled = true, -- Sets the manual mining speed for the player force. A value of 1 = 100% faster. Setting it -- to 0.5 would make it 50% faster than the base speed. manual_mining_speed_modifier = 1000, - -- increase the amount of inventory slots for the player force character_inventory_slots_bonus = 0, - -- increases the run speed of all characters for the player force character_running_speed_modifier = 2, - -- a flat health bonus to the player force character_health_bonus = 1000000, - + -- starts with a fully slotted power armor mk2 + start_with_power_armor = true, -- adds additional items to the player force when starting in addition to defined in start_items above - starting_items = { - }, - }, + starting_items = {} + } }, - -- core feature diggy_hole = { enabled = true, - -- initial damage per tick it damages a rock to mine, can be enhanced by robot_damage_per_mining_prod_level robot_initial_mining_damage = 4, - -- damage added per level of mining productivity level research - robot_damage_per_mining_prod_level = 1, + robot_damage_per_mining_prod_level = 1 }, - -- adds the ability to collapse caves diggy_cave_collapse = { enabled = true, - -- adds per tile what the current stress is enable_stress_grid = false, - -- shows the mask on spawn enable_mask_debug = false, - --the size of the mask used mask_size = 9, - --how much the mask will effect tiles in the different rings of the mask mask_relative_ring_weights = {2, 3, 4}, - -- delay in seconds before the cave collapses collapse_delay = 2.5, - -- the threshold that will be applied to all neighbors on a collapse via a mask collapse_threshold_total_strength = 16, - support_beam_entities = { ['market'] = 9, ['stone-wall'] = 3, @@ -97,31 +80,25 @@ local Config = { ['concrete'] = 0.04, ['hazard-concrete'] = 0.04, ['refined-concrete'] = 0.06, - ['refined-hazard-concrete'] = 0.06, + ['refined-hazard-concrete'] = 0.06 }, cracking_sounds = { - 'R U N, Y O U F O O L S !', + 'R U N, Y O U F O O L S !' } }, - -- Adds the ability to drop coins and track how many are sent into space coin_gathering = { enabled = true, - -- value between 0 and 1, higher value means stronger variance between coordinates noise_variance = 0.75, - -- minimum noise value to spawn a treasure chest, works best with a very high noise variance, -- otherwise you risk spawning a lot of chests together treasure_chest_noise_threshold = 0.69, - -- minimum distance from spawn where a chest can spawn minimal_treasure_chest_distance = 25, - -- chances to receive a coin when mining mining_coin_chance = 0.15, mining_coin_amount = {min = 1, max = 5}, - -- lets you set the coin modifiers for aliens -- the modifier value increases the upper random limit that biters can drop alien_coin_modifiers = { @@ -135,15 +112,12 @@ local Config = { ['big-spitter'] = 5, ['big-worm-turret'] = 5, ['behemoth-biter'] = 7, - ['behemoth-spitter'] = 7, + ['behemoth-spitter'] = 7 }, - -- chance of aliens dropping coins between 0 and 1, where 1 is 100% alien_coin_drop_chance = 0.28, - -- shows the chest locations, only use when debugging display_chest_locations = false, - treasure_chest_raffle = { ['coin'] = {chance = 1.00, min = 20, max = 255}, ['stone'] = {chance = 0.20, min = 15, max = 40}, @@ -174,25 +148,20 @@ local Config = { ['productivity-module-2'] = {chance = 0.01, min = 1, max = 2}, ['speed-module'] = {chance = 0.03, min = 1, max = 2}, ['speed-module-2'] = {chance = 0.01, min = 1, max = 2}, - ['small-lamp'] = {chance = 0.05, min = 1, max = 5}, + ['small-lamp'] = {chance = 0.05, min = 1, max = 5} } }, - -- replaces the chunks with void refresh_map = { - enabled = true, + enabled = true }, - -- automatically opens areas simple_room_generator = { enabled = true, - -- value between 0 and 1, higher value means stronger variance between coordinates noise_variance = 0.066, - -- shows where rooms are located display_room_locations = false, - -- minimum distance and noise range required for water to spawn room_noise_minimum_distance = 9, room_noise_ranges = { @@ -200,158 +169,148 @@ local Config = { {name = 'water', min = 0.73, max = 0.81}, {name = 'water', min = 0.54, max = 0.7}, {name = 'dirt', min = 0.46, max = 0.53}, - {name = 'dirt', min = 0.37, max = 0.45}, - }, + {name = 'dirt', min = 0.37, max = 0.45} + } }, - -- responsible for resource spawning scattered_resources = { enabled = true, - -- determines how distance is measured - distance = function (x, y) return abs(x) + abs(y) end, + distance = function(x, y) + return abs(x) + abs(y) + end, --distance = function (x, y) return math.sqrt(x * x + y * y) end, -- defines the weights of which resource_richness_value to spawn resource_richness_weights = { - ['scarce'] = 440, - ['low'] = 350, + ['scarce'] = 440, + ['low'] = 350, ['sufficient'] = 164, - ['good'] = 30, - ['plenty'] = 10, - ['jackpot'] = 6, + ['good'] = 30, + ['plenty'] = 10, + ['jackpot'] = 6 }, - -- defines the min and max range of ores to spawn resource_richness_values = { - ['scarce'] = {1, 200}, - ['low'] = {201, 400}, + ['scarce'] = {1, 200}, + ['low'] = {201, 400}, ['sufficient'] = {401, 750}, - ['good'] = {751, 1200}, - ['plenty'] = {1201, 2000}, - ['jackpot'] = {2001, 5000}, + ['good'] = {751, 1200}, + ['plenty'] = {1201, 2000}, + ['jackpot'] = {2001, 5000} }, - -- increases the amount of resources by flat multiplication to initial amount -- highly suggested to use for fluids so their yield is reasonable resource_type_scalar = { ['crude-oil'] = 1500, - ['uranium-ore'] = 1.25, + ['uranium-ore'] = 1.25 }, - -- ============== -- Debug settings -- ============== -- shows the ore locations, only use when debugging (compound_cluster_mode) display_ore_clusters = false, - -- ======================= -- Scattered mode settings -- ======================= -- creates scattered ore (single tiles) at random locations scattered_mode = false, - -- defines the increased chance of spawning resources -- calculated_probability = resource_probability + ((distance / scattered_distance_probability_modifier) / 100) -- this means the chance increases by 1% every DISTANCE tiles up to the max_probability scattered_distance_probability_modifier = 10, - -- min percentage of chance that resources will spawn after mining scattered_min_probability = 0.01, - -- max chance of spawning resources based on resource_probability + calculated scattered_distance_probability_modifier scattered_max_probability = 0.10, - -- percentage of resource added to the sum. 100 tiles means -- 10% more resources with a distance_richness_modifier of 10 -- 20% more resources with a distance_richness_modifier of 5 scattered_distance_richness_modifier = 7, - -- multiplies probability only if cluster mode is enabled scattered_cluster_probability_multiplier = 0.5, - -- multiplies yield only if cluster mode is enabled scattered_cluster_yield_multiplier = 1.7, - -- weights per resource of spawning scattered_resource_weights = { - ['coal'] = 160, - ['copper-ore'] = 215, - ['iron-ore'] = 389, - ['stone'] = 212, - ['uranium-ore'] = 21, - ['crude-oil'] = 3, + ['coal'] = 160, + ['copper-ore'] = 215, + ['iron-ore'] = 389, + ['stone'] = 212, + ['uranium-ore'] = 21, + ['crude-oil'] = 3 }, - -- minimum distance from the spawn point required before it spawns scattered_minimum_resource_distance = { - ['coal'] = 16, - ['copper-ore'] = 18, - ['iron-ore'] = 18, - ['stone'] = 15, + ['coal'] = 16, + ['copper-ore'] = 18, + ['iron-ore'] = 18, + ['stone'] = 15, ['uranium-ore'] = 86, - ['crude-oil'] = 57, + ['crude-oil'] = 57 }, - -- ============================== -- Compound cluster mode settings -- ============================== -- creates compound clusters of ores defined by a layered ore-gen cluster_mode = true, - -- spawns tendrils of ore with roughly 80% purity - ore_pattern = require 'map_gen.maps.diggy.orepattern.tendrils_impure', + ore_pattern = require 'map_gen.maps.diggy.orepattern.tendrils_impure' -- spawns some smaller dedicated and bigger mixed tendrils --ore_pattern = require 'map_gen.maps.diggy.orepattern.tendrils', -- spawns clusters of ore similar to vanilla, but mixed --ore_pattern = require 'map_gen.maps.diggy.orepattern.clusters', - }, - -- controls the alien spawning mechanic alien_spawner = { enabled = true, - -- minimum distance from spawn before aliens can spawn alien_minimum_distance = 40, - - -- chance of spawning aliens when mining + -- chance of spawning aliens when mining from 0 to 1 alien_probability = 0.05, - -- spawns the following units when they die. To disable, remove the contents -- any non-rounded number will turn into a chance to spawn an additional alien -- example: 2.5 would spawn 2 for sure and 50% chance to spawn one additionally hail_hydra = { -- spitters - ['small-spitter'] = {['small-worm-turret'] = 0.2}, - ['medium-spitter'] = {['medium-worm-turret'] = 0.2}, - ['big-spitter'] = {['big-worm-turret'] = 0.2}, - ['behemoth-spitter'] = {['big-worm-turret'] = 0.4}, - + ['small-spitter'] = {['small-worm-turret'] = {min = 0.1, max = 0.8}}, + ['medium-spitter'] = {['medium-worm-turret'] = {min = 0.1, max = 0.8}}, + ['big-spitter'] = {['big-worm-turret'] = {min = 0.1, max = 0.8}}, + ['behemoth-spitter'] = {['behemoth-worm-turret'] = {min = 0.2, max = 0.8}}, -- biters - ['medium-biter'] = {['small-biter'] = 1.2}, - ['big-biter'] = {['medium-biter'] = 1.2}, - ['behemoth-biter'] = {['big-biter'] = 1.2}, - + ['medium-biter'] = {['small-biter'] = {min = 0.6, max = 1.5}}, + ['big-biter'] = {['medium-biter'] = {min = 0.6, max = 1.5}}, + ['behemoth-biter'] = {['big-biter'] = {min = 0.6, max = 2}}, -- worms - ['small-worm-turret'] = {['small-biter'] = 2.5}, - ['medium-worm-turret'] = {['small-biter'] = 2.5, ['medium-biter'] = 0.6}, - ['big-worm-turret'] = {['small-biter'] = 3.8, ['medium-biter'] = 1.3, ['big-biter'] = 1.1}, - }, + ['small-worm-turret'] = {['small-biter'] = {min = 1, max = 2.5}}, + ['medium-worm-turret'] = { + ['small-biter'] = {min = 1, max = 2.5}, + ['medium-biter'] = {min = 0.3, max = 1.5} + }, + ['big-worm-turret'] = { + ['small-biter'] = {min = 1, max = 2.5}, + ['medium-biter'] = {min = 0.7, max = 1.5}, + ['big-biter'] = {min = 0.7, max = 2} + }, + ['behemoth-worm-turret'] = { + ['small-biter'] = {min = 1.5, max = 3}, + ['medium-biter'] = {min = 1.2, max = 2}, + ['big-biter'] = {min = 1, max = 2}, + ['behemoth-biter'] = {min = 0.7, max = 1.2} + } + } }, - --Tracks players causing collapses antigrief = { enabled = true, autojail = true, - allowed_collapses_first_hour = 4, + allowed_collapses_first_hour = 4 }, - experience = { enabled = true, -- controls the formula for calculating level up costs in stone sent to surface @@ -359,36 +318,33 @@ local Config = { first_lvl_xp = 350, -- Diggy default 350. This sets the price for the first level. xp_fine_tune = 400, -- Diggy default 200. This value is used to fine tune the overall requirement climb without affecting the speed cost_precision = 3, -- Diggy default 3. This sets the precision of the required experience to level up. E.g. 1234 becomes 1200 with precision 2 and 1230 with precision 3. - -- percentage * mining productivity level gets added to mining speed mining_speed_productivity_multiplier = 5, - XP = { - ['sand-rock-big'] = 5, - ['rock-big'] = 5, - ['rock-huge'] = 10, - ['rocket_launch'] = 0.01, -- XP reward in percentage of total experience when a rocket launches (Diggy default: 0.01 which equals 1%) - ['automation-science-pack'] = 4, - ['logistic-science-pack'] = 8, - ['chemical-science-pack'] = 15, - ['military-science-pack'] = 12, - ['production-science-pack'] = 25, - ['utility-science-pack'] = 50, - ['space-science-pack'] = 10, - ['enemy_killed'] = 10, -- Base XP for killing biters and spitters. - ['death-penalty'] = 0.0035, -- XP deduct in percentage of total experience when a player dies (Diggy default: 0.0035 which equals 0.35%) + ['sand-rock-big'] = 5, + ['rock-big'] = 5, + ['rock-huge'] = 10, + ['rocket_launch'] = 0.05, -- XP reward in percentage of total experience when a rocket launches (Diggy default: 0.05 which equals 5%) + ['rocket_launch_max'] = 500000, -- Max XP reward from rocket launches (Diggy default: 500000) + ['automation-science-pack'] = 4, + ['logistic-science-pack'] = 8, + ['chemical-science-pack'] = 15, + ['military-science-pack'] = 12, + ['production-science-pack'] = 25, + ['utility-science-pack'] = 50, + ['space-science-pack'] = 10, + ['enemy_killed'] = 10, -- Base XP for killing biters and spitters. + ['death-penalty'] = 0.0035, -- XP deduct in percentage of total experience when a player dies (Diggy default: 0.0035 which equals 0.35%) --['cave-in-penalty'] = 100 -- XP lost every cave in. - ['infinity-research'] = 0.60 -- XP reward in percentage of the required experience from current level to next level (Diggy default: 0.60 which equals 60%) + ['infinity-research'] = 0.60 -- XP reward in percentage of the required experience from current level to next level (Diggy default: 0.60 which equals 60%) }, - buffs = { -- define new buffs here, they are handed out for each level - mining_speed = {value = 5, max = 100}, + mining_speed = {value = 5, max = 10}, inventory_slot = {value = 1, max = 100}, -- double_level is the level interval for receiving a double bonus (Diggy default: 5 which equals every 5th level) - health_bonus = {value = 2.5, double_level = 5, max = 500}, + health_bonus = {value = 2.5, double_level = 5, max = 500} }, - -- add or remove a table entry to add or remove a unlockable item from the market. unlockables = { {level = 2, price = 4, name = 'wood'}, @@ -431,7 +387,7 @@ local Config = { {level = 63, price = 40, name = 'rocket'}, {level = 71, price = 80, name = 'explosive-rocket'}, {level = 78, price = 1000, name = 'satellite'}, - {level = 100, price = 1, name = 'iron-stick'}, + {level = 100, price = 1, name = 'iron-stick'} }, -- modifies the experience per alien type, higher is more xp alien_experience_modifiers = { @@ -446,9 +402,13 @@ local Config = { ['big-worm-turret'] = 5, ['behemoth-biter'] = 7, ['behemoth-spitter'] = 7, - }, + ['behemoth-worm-turret'] = 7 + } }, - }, + weapon_balance = { + enabled = true + } + } } return Config diff --git a/map_gen/maps/diggy/feature/alien_spawner.lua b/map_gen/maps/diggy/feature/alien_spawner.lua index 48cd234e..0ce4ba30 100644 --- a/map_gen/maps/diggy/feature/alien_spawner.lua +++ b/map_gen/maps/diggy/feature/alien_spawner.lua @@ -178,7 +178,7 @@ function AlienSpawner.register(config) return end - spawn_aliens(get_aliens(create_spawner_request(3), force.evolution_factor), force, event.surface, x, y) + spawn_aliens(get_aliens(create_spawner_request(2), force.evolution_factor), force, event.surface, x, y) end) end diff --git a/map_gen/maps/diggy/feature/experience.lua b/map_gen/maps/diggy/feature/experience.lua index 8c64344c..8af758c3 100644 --- a/map_gen/maps/diggy/feature/experience.lua +++ b/map_gen/maps/diggy/feature/experience.lua @@ -64,7 +64,7 @@ local gain_xp_color = Color.light_sky_blue local lose_xp_color = Color.red local unlocked_color = Color.black local locked_color = Color.gray -local table_column_layout = {type = 'table', column_count = 2} +local table_column_layout = {type = 'table', column_count = 3} local level_up_formula = (function(level_reached) local difficulty_scale = floor(config.difficulty_scale) @@ -226,7 +226,7 @@ local function on_player_mined_entity(event) return end - print_player_floating_text_position(player_index, format('+%s XP', exp), gain_xp_color, 0, -0.5) + print_player_floating_text_position(player_index, format('[img=entity/' .. name .. '] +%s XP', exp), gain_xp_color, 0, -0.5) add_experience(force, exp) end @@ -248,7 +248,7 @@ local function on_research_finished(event) end exp = award_xp * research.research_unit_count end - local text = format('Research completed! +%s XP', exp) + local text = format('[img=item/automation-science-pack] Research completed! +%s XP', exp) for _, p in pairs(game.connected_players) do local player_index = p.index print_player_floating_text_position(player_index, text, gain_xp_color, -1, -0.5) @@ -277,8 +277,9 @@ end ---@param event LuaEvent local function on_rocket_launched(event) local force = event.rocket.force - local exp = add_experience_percentage(force, config.XP['rocket_launch']) - local text = format('Rocket launched! +%s XP', exp) + + local exp = add_experience_percentage(force, config.XP['rocket_launch'], nil, config.XP['rocket_launch_max']) + local text = format('[img=item/satellite] Rocket launched! +%s XP', exp) for _, p in pairs(game.connected_players) do local player_index = p.index print_player_floating_text_position(player_index, text, gain_xp_color, -1, -0.5) @@ -291,6 +292,7 @@ local function on_entity_died(event) local entity = event.entity local force = event.force local cause = event.cause + local entity_name = entity.name --For bot mining and turrets if not cause or not cause.valid or cause.type ~= 'player' then @@ -299,7 +301,6 @@ local function on_entity_died(event) -- stuff killed by the player force, but not the player if force and force.name == 'player' then - local entity_name = entity.name if cause and (cause.name == 'artillery-turret' or cause.name == 'gun-turret' or cause.name == 'laser-turret' or cause.name == 'flamethrower-turret') then exp = config.XP['enemy_killed'] * (config.alien_experience_modifiers[entity_name] or 1) floating_text_position = cause.position @@ -317,7 +318,7 @@ local function on_entity_died(event) end if exp > 0 then - Game.print_floating_text(entity.surface, floating_text_position, format('+%s XP', exp), gain_xp_color) + Game.print_floating_text(entity.surface, floating_text_position, format('[img=entity/' .. entity_name .. '] +%s XP', exp), gain_xp_color) add_experience(force, exp) end @@ -329,7 +330,7 @@ local function on_entity_died(event) end local exp = config.XP['enemy_killed'] * (config.alien_experience_modifiers[entity.name] or 1) - print_player_floating_text_position(cause.player.index, format('+%d XP', exp), gain_xp_color, -1, -0.5) + print_player_floating_text_position(cause.player.index, format('[img=entity/' .. entity_name .. '] +%s XP', exp), gain_xp_color, -1, -0.5) add_experience(force, exp) end @@ -338,7 +339,7 @@ end local function on_player_respawned(event) local player = get_player_by_index(event.player_index) local exp = remove_experience_percentage(player.force, config.XP['death-penalty'], 50) - local text = format('-%s XP', exp) + local text = format('[img=entity.player] -%s XP', exp) game.print(format('%s drained %s experience.', player.name, exp), lose_xp_color) for _, p in pairs(game.connected_players) do print_player_floating_text_position(p.index, text, lose_xp_color, -1, -0.5) @@ -364,6 +365,7 @@ local function redraw_heading(data, header) local heading_table = frame.add(table_column_layout) apply_heading_style(heading_table.add({type = 'label', caption = 'Requirement'}).style, 100) + apply_heading_style(heading_table.add({type = 'label'}).style, 25) apply_heading_style(heading_table.add({type = 'label', caption = header_caption}).style, 220) end @@ -414,12 +416,18 @@ local function redraw_table(data) level_column.style.minimal_width = 100 level_column.style.font_color = color + local spacer = list.add({ + type = 'flow' + }) + spacer.style.minimal_width = 25 + local item_column = list.add({ type = 'label', - caption = prototype.name + caption = '[img=item/' .. prototype.name .. '] | ' .. prototype.name }) - item_column.style.minimal_width = 22 + item_column.style.minimal_width = 200 item_column.style.font_color = color + item_column.style.horizontal_align = 'left' last_level = current_item_level end @@ -444,14 +452,20 @@ local function redraw_buff(data) level_label.style.minimal_width = 100 level_label.style.font_color = unlocked_color + local spacer = list.add({ + type = 'flow' + }) + spacer.style.minimal_width = 25 + local buff_caption local effect_value = effects.value + local effect_max = effects.max if name == 'mining_speed' then - buff_caption = format('+%d mining speed', effect_value) + buff_caption = format('+%d%% mining speed (up to: %d00%%)', effect_value, effect_max) elseif name == 'inventory_slot' then - buff_caption = format('+%d inventory slot%s', effect_value, effect_value > 1 and 's' or '') + buff_caption = format('+%d inventory slot%s (up to: %d)', effect_value, effect_value > 1 and 's' or '', effect_max) elseif name == 'health_bonus' then - buff_caption = format('+%d max health', effect_value) + buff_caption = format('+%d max health (up to: %d)', effect_value, effect_max) else buff_caption = format('+%d %s', effect_value, name) end diff --git a/map_gen/maps/diggy/feature/setup_player.lua b/map_gen/maps/diggy/feature/setup_player.lua index 435097bb..64630dd3 100644 --- a/map_gen/maps/diggy/feature/setup_player.lua +++ b/map_gen/maps/diggy/feature/setup_player.lua @@ -3,28 +3,25 @@ local Event = require 'utils.event' local SetupPlayer = {} global.SetupPlayer = { - first_player_spawned = false, + first_player_spawned = false } function SetupPlayer.register(config) - Event.add(defines.events.on_player_created, function () - local redmew_player_create = global.config.player_create + Event.add( + defines.events.on_player_created, + function() + local redmew_player_create = global.config.player_create - if #config.starting_items > 0 then - redmew_player_create.starting_items = config.starting_items + if #config.starting_items > 0 then + redmew_player_create.starting_items = config.starting_items + end + + if not _DEBUG then + local cheats = config.cheats + redmew_player_create.cheats = cheats + end end - - local cheats = config.cheats - local redmew_cheats = redmew_player_create.cheats - redmew_cheats.manual_mining_speed_modifier = cheats.manual_mining_speed_modifier - redmew_cheats.character_inventory_slots_bonus = cheats.character_inventory_slots_bonus - redmew_cheats.character_running_speed_modifier = cheats.character_running_speed_modifier - redmew_cheats.character_health_bonus = cheats.character_health_bonus - - if #cheats.starting_items > 0 then - redmew_cheats.starting_items = cheats.starting_items - end - end) + ) end return SetupPlayer diff --git a/map_gen/maps/diggy/feature/weapon_balance.lua b/map_gen/maps/diggy/feature/weapon_balance.lua new file mode 100644 index 00000000..a235d5d6 --- /dev/null +++ b/map_gen/maps/diggy/feature/weapon_balance.lua @@ -0,0 +1,93 @@ +local Event = require 'utils.event' +local floor = math.floor + +local player_ammo_starting_modifiers = { + ['artillery-shell'] = -0.75, + ['biological'] = -0.5, + ['bullet'] = -0.25, + ['cannon-shell'] = -0.15, + ['capsule'] = -0.5, + ['combat-robot-beam'] = -0.5, + ['combat-robot-laser'] = -0.5, + ['electric'] = -0.5, + ['flamethrower'] = -0, + ['grenade'] = -0.5, + ['landmine'] = -0.33, + ['laser-turret'] = -0.50, + ['melee'] = 1, + ['railgun'] = 0, + ['rocket'] = -0.4, + ['shotgun-shell'] = -0.20 +} + +local player_ammo_research_modifiers = { + ['artillery-shell'] = -0.75, + ['biological'] = -0.5, + ['bullet'] = -0.20, + ['cannon-shell'] = -0.15, + ['capsule'] = -0.5, + ['combat-robot-beam'] = -0.5, + ['combat-robot-laser'] = -0.5, + ['electric'] = -0.6, + ['flamethrower'] = -0, + ['grenade'] = -0.5, + ['landmine'] = -0.5, + ['laser-turret'] = -0.50, + ['melee'] = -0.5, + ['railgun'] = -0.5, + ['rocket'] = -0.4, + ['shotgun-shell'] = -0.20 +} + +local player_turrets_research_modifiers = { + ['gun-turret'] = -0.5, + ['laser-turret'] = -0.50, + ['flamethrower-turret'] = -0.25 +} + +local function init_weapon_damage() + local forces = game.forces + local p_force = forces.player + + for k, v in pairs(player_ammo_starting_modifiers) do + p_force.set_ammo_damage_modifier(k, v) + end +end + +local function research_finished(event) + local r = event.research + local p_force = r.force + + for _, e in ipairs(r.effects) do + local t = e.type + + if t == 'ammo-damage' then + local category = e.ammo_category + local factor = player_ammo_research_modifiers[category] + + if factor then + local current_m = p_force.get_ammo_damage_modifier(category) + local m = e.modifier + p_force.set_ammo_damage_modifier(category, floor((current_m + factor * m)*10)*0.1) + end + elseif t == 'turret-attack' then + local category = e.turret_id + local factor = player_turrets_research_modifiers[category] + + if factor then + local current_m = p_force.get_turret_attack_modifier(category) + local m = e.modifier + p_force.set_turret_attack_modifier(category, floor((current_m + factor * m)*10)*0.1) + end + end + end +end + +local weapon_balance = {} + +function weapon_balance.register() + Event.on_init(init_weapon_damage) + Event.add(defines.events.on_research_finished, research_finished) +end + +return weapon_balance