local function P_RadiusExplode(position, wavespeed, args)

    local angleskip = (args and args.angleskip) or 20
    local mobjtype = (args and args.mobjtype or MT_SONIC3KBOSSEXPLODE)

    if type(position) == "userdata" and not (position and position.valid) then return end

    for angle=1, 360, angleskip do

        local explode = P_SpawnMobj(position.x, position.y, position.z, mobjtype)

        explode.scale = (args and args.scale) or FU

        if (args and args.fuse) then
            explode.fuse = args.fuse
        end

        if (args and args.callback) then
            do args.callback(explode, angle, angleskip) end
        end

        P_InstaThrust(explode, FixedAngle(angle*FU), wavespeed)
    end
end

addHook("PlayerThink", function(player)
	if player.mo and player.playerstate == PST_LIVE and player.mo.skin == "metalsonic" then
		
		if (player.custom2tic == 1) and player.control then
			
			if player.powers[pw_super] then
			P_Telekinesis(player, 100*FRACUNIT, 750*FRACUNIT)
			P_RadiusExplode(player.mo, 60*FRACUNIT)
			else
			P_Telekinesis(player, 50*FRACUNIT, 600*FRACUNIT)
			P_RadiusExplode(player.mo, 20*FRACUNIT)
			end
			player.mo.state = S_PLAY_SUPER_TRANS4
			
		end
		
	end
end)