addHook("PlayerThink", function(player)
    if player.mo and player.valid then
		if (tostring(mapheaderinfo[gamemap].actnum) == "59")
			if ((player.playerstate == PST_REBORN) or (leveltime == 1))
				player.mo.state = S_PLAY_PAIN
				P_SetObjectMomZ(player.mo, 128*FRACUNIT, false)
				P_Earthquake(player.mo, player.mo, 256*FRACUNIT)
                P_StartQuake(79*FRACUNIT, 3*TICRATE)
                P_FlashPal(player, PAL_NUKE, 3*TICRATE)

				for a=1,64 do
					local explode = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z, MT_BOSSEXPLODE)
					explode.momx = P_RandomRange(-FRACUNIT, FRACUNIT) * 4
					explode.momy = P_RandomRange(-32768, 32767) * 4
					explode.momz = P_RandomFixed() * 8
					explode.scale = 5*FRACUNIT
					S_StartSound(nil, sfx_alarm, player)
					S_StartSound(nil, sfx_cybdth, player)
					S_StartSound(nil, sfx_crumbl, player)
					S_StartSound(nil, sfx_bgxpld, player)
				end
				P_RadiusAttack(player.mo, player.mo, 512*FRACUNIT)
			end
		end
        player.mo.spritexscale = 3*FRACUNIT/2
        player.mo.spriteyscale = 2*FRACUNIT/3
        
        if not P_IsObjectOnGround(player.mo) then
            if (player.mo.momz <= 0 and not (player.mo.eflags & MFE_VERTICALFLIP))
            or (player.mo.momz >= 0 and player.mo.eflags & MFE_VERTICALFLIP) then
                P_SetObjectMomZ(player.mo, -FRACUNIT, true)
            end
        end
        
        if not (player.playerstate == PST_DEAD) then
            if player.mo.eflags & MFE_JUSTHITFLOOR then
                S_StartSound(player.mo, sfx_s3k5d)
                local fatdust
                for i = 0,7 do
                    fatdust = P_SpawnMobjFromMobj(player.mo, 0, 0, 0, MT_DUST)
                    fatdust.scale = 3*player.mo.scale/2
                    P_InstaThrust(fatdust, player.mo.angle + ANGLE_45*i, 10*FRACUNIT)
                end
            end
            if P_IsObjectOnGround(player.mo) and (gamemap != 355) then
                if player.mo.floorrover then
                    --fucking fatass
                    EV_CrumbleChain(player.mo.floorrover)
					P_SetObjectMomZ(player.mo, -50*FRACUNIT, false)
                end
            end
        end
        
    end
end)