if srb2p return end

addHook("MobjThinker", function(mo)
	if (mo and mo.valid)
	and mo.type == MT_MECHASHOT
	and mo.state == mobjinfo[mo.type].spawnstate
		local mechafirefloat = P_SpawnMobj(mo.x+P_RandomRange(-10,10)*FRACUNIT,mo.y+P_RandomRange(-10,10)*FRACUNIT,mo.z+mo.height-15*FRACUNIT+P_RandomRange(-10,10)*FRACUNIT, MT_SPINDUST)
		mechafirefloat.state = S_SPINFIRE1
		mechafirefloat.fuse = 7
		mechafirefloat.scale = mo.scale/2
	end
end, MT_MECHASHOT)

local function mechadashmode(mo, trailmo, freq)
    if not mo.prevz or not mo.prevleveltime or (mo.prevleveltime ~= leveltime - 1) then
       mo.prevz = mo.z
    end
    local rmomz = mo.z - mo.prevz
    mo.prevz = mo.z
    mo.prevleveltime = leveltime
    local mospeed = R_PointToDist2(0, 0, R_PointToDist2(0, 0, mo.momx, mo.momy), rmomz)
    local dist = (mospeed/freq)
    for i = dist, 1, -1 do
        local spawnedmo = P_SpawnMobjFromMobj(mo, (mo.momx/dist)*i, (mo.momy/dist)*i, (rmomz/dist)*i, trailmo)
        spawnedmo.color = SKINCOLOR_RED
        spawnedmo.blendmode = AST_ADD
		spawnedmo.frame = FF_TRANS50
		spawnedmo.fuse = 8
		spawnedmo.destscale = 0
    end
end

addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo and player.mo.skin == "mecha"
			if not (player.mo.spinslash)
				player.mo.spinslash = 0
			end
			if player.mo.spinslash > 0
				player.mo.spinslash = $1 - 1
			end
			if player.mo.spinslash > 1
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
				player.mo.momy = 0
				player.mo.momx = 0
				player.powers[pw_nocontrol] = 2
				player.mo.state = S_PLAY_JUMP
				player.pflags = $1|PF_THOKKED
				player.pflags = $1|PF_JUMPED
				local mechadust2 = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z + ((player.mo.eflags & MFE_VERTICALFLIP)/MFE_VERTICALFLIP * (player.mo.height - mobjinfo[MT_SPINDUST].height)), MT_SPINDUST)
				mechadust2.tics = 8
				mechadust2.eflags = $1 | (player.mo.eflags & MFE_VERTICALFLIP)
				mechadust2.scale = player.mo.scale >> 1
				mechadust2.destscale = player.mo.scale << 3
				mechadust2.scalespeed = FixedMul(mechadust2.scalespeed, player.mo.scale)
				P_SetObjectMomZ(mechadust2, player.dashspeed/20, -30*FRACUNIT, false)				
				P_InstaThrust(mechadust2, player.mo.angle+(P_RandomRange(-ANG30/FRACUNIT, ANG30/FRACUNIT)*FRACUNIT), FixedMul(-player.runspeed/12-1*FRACUNIT-P_RandomByte()<<11, player.mo.scale))
				P_TryMove(mechadust2, mechadust2.x+mechadust2.momx, mechadust2.y+mechadust2.momy, true)
				P_SpawnSkidDust(player, 15*FRACUNIT, sfx_none)
				if not (player.cmd.buttons & BT_CUSTOM3)
					player.mo.momz = 0
				end
				if (player.cmd.buttons & BT_CUSTOM3)
					if (player.mo.eflags & MFE_UNDERWATER)
						P_SetObjectMomZ(player.mo, 3*FRACUNIT/2, false)
					else
						P_SetObjectMomZ(player.mo, 3*FRACUNIT, false)
					end
				end
			end
			if player.mo.spinslash > 20
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
				if (leveltime % 8 == 0)
					S_StartSound(player.mo, sfx_spin)
				end
			end
			if player.mo.spinslash == 1
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
				S_StartSound(player.mo, sfx_zoom)
				if (player.cmd.buttons & BT_CUSTOM3)
					if player.powers[pw_super]
						P_SetObjectMomZ(player.mo, 39*FRACUNIT, false)
						P_SpawnParaloop(player.mo.x,player.mo.y,player.mo.z,player.mo.scale*52,22,MT_SPINFIRE,ANGLE_90,nil,true)
				elseif (player.mo.eflags & MFE_UNDERWATER)
						P_SetObjectMomZ(player.mo, 29*FRACUNIT/2, false)
						P_SpawnParaloop(player.mo.x,player.mo.y,player.mo.z,player.mo.scale*52,22,MT_MEDIUMBUBBLE,ANGLE_90,nil,true)
					else
						P_SetObjectMomZ(player.mo, 29*FRACUNIT, false)
						P_SpawnParaloop(player.mo.x,player.mo.y,player.mo.z,player.mo.scale*52,22,MT_SPINFIRE,ANGLE_90,nil,true)
					end
				else
					if player.powers[pw_super]
						P_SetObjectMomZ(player.mo, 29*FRACUNIT, false)
						P_SpawnParaloop(player.mo.x,player.mo.y,player.mo.z,player.mo.scale*52,22,MT_SPINFIRE,ANGLE_90,nil,true)
				elseif (player.mo.eflags & MFE_UNDERWATER)
						P_SetObjectMomZ(player.mo, 19*FRACUNIT/2, false)
						P_SpawnParaloop(player.mo.x,player.mo.y,player.mo.z,player.mo.scale*52,22,MT_MEDIUMBUBBLE,ANGLE_90,nil,true)
					else
						P_SetObjectMomZ(player.mo, 19*FRACUNIT, false)
						P_SpawnParaloop(player.mo.x,player.mo.y,player.mo.z,player.mo.scale*52,22,MT_SPINFIRE,ANGLE_90,nil,true)
					end
				end
			end
			if not (player.mo.custom1down)
				player.mo.custom1down = 0
			end
			if not (player.mo.custom2down)
				player.mo.custom2down = 0
			end
			if not (player.mo.electricball)
				player.mo.electricball = 0
			end
			if player.mo.electricball > 0
				player.mo.electricball = $1 - 1
			end
			if player.mo.electricball > 1
			and (player.pflags & PF_JUMPED)
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
				P_SetObjectMomZ(player.mo, 9*FRACUNIT, false)
				local ghost = P_SpawnGhostMobj(player.mo)
				ghost.color = player.mo.color
				ghost.fuse = 4
				ghost.colorized = true
				player.mo.state = S_PLAY_WALK
			end
			if player.mo.electricball == 1
			and (player.pflags & PF_JUMPED)
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
				player.mo.state = S_PLAY_FLOAT
				S_StartSound(player.mo, sfx_s23c)
				player.mo.momz = 1*FRACUNIT
				P_SpawnPlayerMissile(player.mo, MT_MECHASHOT, MF2_SCATTER)
			end
			if not (player.mo.speeddash)
				player.mo.speeddash = 0
			end
			if player.mo.speeddash > 0
				player.mo.speeddash = $1 - 1
			end
			if player.mo.speeddash > 1
			and (P_IsObjectOnGround(player.mo))
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
				player.drawangle = player.mo.angle
				local ghost = P_SpawnGhostMobj(player.mo)
				ghost.color = player.mo.color
				ghost.fuse = 4
				ghost.colorized = true
				player.mo.state = S_PLAY_FLOAT
				player.mo.momx = 0
				P_InstaThrust(player.mo, player.mo.angle, player.speed+2)
			end
			if player.mo.speeddash == 1
			and (P_IsObjectOnGround(player.mo))
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
				S_StartSound(player.mo, sfx_skid)
			end
			if (player.cmd.buttons & BT_CUSTOM1)
			and not (player.mo.state == S_PLAY_PAIN)
			and not player.weapondelay
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
			and not player.exiting
			and not player.powers[pw_carry]
			and not (player.pflags & PF_STASIS)
			and not (player.mo.state == S_PLAY_SUPER_TRANS1)
			and not (player.mo.tracer and player.mo.tracer.mechaype == MT_TUBEWAYPOINT)
			and not (player.pflags & PF_SPINNING)
			and not (player.mo.eflags & MFE_SPRUNG)
			and not (player.pflags & PF_JUMPED)
			and player.mo.custom1down == 0
			and (P_IsObjectOnGround(player.mo))
				player.mo.custom1down = 1
				player.weapondelay = 15
				player.mo.speeddash = 10
				S_StartSound(player.mo, sfx_zoom)
			end
			if not (player.cmd.buttons & BT_CUSTOM1)
				player.mo.custom1down = 0
			end
			if (player.cmd.buttons & BT_CUSTOM2)
			and (player.mo.state == S_PLAY_JUMP)
			and not player.weapondelay
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
			and not player.exiting
			and not player.powers[pw_carry]
			and not (player.pflags & PF_STASIS)
			and (player.pflags & PF_JUMPED)
			and not (player.mo.tracer and player.mo.tracer.mechaype == MT_TUBEWAYPOINT)
			and player.mo.custom2down == 0
				player.mo.custom2down = 1
				player.weapondelay = 3*TICRATE
				player.mo.electricball = 18
				S_StartSound(player.mo, sfx_s3k53)
			end
			if not (player.cmd.buttons & BT_CUSTOM2)
				player.mo.custom2down = 0
			end
			for x=player.mo.x,player.mo.x+player.mo.radius*2,player.mo.radius*2
				for y=player.mo.y,player.mo.y+player.mo.radius*2,player.mo.radius*2
					local ss = R_PointInSubsector(x,y)
					for fof in ss.sector.ffloors()
						if (fof.flags & FF_BUSTUP) and (fof.flags & FF_EXISTS)
							if (player.mo.z+player.mo.momz==fof.topheight or player.mo.z+player.mo.height+player.mo.momz==fof.bottomheight or (player.mo.eflags & MFE_VERTICALFLIP and (player.mo.z+player.mo.momz==fof.bottomheight or player.mo.z-player.mo.height-player.mo.momz==fof.topheight)))
							and (player.mo.eflags & MFE_JUSTHITFLOOR)
								EV_CrumbleChain(ss.sector, fof)
								S_StartSound(player.mo, sfx_s3k5f)
								player.mo.state = S_PLAY_JUMP
							end
						end
					end
				end
			end
			if player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
			and not (player.powers[pw_carry] == CR_NIGHTSMODE)
				if leveltime == 1
					P_BlackOw(player)
					P_Earthquake(player.mo, player.mo, 256*FRACUNIT)
					P_StartQuake(79*FRACUNIT, 3)
					P_FlashPal(player, PAL_WHITE, 3)
					P_NukeEnemies(player.mo, player.mo, RING_DIST)
					S_StartSound(player.mo, sfx_bgxpld)
					A_OldRingExplode(player.mo, MT_SONIC3KBOSSEXPLODE)
					P_StartQuake(20*FRACUNIT, 35, {0, 0, 0}, player.mo.radius)
					local thok = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z, MT_THOK)
					A_SetScale(thok, 24*FRACUNIT, 1)
					thok.scalespeed = FRACUNIT/2
					thok.color = SKINCOLOR_WHITE
					thok.tics = TICRATE
				end
			end
			if not (player.powers[pw_carry] == CR_NIGHTSMODE)
			and not (player.mo.state == S_PLAY_JUMP)
				if player.speed >= player.runspeed
				or player.dashmode > 3*TICRATE
					local firefloat = P_SpawnMobj(player.mo.x+P_RandomRange(-10,10)*FRACUNIT,player.mo.y+P_RandomRange(-10,10)*FRACUNIT,player.mo.z+player.mo.height-15*FRACUNIT+P_RandomRange(-10,10)*FRACUNIT, MT_SPINDUST)
					firefloat.state = S_SPINFIRE1
					firefloat.fuse = 7
					firefloat.scale = player.mo.scale/2
				end
			end
			if not player.powers[pw_extralife]
			and not (player.exiting)
				if player.powers[pw_super] then
					S_ChangeMusic("mehsup",true,player)
				end	
			else
				P_RestoreMusic(player)
			end
			if player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
				if (player.mo.eflags & MFE_JUSTHITFLOOR)
				and (player.mo.eflags & MFE_ONGROUND)
				and not (player.mo.eflags & MFE_TOUCHWATER)
				and not (player.mo.eflags & MFE_SPRUNG)
				and not (player.mo.flags & FF_EXISTS) 
				and not (player.mo.flags & FF_STRONGBUST) 
				and not (player.mo.flags & FF_BUSTUP)
				and not player.powers[pw_justlaunched]
					P_SpawnParaloop(player.mo.x, player.mo.y, player.mo.z, 80*FRACUNIT, 8, MT_EXPLODE, ANGLE_90, S_XPLD2, true)
					S_StartSound(player.mo, sfx_s3k96)
				end
			end
			if player.playerstate == PST_DEAD then
				player.mo.flags = $ & ~MF_NOCLIP
				player.mo.flags = $ & ~MF_NOCLIPHEIGHT
			end
			if player.playerstate == PST_DEAD
			and player.deadtimer == 48
				player.mo.flags2 = $1|MF2_DONTDRAW
				player.mo.momx = 0
				player.mo.momy = 0
				player.mo.momz = 0
				player.mo.flags = $ & ~MF_NOCLIP
				player.mo.flags = $ & ~MF_NOCLIPHEIGHT
				player.mo.state = S_CYBRAKDEMONNAPALMBOMBSMALL_DIE2
			end
			if player.powers[pw_flashing] == 100
				player.powers[pw_flashing] = 0
			end
			if player.dashmode > 3*TICRATE
			and not (player.mo.state == S_PLAY_SPINDASH)
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
				mechadashmode(player.mo, MT_THOK, 4*FRACUNIT)
				local boost = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z, MT_THOK)
				boost.color = SKINCOLOR_RED
				boost.colorized = true
				boost.sprite = SPR_FIRS
				boost.frame = S|FF_TRANS50
				boost.angle = player.mo.angle
				boost.fuse = 1
			end
			if (player.mo.state == S_PLAY_FLOAT or player.mo.state == S_PLAY_FLOAT_RUN or player.mo.state == S_PLAY_DASH)
			and player.playerstate == PST_LIVE
				S_StartSound(player.mo, sfx_fire)
			end
			if player.dashmode > 3*TICRATE
			and not player.powers[pw_sneakers]
			and not player.powers[pw_super]
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
				if player.speed >= player.runspeed
				and (player.speed > 72*FRACUNIT)
					if (leveltime & 3) == 1
						local mechamaxdash = P_SpawnGhostMobj(player.mo)
						mechamaxdash.color = SKINCOLOR_RED
						mechamaxdash.colorized = true
						mechamaxdash.blendmode = AST_ADD
					end
				end
			end
			if player.dashmode > 3*TICRATE
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
			//and (player.powers[pw_sneakers] or player.powers[pw_super])
				if (leveltime & 3) == 1
					local mechamaxdashboots = P_SpawnGhostMobj(player.mo)
					mechamaxdashboots.color = SKINCOLOR_RED
					mechamaxdashboots.colorized = true
					mechamaxdashboots.blendmode = AST_ADD
					mechamaxdashboots.frame = ($1 & ~FF_TRANSMASK)|FF_TRANS40
					mechamaxdashboots.eflags = player.mo.eflags & MFE_VERTICALFLIP
				end
			end
			if player.dashmode > 3*TICRATE
			and not (player.mo.state == S_PLAY_SPINDASH)
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
				if (leveltime % 3) == 1
					local speedrun = P_SpawnMobj(player.mo.x + (P_RandomRange(-36,36) * player.mo.scale),
					player.mo.y + (P_RandomRange(-36,36) * player.mo.scale),
					player.mo.z + (player.mo.height/2) + (P_RandomRange(-20,20) * player.mo.scale), MT_SMOKE)
					if speedrun and speedrun.valid
						speedrun.state = S_WATERZAP
						speedrun.angle = player.drawangle
						speedrun.momx = 3*player.mo.momx/4
						speedrun.momy = 3*player.mo.momy/4
						speedrun.momz = 3*player.mo.momz/4
						speedrun.scale = player.mo.scale
					end
				end
			end
			if player.dashmode > 3*TICRATE
			and not (player.mo.state == S_PLAY_SPINDASH)
			and not (CBW_Battle)
			and P_IsObjectOnGround(player.mo)
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
				P_ElementalFire(player, false)
			end
			if player.dashmode > 3*TICRATE
			and not (player.mo.state == S_PLAY_SPINDASH)
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
				if (leveltime % 24 == 0)
					local thok = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z, MT_THOK)
					thok.state = S_FACESTABBERSPEAR
					thok.angle = player.drawangle+ANGLE_90
					thok.scale = player.mo.scale/2+FRACUNIT/4
					thok.fuse = 8
					thok.color = SKINCOLOR_RED
					thok.colorized = true
					thok.blendmode = AST_ADD
				end
			end
			if player.dashmode > 3*TICRATE
			and not (player.mo.state == S_PLAY_SPINDASH)
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
				if (leveltime % 59 == 0)
					S_StartSound(player.mo, sfx_s3ka1)
				end
			end
			//Mecha Sonic Super Form
			if player.powers[pw_super]
				if (leveltime % 8 == 0)
					local supermechaparticles = P_SpawnMobj(player.mo.x-P_RandomRange(-51, 51)*player.mo.scale, player.mo.y+P_RandomRange(-51, 51)*player.mo.scale, player.mo.z+10*player.mo.scale, MT_THOK)
					supermechaparticles.eflags = player.mo.eflags
					supermechaparticles.blendmode = AST_ADD
					P_SetObjectMomZ(supermechaparticles, 4*FRACUNIT)
					supermechaparticles.state = S_WATERZAP
					supermechaparticles.scale = player.mo.scale/3
					supermechaparticles.fuse = 10				
					supermechaparticles.scalespeed = $/3
					supermechaparticles.destscale = $*99
					local supermechaparticles2 = P_SpawnMobj(player.mo.x-P_RandomRange(-51, 51)*player.mo.scale, player.mo.y+P_RandomRange(-51, 51)*player.mo.scale, player.mo.z+10*player.mo.scale, MT_THOK)
					supermechaparticles2.eflags = player.mo.eflags
					supermechaparticles2.blendmode = AST_ADD
					P_SetObjectMomZ(supermechaparticles2, 4*FRACUNIT)
					supermechaparticles2.state = S_SPINFIRE1
					supermechaparticles2.scale = player.mo.scale/3
					supermechaparticles2.fuse = 10				
					supermechaparticles2.scalespeed = $/3
					supermechaparticles2.destscale = $*99
				end
			end
			if (player.pflags & PF_STARTDASH)
			and not (player.powers[pw_shield] == SH_ELEMENTAL)
			and not (player.mo.eflags & MFE_UNDERWATER)
			and player.playerstate == PST_LIVE
			and not P_PlayerInPain(player)
				local mechadust = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z + ((player.mo.eflags & MFE_VERTICALFLIP)/MFE_VERTICALFLIP * (player.mo.height - mobjinfo[MT_SPINDUST].height)), MT_SPINDUST)
				mechadust.tics = 8
				mechadust.eflags = $1 | (player.mo.eflags & MFE_VERTICALFLIP)
				mechadust.scale = player.mo.scale >> 1
				mechadust.destscale = player.mo.scale << 3
				mechadust.scalespeed = FixedMul(mechadust.scalespeed, player.mo.scale)
				P_SetObjectMomZ(mechadust, player.dashspeed/20, false)				
				P_InstaThrust(mechadust, player.mo.angle+(P_RandomRange(-ANG30/FRACUNIT, ANG30/FRACUNIT)*FRACUNIT), FixedMul(-player.runspeed/12-1*FRACUNIT-P_RandomByte()<<11, player.mo.scale))
				P_TryMove(mechadust, mechadust.x+mechadust.momx, mechadust.y+mechadust.momy, true)
				P_SpawnSkidDust(player, 15*FRACUNIT, sfx_none)
				player.charflags = $1|SF_NOSPINDASHDUST
			else
				player.charflags = $1 & ~SF_NOSPINDASHDUST
			end
		end
	end
end)

addHook("SpinSpecial", function(player)
	if (player.mo.skin == "mecha")
	and player.playerstate == PST_LIVE
	and not P_PlayerInPain(player)
		if (player.pflags & PF_STARTDASH)
			if (leveltime % 3 == 0)
				S_StartSound(player.mo, sfx_spndsh)
			end
		end
	end
end)

addHook("MobjMoveBlocked", function(mo)
	if (mo and mo.player and mo.valid and mo.skin == "mecha")
		if (mo.player.cmd.buttons & BT_CUSTOM3)
		and mo.player.playerstate == PST_LIVE
		and not P_PlayerInPain(mo.player)
		and not mo.player.exiting
		and not mo.player.weapondelay
		and (mo.player.pflags & PF_JUMPED)
		and not (mo.flags & MF_MONITOR or mo.flags & MF_ENEMY or mo.flags & MF_BOSS)
			mo.player.weapondelay = 6*TICRATE
			mo.spinslash = 89
		end
	end
end, MT_PLAYER)

addHook("MobjCollide", function(spike, plmo)
    if not (plmo and plmo.valid and plmo.skin == "mecha") then return end
	if plmo.type ~= MT_PLAYER then return end
	if plmo.z + plmo.height < spike.z or spike.z + spike.height < plmo.z then return end
	local player = plmo.player
	P_KillMobj(spike, plmo, plmo)
end, MT_SPIKE)

addHook("MobjCollide", function(spike, plmo)
    if not (plmo and plmo.valid and plmo.skin == "mecha") then return end
	if plmo.type ~= MT_PLAYER then return end
	if (plmo.z > spike.z+spike.height*4) or (spike.z > plmo.z+plmo.height*2) then return end
	local player = plmo.player
	P_KillMobj(spike, plmo, plmo)
end, MT_WALLSPIKE)

addHook("PlayerThink", function(player)
	if player.mo
	and player.mo.valid
	and player.playerstate == PST_LIVE
	and not P_PlayerInPain(player)
	and player.mo.skin == "mecha"
		if player.mo.spiked == nil
			player.mo.spiked = false
		else
			if player.mo.spiked == true
				if P_IsObjectOnGround(player.mo)
					player.mo.spiked = false
				end
			end
		end
	end
end)

addHook("JumpSpinSpecial", function(player)
	if player.mo
	and player.mo.valid
	and player.playerstate == PST_LIVE
	and not P_PlayerInPain(player)
	and player.mo.skin == "mecha"
		if player.mo.spiked == false
			for i = 1, 8
				P_SPMAngle(player.mo, MT_SPIKEBURST, player.mo.angle+ANGLE_45*i)
				local spikes1 = P_SPMAngle(player.mo, MT_SPIKEBURST, player.mo.angle+ANGLE_45*i)
				if spikes1
				and spikes1.valid
					P_SetObjectMomZ(spikes1, 4*FRACUNIT)
				end
				local spikes2 = P_SPMAngle(player.mo, MT_SPIKEBURST, player.mo.angle+ANGLE_45*i)
				if spikes2
				and spikes2.valid
					P_SetObjectMomZ(spikes2, -4*FRACUNIT)
				end
			end
			local spike_up = P_SPMAngle(player.mo, MT_SPIKEBURST3, player.mo.angle)
			if spike_up
			and spike_up.valid
				spike_up.momx = 0
				spike_up.momy = 0
				P_SetObjectMomZ(spike_up, 40*FRACUNIT)
			end
			local spike_down = P_SPMAngle(player.mo, MT_SPIKEBURST4, player.mo.angle)
			if spike_down
			and spike_down.valid
				spike_down.momx = 0
				spike_down.momy = 0
				P_SetObjectMomZ(spike_down, -40*FRACUNIT)
			end
			player.mo.spiked = true
		end
	end
end)