Skip to content

Commit 3b69b78

Browse files
authored
Update Diggy scenario (#1493)
* Update Diggy scenario * Add more features to Experience
1 parent a6c5f15 commit 3b69b78

File tree

11 files changed

+116
-15
lines changed

11 files changed

+116
-15
lines changed

config.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,14 @@ storage.config = {
507507
},
508508
buffs = {
509509
-- define new buffs here, they are handed out for each level
510-
-- double_level is the level interval for receiving a double bonus (Diggy default: 5 which equals every 5th level)
511-
mining_speed = { value = 5, max = 20 },
510+
-- double_level (optional): the level interval for receiving a double bonus (Diggy default: 5 which equals every 5th level)
511+
-- level interval (optional): the interval to receive the bonus. Default is 1
512+
mining_speed = { value = 20, max = 29 },
512513
inventory_slot = { value = 1, max = 100 },
513514
health_bonus = { value = 2.5, double_level = 5, max = 500 },
515+
character_reach = { value = 1, max = 10, level_interval = 10 },
516+
crafting_speed = { value = 0.1, max = 10 },
517+
running_speed = { value = 0.025, max = 3 },
514518
},
515519
-- add or remove a table entry to add or remove an unlockable item from the market.
516520
unlockables = {
@@ -555,6 +559,7 @@ storage.config = {
555559
{ level = 63, price = 250, name = 'rocket-launcher' },
556560
{ level = 63, price = 40, name = 'rocket' },
557561
{ level = 71, price = 80, name = 'explosive-rocket' },
562+
{ level = 75, price = 800, name = 'energy-shield-mk2-equipment' },
558563
{ level = 78, price = 1000, name = 'satellite' },
559564
{ level = 100, price = 2500, name = 'spidertron' },
560565
},

features/gui/experience.lua

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ local gui_toggled = {}
4646
local mining_efficiency = { active_modifier = 0, research_modifier = 0, level_modifier = 0 }
4747
local inventory_slots = { active_modifier = 0, research_modifier = 0, level_modifier = 0 }
4848
local 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
5154
local 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)
436460
end
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)
541568
end
542569

543570
local 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)
566596
end
@@ -625,6 +655,54 @@ Public.update_health_bonus = function(force, level_up)
625655
}
626656
end
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

630708
Event.on_init(on_init)

features/market_chest.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ Event.on_built(function(event)
133133
end)
134134

135135
Event.on_destroyed(function(event)
136-
local id = event.useful_id or event.entity.unit_number
136+
local id = event.useful_id or (event.entity and event.entity.valid and event.entity.unit_number)
137+
if not id then
138+
return
139+
end
140+
137141
local data = b_get(this.chests, id)
138142
local inv = event.buffer
139143
if data and inv and inv.valid and inv.get_item_count { name = 'buffer-chest' } > 0 then

features/player_stats.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ local function get_cause_name(cause)
133133
return name
134134
end
135135
end
136-
return 'player_stats.unknown_death_cause'
136+
return {'player_stats.unknown_death_cause'}
137137
end
138138

139139
local function player_died(event)

locale/en/redmew_gui.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ float_xp_gained_rocket=Rocket launched! +__1__ XP
146146
gui_buff_health=+__1__ max health (up to: __2__)
147147
gui_buff_inv=+__1__ inventory slot(s) (up to: __2__)
148148
gui_buff_mining=+__1__% mining speed (up to: __2__%)
149+
gui_buff_character_reach=+__1__ reach (up to: __2__)
150+
gui_buff_crafting_speed=+__1__% crafting speed (up to: __2__%)
151+
gui_buff_running_speed=+__1__% running speed (up to: __2__%)
149152
gui_experience_button_tip=Experience
150153
gui_progress_bar=__1__% xp to next level
151154
gui_progress_caption=Progress to next level:

map_gen/maps/diggy/feature/alien_spawner.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ local function spawn_aliens(aliens, force, surface, x, y)
150150
force = force,
151151
amount = amount
152152
},
153+
move_stuck_players = true,
153154
})
154155
break
155156
end

map_gen/maps/diggy/feature/diggy_hole.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ local function diggy_hole(entity)
114114
local predicted = random()
115115
if predicted < 0.2 then
116116
rocks[i] = {name = 'huge-rock', position = void_position}
117-
elseif predicted < 0.6 then
118-
rocks[i] = {name = 'big-rock', position = void_position}
119117
else
120118
rocks[i] = {name = 'big-rock', position = void_position}
121119
end

map_gen/maps/diggy/presets/danger_ores.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ local config = {
2828
starting_items = {
2929
{name = 'stone-wall', count = 12},
3030
{name = 'iron-gear-wheel', count = 8},
31-
{name = 'iron-plate', count = 16}
31+
{name = 'iron-plate', count = 16},
32+
{name = 'pistol', count = 1},
33+
{name = 'firearm-magazine', count = 32},
34+
{name = 'burner-mining-drill', count = 3},
35+
{name = 'stone-furnace', count = 5},
3236
},
3337

3438
-- 0.01 bonus equals 1% in game. This value is recommended to be tweaked for single player
@@ -70,7 +74,7 @@ local config = {
7074
robot_damage_per_mining_prod_level = 1,
7175

7276
-- turn this setting on if you want to bring back landfill research, default is off due to griefing
73-
allow_landfill_research = false,
77+
allow_landfill_research = true,
7478
},
7579
-- adds the ability to collapse caves
7680
diggy_cave_collapse = {

map_gen/maps/diggy/presets/danger_ores_BnB.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ local config = {
2828
starting_items = {
2929
{name = 'stone-wall', count = 12},
3030
{name = 'iron-gear-wheel', count = 8},
31-
{name = 'iron-plate', count = 16}
31+
{name = 'iron-plate', count = 16},
32+
{name = 'pistol', count = 1},
33+
{name = 'firearm-magazine', count = 32},
34+
{name = 'burner-mining-drill', count = 3},
35+
{name = 'stone-furnace', count = 5},
3236
},
3337

3438
-- 0.01 bonus equals 1% in game. This value is recommended to be tweaked for single player
@@ -70,7 +74,7 @@ local config = {
7074
robot_damage_per_mining_prod_level = 1,
7175

7276
-- turn this setting on if you want to bring back landfill research, default is off due to griefing
73-
allow_landfill_research = false,
77+
allow_landfill_research = true,
7478
},
7579
-- adds the ability to collapse caves
7680
diggy_cave_collapse = {

map_gen/maps/diggy/presets/normal.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ local config = {
2828
starting_items = {
2929
{name = 'stone-wall', count = 12},
3030
{name = 'iron-gear-wheel', count = 8},
31-
{name = 'iron-plate', count = 16}
31+
{name = 'iron-plate', count = 16},
32+
{name = 'pistol', count = 1},
33+
{name = 'firearm-magazine', count = 32},
34+
{name = 'burner-mining-drill', count = 3},
35+
{name = 'stone-furnace', count = 5},
3236
},
3337

3438
-- 0.01 bonus equals 1% in game. This value is recommended to be tweaked for single player
@@ -70,7 +74,7 @@ local config = {
7074
robot_damage_per_mining_prod_level = 1,
7175

7276
-- turn this setting on if you want to bring back landfill research, default is off due to griefing
73-
allow_landfill_research = false,
77+
allow_landfill_research = true,
7478
},
7579
-- adds the ability to collapse caves
7680
diggy_cave_collapse = {

0 commit comments

Comments
 (0)