function damage_received(damage, message, entity_thats_responsible, is_fatal, projectile_thats_responsible)
	-- whenever damaged by player spawn portal with enemies at player coordinates
	-- only if no portal already exists to prevent lag bomb by spawning shitload of hamis
	if IsPlayer(entity_thats_responsible) == true and EntityGetWithName("ln_hooded_portal") == 0 then
		local player_x, player_y = EntityGetTransform(entity_thats_responsible)
		local portal = EntityCreateNew("ln_hooded_portal")
		local portal_body = EntityAddComponent2(portal, "ParticleEmitterComponent", {
			emitted_material_name="meat_static",
			lifetime_min=1,
			lifetime_max=1,
			emission_interval_min_frames=1,
			emission_interval_max_frames=1,
			velocity_always_away_from_center=-20,
			emit_cosmetic_particles=true,
			x_vel_min=-10,
			x_vel_max=10,
			y_vel_min=-10,
			y_vel_max=10,
			count_min=200,
			count_max=200,
			fade_based_on_lifetime=true,
			airflow_force=0.1,
		})
		ComponentSetValue2(portal_body, "gravity", 0, 0)
		ComponentSetValue2(portal_body, "area_circle_radius", 15, 15)
		local portal_emitter = EntityAddComponent2(portal, "ParticleEmitterComponent", {
			emitted_material_name="spark_red_bright",
			lifetime_min=10,
			lifetime_max=20,
			emission_interval_min_frames=65,
			emission_interval_max_frames=65,
			velocity_always_away_from_center=100,
			emit_cosmetic_particles=true,
			x_vel_min=-100,
			x_vel_max=100,
			y_vel_min=-100,
			y_vel_max=100,
			count_min=1000,
			count_max=1000,
			fade_based_on_lifetime=true,
			airflow_force=0.1,
		})
		ComponentSetValue2(portal_emitter, "gravity", 0, 0)
		ComponentSetValue2(portal_emitter, "area_circle_radius", 0, 15)
		EntityAddComponent2(portal, "LightComponent", {
			radius=255,
			fade_out_time=1.5,
			r=64,
			g=100,
			b=255,
		})
		EntityAddComponent2(portal, "AudioComponent", {
			file="data/audio/Desktop/projectiles.bank",
			event_root="player_projectiles/tentacle_portal",
			set_latest_event_position=true,
		})
		EntityAddComponent2(portal, "LifetimeComponent", {
			lifetime=65,
		})
		EntitySetTransform(portal, player_x, player_y)
		SetTimeOut(1, "mods/lewd_noita/files/enemies/hooded.lua", "hooded_portal")
	end
end

function hooded_portal()
	local portal_x, portal_y = EntityGetTransform(EntityGetWithName("ln_hooded_portal"))
	SetRandomSeed(portal_x, portal_y)
	local rand = Random(1, 22)

	if rand == 1 then
		EntityLoad("mods/lewd_noita/files/enemies/chainer.xml", portal_x, portal_y)
	elseif rand == 2 then
		EntityLoad("mods/lewd_noita/files/enemies/flyswarm.xml", portal_x, portal_y)
		EntityLoad("mods/lewd_noita/files/enemies/flyswarm.xml", portal_x, portal_y)
		EntityLoad("mods/lewd_noita/files/enemies/flyswarm.xml", portal_x, portal_y)
	elseif rand == 3 then
		EntityLoad("mods/lewd_noita/files/enemies/giantsnail.xml", portal_x, portal_y)
		EntityLoad("mods/lewd_noita/files/enemies/giantsnail.xml", portal_x, portal_y)
		EntityLoad("mods/lewd_noita/files/enemies/giantsnail.xml", portal_x, portal_y)
	elseif rand == 4 then
		EntityLoad("mods/lewd_noita/files/enemies/hellhound.xml", portal_x, portal_y)
	elseif rand == 5 then
		EntityLoad("mods/lewd_noita/files/enemies/hornygasflower.xml", portal_x, portal_y)
		EntityLoad("mods/lewd_noita/files/enemies/hornygasflower.xml", portal_x, portal_y)
		EntityLoad("mods/lewd_noita/files/enemies/hornygasflower.xml", portal_x, portal_y)
	elseif rand == 6 then
		EntityLoad("mods/lewd_noita/files/enemies/kobold.xml", portal_x, portal_y)
	elseif rand == 7 then
		for i = 1, 4 do
			local rnd = Random(1, 4)
			if rnd == 1 then
				EntityLoad("mods/lewd_noita/files/enemies/maggot_1.xml", portal_x, portal_y)
			elseif rnd == 2 then
				EntityLoad("mods/lewd_noita/files/enemies/maggot_2.xml", portal_x, portal_y)
			elseif rnd == 3 then
				EntityLoad("mods/lewd_noita/files/enemies/maggot_3.xml", portal_x, portal_y)
			elseif rnd == 4 then
				EntityLoad("mods/lewd_noita/files/enemies/maggot_4.xml", portal_x, portal_y)
			end
		end
	elseif rand == 8 then
		EntityLoad("mods/lewd_noita/files/enemies/tank_corrupt.xml", portal_x, portal_y)
		EntityLoad("mods/lewd_noita/files/enemies/tank_corrupt.xml", portal_x, portal_y)
		EntityLoad("mods/lewd_noita/files/enemies/tank_corrupt.xml", portal_x, portal_y)
	elseif rand == 9 then
		EntityLoad("mods/lewd_noita/files/enemies/webspider.xml", portal_x, portal_y)
	elseif rand == 10 then
		EntityLoad("mods/lewd_noita/files/enemies/wizard_futa.xml", portal_x, portal_y)
		EntityLoad("mods/lewd_noita/files/enemies/wizard_futa.xml", portal_x, portal_y)
		EntityLoad("mods/lewd_noita/files/enemies/wizard_futa.xml", portal_x, portal_y)
	elseif rand == 11 then
		EntityLoad("mods/lewd_noita/files/enemies/wolf_cyber.xml", portal_x, portal_y)
		EntityLoad("mods/lewd_noita/files/enemies/wolf_cyber.xml", portal_x, portal_y)
		EntityLoad("mods/lewd_noita/files/enemies/wolf_cyber.xml", portal_x, portal_y)
	elseif rand == 12 then
		EntityLoad("data/entities/animals/fungus_giga.xml", portal_x, portal_y)
	elseif rand == 13 then
		EntityLoad("data/entities/animals/fungus_big.xml", portal_x, portal_y)
	elseif rand == 14 then
		EntityLoad("data/entities/animals/statue.xml", portal_x, portal_y)
	elseif rand == 15 then
		EntityLoad("data/entities/animals/necromancer.xml", portal_x, portal_y)
	elseif rand == 16 then
		EntityLoad("data/entities/animals/shaman.xml", portal_x, portal_y)
	elseif rand == 17 then
		EntityLoad("data/entities/animals/spitmonster.xml", portal_x, portal_y)
	elseif rand == 18 then
		EntityLoad("data/entities/animals/skullfly.xml", portal_x, portal_y)
	elseif rand == 19 then
		EntityLoad("data/entities/animals/playerghost.xml", portal_x, portal_y)
	elseif rand == 20 then
		EntityLoad("data/entities/animals/spearbot.xml", portal_x, portal_y)
	elseif rand == 21 then
		EntityLoad("data/entities/animals/longleg.xml", portal_x, portal_y)
		EntityLoad("data/entities/animals/longleg.xml", portal_x, portal_y)
		EntityLoad("data/entities/animals/longleg.xml", portal_x, portal_y)
		EntityLoad("data/entities/animals/longleg.xml", portal_x, portal_y)
		EntityLoad("data/entities/animals/longleg.xml", portal_x, portal_y)
		EntityLoad("data/entities/animals/longleg.xml", portal_x, portal_y)
		EntityLoad("data/entities/animals/longleg.xml", portal_x, portal_y)
		EntityLoad("data/entities/animals/longleg.xml", portal_x, portal_y)
		EntityLoad("data/entities/animals/longleg.xml", portal_x, portal_y)
		EntityLoad("data/entities/animals/longleg.xml", portal_x, portal_y)
	elseif rand == 22 then
		EntityLoad("data/entities/animals/miner_chef.xml", portal_x, portal_y)
	end

end

function death(damage_type_bit_field, damage_message, entity_thats_responsible, drop_items)
	local loot = {
		"bloodmoney_10000",
		"broken_wand",
		"chest_leggy",
		"chest_random_super",
		"gourd",
		"heart_evil",
		"jar_of_urine",
		"poopstone",
		"potion_beer",
		"potion_milk",
		"potion_mimic",
		"potion_porridge",
		"potion_secret",
		"random_card",
		"safe_haven",
		"stonestone",
		"utility_box",
		"wandstone",
		"waterstone",
	}
	local rand_x = tonumber(ComponentGetValue(EntityGetFirstComponent(GetUpdatedEntityID(), "PositionSeedComponent"), "pos_x"))
	local rand_y = tonumber(ComponentGetValue(EntityGetFirstComponent(GetUpdatedEntityID(), "PositionSeedComponent"), "pos_y"))
	SetRandomSeed(rand_x, rand_y)
	local hooded_x, hooded_y = EntityGetTransform(GetUpdatedEntityID())
	EntityLoad("data/entities/items/pickup/" .. loot[Random(1, #loot)] .. ".xml", hooded_x, hooded_y)
end