mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-30 04:30:58 +02:00
Tweaking level up formula for late late game
Tweaking xp gained from infinite research to add 60% towards current level up progress. Added max level for boosts
This commit is contained in:
parent
c72f8fe8ba
commit
34fd76592c
@ -357,9 +357,9 @@ local Config = {
|
|||||||
experience = {
|
experience = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
-- controls the formula for calculating level up costs in stone sent to surface
|
-- controls the formula for calculating level up costs in stone sent to surface
|
||||||
difficulty_scale = 15, -- Diggy default 15. Higher increases experience requirement climb
|
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.
|
first_lvl_xp = 350, -- Diggy default 350. This sets the price for the first level.
|
||||||
xp_fine_tune = 200, -- Diggy default 200. This value is used to fine tune the overall requirement climb without affecting the speed
|
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.
|
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
|
-- percentage * mining productivity level gets added to mining speed
|
||||||
@ -380,14 +380,15 @@ local Config = {
|
|||||||
['enemy_killed'] = 10, -- Base XP for killing biters and spitters.
|
['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%)
|
['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.
|
--['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 = {
|
buffs = {
|
||||||
-- define new buffs here, they are handed out for each level
|
-- define new buffs here, they are handed out for each level
|
||||||
mining_speed = {value = 5},
|
mining_speed = {value = 5, max = 100},
|
||||||
inventory_slot = {value = 1},
|
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)
|
-- 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},
|
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.
|
-- add or remove a table entry to add or remove a unlockable item from the market.
|
||||||
|
@ -69,15 +69,16 @@ local table_column_layout = {type = 'table', column_count = 2}
|
|||||||
local level_up_formula = (function (level_reached)
|
local level_up_formula = (function (level_reached)
|
||||||
local difficulty_scale = floor(config.difficulty_scale)
|
local difficulty_scale = floor(config.difficulty_scale)
|
||||||
local level_fine_tune = floor(config.xp_fine_tune)
|
local level_fine_tune = floor(config.xp_fine_tune)
|
||||||
local start_value = (floor(config.first_lvl_xp) * 0.5)
|
local start_value = (floor(config.first_lvl_xp))
|
||||||
local precision = (floor(config.cost_precision))
|
local precision = (floor(config.cost_precision))
|
||||||
local function formula(level)
|
local function formula(level)
|
||||||
return (
|
return (floor(
|
||||||
difficulty_scale * (level) ^ 3
|
(1.15 ^ (level * 0.1))
|
||||||
+ (level_fine_tune + start_value) * (level) ^ 2
|
+ difficulty_scale * (level) ^ 3
|
||||||
|
+ level_fine_tune * (level) ^ 2
|
||||||
+ start_value * (level)
|
+ start_value * (level)
|
||||||
- difficulty_scale * (level)
|
- difficulty_scale * (level)
|
||||||
- level_fine_tune * (level)
|
- level_fine_tune * (level))
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
local value = formula(level_reached + 1)
|
local value = formula(level_reached + 1)
|
||||||
@ -90,6 +91,30 @@ local level_up_formula = (function (level_reached)
|
|||||||
return value - lower_value
|
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
|
||||||
|
---@return number required total experience to reach supplied level
|
||||||
|
local function calculate_level_xp(level)
|
||||||
|
if level_table[level] == nil then
|
||||||
|
local value
|
||||||
|
if level == 1 then
|
||||||
|
value = level_up_formula(level-1)
|
||||||
|
else
|
||||||
|
value = level_up_formula(level-1)+calculate_level_xp(level-1)
|
||||||
|
end
|
||||||
|
insert(level_table, level, value)
|
||||||
|
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
|
||||||
|
local function percentage_of_level_req(level, percentage)
|
||||||
|
return level_up_formula(level)*percentage
|
||||||
|
end
|
||||||
|
|
||||||
---Updates the market contents based on the current level.
|
---Updates the market contents based on the current level.
|
||||||
---@param force LuaForce the force which the unlocking requirement should be based of
|
---@param force LuaForce the force which the unlocking requirement should be based of
|
||||||
function Experience.update_market_contents(force)
|
function Experience.update_market_contents(force)
|
||||||
@ -109,8 +134,9 @@ end
|
|||||||
---@param force LuaForce the force of which will be updated
|
---@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)
|
---@param level_up number a level if updating as part of a level up (optional)
|
||||||
function Experience.update_mining_speed(force, level_up)
|
function Experience.update_mining_speed(force, level_up)
|
||||||
level_up = level_up ~= nil and level_up or 0
|
|
||||||
local buff = config.buffs['mining_speed']
|
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
|
if level_up > 0 and buff ~= nil then
|
||||||
local level = get_force_data(force).current_level
|
local level = get_force_data(force).current_level
|
||||||
local adjusted_value = floor(max(buff.value, 24*0.9^level))
|
local adjusted_value = floor(max(buff.value, 24*0.9^level))
|
||||||
@ -126,13 +152,15 @@ function Experience.update_mining_speed(force, level_up)
|
|||||||
-- add the new active modifier to the non-buffed modifier
|
-- add the new active modifier to the non-buffed modifier
|
||||||
force.manual_mining_speed_modifier = old_modifier + mining_efficiency.active_modifier
|
force.manual_mining_speed_modifier = old_modifier + mining_efficiency.active_modifier
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
---Updates a forces inventory slots. By removing active modifiers and re-adding
|
---Updates a forces inventory slots. By removing active modifiers and re-adding
|
||||||
---@param force LuaForce the force of which will be updated
|
---@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)
|
---@param level_up number a level if updating as part of a level up (optional)
|
||||||
function Experience.update_inventory_slots(force, level_up)
|
function Experience.update_inventory_slots(force, level_up)
|
||||||
level_up = level_up ~= nil and level_up or 0
|
|
||||||
local buff = config.buffs['inventory_slot']
|
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
|
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
|
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
|
inventory_slots.level_modifier = inventory_slots.level_modifier + value
|
||||||
@ -147,13 +175,15 @@ function Experience.update_inventory_slots(force, level_up)
|
|||||||
-- add the new active modifier to the non-buffed modifier
|
-- add the new active modifier to the non-buffed modifier
|
||||||
force.character_inventory_slots_bonus = old_modifier + inventory_slots.active_modifier
|
force.character_inventory_slots_bonus = old_modifier + inventory_slots.active_modifier
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
---Updates a forces inventory slots. By removing active modifiers and re-adding
|
---Updates a forces health bonus. By removing active modifiers and re-adding
|
||||||
---@param force LuaForce the force of which will be updated
|
---@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)
|
---@param level_up number a level if updating as part of a level up (optional)
|
||||||
function Experience.update_health_bonus(force, level_up)
|
function Experience.update_health_bonus(force, level_up)
|
||||||
level_up = level_up ~= nil and level_up or 0
|
|
||||||
local buff = config.buffs['health_bonus']
|
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
|
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
|
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
|
health_bonus.level_modifier = health_bonus.level_modifier + value
|
||||||
@ -168,6 +198,7 @@ function Experience.update_health_bonus(force, level_up)
|
|||||||
-- add the new active modifier to the non-buffed modifier
|
-- add the new active modifier to the non-buffed modifier
|
||||||
force.character_health_bonus = old_modifier + health_bonus.active_modifier
|
force.character_health_bonus = old_modifier + health_bonus.active_modifier
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- declaration of variables to prevent table look ups @see Experience.register
|
-- declaration of variables to prevent table look ups @see Experience.register
|
||||||
local sand_rock_xp
|
local sand_rock_xp
|
||||||
@ -204,14 +235,19 @@ end
|
|||||||
local function on_research_finished(event)
|
local function on_research_finished(event)
|
||||||
local research = event.research
|
local research = event.research
|
||||||
local force = research.force
|
local force = research.force
|
||||||
|
local exp
|
||||||
|
if research.research_unit_count_formula ~= nil then
|
||||||
|
local force_data = get_force_data(force)
|
||||||
|
exp = percentage_of_level_req(force_data.current_level, config.XP['infinity-research'])
|
||||||
|
else
|
||||||
local award_xp = 0
|
local award_xp = 0
|
||||||
|
|
||||||
for _, ingredient in pairs(research.research_unit_ingredients) do
|
for _, ingredient in pairs(research.research_unit_ingredients) do
|
||||||
local name = ingredient.name
|
local name = ingredient.name
|
||||||
local reward = config.XP[name]
|
local reward = config.XP[name]
|
||||||
award_xp = award_xp + reward
|
award_xp = award_xp + reward
|
||||||
end
|
end
|
||||||
local exp = award_xp * research.research_unit_count
|
exp = award_xp * research.research_unit_count
|
||||||
|
end
|
||||||
local text = format('Research completed! +%s XP', exp)
|
local text = format('Research completed! +%s XP', exp)
|
||||||
for _, p in pairs(game.connected_players) do
|
for _, p in pairs(game.connected_players) do
|
||||||
local player_index = p.index
|
local player_index = p.index
|
||||||
@ -310,23 +346,6 @@ local function on_player_respawned(event)
|
|||||||
ScoreTable.add('Experience lost', exp)
|
ScoreTable.add('Experience lost', exp)
|
||||||
end
|
end
|
||||||
|
|
||||||
local level_table = {}
|
|
||||||
---Get experiment 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
|
|
||||||
---@return number required total experience to reach supplied level
|
|
||||||
local function calculate_level_xp(level)
|
|
||||||
if level_table[level] == nil then
|
|
||||||
local value
|
|
||||||
if level == 1 then
|
|
||||||
value = level_up_formula(level-1)
|
|
||||||
else
|
|
||||||
value = level_up_formula(level-1)+calculate_level_xp(level-1)
|
|
||||||
end
|
|
||||||
insert(level_table, level, value)
|
|
||||||
end
|
|
||||||
return level_table[level]
|
|
||||||
end
|
|
||||||
local function redraw_title(data)
|
local function redraw_title(data)
|
||||||
local force_data = get_force_data('player')
|
local force_data = get_force_data('player')
|
||||||
data.frame.caption = Utils.comma_value(force_data.total_experience) .. ' total experience earned!'
|
data.frame.caption = Utils.comma_value(force_data.total_experience) .. ' total experience earned!'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user