mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-03 13:12:11 +02:00
Cliff explosives related tweaks
Changes: - Chests with cliff-explosives in holds now explode after 5 second delay. - Changed the price of cliff explosives to cost 1000 coins for 5 (4x cheaper than before). Reasoning: This is an experiment to shift the coin spending meta. - Players now can find explosives and cliff-explosives in chests in the wild.
This commit is contained in:
parent
f32e9c3197
commit
3b782829d3
@ -1516,36 +1516,77 @@ function Public.update_alert_sound_frequency_tracker()
|
||||
end
|
||||
end
|
||||
|
||||
-- Check for cliff explosives in chest.
|
||||
function Public.check_for_cliff_explosives_in_hold_wooden_chests()
|
||||
local memory = Memory.get_crew_memory()
|
||||
local input_chests = memory.hold_surface_destroyable_wooden_chests
|
||||
local queued_chests_timers = memory.hold_surface_timers_of_wooden_chests_queued_for_destruction
|
||||
local tick_tack_timer = 5 -- how long it takes before chests detonate
|
||||
|
||||
if not input_chests then return end
|
||||
|
||||
for i, chest in ipairs(input_chests) do
|
||||
-- check which chests have cliff explosives in them
|
||||
for i, chest in pairs(input_chests) do
|
||||
-- @TODO: decide what to do when chest is invalid (perhaps it was destroyed by some future feature)
|
||||
if chest and chest.valid then
|
||||
local item_count = chest.get_item_count('cliff-explosives')
|
||||
if item_count and item_count > 0 then
|
||||
local surface = chest.surface
|
||||
local explosion = {
|
||||
name = 'wooden-chest-explosion',
|
||||
position = chest.position
|
||||
}
|
||||
local remnants = {
|
||||
name = 'wooden-chest-remnants',
|
||||
position = chest.position
|
||||
}
|
||||
|
||||
chest.destroy()
|
||||
surface.create_entity(explosion)
|
||||
surface.create_entity(remnants)
|
||||
|
||||
table.fast_remove(memory.hold_surface_destroyable_wooden_chests, i)
|
||||
if not queued_chests_timers[i] then
|
||||
queued_chests_timers[i] = tick_tack_timer
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- update chest timers and when timer reaches 0 explode them
|
||||
for i, _ in pairs(queued_chests_timers) do
|
||||
local chest = input_chests[i]
|
||||
if chest and chest.valid then
|
||||
local surface = chest.surface
|
||||
queued_chests_timers[i] = queued_chests_timers[i] - 1
|
||||
local timer = queued_chests_timers[i]
|
||||
|
||||
if timer <= 0 then
|
||||
-- check if sneaky players didn't decide to remove the explosives just before the explosion
|
||||
local item_count = chest.get_item_count('cliff-explosives')
|
||||
if item_count and item_count > 0 then
|
||||
local explosion = {
|
||||
name = 'wooden-chest-explosion',
|
||||
position = chest.position
|
||||
}
|
||||
local remnants = {
|
||||
name = 'wooden-chest-remnants',
|
||||
position = chest.position
|
||||
}
|
||||
|
||||
chest.destroy()
|
||||
surface.create_entity(explosion)
|
||||
surface.create_entity(remnants)
|
||||
|
||||
input_chests[i] = nil
|
||||
end
|
||||
|
||||
queued_chests_timers[i] = nil
|
||||
else
|
||||
local tick_tacks = {'*tick*', '*tick*', '*tack*', '*tak*', '*tik*', '*tok*'}
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = chest.position,
|
||||
text = tick_tacks[Math.random(#tick_tacks)],
|
||||
color = {r = 0.75, g = 0.75, b = 0.75}
|
||||
}
|
||||
)
|
||||
end
|
||||
else
|
||||
-- we probably don't want to have it in the queue anymore if it's invalid now, do we?
|
||||
queued_chests_timers[i] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- Code taken from Mountain fortress
|
||||
local function equalise_fluid_storage_pair(storage1, storage2)
|
||||
if not storage1.valid then
|
||||
|
@ -619,7 +619,7 @@ function Public.surface_place_random_obstacle_boxes(surface, center, width, heig
|
||||
for j = 1, size^2 do
|
||||
local p2 = surface.find_non_colliding_position('wooden-chest', p, 5, 0.1, true) or p
|
||||
local e = surface.create_entity{name = 'wooden-chest', position = p2, force = memory.force_name, create_build_effect_smoke = false}
|
||||
memory.hold_surface_destroyable_wooden_chests[#memory.hold_surface_destroyable_wooden_chests + 1] = e
|
||||
memory.hold_surface_destroyable_wooden_chests[e.unit_number] = e
|
||||
e.destructible = false
|
||||
e.minable = false
|
||||
e.rotatable = false
|
||||
|
@ -757,6 +757,7 @@ function Public.initialise_crew(accepted_proposal)
|
||||
memory.overworldy = 0
|
||||
|
||||
memory.hold_surface_destroyable_wooden_chests = {}
|
||||
memory.hold_surface_timers_of_wooden_chests_queued_for_destruction = {}
|
||||
|
||||
memory.seaname = SurfacesCommon.encode_surface_name(memory.id, 0, SurfacesCommon.enum.SEA, enum.DEFAULT)
|
||||
|
||||
|
@ -51,6 +51,8 @@ Public.chest_loot_data_raw = {
|
||||
{12, 0, 1, false, 'artillery-shell', 1, 1},
|
||||
{4, 0, 0.8, false, 'pistol', 1, 3},
|
||||
{3, 0, 0.2, false, 'storage-tank', 2, 4},
|
||||
{2, 0.1, 1, false, 'explosives', 5, 9},
|
||||
{2, 0.2, 1, false, 'cliff-explosives', 2, 4},
|
||||
{0.25, 0, 0.5, false, 'uranium-238', 5, 8},
|
||||
|
||||
{8, 0, 1.2, true, 'steel-chest', 4, 12},
|
||||
|
@ -111,8 +111,8 @@ Public.cabin_shop_data = {
|
||||
offer = {type='give-item', item = 'uranium-238', count = 10},
|
||||
},
|
||||
{
|
||||
price = {{'coin', 800}, {'explosives', 4}},
|
||||
offer = {type='give-item', item = 'cliff-explosives', count = 1},
|
||||
price = {{'coin', 1000}, {'explosives', 5}},
|
||||
offer = {type='give-item', item = 'cliff-explosives', count = 5},
|
||||
},
|
||||
--disabled now that we can wait after any destination:
|
||||
-- {
|
||||
|
Loading…
x
Reference in New Issue
Block a user