1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00
ComfyFactorio/modules/explosive_player_respawn.lua

21 lines
934 B
Lua
Raw Normal View History

2019-02-05 09:42:45 +02:00
-- clear the player respawn from enemies with a kaboom -- by mewmew
2021-03-24 21:14:55 +02:00
local Event = require 'utils.event'
2019-02-05 09:42:45 +02:00
local function damage_entities_in_radius(surface, position, radius)
2021-03-24 17:46:00 +02:00
local entities_to_damage = surface.find_entities_filtered({area = {{position.x - radius, position.y - radius}, {position.x + radius, position.y + radius}}})
for _, entity in pairs(entities_to_damage) do
if entity.health and entity.force.name == 'enemy' then
entity.surface.create_entity({name = 'big-explosion', position = entity.position})
entity.destroy()
end
end
2019-02-05 09:42:45 +02:00
end
2021-03-24 17:46:00 +02:00
2019-02-05 09:42:45 +02:00
local function on_player_respawned(event)
2021-03-24 17:46:00 +02:00
local player = game.players[event.player_index]
player.surface.create_entity({name = 'uranium-cannon-shell-explosion', position = player.position})
damage_entities_in_radius(player.surface, player.position, 11)
2019-02-05 09:42:45 +02:00
end
2021-03-24 21:14:55 +02:00
Event.add(defines.events.on_player_respawned, on_player_respawned)