Add flames and explosions to transition
This commit is contained in:
parent
d09b66deb5
commit
e0df3f1335
1 changed files with 67 additions and 5 deletions
|
@ -84,6 +84,56 @@ local function explode_silo(silo)
|
||||||
silo.die()
|
silo.die()
|
||||||
end
|
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)
|
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
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
local transit_tick = game.tick + (26 * 59)
|
local burn_tick = game.tick + (14 * 59)
|
||||||
local explode_tick = game.tick + (31 * 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()
|
script.on_nth_tick(burn_tick, function()
|
||||||
explode_silo(event.rocket_silo)
|
burn_silo(event.rocket_silo)
|
||||||
script.on_nth_tick(explode_tick, nil)
|
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)
|
end)
|
||||||
|
|
||||||
script.on_nth_tick(transit_tick, function()
|
script.on_nth_tick(transit_tick, function()
|
||||||
transit_player(player.index)
|
transit_player(player.index)
|
||||||
script.on_nth_tick(transit_tick, nil)
|
script.on_nth_tick(transit_tick, nil)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
script.on_nth_tick(explode_tick, function()
|
||||||
|
explode_silo(event.rocket_silo)
|
||||||
|
script.on_nth_tick(explode_tick, nil)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
ToNauvis.events[defines.events.on_post_entity_died] = function(event)
|
ToNauvis.events[defines.events.on_post_entity_died] = function(event)
|
||||||
|
|
Loading…
Add table
Reference in a new issue