From e0df3f13358401a6521143409f2e02da8558a136 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Fri, 6 Jun 2025 14:25:44 +0200 Subject: [PATCH] Add flames and explosions to transition --- lignumis/scripts/to-nauvis.lua | 72 +++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 5 deletions(-) diff --git a/lignumis/scripts/to-nauvis.lua b/lignumis/scripts/to-nauvis.lua index 3985a75..27cffdd 100644 --- a/lignumis/scripts/to-nauvis.lua +++ b/lignumis/scripts/to-nauvis.lua @@ -84,6 +84,56 @@ local function explode_silo(silo) silo.die() end + +local get_random_position = function(box, x_scale, y_scale) + x_scale = x_scale or 1 + y_scale = y_scale or 1 + local x1 = box.left_top.x + local y1 = box.left_top.y + local x2 = box.right_bottom.x + local y2 = box.right_bottom.y + local x = ((x2 - x1) * x_scale * (math.random() - 0.5)) + ((x1 + x2) / 2) + local y = ((y2 - y1) * y_scale * (math.random() - 0.5)) + ((y1 + y2) / 2) + return { x, y } +end + + +local function burn_silo(silo) + local surface = silo.surface + local box = silo.bounding_box + for k = 1, 6 do + local position = get_random_position(box, 0.8, 0.5) + surface.create_entity + { + name = "crash-site-fire-flame", + position = position + } + local fire = surface.create_entity + { + name = "crash-site-fire-smoke", + position = position + } + fire.time_to_live = math.random(59 * 9, 59 * 14 - 1) + fire.time_to_next_effect = math.random(59 * 2) + end +end + + +local function pre_explode_silo(silo) + local surface = silo.surface + local box = silo.bounding_box + for k = 1, 3 do + local explosions = surface.create_entity + { + name = "crash-site-explosion-smoke", + position = get_random_position(box, 0.8, 0.5) + } + explosions.time_to_live = math.random(59 * 6, 59 * 11 - 1) + explosions.time_to_next_effect = math.random(59 * 3) + end +end + + ToNauvis.events[defines.events.on_rocket_launch_ordered] = function(event) if not event.rocket_silo or event.rocket_silo.name ~= "provisional-rocket-silo" then return end @@ -103,18 +153,30 @@ ToNauvis.events[defines.events.on_rocket_launch_ordered] = function(event) end end - local transit_tick = game.tick + (26 * 59) - local explode_tick = game.tick + (31 * 59) + local burn_tick = game.tick + (14 * 59) + local pre_explode_tick = game.tick + (17 * 59) + local transit_tick = game.tick + (23 * 59) + local explode_tick = game.tick + (28 * 59) - script.on_nth_tick(explode_tick, function() - explode_silo(event.rocket_silo) - script.on_nth_tick(explode_tick, nil) + script.on_nth_tick(burn_tick, function() + burn_silo(event.rocket_silo) + script.on_nth_tick(burn_tick, nil) + end) + + script.on_nth_tick(pre_explode_tick, function() + pre_explode_silo(event.rocket_silo) + script.on_nth_tick(pre_explode_tick, nil) end) script.on_nth_tick(transit_tick, function() transit_player(player.index) script.on_nth_tick(transit_tick, nil) end) + + script.on_nth_tick(explode_tick, function() + explode_silo(event.rocket_silo) + script.on_nth_tick(explode_tick, nil) + end) end ToNauvis.events[defines.events.on_post_entity_died] = function(event)