mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-18 03:21:47 +02:00
Merge pull request #489 from iltar/added-big-rocks
Added big rocks to the table
This commit is contained in:
commit
aa1cf8ed74
@ -110,6 +110,7 @@ local Config = {
|
||||
['market'] = 9,
|
||||
['stone-wall'] = 3,
|
||||
['sand-rock-big'] = 2,
|
||||
['rock-big'] = 2,
|
||||
['rock-huge'] = 2.5,
|
||||
['out-of-map'] = 1,
|
||||
['stone-path'] = 0.03,
|
||||
@ -118,9 +119,7 @@ local Config = {
|
||||
['refined-concrete'] = 0.06,
|
||||
},
|
||||
cracking_sounds = {
|
||||
'CRACK',
|
||||
'KRRRR',
|
||||
'R U N',
|
||||
' R U NY O UF O O L S !',
|
||||
}
|
||||
},
|
||||
|
||||
@ -362,6 +361,7 @@ local Config = {
|
||||
|
||||
XP = {
|
||||
['sand-rock-big'] = 5,
|
||||
['rock-big'] = 5,
|
||||
['rock-huge'] = 10,
|
||||
['rocket_launch'] = 0.01, -- XP reward in percentage of total experience when a rocket launches (Diggy default: 0.01 which equals 1%)
|
||||
['science-pack-1'] = 4,
|
||||
|
@ -43,7 +43,7 @@ end, function(tbl)
|
||||
alien_size_chart = tbl.alien_size_chart
|
||||
end)
|
||||
|
||||
local rocks_to_find = {'sand-rock-big', 'rock-huge'}
|
||||
local rocks_to_find = {'sand-rock-big', 'rock-huge', 'rock-big'}
|
||||
|
||||
---Triggers mining at the collision_box of the alien, to free it
|
||||
local do_alien_mining = Token.register(function(params)
|
||||
|
@ -87,11 +87,12 @@ DiggyCaveCollapse.events = {
|
||||
]]
|
||||
on_collapse = script.generate_event_name()
|
||||
}
|
||||
local collapse_rocks = Template.diggy_rocks
|
||||
local collapse_rocks_size = #collapse_rocks
|
||||
|
||||
local function create_collapse_template(positions, surface)
|
||||
local entities = {}
|
||||
local entity_count = 0
|
||||
|
||||
local find_entities_filtered = surface.find_entities_filtered
|
||||
|
||||
for _, position in pairs(positions) do
|
||||
@ -99,7 +100,7 @@ local function create_collapse_template(positions, surface)
|
||||
local y = position.y
|
||||
local do_insert = true
|
||||
|
||||
for _, entity in pairs(find_entities_filtered({area = {{x, y}, {x + 1, y + 1}}})) do
|
||||
for _, entity in pairs(find_entities_filtered({area = {position, {x + 1, y + 1}}})) do
|
||||
pcall(function()
|
||||
local strength = support_beam_entities[entity.name]
|
||||
if strength then
|
||||
@ -112,7 +113,7 @@ local function create_collapse_template(positions, surface)
|
||||
|
||||
if do_insert then
|
||||
entity_count = entity_count + 1
|
||||
entities[entity_count] = {position = {x = x, y = y}, name = 'sand-rock-big'}
|
||||
entities[entity_count] = {position = position, name = collapse_rocks[random(collapse_rocks_size)]}
|
||||
end
|
||||
end
|
||||
|
||||
@ -120,7 +121,7 @@ local function create_collapse_template(positions, surface)
|
||||
end
|
||||
|
||||
local function create_collapse_alert(surface, position)
|
||||
local target = surface.create_entity{position = position, name = 'sand-rock-big'}
|
||||
local target = surface.create_entity{position = position, name = 'rock-big'}
|
||||
for _, player in pairs(game.connected_players) do
|
||||
player.add_custom_alert(target, collapse_alert, 'Cave collapsed!', true)
|
||||
end
|
||||
@ -190,7 +191,7 @@ local function on_collapse_triggered(event)
|
||||
|
||||
local x_t = new_tile_map[x]
|
||||
if x_t and x_t[y] then
|
||||
Template.insert(surface, {}, {{position = position, name = 'sand-rock-big'}})
|
||||
Template.insert(surface, {}, {{position = position, name = 'rock-big'}})
|
||||
return
|
||||
end
|
||||
spawn_cracking_sound_text(surface, position)
|
||||
@ -244,7 +245,11 @@ local function on_mined_entity(event)
|
||||
local name = entity.name
|
||||
local strength = support_beam_entities[name]
|
||||
if strength then
|
||||
stress_map_add(entity.surface, entity.position, strength, false, (not (name == 'sand-rock-big' or name == 'rock-huge')) and event.player_index)
|
||||
local player_index
|
||||
if not Template.is_diggy_rock(name) then
|
||||
player_index = event.player_index
|
||||
end
|
||||
stress_map_add(entity.surface, entity.position, strength, false, player_index)
|
||||
end
|
||||
end
|
||||
|
||||
@ -254,7 +259,7 @@ local function on_entity_died(event)
|
||||
local strength = support_beam_entities[name]
|
||||
if strength then
|
||||
local player_index
|
||||
if name ~= 'sand-rock-big' and name ~= 'rock-huge' then
|
||||
if not Template.is_diggy_rock(name) then
|
||||
local cause = event.cause
|
||||
player_index = cause and cause.player and cause.player.index or nil
|
||||
end
|
||||
@ -364,7 +369,7 @@ function DiggyCaveCollapse.register(cfg)
|
||||
Event.add(defines.events.on_marked_for_deconstruction, function (event)
|
||||
local entity = event.entity
|
||||
local name = entity.name
|
||||
if name == 'sand-rock-big' or name == 'rock-huge' then
|
||||
if Template.is_diggy_rock(name) then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -47,7 +47,7 @@ local function update_robot_mining_damage()
|
||||
ScoreTable.set('Robot mining damage', robot_mining.damage)
|
||||
end
|
||||
|
||||
---Triggers a diggy diggy hole for a given sand-rock-big or rock-huge.
|
||||
---Triggers a diggy diggy hole for a given sand-rock-big, rock-big or rock-huge.
|
||||
---@param entity LuaEntity
|
||||
local function diggy_hole(entity)
|
||||
local tiles = {}
|
||||
@ -82,8 +82,11 @@ local function diggy_hole(entity)
|
||||
for i = #out_of_map_found, 1, -1 do
|
||||
local void_position = out_of_map_found[i]
|
||||
tiles[i] = {name = 'dirt-' .. random(1, 7), position = void_position}
|
||||
if random() < 0.35 then
|
||||
local predicted = random()
|
||||
if predicted < 0.2 then
|
||||
rocks[i] = {name = 'rock-huge', position = void_position}
|
||||
elseif predicted < 0.6 then
|
||||
rocks[i] = {name = 'rock-big', position = void_position}
|
||||
else
|
||||
rocks[i] = {name = 'sand-rock-big', position = void_position}
|
||||
end
|
||||
@ -127,7 +130,7 @@ function DiggyHole.register(config)
|
||||
Event.add(defines.events.on_entity_died, function (event)
|
||||
local entity = event.entity
|
||||
local name = entity.name
|
||||
if name ~= 'sand-rock-big' and name ~= 'rock-huge' then
|
||||
if not Template.is_diggy_rock(name) then
|
||||
return
|
||||
end
|
||||
diggy_hole(entity)
|
||||
@ -144,7 +147,7 @@ function DiggyHole.register(config)
|
||||
return
|
||||
end
|
||||
|
||||
if name ~= 'sand-rock-big' and name ~= 'rock-huge' then
|
||||
if not Template.is_diggy_rock(name) then
|
||||
return
|
||||
end
|
||||
|
||||
@ -156,7 +159,7 @@ function DiggyHole.register(config)
|
||||
local entity = event.entity
|
||||
local name = entity.name
|
||||
|
||||
if name ~= 'sand-rock-big' and name ~= 'rock-huge' then
|
||||
if not Template.is_diggy_rock(name) then
|
||||
return
|
||||
end
|
||||
|
||||
@ -187,7 +190,7 @@ function DiggyHole.register(config)
|
||||
Event.add(defines.events.on_player_mined_entity, function (event)
|
||||
local entity = event.entity
|
||||
local name = entity.name
|
||||
if name ~= 'sand-rock-big' and name ~= 'rock-huge' then
|
||||
if not Template.is_diggy_rock(name) then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -157,6 +157,7 @@ end
|
||||
|
||||
-- declaration of variables to prevent table look ups @see Experience.register
|
||||
local sand_rock_xp
|
||||
local rock_big_xp
|
||||
local rock_huge_xp
|
||||
|
||||
---Awards experience when a rock has been mined (increases by 1 XP every 5th level)
|
||||
@ -240,18 +241,21 @@ local function on_entity_died (event)
|
||||
if not cause or cause.type ~= 'player' or not cause.valid then
|
||||
local exp
|
||||
if force and force.name == 'player' then
|
||||
local entity_name = entity.name
|
||||
if cause and (cause.name == 'artillery-turret' or cause.name == 'gun-turret' or cause.name == 'laser-turret' or cause.name == 'flamethrower-turret') then
|
||||
exp = config.XP['enemy_killed'] * config.alien_experience_modifiers[entity.name]
|
||||
exp = config.XP['enemy_killed'] * config.alien_experience_modifiers[entity_name]
|
||||
local text = string_format('+ %d XP', exp)
|
||||
Game.print_floating_text(cause.surface, cause.position, text, gain_xp_color)
|
||||
ForceControl.add_experience(force, exp)
|
||||
return
|
||||
else
|
||||
local level = ForceControl.get_force_data(force).current_level
|
||||
if entity.name == 'sand-rock-big' then
|
||||
exp = floor((sand_rock_xp + (level / 5)) / 2)
|
||||
elseif entity.name == 'rock-huge' then
|
||||
exp = floor((rock_huge_xp + (level / 5)) / 2)
|
||||
if entity_name == 'sand-rock-big' then
|
||||
exp = floor((sand_rock_xp + level * 0.2) * 0.5)
|
||||
elseif entity_name == 'rock-big' then
|
||||
exp = floor((rock_big_xp + level * 0.2) * 0.5)
|
||||
elseif entity_name == 'rock-huge' then
|
||||
exp = floor((rock_huge_xp + level * 0.2) * 0.5)
|
||||
else
|
||||
return
|
||||
end
|
||||
@ -523,6 +527,7 @@ function Experience.register(cfg)
|
||||
|
||||
-- Prevents table lookup thousands of times
|
||||
sand_rock_xp = config.XP['sand-rock-big']
|
||||
rock_big_xp = config.XP['rock-big']
|
||||
rock_huge_xp = config.XP['rock-huge']
|
||||
end
|
||||
|
||||
|
@ -18,7 +18,7 @@ local do_spawn_tile = Token.register(function(params)
|
||||
Template.insert(params.surface, {params.tile}, {})
|
||||
end)
|
||||
|
||||
local rocks_lookup = {'sand-rock-big', 'rock-huge'}
|
||||
local rocks_lookup = Template.diggy_rocks
|
||||
|
||||
local do_mine = Token.register(function(params)
|
||||
local surface = params.surface
|
||||
|
@ -58,7 +58,7 @@ function StartingZone.register(config)
|
||||
end
|
||||
|
||||
if (distance > rock_range) then
|
||||
insert(rocks, {name = 'sand-rock-big', position = {x = x, y = y}})
|
||||
insert(rocks, {name = 'rock-big', position = {x = x, y = y}})
|
||||
end
|
||||
|
||||
-- hack to avoid starting area from collapsing
|
||||
|
@ -155,4 +155,12 @@ function Template.resources(surface, resources)
|
||||
end
|
||||
end
|
||||
|
||||
Template.diggy_rocks = {'sand-rock-big', 'rock-big', 'rock-big'}
|
||||
|
||||
---Returns true if the entity name is that of a diggy rock.
|
||||
---@param entity_name string
|
||||
function Template.is_diggy_rock(entity_name)
|
||||
return entity_name == 'sand-rock-big' or entity_name == 'rock-big' or entity_name == 'rock-huge'
|
||||
end
|
||||
|
||||
return Template
|
||||
|
Loading…
Reference in New Issue
Block a user