dofile_once( "data/scripts/lib/utilities.lua" )


local entity_id    = GetUpdatedEntityID()
local pos_x, pos_y = EntityGetTransform( entity_id )

local nearby = EntityGetInRadiusWithTag(pos_x, pos_y, 50, "mortal")

for k, enemy in pairs(nearby)do
    local has_script = false
    local lua_components = EntityGetComponent(enemy, "LuaComponent")
    if(lua_components ~= nil)then
        for k, comp in pairs(lua_components)do
            local script = ComponentGetValue2(comp, "script_damage_received")
            if(script == "mods/spellbound_bundle/files/scripts/misc/sacrificiallaunchattach.lua")then
                has_script = true
            end
        end
    end    
    if(has_script ~= true)then
       -- print("script has been attached")
        EntityAddComponent(enemy, "LuaComponent", {
            script_damage_received="mods/spellbound_bundle/files/scripts/misc/sacrificiallaunchattach.lua",
            remove_after_executed="1",
        })
    end
end
