From 5a7b30f57009c2554528eb72a6ebc8935b914504 Mon Sep 17 00:00:00 2001 From: RedRafe Date: Mon, 9 Dec 2024 22:31:45 +0100 Subject: [PATCH] Move Diggy experience to common features/gui --- config.lua | 97 ++- control.lua | 3 + .../feature => features/gui}/experience.lua | 731 +++++++++--------- map_gen/maps/diggy/feature/cutscene.lua | 4 +- map_gen/maps/diggy/presets/danger_ores.lua | 96 --- .../maps/diggy/presets/danger_ores_BnB.lua | 96 --- map_gen/maps/diggy/presets/normal.lua | 96 --- map_gen/maps/diggy/scenario.lua | 1 + 8 files changed, 458 insertions(+), 666 deletions(-) rename {map_gen/maps/diggy/feature => features/gui}/experience.lua (68%) diff --git a/config.lua b/config.lua index 0ef80aece..f55caa107 100644 --- a/config.lua +++ b/config.lua @@ -471,7 +471,102 @@ storage.config = { }, admin_panel = { enabled = true, - } + }, + experience = { + enabled = false, + -- controls the formula for calculating level up costs in stone sent to surface + difficulty_scale = 20, -- Diggy default 20. Higher increases experience requirement climb + first_lvl_xp = 350, -- Diggy default 350. This sets the price for the first level. + xp_fine_tune = 400, -- Diggy default 400. 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 = { + ['big-rock'] = 5, + ['huge-rock'] = 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%) + }, + buffs = { + -- define new buffs here, they are handed out for each level + 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 } + }, + -- add or remove a table entry to add or remove an unlockable item from the market. + unlockables = { + { level = 2, price = 4, name = 'wood' }, + { level = 3, price = 5, name = 'stone-wall' }, + { level = 4, price = 20, name = 'pistol' }, + { level = 4, price = 5, name = 'firearm-magazine' }, + { level = 5, price = 100, name = 'light-armor' }, + { level = 6, price = 6, name = 'small-lamp' }, + { level = 6, price = 5, name = 'raw-fish' }, + { level = 8, price = 1, name = 'stone-brick' }, + { level = 10, price = 85, name = 'shotgun' }, + { level = 10, price = 4, name = 'shotgun-shell' }, + { level = 12, price = 200, name = 'heavy-armor' }, + { level = 14, price = 25, name = 'landfill' }, + { level = 15, price = 85, name = 'submachine-gun' }, + { level = 18, price = 10, name = 'piercing-rounds-magazine' }, + { level = 18, price = 8, name = 'piercing-shotgun-shell' }, + { level = 19, price = 2, name = 'rail' }, + { level = 19, price = 1, name = 'iron-stick' }, + { level = 20, price = 50, name = 'locomotive' }, + { level = 20, price = 350, name = 'modular-armor' }, + { level = 21, price = 5, name = 'rail-signal' }, + { level = 22, price = 5, name = 'rail-chain-signal' }, + { level = 23, price = 15, name = 'train-stop' }, + { level = 24, price = 35, name = 'cargo-wagon' }, + { level = 24, price = 35, name = 'fluid-wagon' }, + { level = 26, price = 150, name = 'tank' }, + { level = 29, price = 750, name = 'power-armor' }, + { level = 30, price = 30, name = 'logistic-robot' }, + { level = 31, price = 200, name = 'personal-roboport-equipment' }, + { level = 32, price = 20, name = 'construction-robot' }, + { level = 34, price = 750, name = 'fission-reactor-equipment' }, + { level = 35, price = 150, name = 'battery-equipment' }, + { level = 38, price = 250, name = 'exoskeleton-equipment' }, + { level = 40, price = 125, name = 'energy-shield-equipment' }, + { level = 42, price = 500, name = 'personal-laser-defense-equipment' }, + { level = 44, price = 1250, name = 'power-armor-mk2' }, + { level = 46, price = 750, name = 'battery-mk2-equipment' }, + { level = 48, price = 550, name = 'combat-shotgun' }, + { level = 51, price = 25, name = 'uranium-rounds-magazine' }, + { level = 63, price = 250, name = 'rocket-launcher' }, + { level = 63, price = 40, name = 'rocket' }, + { level = 71, price = 80, name = 'explosive-rocket' }, + { level = 78, price = 1000, name = 'satellite' }, + { level = 100, price = 2500, name = 'spidertron' }, + }, + -- modifies the experience per alien type, higher is more xp + alien_experience_modifiers = { + ['small-biter'] = 2, + ['small-spitter'] = 2, + ['small-worm-turret'] = 2, + ['medium-biter'] = 3, + ['medium-spitter'] = 3, + ['medium-worm-turret'] = 3, + ['big-biter'] = 5, + ['big-spitter'] = 5, + ['big-worm-turret'] = 5, + ['behemoth-biter'] = 7, + ['behemoth-spitter'] = 7, + ['behemoth-worm-turret'] = 7 + } + }, } return storage.config diff --git a/control.lua b/control.lua index f9d0136d1..65f0195f4 100644 --- a/control.lua +++ b/control.lua @@ -176,6 +176,9 @@ end if config.player_shortcuts.enabled then require 'features.gui.shortcuts' end +if config.experience.enabled then + require 'features.gui.experience' +end if config.score.enabled then require 'features.gui.score' end diff --git a/map_gen/maps/diggy/feature/experience.lua b/features/gui/experience.lua similarity index 68% rename from map_gen/maps/diggy/feature/experience.lua rename to features/gui/experience.lua index b2cd509f8..a28b3d451 100644 --- a/map_gen/maps/diggy/feature/experience.lua +++ b/features/gui/experience.lua @@ -1,48 +1,48 @@ --- dependencies +-- This feature adds an experience leveling system based on ForceControl.lua +-- made by Linaori & SimonFlapse +-- modified by Valansch, grilledham, RedRafe +-- ======================================================= -- + +local config = require 'config'.experience +local Color = require 'resources.color_presets' local Event = require 'utils.event' +local ForceControl = require 'features.force_control' local Game = require 'utils.game' local Global = require 'utils.global' -local Toast = require 'features.gui.toast' -local ForceControl = require 'features.force_control' -local ScoreTracker = require 'utils.score_tracker' -local Retailer = require 'features.retailer' local Gui = require 'utils.gui' +local Retailer = require 'features.retailer' +local ScoreTracker = require 'utils.score_tracker' +local Toast = require 'features.gui.toast' local Utils = require 'utils.core' -local Color = require 'resources.color_presets' -local floor = math.floor -local log = math.log -local max = math.max -local insert = table.insert -local pairs = pairs + +local Public = {} + local add_experience = ForceControl.add_experience local add_experience_percentage = ForceControl.add_experience_percentage -local remove_experience_percentage = ForceControl.remove_experience_percentage -local get_force_data = ForceControl.get_force_data -local set_item = Retailer.set_item local disable_item = Retailer.disable_item local enable_item = Retailer.enable_item -local experience_lost_name = 'experience-lost' - --- this -local Experience = {} +local get_force_data = ForceControl.get_force_data +local remove_experience_percentage = ForceControl.remove_experience_percentage +local set_item = Retailer.set_item -local mining_efficiency = { - active_modifier = 0, - research_modifier = 0, - level_modifier = 0 -} +local floor = math.floor +local insert = table.insert +local log = math.log +local max = math.max +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 inventory_slots = { - active_modifier = 0, - research_modifier = 0, - level_modifier = 0 -} -local health_bonus = { - active_modifier = 0, - research_modifier = 0, - level_modifier = 0 -} +local experience_lost_name = 'experience-lost' +local table_column_layout = { type = 'table', column_count = 3 } +local level_table = {} +local mining_efficiency = { active_modifier = 0, research_modifier = 0, level_modifier = 0 } +local inventory_slots = { active_modifier = 0, research_modifier = 0, level_modifier = 0 } +local health_bonus = { active_modifier = 0, research_modifier = 0, level_modifier = 0 } +local rock_big_xp +local rock_huge_xp Global.register( { @@ -57,15 +57,9 @@ Global.register( end ) -local config +-- == HELPERS ============================================================== -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 = 3} - -local level_up_formula = (function(level_reached) +local level_up_formula = function(level_reached) local difficulty_scale = floor(config.difficulty_scale) local level_fine_tune = floor(config.xp_fine_tune) local start_value = (floor(config.first_lvl_xp)) @@ -81,9 +75,8 @@ local level_up_formula = (function(level_reached) end lower_value = lower_value - (lower_value % (10 ^ (floor(log(lower_value, 10)) - precision))) return value - lower_value -end) +end -local level_table = {} ---Get experience requirement for a given level ---Primarily used for the Experience GUI to display total experience required to unlock a specific item ---@param level number a number specifying the level @@ -100,6 +93,7 @@ local function calculate_level_xp(level) end return level_table[level] end + ---Get a percentage of required experience between a level and the next level ---@param level number a number specifying the current level ---@return number a percentage of the required experience to level up from one level to the other @@ -107,95 +101,221 @@ local function percentage_of_level_req(level, percentage) return level_up_formula(level) * percentage end ----Updates the market contents based on the current level. ----@param force LuaForce the force which the unlocking requirement should be based of -function Experience.update_market_contents(force) - local current_level = get_force_data(force).current_level - local force_name = force.name +-- == GUI ===================================================================== + +local main_frame_name = Gui.uid_name() +local main_button_name = Gui.uid_name() + +local function redraw_title(data) + local force_data = get_force_data('player') + data.frame.caption = { 'diggy.gui_total_xp', Utils.comma_value(force_data.total_experience) } +end + +local function apply_heading_style(style, width) + style.font = 'default-bold' + style.width = width +end + +local function redraw_heading(data, header) + local head_condition = (header == 1) + local frame = (head_condition) and data.experience_list_heading or data.buff_list_heading + local header_caption = (head_condition) and { 'diggy.gui_reward_item' } or { 'diggy.gui_reward_buff' } + Gui.clear(frame) + + local heading_table = frame.add(table_column_layout) + apply_heading_style(heading_table.add({ type = 'label', caption = { 'diggy.gui_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 + +local function redraw_progressbar(data) + local force_data = get_force_data('player') + local flow = data.experience_progressbars + Gui.clear(flow) + + apply_heading_style(flow.add({ + type = 'label', + tooltip = { + 'diggy.gui_progress_tip', + force_data.current_level, + Utils.comma_value((force_data.total_experience - force_data.current_experience) + force_data.experience_level_up_cap), + Utils.comma_value(force_data.experience_level_up_cap - force_data.current_experience), + }, + caption = { 'diggy.gui_progress_caption' }, + }).style) + local level_progressbar = flow.add({ type = 'progressbar', tooltip = { 'diggy.gui_progress_bar', floor(force_data.experience_percentage * 100) * 0.01 } }) + level_progressbar.style.width = 350 + level_progressbar.value = force_data.experience_percentage * 0.01 +end + +local function redraw_table(data) + local experience_scroll_pane = data.experience_scroll_pane + Gui.clear(experience_scroll_pane) + + redraw_progressbar(data) + redraw_heading(data, 1) + + local last_level = 0 + local current_force_level = get_force_data('player').current_level + for _, prototype in pairs(config.unlockables) do - local prototype_level = prototype.level - if current_level < prototype_level then - disable_item(force_name, prototype.name, {'diggy.market_disabled', prototype_level}) + local current_item_level = prototype.level + local first_item_for_level = current_item_level ~= last_level + local color + + if current_force_level >= current_item_level then + color = unlocked_color else - enable_item(force_name, prototype.name) + color = locked_color end - end -end ----Updates a forces manual mining speed modifier. By removing active modifiers and re-adding ----@param force LuaForce the force of which will be updated ----@param level_up number a level if updating as part of a level up (optional) -function Experience.update_mining_speed(force, level_up) - local buff = config.buffs['mining_speed'] - if buff.max == nil or force.manual_mining_speed_modifier < buff.max then - level_up = level_up ~= nil and level_up or 0 - if level_up > 0 and buff ~= nil then - local level = get_force_data(force).current_level - local adjusted_value = floor(max(buff.value, 24 * 0.9 ^ level)) - local value = (buff.double_level ~= nil and level_up % buff.double_level == 0) and adjusted_value * 2 or adjusted_value - mining_efficiency.level_modifier = mining_efficiency.level_modifier + (value * 0.01) + local list = experience_scroll_pane.add(table_column_layout) + + local level_caption = '' + if first_item_for_level then + level_caption = { 'diggy.gui_tabel_level', current_item_level } end - -- remove the current buff - local old_modifier = force.manual_mining_speed_modifier - mining_efficiency.active_modifier - old_modifier = old_modifier >= 0 and old_modifier or 0 - -- update the active modifier - mining_efficiency.active_modifier = mining_efficiency.research_modifier + mining_efficiency.level_modifier - -- add the new active modifier to the non-buffed modifier - force.manual_mining_speed_modifier = old_modifier + mining_efficiency.active_modifier + local level_column = list.add({ + type = 'label', + caption = level_caption, + tooltip = { 'diggy.gui_tabel_xp', Utils.comma_value(calculate_level_xp(current_item_level)) }, + }) + 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 = '[img=item/' .. prototype.name .. '] | ' .. prototype.name }) + item_column.style.minimal_width = 200 + item_column.style.font_color = color + item_column.style.horizontal_align = 'left' + + last_level = current_item_level end end ----Updates a forces inventory slots. By removing active modifiers and re-adding ----@param force LuaForce the force of which will be updated ----@param level_up number a level if updating as part of a level up (optional) -function Experience.update_inventory_slots(force, level_up) - local buff = config.buffs['inventory_slot'] - if buff.max == nil or force.character_inventory_slots_bonus < buff.max then - level_up = level_up ~= nil and level_up or 0 - if level_up > 0 and buff ~= nil then - local value = (buff.double_level ~= nil and level_up % buff.double_level == 0) and buff.value * 2 or buff.value - inventory_slots.level_modifier = inventory_slots.level_modifier + value +local function redraw_buff(data) + local buff_scroll_pane = data.buff_scroll_pane + Gui.clear(buff_scroll_pane) + + local all_levels_shown = false + for name, effects in pairs(config.buffs) do + local list = buff_scroll_pane.add(table_column_layout) + list.style.horizontal_spacing = 16 + + local level_caption = '' + if not all_levels_shown then + all_levels_shown = true + level_caption = { 'diggy.gui_buff_level' } end - -- remove the current buff - local old_modifier = force.character_inventory_slots_bonus - inventory_slots.active_modifier - old_modifier = old_modifier >= 0 and old_modifier or 0 - -- update the active modifier - inventory_slots.active_modifier = inventory_slots.research_modifier + inventory_slots.level_modifier + local level_label = list.add({ type = 'label', caption = level_caption }) + level_label.style.minimal_width = 100 + level_label.style.font_color = unlocked_color - -- add the new active modifier to the non-buffed modifier - force.character_inventory_slots_bonus = old_modifier + inventory_slots.active_modifier + 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 = { 'diggy.gui_buff_mining', effect_value, effect_max * 100 } + elseif name == 'inventory_slot' then + buff_caption = { 'diggy.gui_buff_inv', effect_value, effect_max } + elseif name == 'health_bonus' then + buff_caption = { 'diggy.gui_buff_health', effect_value, effect_max } + else + buff_caption = { 'diggy.gui_buff_other', effect_value, name } + end + + local buffs_label = list.add({ type = 'label', caption = buff_caption }) + buffs_label.style.minimal_width = 220 + buffs_label.style.font_color = unlocked_color end end ----Updates a forces health bonus. By removing active modifiers and re-adding ----@param force LuaForce the force of which will be updated ----@param level_up number a level if updating as part of a level up (optional) -function Experience.update_health_bonus(force, level_up) - local buff = config.buffs['health_bonus'] - if buff.max == nil or force.character_health_bonus < buff.max then - level_up = level_up ~= nil and level_up or 0 - if level_up > 0 and buff ~= nil then - local value = (buff.double_level ~= nil and level_up % buff.double_level == 0) and buff.value * 2 or buff.value - health_bonus.level_modifier = health_bonus.level_modifier + value +local function toggle(event) + local player = event.player + local frame = Gui.get_left_element(player, main_frame_name) + + if (frame and event.trigger == nil) then + Gui.destroy(frame) + local main_button = Gui.get_top_element(player, main_button_name) + if main_button then + main_button.toggled = false end + return + elseif (frame) then + local data = Gui.get_data(frame) + redraw_title(data) + redraw_progressbar(data) + redraw_table(data) + return + end - -- remove the current buff - local old_modifier = force.character_health_bonus - health_bonus.active_modifier - old_modifier = old_modifier >= 0 and old_modifier or 0 - -- update the active modifier - health_bonus.active_modifier = health_bonus.research_modifier + health_bonus.level_modifier + frame = Gui.add_left_element(player, { name = main_frame_name, type = 'frame', direction = 'vertical' }) - -- add the new active modifier to the non-buffed modifier - force.character_health_bonus = old_modifier + health_bonus.active_modifier + local experience_progressbars = frame.add({ type = 'flow', direction = 'vertical' }) + local experience_list_heading = frame.add({ type = 'flow', direction = 'horizontal' }) + + local experience_scroll_pane = frame.add({ type = 'scroll-pane' }) + experience_scroll_pane.style.maximal_height = 300 + + local buff_list_heading = frame.add({ type = 'flow', direction = 'horizontal' }) + + local buff_scroll_pane = frame.add({ type = 'scroll-pane' }) + buff_scroll_pane.style.maximal_height = 100 + + frame.add({ type = 'button', name = main_button_name, caption = { 'diggy.gui_close_btn' } }) + + local data = { + frame = frame, + experience_progressbars = experience_progressbars, + experience_list_heading = experience_list_heading, + experience_scroll_pane = experience_scroll_pane, + buff_list_heading = buff_list_heading, + buff_scroll_pane = buff_scroll_pane, + } + + redraw_title(data) + redraw_table(data) + + redraw_heading(data, 2) + redraw_buff(data) + + Gui.set_data(frame, data) +end + +---Updates the experience progress gui for every player that has it open +local function update_gui() + local players = game.connected_players + for i = #players, 1, -1 do + local p = players[i] + local frame = Gui.get_left_element(p, main_frame_name) + + if frame and frame.valid then + local data = { player = p, trigger = 'update_gui' } + Public.toggle(data) + end end + + -- Resets buffs if they have been set to 0 + local force = game.forces.player + Public.update_inventory_slots(force, 0) + Public.update_mining_speed(force, 0) + Public.update_health_bonus(force, 0) end --- declaration of variables to prevent table look ups @see Experience.register -local sand_rock_xp -local rock_big_xp -local rock_huge_xp +Gui.allow_player_to_toggle_top_element_visibility(main_button_name) +Gui.on_click(main_button_name, toggle) +Gui.on_custom_close(main_frame_name, function(event) + event.element.destroy() +end) + +-- == EVENTS ================================================================== ---Awards experience when a rock has been mined (increases by 1 XP every 5th level) ---@param event LuaEvent @@ -207,8 +327,6 @@ local function on_player_mined_entity(event) local level = get_force_data(force).current_level local exp = 0 if name == 'big-rock' then - exp = sand_rock_xp + floor(level / 5) - elseif name == 'big-rock' then exp = rock_big_xp + floor(level / 5) elseif name == 'huge-rock' then exp = rock_huge_xp + floor(level / 5) @@ -218,7 +336,7 @@ local function on_player_mined_entity(event) return end - local text = {'', '[img=entity/' .. name .. '] ', {'diggy.float_xp_gained_mine', exp}} + local text = { '', '[img=entity/' .. name .. '] ', { 'diggy.float_xp_gained_mine', exp } } local player = game.get_player(player_index) player.create_local_flying_text { text = text, color = gain_xp_color, position = player.position } add_experience(force, exp) @@ -242,8 +360,8 @@ local function on_research_finished(event) end exp = award_xp * research.research_unit_count end - local text = {'', '[img=item/automation-science-pack] ', {'diggy.float_xp_gained_research', exp}} - Game.create_local_flying_text{ text = text, color = gain_xp_color, create_at_cursor = true } + local text = { '', '[img=item/automation-science-pack] ', { 'diggy.float_xp_gained_research', exp } } + Game.create_local_flying_text { text = text, color = gain_xp_color, create_at_cursor = true } add_experience(force, exp) local current_modifier = mining_efficiency.research_modifier @@ -257,9 +375,9 @@ local function on_research_finished(event) mining_efficiency.research_modifier = new_modifier inventory_slots.research_modifier = force.mining_drill_productivity_bonus * 50 -- 1 per level - Experience.update_inventory_slots(force, 0) - Experience.update_mining_speed(force, 0) - Experience.update_health_bonus(force, 0) + Public.update_inventory_slots(force, 0) + Public.update_mining_speed(force, 0) + Public.update_health_bonus(force, 0) end ---Awards experience when a rocket has been launched based on percentage of total experience @@ -268,7 +386,7 @@ local function on_rocket_launched(event) local force = event.rocket.force local exp = add_experience_percentage(force, config.XP['rocket_launch'], nil, config.XP['rocket_launch_max']) - local text = {'', '[img=item/satellite] ', {'diggy.float_xp_gained_rocket', exp}} + local text = { '', '[img=item/satellite] ', { 'diggy.float_xp_gained_rocket', exp } } Game.create_local_flying_text { text = text, color = gain_xp_color, create_at_cursor = true } end @@ -280,7 +398,7 @@ local function on_entity_died(event) local cause = event.cause local entity_name = entity.name - --For bot mining and turrets + -- For bot mining and turrets if not cause or not cause.valid or cause.type ~= 'character' then local exp = 0 local floating_text_position @@ -293,8 +411,6 @@ local function on_entity_died(event) else local level = get_force_data(force).current_level if entity_name == 'big-rock' then - exp = floor((sand_rock_xp + level * 0.2) * 0.5) - elseif entity_name == 'big-rock' then exp = floor((rock_big_xp + level * 0.2) * 0.5) elseif entity_name == 'huge-rock' then exp = floor((rock_huge_xp + level * 0.2) * 0.5) @@ -304,7 +420,12 @@ local function on_entity_died(event) end if exp > 0 then - Game.create_local_flying_text({ surface = entity.surface, position = floating_text_position, text = {'', '[img=entity/' .. entity_name .. '] ', {'diggy.float_xp_gained_kill', exp}}, color = gain_xp_color}) + Game.create_local_flying_text({ + surface = entity.surface, + position = floating_text_position, + text = { '', '[img=entity/' .. entity_name .. '] ', { 'diggy.float_xp_gained_kill', exp } }, + color = gain_xp_color, + }) add_experience(force, exp) end @@ -316,7 +437,11 @@ local function on_entity_died(event) end local exp = config.XP['enemy_killed'] * (config.alien_experience_modifiers[entity.name] or 1) - cause.player.create_local_flying_text { position = cause.player.position, text = {'', '[img=entity/' .. entity_name .. '] ', {'diggy.float_xp_gained_kill', exp}}, color = gain_xp_color } + cause.player.create_local_flying_text { + position = cause.player.position, + text = { '', '[img=entity/' .. entity_name .. '] ', { 'diggy.float_xp_gained_kill', exp } }, + color = gain_xp_color, + } add_experience(force, exp) end @@ -325,282 +450,147 @@ end local function on_player_respawned(event) local player = game.get_player(event.player_index) local exp = remove_experience_percentage(player.force, config.XP['death-penalty'], 50) - local text = {'', '[img=entity.character]', {'diggy.float_xp_drain', exp}} - game.print({'diggy.player_drained_xp', player.name, exp}, {color = lose_xp_color}) + local text = { '', '[img=entity.character]', { 'diggy.float_xp_drain', exp } } + game.print({ 'diggy.player_drained_xp', player.name, exp }, { color = lose_xp_color }) Game.create_local_flying_text { surface = player.surface, text = text, color = lose_xp_color, create_at_cursor = true } ScoreTracker.change_for_global(experience_lost_name, exp) end -local function redraw_title(data) - local force_data = get_force_data('player') - data.frame.caption = {'diggy.gui_total_xp', Utils.comma_value(force_data.total_experience)} -end - -local function apply_heading_style(style, width) - style.font = 'default-bold' - style.width = width -end - -local function redraw_heading(data, header) - local head_condition = (header == 1) - local frame = (head_condition) and data.experience_list_heading or data.buff_list_heading - local header_caption = (head_condition) and {'diggy.gui_reward_item'} or {'diggy.gui_reward_buff'} - Gui.clear(frame) - - local heading_table = frame.add(table_column_layout) - apply_heading_style(heading_table.add({type = 'label', caption = {'diggy.gui_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 - -local function redraw_progressbar(data) - local force_data = get_force_data('player') - local flow = data.experience_progressbars - Gui.clear(flow) +local function on_player_created(event) + local player = game.get_player(event.player_index) + if not (player and player.valid) then + return + end - apply_heading_style( - flow.add( - { - type = 'label', - tooltip = {'diggy.gui_progress_tip', force_data.current_level, Utils.comma_value((force_data.total_experience - force_data.current_experience) + force_data.experience_level_up_cap), Utils.comma_value(force_data.experience_level_up_cap - force_data.current_experience)}, - name = 'Diggy.Experience.Frame.Progress.Level', - caption = {'diggy.gui_progress_caption'} - } - ).style - ) - local level_progressbar = flow.add({type = 'progressbar', tooltip = {'diggy.gui_progress_bar', floor(force_data.experience_percentage * 100) * 0.01}}) - level_progressbar.style.width = 350 - level_progressbar.value = force_data.experience_percentage * 0.01 + Gui.add_top_element(player, { + name = main_button_name, + type = 'sprite-button', + sprite = 'entity/market', + tooltip = { 'diggy.gui_experience_button_tip' }, + auto_toggle = true, + }) end -local function redraw_table(data) - local experience_scroll_pane = data.experience_scroll_pane - Gui.clear(experience_scroll_pane) - - redraw_progressbar(data) - redraw_heading(data, 1) +-- == EXPERIENCE ============================================================== - local last_level = 0 - local current_force_level = get_force_data('player').current_level +--- Toggle the player's experience main window +Public.toggle = toggle +---Updates the market contents based on the current level. +---@param force LuaForce the force which the unlocking requirement should be based of +Public.update_market_contents = function(force) + local current_level = get_force_data(force).current_level + local force_name = force.name for _, prototype in pairs(config.unlockables) do - local current_item_level = prototype.level - local first_item_for_level = current_item_level ~= last_level - local color - - if current_force_level >= current_item_level then - color = unlocked_color + local prototype_level = prototype.level + if current_level < prototype_level then + disable_item(force_name, prototype.name, { 'diggy.market_disabled', prototype_level }) else - color = locked_color + enable_item(force_name, prototype.name) end + end +end - local list = experience_scroll_pane.add(table_column_layout) - - local level_caption = '' - if first_item_for_level then - level_caption = {'diggy.gui_tabel_level', current_item_level} +---Updates a forces manual mining speed modifier. By removing active modifiers and re-adding +---@param force LuaForce the force of which will be updated +---@param level_up? number a level if updating as part of a level up +Public.update_mining_speed = function(force, level_up) + local buff = config.buffs['mining_speed'] + if buff.max == nil or force.manual_mining_speed_modifier < buff.max then + level_up = level_up ~= nil and level_up or 0 + if level_up > 0 and buff ~= nil then + local level = get_force_data(force).current_level + local adjusted_value = floor(max(buff.value, 24 * 0.9 ^ level)) + local value = (buff.double_level ~= nil and level_up % buff.double_level == 0) and adjusted_value * 2 or adjusted_value + mining_efficiency.level_modifier = mining_efficiency.level_modifier + (value * 0.01) end + -- remove the current buff + local old_modifier = force.manual_mining_speed_modifier - mining_efficiency.active_modifier + old_modifier = old_modifier >= 0 and old_modifier or 0 + -- update the active modifier + mining_efficiency.active_modifier = mining_efficiency.research_modifier + mining_efficiency.level_modifier - local level_column = - list.add( - { - type = 'label', - caption = level_caption, - tooltip = {'diggy.gui_tabel_xp', Utils.comma_value(calculate_level_xp(current_item_level))} - } - ) - 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 = '[img=item/' .. prototype.name .. '] | ' .. prototype.name - } - ) - item_column.style.minimal_width = 200 - item_column.style.font_color = color - item_column.style.horizontal_align = 'left' - - last_level = current_item_level + -- add the new active modifier to the non-buffed modifier + force.manual_mining_speed_modifier = old_modifier + mining_efficiency.active_modifier end end -local function redraw_buff(data) - local buff_scroll_pane = data.buff_scroll_pane - Gui.clear(buff_scroll_pane) - - local all_levels_shown = false - for name, effects in pairs(config.buffs) do - local list = buff_scroll_pane.add(table_column_layout) - list.style.horizontal_spacing = 16 - - local level_caption = '' - if not all_levels_shown then - all_levels_shown = true - level_caption = {'diggy.gui_buff_level'} +---Updates a forces inventory slots. By removing active modifiers and re-adding +---@param force LuaForce the force of which will be updated +---@param level_up? number a level if updating as part of a level up +Public.update_inventory_slots = function(force, level_up) + local buff = config.buffs['inventory_slot'] + if buff.max == nil or force.character_inventory_slots_bonus < buff.max then + level_up = level_up ~= nil and level_up or 0 + if level_up > 0 and buff ~= nil then + local value = (buff.double_level ~= nil and level_up % buff.double_level == 0) and buff.value * 2 or buff.value + inventory_slots.level_modifier = inventory_slots.level_modifier + value end - local level_label = list.add({type = 'label', caption = level_caption}) - 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 = {'diggy.gui_buff_mining', effect_value, effect_max * 100} - elseif name == 'inventory_slot' then - buff_caption = {'diggy.gui_buff_inv', effect_value, effect_max} - elseif name == 'health_bonus' then - buff_caption = {'diggy.gui_buff_health', effect_value, effect_max} - else - buff_caption = {'diggy.gui_buff_other', effect_value, name} - end + -- remove the current buff + local old_modifier = force.character_inventory_slots_bonus - inventory_slots.active_modifier + old_modifier = old_modifier >= 0 and old_modifier or 0 + -- update the active modifier + inventory_slots.active_modifier = inventory_slots.research_modifier + inventory_slots.level_modifier - local buffs_label = list.add({type = 'label', caption = buff_caption}) - buffs_label.style.minimal_width = 220 - buffs_label.style.font_color = unlocked_color + -- add the new active modifier to the non-buffed modifier + force.character_inventory_slots_bonus = old_modifier + inventory_slots.active_modifier end end -function Experience.toggle(event) - local player = event.player - local frame = Gui.get_left_element(player, 'Diggy.Experience.Frame') - - if (frame and event.trigger == nil) then - Gui.destroy(frame) - local main_button = Gui.get_top_element(player, 'Diggy.Experience.Button') - if main_button then - main_button.toggled = false +---Updates a forces health bonus. By removing active modifiers and re-adding +---@param force LuaForce the force of which will be updated +---@param level_up? number a level if updating as part of a level up +Public.update_health_bonus = function(force, level_up) + local buff = config.buffs['health_bonus'] + if buff.max == nil or force.character_health_bonus < buff.max then + level_up = level_up ~= nil and level_up or 0 + if level_up > 0 and buff ~= nil then + local value = (buff.double_level ~= nil and level_up % buff.double_level == 0) and buff.value * 2 or buff.value + health_bonus.level_modifier = health_bonus.level_modifier + value end - return - elseif (frame) then - local data = Gui.get_data(frame) - redraw_title(data) - redraw_progressbar(data) - redraw_table(data) - return - end - - frame = Gui.add_left_element(player, {name = 'Diggy.Experience.Frame', type = 'frame', direction = 'vertical'}) - - local experience_progressbars = frame.add({type = 'flow', direction = 'vertical'}) - local experience_list_heading = frame.add({type = 'flow', direction = 'horizontal'}) - - local experience_scroll_pane = frame.add({type = 'scroll-pane'}) - experience_scroll_pane.style.maximal_height = 300 - - local buff_list_heading = frame.add({type = 'flow', direction = 'horizontal'}) - - local buff_scroll_pane = frame.add({type = 'scroll-pane'}) - buff_scroll_pane.style.maximal_height = 100 - - frame.add({type = 'button', name = 'Diggy.Experience.Button', caption = {'diggy.gui_close_btn'}}) - - local data = { - frame = frame, - experience_progressbars = experience_progressbars, - experience_list_heading = experience_list_heading, - experience_scroll_pane = experience_scroll_pane, - buff_list_heading = buff_list_heading, - buff_scroll_pane = buff_scroll_pane - } - - redraw_title(data) - redraw_table(data) - - redraw_heading(data, 2) - redraw_buff(data) - Gui.set_data(frame, data) -end + -- remove the current buff + local old_modifier = force.character_health_bonus - health_bonus.active_modifier + old_modifier = old_modifier >= 0 and old_modifier or 0 + -- update the active modifier + health_bonus.active_modifier = health_bonus.research_modifier + health_bonus.level_modifier -local function on_player_created(event) - local player= game.get_player(event.player_index) - if not (player and player.valid) then - return + -- add the new active modifier to the non-buffed modifier + force.character_health_bonus = old_modifier + health_bonus.active_modifier end - - Gui.add_top_element(player, - { - name = 'Diggy.Experience.Button', - type = 'sprite-button', - sprite = 'entity/market', - tooltip = {'diggy.gui_experience_button_tip'}, - auto_toggle = true, - } - ) end -Gui.allow_player_to_toggle_top_element_visibility('Diggy.Experience.Button') - -Gui.on_click('Diggy.Experience.Button', Experience.toggle) -Gui.on_custom_close( - 'Diggy.Experience.Frame', - function(event) - event.element.destroy() - end -) - ----Updates the experience progress gui for every player that has it open -local function update_gui() - local players = game.connected_players - for i = #players, 1, -1 do - local p = players[i] - local frame = Gui.get_left_element(p, 'Diggy.Experience.Frame') +Public.on_init = function() + -- Adds the 'player' force to participate in the force control system. + local force = game.forces.player + ForceControl.register_force(force) - if frame and frame.valid then - local data = {player = p, trigger = 'update_gui'} - Experience.toggle(data) - end + local force_name = force.name + for _, prototype in pairs(config.unlockables) do + set_item(force_name, prototype) end - --Resets buffs if they have been set to 0 - local force = game.forces.player - Experience.update_inventory_slots(force, 0) - Experience.update_mining_speed(force, 0) - Experience.update_health_bonus(force, 0) + Public.update_market_contents(force) end -function Experience.register(cfg) - ScoreTracker.register(experience_lost_name, {'diggy.score_experience_lost'}, '[img=recipe.artillery-targeting-remote]') +Public.register = function(cfg) + ScoreTracker.register(experience_lost_name, { 'diggy.score_experience_lost' }, '[img=recipe.artillery-targeting-remote]') local global_to_show = storage.config.score.global_to_show global_to_show[#global_to_show + 1] = experience_lost_name - config = cfg - - --Adds the function on how to calculate level caps (When to level up) + -- Adds the function on how to calculate level caps (When to level up) local ForceControlBuilder = ForceControl.register(level_up_formula) - --Adds a function that'll be executed at every level up - ForceControlBuilder.register_on_every_level( - function(level_reached, force) - Toast.toast_force(force, 10, {'diggy.toast_new_level', level_reached}) - Experience.update_inventory_slots(force, level_reached) - Experience.update_mining_speed(force, level_reached) - Experience.update_health_bonus(force, level_reached) - Experience.update_market_contents(force) - end - ) + -- Adds a function that'll be executed at every level up + ForceControlBuilder.register_on_every_level(function(level_reached, force) + Toast.toast_force(force, 10, { 'diggy.toast_new_level', level_reached }) + Public.update_inventory_slots(force, level_reached) + Public.update_mining_speed(force, level_reached) + Public.update_health_bonus(force, level_reached) + Public.update_market_contents(force) + end) -- Events Event.add(defines.events.on_player_mined_entity, on_player_mined_entity) @@ -612,22 +602,13 @@ function Experience.register(cfg) Event.on_nth_tick(61, update_gui) -- Prevents table lookup thousands of times - sand_rock_xp = config.XP['big-rock'] - rock_big_xp = config.XP['big-rock'] - rock_huge_xp = config.XP['huge-rock'] + rock_big_xp = cfg.XP['big-rock'] + rock_huge_xp = cfg.XP['huge-rock'] end -function Experience.on_init() - --Adds the 'player' force to participate in the force control system. - local force = game.forces.player - ForceControl.register_force(force) - - local force_name = force.name - for _, prototype in pairs(config.unlockables) do - set_item(force_name, prototype) - end +-- ============================================================================ - Experience.update_market_contents(force) -end +Event.on_init(Public.on_init) +Public.register(config) -return Experience +return Public diff --git a/map_gen/maps/diggy/feature/cutscene.lua b/map_gen/maps/diggy/feature/cutscene.lua index 104a401c5..453ca31a2 100644 --- a/map_gen/maps/diggy/feature/cutscene.lua +++ b/map_gen/maps/diggy/feature/cutscene.lua @@ -7,7 +7,7 @@ local CS_Rendering = require 'features.cutscene.rendering' local RS = require 'map_gen.shared.redmew_surface' local Color = require 'resources.color_presets' local PC = require 'features.player_create' -local Experience = require 'map_gen.maps.diggy.feature.experience' +local Experience = require 'features.gui.experience' local register_rendering = Cutscene.register_rendering local play_sound = Cutscene.play_sound local draw_text = CS_Rendering.draw_text @@ -132,7 +132,7 @@ local function cutscene_function(player_index, waypoint_index, params) draw_text_auto_replacing(tick, settings, {x = 8.5, y = 3}, {'This is our toolbar!'}, player, {scale = 2.5, alignment = 'left'}, false, true, 275) - draw_text_auto_replacing(tick, settings, {x = 8.5, y = 3}, {'', "Here you'll find a wide range of tools and informations about us!"}, player, {scale = 2.5, alignment = 'left'}, false, true, 275 * 2) + draw_text_auto_replacing(tick, settings, {x = 8.5, y = 3}, {'', "Here you'll find a wide range of tools and information about us!"}, player, {scale = 2.5, alignment = 'left'}, false, true, 275 * 2) draw_text_auto_replacing(tick, settings, {x = 8.5, y = 3}, {'', '', 'Hover your mouse over them for more information'}, player, {scale = 2.5, alignment = 'left'}, false, true, 275 * 3) diff --git a/map_gen/maps/diggy/presets/danger_ores.lua b/map_gen/maps/diggy/presets/danger_ores.lua index 56ddf5f76..f87a4d834 100644 --- a/map_gen/maps/diggy/presets/danger_ores.lua +++ b/map_gen/maps/diggy/presets/danger_ores.lua @@ -346,102 +346,6 @@ local config = { autojail = true, allowed_collapses_first_hour = 4 }, - experience = { - enabled = true, - load = function() return require('map_gen.maps.diggy.feature.experience') end, - -- controls the formula for calculating level up costs in stone sent to surface - difficulty_scale = 20, -- Diggy default 15. Higher increases experience requirement climb - 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 = { - ['big-rock'] = 5, - ['huge-rock'] = 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%) - }, - buffs = { - -- define new buffs here, they are handed out for each level - 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} - }, - -- add or remove a table entry to add or remove a unlockable item from the market. - unlockables = { - {level = 2, price = 4, name = 'wood'}, - {level = 3, price = 5, name = 'stone-wall'}, - {level = 4, price = 20, name = 'pistol'}, - {level = 4, price = 5, name = 'firearm-magazine'}, - {level = 5, price = 100, name = 'light-armor'}, - {level = 6, price = 6, name = 'small-lamp'}, - {level = 6, price = 5, name = 'raw-fish'}, - {level = 8, price = 1, name = 'stone-brick'}, - {level = 10, price = 85, name = 'shotgun'}, - {level = 10, price = 4, name = 'shotgun-shell'}, - {level = 12, price = 200, name = 'heavy-armor'}, - {level = 14, price = 25, name = 'landfill'}, --Decreased to 25 from 35 - {level = 15, price = 85, name = 'submachine-gun'}, - {level = 18, price = 10, name = 'piercing-rounds-magazine'}, - {level = 18, price = 8, name = 'piercing-shotgun-shell'}, - {level = 19, price = 2, name = 'rail'}, - {level = 20, price = 50, name = 'locomotive'}, - {level = 20, price = 350, name = 'modular-armor'}, - {level = 21, price = 5, name = 'rail-signal'}, - {level = 22, price = 5, name = 'rail-chain-signal'}, - {level = 23, price = 15, name = 'train-stop'}, - {level = 24, price = 35, name = 'cargo-wagon'}, - {level = 24, price = 35, name = 'fluid-wagon'}, - {level = 26, price = 150, name = 'tank'}, - {level = 29, price = 750, name = 'power-armor'}, - {level = 30, price = 30, name = 'logistic-robot'}, - {level = 31, price = 200, name = 'personal-roboport-equipment'}, - {level = 32, price = 20, name = 'construction-robot'}, - {level = 34, price = 750, name = 'fission-reactor-equipment'}, - {level = 35, price = 150, name = 'battery-equipment'}, - {level = 38, price = 250, name = 'exoskeleton-equipment'}, - {level = 40, price = 125, name = 'energy-shield-equipment'}, - {level = 42, price = 500, name = 'personal-laser-defense-equipment'}, - {level = 44, price = 1250, name = 'power-armor-mk2'}, - {level = 46, price = 750, name = 'battery-mk2-equipment'}, - {level = 48, price = 550, name = 'combat-shotgun'}, - {level = 51, price = 25, name = 'uranium-rounds-magazine'}, - {level = 63, price = 250, name = 'rocket-launcher'}, - {level = 63, price = 40, name = 'rocket'}, - {level = 71, price = 80, name = 'explosive-rocket'}, - {level = 78, price = 1000, name = 'satellite'}, - {level = 100, price = 2500, name = 'spidertron'}, - {level = 100, price = 1, name = 'iron-stick'} - }, - -- modifies the experience per alien type, higher is more xp - alien_experience_modifiers = { - ['small-biter'] = 2, - ['small-spitter'] = 2, - ['small-worm-turret'] = 2, - ['medium-biter'] = 3, - ['medium-spitter'] = 3, - ['medium-worm-turret'] = 3, - ['big-biter'] = 5, - ['big-spitter'] = 5, - ['big-worm-turret'] = 5, - ['behemoth-biter'] = 7, - ['behemoth-spitter'] = 7, - ['behemoth-worm-turret'] = 7 - } - }, weapon_balance = { enabled = true, load = function() return require('map_gen.maps.diggy.feature.weapon_balance') end diff --git a/map_gen/maps/diggy/presets/danger_ores_BnB.lua b/map_gen/maps/diggy/presets/danger_ores_BnB.lua index 3888e1f73..ff1ec72e3 100644 --- a/map_gen/maps/diggy/presets/danger_ores_BnB.lua +++ b/map_gen/maps/diggy/presets/danger_ores_BnB.lua @@ -346,102 +346,6 @@ local config = { autojail = true, allowed_collapses_first_hour = 4 }, - experience = { - enabled = true, - load = function() return require('map_gen.maps.diggy.feature.experience') end, - -- controls the formula for calculating level up costs in stone sent to surface - difficulty_scale = 20, -- Diggy default 15. Higher increases experience requirement climb - 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 = { - ['big-rock'] = 5, - ['huge-rock'] = 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%) - }, - buffs = { - -- define new buffs here, they are handed out for each level - 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} - }, - -- add or remove a table entry to add or remove a unlockable item from the market. - unlockables = { - {level = 2, price = 4, name = 'wood'}, - {level = 3, price = 5, name = 'stone-wall'}, - {level = 4, price = 20, name = 'pistol'}, - {level = 4, price = 5, name = 'firearm-magazine'}, - {level = 5, price = 100, name = 'light-armor'}, - {level = 6, price = 6, name = 'small-lamp'}, - {level = 6, price = 5, name = 'raw-fish'}, - {level = 8, price = 1, name = 'stone-brick'}, - {level = 10, price = 85, name = 'shotgun'}, - {level = 10, price = 4, name = 'shotgun-shell'}, - {level = 12, price = 200, name = 'heavy-armor'}, - {level = 14, price = 25, name = 'landfill'}, --Decreased to 25 from 35 - {level = 15, price = 85, name = 'submachine-gun'}, - {level = 18, price = 10, name = 'piercing-rounds-magazine'}, - {level = 18, price = 8, name = 'piercing-shotgun-shell'}, - {level = 19, price = 2, name = 'rail'}, - {level = 20, price = 50, name = 'locomotive'}, - {level = 20, price = 350, name = 'modular-armor'}, - {level = 21, price = 5, name = 'rail-signal'}, - {level = 22, price = 5, name = 'rail-chain-signal'}, - {level = 23, price = 15, name = 'train-stop'}, - {level = 24, price = 35, name = 'cargo-wagon'}, - {level = 24, price = 35, name = 'fluid-wagon'}, - {level = 26, price = 150, name = 'tank'}, - {level = 29, price = 750, name = 'power-armor'}, - {level = 30, price = 30, name = 'logistic-robot'}, - {level = 31, price = 200, name = 'personal-roboport-equipment'}, - {level = 32, price = 20, name = 'construction-robot'}, - {level = 34, price = 750, name = 'fission-reactor-equipment'}, - {level = 35, price = 150, name = 'battery-equipment'}, - {level = 38, price = 250, name = 'exoskeleton-equipment'}, - {level = 40, price = 125, name = 'energy-shield-equipment'}, - {level = 42, price = 500, name = 'personal-laser-defense-equipment'}, - {level = 44, price = 1250, name = 'power-armor-mk2'}, - {level = 46, price = 750, name = 'battery-mk2-equipment'}, - {level = 48, price = 550, name = 'combat-shotgun'}, - {level = 51, price = 25, name = 'uranium-rounds-magazine'}, - {level = 63, price = 250, name = 'rocket-launcher'}, - {level = 63, price = 40, name = 'rocket'}, - {level = 71, price = 80, name = 'explosive-rocket'}, - {level = 78, price = 1000, name = 'satellite'}, - {level = 100, price = 2500, name = 'spidertron'}, - {level = 100, price = 1, name = 'iron-stick'} - }, - -- modifies the experience per alien type, higher is more xp - alien_experience_modifiers = { - ['small-biter'] = 2, - ['small-spitter'] = 2, - ['small-worm-turret'] = 2, - ['medium-biter'] = 3, - ['medium-spitter'] = 3, - ['medium-worm-turret'] = 3, - ['big-biter'] = 5, - ['big-spitter'] = 5, - ['big-worm-turret'] = 5, - ['behemoth-biter'] = 7, - ['behemoth-spitter'] = 7, - ['behemoth-worm-turret'] = 7 - } - }, weapon_balance = { enabled = true, load = function() return require('map_gen.maps.diggy.feature.weapon_balance') end diff --git a/map_gen/maps/diggy/presets/normal.lua b/map_gen/maps/diggy/presets/normal.lua index 704b2b29a..e7b0f547c 100644 --- a/map_gen/maps/diggy/presets/normal.lua +++ b/map_gen/maps/diggy/presets/normal.lua @@ -346,102 +346,6 @@ local config = { autojail = true, allowed_collapses_first_hour = 4 }, - experience = { - enabled = true, - load = function() return require('map_gen.maps.diggy.feature.experience') end, - -- controls the formula for calculating level up costs in stone sent to surface - difficulty_scale = 20, -- Diggy default 15. Higher increases experience requirement climb - 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 = { - ['big-rock'] = 5, - ['huge-rock'] = 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%) - }, - buffs = { - -- define new buffs here, they are handed out for each level - 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} - }, - -- add or remove a table entry to add or remove a unlockable item from the market. - unlockables = { - {level = 2, price = 4, name = 'wood'}, - {level = 3, price = 5, name = 'stone-wall'}, - {level = 4, price = 20, name = 'pistol'}, - {level = 4, price = 5, name = 'firearm-magazine'}, - {level = 5, price = 100, name = 'light-armor'}, - {level = 6, price = 6, name = 'small-lamp'}, - {level = 6, price = 5, name = 'raw-fish'}, - {level = 8, price = 1, name = 'stone-brick'}, - {level = 10, price = 85, name = 'shotgun'}, - {level = 10, price = 4, name = 'shotgun-shell'}, - {level = 12, price = 200, name = 'heavy-armor'}, - {level = 14, price = 25, name = 'landfill'}, --Decreased to 25 from 35 - {level = 15, price = 85, name = 'submachine-gun'}, - {level = 18, price = 10, name = 'piercing-rounds-magazine'}, - {level = 18, price = 8, name = 'piercing-shotgun-shell'}, - {level = 19, price = 2, name = 'rail'}, - {level = 20, price = 50, name = 'locomotive'}, - {level = 20, price = 350, name = 'modular-armor'}, - {level = 21, price = 5, name = 'rail-signal'}, - {level = 22, price = 5, name = 'rail-chain-signal'}, - {level = 23, price = 15, name = 'train-stop'}, - {level = 24, price = 35, name = 'cargo-wagon'}, - {level = 24, price = 35, name = 'fluid-wagon'}, - {level = 26, price = 150, name = 'tank'}, - {level = 29, price = 750, name = 'power-armor'}, - {level = 30, price = 30, name = 'logistic-robot'}, - {level = 31, price = 200, name = 'personal-roboport-equipment'}, - {level = 32, price = 20, name = 'construction-robot'}, - {level = 34, price = 750, name = 'fission-reactor-equipment'}, - {level = 35, price = 150, name = 'battery-equipment'}, - {level = 38, price = 250, name = 'exoskeleton-equipment'}, - {level = 40, price = 125, name = 'energy-shield-equipment'}, - {level = 42, price = 500, name = 'personal-laser-defense-equipment'}, - {level = 44, price = 1250, name = 'power-armor-mk2'}, - {level = 46, price = 750, name = 'battery-mk2-equipment'}, - {level = 48, price = 550, name = 'combat-shotgun'}, - {level = 51, price = 25, name = 'uranium-rounds-magazine'}, - {level = 63, price = 250, name = 'rocket-launcher'}, - {level = 63, price = 40, name = 'rocket'}, - {level = 71, price = 80, name = 'explosive-rocket'}, - {level = 78, price = 1000, name = 'satellite'}, - {level = 100, price = 2500, name = 'spidertron'}, - {level = 100, price = 1, name = 'iron-stick'} - }, - -- modifies the experience per alien type, higher is more xp - alien_experience_modifiers = { - ['small-biter'] = 2, - ['small-spitter'] = 2, - ['small-worm-turret'] = 2, - ['medium-biter'] = 3, - ['medium-spitter'] = 3, - ['medium-worm-turret'] = 3, - ['big-biter'] = 5, - ['big-spitter'] = 5, - ['big-worm-turret'] = 5, - ['behemoth-biter'] = 7, - ['behemoth-spitter'] = 7, - ['behemoth-worm-turret'] = 7 - } - }, weapon_balance = { enabled = true, load = function() return require('map_gen.maps.diggy.feature.weapon_balance') end diff --git a/map_gen/maps/diggy/scenario.lua b/map_gen/maps/diggy/scenario.lua index 144d7130b..c0d24e5f9 100644 --- a/map_gen/maps/diggy/scenario.lua +++ b/map_gen/maps/diggy/scenario.lua @@ -54,6 +54,7 @@ function Scenario.register(diggy_config) redmew_config.reactor_meltdown.enabled = false redmew_config.hodor.enabled = false redmew_config.paint.enabled = false + redmew_config.experience.enabled = true restart_command({scenario_name = diggy_config.scenario_name})