--A replacement of how the random shadows work to (hopefully) fix the long distance
--explosions in Malicious Metropolis

--Effectively turns the things to scenery
addHook("MobjSpawn",function(mo)
	if not mapheaderinfo[gamemap].altshadows == true return end
		mo.flags = $1|MF_RUNSPAWNFUNC
		mo.flags = $1 & ~(MF_PAIN)
		mo.tics = -1
end
,MT_RANDOMSHADOW)


--Transfers the Shadow's action's pain effect to a sector effect.
--Players will be flung back instead of in the angle of the shadow.
local function shadowpain(l,mo,s)
	if (not mo.player.powers[pw_flashing]
		and not mo.player.kartstuff[k_invincibilitytimer]
		and not mo.player.kartstuff[k_growshrinktimer]
		and not mo.player.kartstuff[k_spinouttimer]
		and P_IsObjectOnGround(mo)
		--[[ and mo.z == mo.z)]])
			P_DamageMobj(mo, nil, nil, 1)
			P_InstaThrust(mo,ANGLE_180+mo.angle, 16<<FRACBITS)
			local fire = P_SpawnMobj(mo.x, mo.y, mo.z, MT_THOK)
			P_SetMobjStateNF(fire,S_QUICKBOOM1)
			P_SetScale(fire, 4<<FRACBITS)
			fire.color = SKINCOLOR_KETCHUP
			S_StartSound(mo, sfx_fire2)
	else
		K_DoInstashield(mo.player)
	end
end

addHook("LinedefExecute",shadowpain,"SHDOPAIN")
