@@ -46,6 +46,9 @@ local gui_toggled = {}
4646local mining_efficiency = { active_modifier = 0 , research_modifier = 0 , level_modifier = 0 }
4747local inventory_slots = { active_modifier = 0 , research_modifier = 0 , level_modifier = 0 }
4848local health_bonus = { active_modifier = 0 , research_modifier = 0 , level_modifier = 0 }
49+ local character_reach = { active_modifier = 0 , research_modifier = 0 , level_modifier = 0 }
50+ local crafting_speed = { active_modifier = 0 , research_modifier = 0 , level_modifier = 0 }
51+ local running_speed = { active_modifier = 0 , research_modifier = 0 , level_modifier = 0 }
4952
5053-- Prevents table lookup thousands of times
5154local rock_big_xp = config .XP [' big-rock' ]
@@ -58,7 +61,10 @@ Global.register(
5861 health_bonus = health_bonus ,
5962 force_sounds = force_sounds ,
6063 gui_toggled = gui_toggled ,
61- level_table = level_table
64+ level_table = level_table ,
65+ character_reach = character_reach ,
66+ crafting_speed = crafting_speed ,
67+ running_speed = running_speed ,
6268 },
6369 function (tbl )
6470 mining_efficiency = tbl .mining_efficiency
@@ -67,6 +73,9 @@ Global.register(
6773 force_sounds = tbl .force_sounds
6874 gui_toggled = tbl .gui_toggled
6975 level_table = tbl .level_table
76+ character_reach = tbl .character_reach
77+ crafting_speed = tbl .crafting_speed
78+ running_speed = tbl .running_speed
7079 end
7180)
7281
@@ -187,6 +196,9 @@ local function update_modifier(params)
187196 if not buff or force [property ] >= (buff .max or math.huge ) then
188197 return
189198 end
199+ if buff .level_interval and (level_up % buff .level_interval ~= 0 ) then
200+ return
201+ end
190202 if level_up > 0 then
191203 local value = formula (params )
192204 if buff .double_level and (level_up % buff .double_level ) == 0 then
@@ -234,6 +246,9 @@ Public.update_main_frame = function(player)
234246 data .bonus_mining_speed .caption = ' + ' .. (player .force .manual_mining_speed_modifier * 100 ).. ' %'
235247 data .bonus_inventory_slot .caption = ' + ' .. player .force .character_inventory_slots_bonus
236248 data .bonus_health_bonus .caption = ' + ' .. player .force .character_health_bonus .. ' %'
249+ data .bonus_character_reach .caption = ' + ' .. (player .force .character_reach_distance_bonus )
250+ data .bonus_crafting_speed .caption = ' + ' .. (player .force .manual_crafting_speed_modifier * 100 ).. ' %'
251+ data .bonus_running_speed .caption = ' + ' .. (player .force .character_running_speed_modifier * 100 ).. ' %'
237252
238253 for _ , row in pairs (data .reward_list .children ) do
239254 for _ , item in pairs (row .children ) do
@@ -295,9 +310,15 @@ Public.get_main_frame = function(player)
295310 data .bonus_mining_speed = label_pair (content , ' Manual mining speed' , ' ---' )
296311 data .bonus_inventory_slot = label_pair (content , ' Inventory slots' , ' ---' )
297312 data .bonus_health_bonus = label_pair (content , ' Max health' , ' ---' )
313+ data .bonus_character_reach = label_pair (content , ' Character reach' , ' ---' )
314+ data .bonus_crafting_speed = label_pair (content , ' Crafting speed' , ' ---' )
315+ data .bonus_running_speed = label_pair (content , ' Running speed' , ' ---' )
298316 data .bonus_mining_speed .tooltip = { ' experience.gui_buff_mining' , buffs .mining_speed .value , buffs .mining_speed .max * 100 }
299317 data .bonus_inventory_slot .tooltip = { ' experience.gui_buff_inv' , buffs .inventory_slot .value , buffs .inventory_slot .max }
300318 data .bonus_health_bonus .tooltip = { ' experience.gui_buff_health' , buffs .health_bonus .value , buffs .health_bonus .max }
319+ data .bonus_character_reach .tooltip = { ' experience.gui_buff_character_reach' , buffs .character_reach .value , buffs .character_reach .max }
320+ data .bonus_crafting_speed .tooltip = { ' experience.gui_buff_crafting_speed' , buffs .crafting_speed .value * 100 , buffs .crafting_speed .max * 100 }
321+ data .bonus_running_speed .tooltip = { ' experience.gui_buff_running_speed' , buffs .running_speed .value * 100 , buffs .running_speed .max * 100 }
301322 end
302323 do -- Rewards
303324 local toggled = gui_toggled [player .index ].rewards
@@ -433,6 +454,9 @@ local function on_research_finished(event)
433454 Public .update_inventory_slots (force , 0 )
434455 Public .update_mining_speed (force , 0 )
435456 Public .update_health_bonus (force , 0 )
457+ Public .update_character_reach_bonus (force , 0 )
458+ Public .update_crafting_speed_bonus (force , 0 )
459+ Public .update_running_speed_bonus (force , 0 )
436460end
437461
438462--- Awards experience when a rocket has been launched based on percentage of total experience
@@ -538,6 +562,9 @@ local function on_nth_tick()
538562 Public .update_inventory_slots (force , 0 )
539563 Public .update_mining_speed (force , 0 )
540564 Public .update_health_bonus (force , 0 )
565+ Public .update_character_reach_bonus (force , 0 )
566+ Public .update_crafting_speed_bonus (force , 0 )
567+ Public .update_running_speed_bonus (force , 0 )
541568end
542569
543570local function on_init ()
@@ -561,6 +588,9 @@ local function on_level_reached(level_reached, force)
561588 Public .update_inventory_slots (force , level_reached )
562589 Public .update_mining_speed (force , level_reached )
563590 Public .update_health_bonus (force , level_reached )
591+ Public .update_character_reach_bonus (force , level_reached )
592+ Public .update_crafting_speed_bonus (force , level_reached )
593+ Public .update_running_speed_bonus (force , level_reached )
564594 Public .update_market_contents (force )
565595 play_level_up_sound (force )
566596end
@@ -625,6 +655,54 @@ Public.update_health_bonus = function(force, level_up)
625655 }
626656end
627657
658+ --- Updates a forces reach bonus. By removing active modifiers and re-adding
659+ --- @param force LuaForce the force of which will be updated
660+ --- @param level_up ? number a level if updating as part of a level up
661+ Public .update_character_reach_bonus = function (force , level_up )
662+ update_modifier {
663+ buff = config .buffs [' character_reach' ],
664+ force = force ,
665+ level_up = level_up ,
666+ modifier = character_reach ,
667+ property = ' character_reach_distance_bonus' ,
668+ }
669+ for _ , reach_property in pairs ({
670+ ' character_build_distance_bonus' ,
671+ ' character_item_drop_distance_bonus' ,
672+ ' character_reach_distance_bonus' ,
673+ ' character_resource_reach_distance_bonus' ,
674+ ' character_item_pickup_distance_bonus'
675+ }) do
676+ force [reach_property ] = force .character_reach_distance_bonus
677+ end
678+ end
679+
680+ --- Updates a forces crafting speed bonus. By removing active modifiers and re-adding
681+ --- @param force LuaForce the force of which will be updated
682+ --- @param level_up ? number a level if updating as part of a level up
683+ Public .update_crafting_speed_bonus = function (force , level_up )
684+ update_modifier {
685+ buff = config .buffs [' crafting_speed' ],
686+ force = force ,
687+ level_up = level_up ,
688+ modifier = crafting_speed ,
689+ property = ' manual_crafting_speed_modifier' ,
690+ }
691+ end
692+
693+ --- Updates a forces running speed bonus. By removing active modifiers and re-adding
694+ --- @param force LuaForce the force of which will be updated
695+ --- @param level_up ? number a level if updating as part of a level up
696+ Public .update_running_speed_bonus = function (force , level_up )
697+ update_modifier {
698+ buff = config .buffs [' running_speed' ],
699+ force = force ,
700+ level_up = level_up ,
701+ modifier = running_speed ,
702+ property = ' character_running_speed_modifier' ,
703+ }
704+ end
705+
628706-- ============================================================================
629707
630708Event .on_init (on_init )
0 commit comments