// this is NOT the reusable part, do not take this unless you ask permission from Trystan.
freeslot("SKINCOLOR_SUPER_BLAK_1","SKINCOLOR_SUPER_BLAK_2","SKINCOLOR_SUPER_BLAK_3","SKINCOLOR_SUPER_BLAK_4","SKINCOLOR_SUPER_BLAK_5")

 skincolors[SKINCOLOR_SUPER_BLAK_1] = {
     name = "Super BLAK 1",
     ramp = {0,3,7,10,14,18,22,26,29,31,31,31,31,31,31,31},
     accessible = false
 }
 skincolors[SKINCOLOR_SUPER_BLAK_2] = {
     name = "Super BLAK 2",
     ramp = {0,4,8,12,16,20,25,29,31,31,31,31,31,31,31,31},
     accessible = false
 }
 skincolors[SKINCOLOR_SUPER_BLAK_3] = {
     name = "Super BLAK 3",
     ramp = {0,5,10,15,20,25,31,31,31,31,31,31,31,31,31,31},
     accessible = false
 }
 skincolors[SKINCOLOR_SUPER_BLAK_4] = {
     name = "Super BLAK 4",
     ramp = {0,5,11,18,24,30,31,31,31,31,31,31,31,31,31,31},
     accessible = false
 }
 skincolors[SKINCOLOR_SUPER_BLAK_5] = {
     name = "Super BLAK 5",
     ramp = {0,7,15,24,31,31,31,31,31,31,31,31,31,31,31,31},
     accessible = false
 }
 
freeslot("SKINCOLOR_SHART")
skincolors[SKINCOLOR_SHART] = {
    name = "Shart",
    ramp = {0,4,7,241,243,230,70,63,45,71,46,47,47,30,30,31},
    invcolor = SKINCOLOR_AZURE,
    invshade = 9,
    chatcolor = V_BLUEMAP,
    accessible = true
}

freeslot("SKINCOLOR_SAPPHBALT")
skincolors[SKINCOLOR_SAPPHBALT] = {
    name = "Sapphbalt",
    ramp = {0,144,146,147,149,150,150,154,154,155,156,157,159,253,254,31

},
    invcolor = SKINCOLOR_APRICOT,
    invshade = 9,
    chatcolor = V_BLUEMAP,
    accessible = true
}

freeslot("S_PLAY_FLOU")
freeslot("SPR2_FLOU")
states[S_PLAY_FLOU] = {SPR_PLAY, SPR2_FLOU, 3, nil, 0, 0, S_PLAY_FLOU}
/*gtfo of the files unless you know what to do with lua. Yeah this meme is dead :/
*/
/*addHook("PlayerThink", do
	for player in players.iterate
		if player.mo.skin == "sonc"
		and (player.cmd.buttons & BT_CUSTOM3) //set the button
			and (player.speed == 0) // must not be moving
			and not P_PlayerInPain(player)
			and P_IsObjectOnGround(player.mo)
			player.mo.state = S_PLAY_GLIDE_LANDING //use this for whatever, if you make it S_PLAY_FALL, they will fall!
			S_ChangeMusic("_DRIPP", true, player)
			player.pflags = $1|PF_FULLSTASIS
			elseif not (player.cmd.buttons & BT_CUSTOM3)
			and player.mo.skin == "sonc"
			P_RestoreMusic(player)
		end
	end
end)

/*hot pizza rolls
hey you, yeah, you. I see you inside this lua. 
Take it as your own and ill steal you and send you to a military complex 
with no way of being able to escape. You are able to use the lua, 
but I expect credit needed.*/

//This code was made like 2 years ago its old as hell (all the jokes are weird I swear I don't act like this!) (2023)

addHook("ThinkFrame", function(player)
	for player in players.iterate
		if player.mo.wallcamflipp == nil
			player.mo.wallcamflipp = 0
		end
	end
end)
addHook("ThinkFrame", function(player)
	for player in players.iterate
		if player.mo.wallcamflipp == nil
			player.mo.wallcamflipp = 0
		end
	end
end)
//wall detection
addHook("ThinkFrame", function(player)
	for player in players.iterate
		if player.atwall == nil
			player.atwall = 0
		end
        if not (player.cling)
            player.cling = false
		end
		if not (player.clingprev)
            player.clingprev = false
        end
        if player.playerstate == PST_DEAD return end
        if (player.mo)  
			local wall = R_PointInSubsector(player.mo.x+FixedMul(48*FRACUNIT, cos(player.mo.angle)), player.mo.y+FixedMul(48*FRACUNIT, sin(player.mo.angle))).sector
			local fheight = wall.floorheight
			local cheight = wall.ceilingheight
			if wall.f_slope then
				fheight = P_GetZAt(wall.f_slope, player.mo.x + player.mo.momx, player.mo.y + player.mo.momy)
			end
			if wall.c_slope then
				cheight = P_GetZAt(wall.c_slope, player.mo.x + player.mo.momx, player.mo.y + player.mo.momy)
			end            
			if (fheight > player.mo.z) or ((cheight <= player.mo.height+player.mo.z) and not (fheight == cheight)/* and (wall.ceilingpic == "F_SKY1")*/) //This last bit seems to be broken...
				player.atwall = 1
			else
				player.atwall = 0
			end
		end
	end
end)

addHook("ThinkFrame", function(player)
	for player in players.iterate
		local trueangle = player.cmd.angleturn<<16 + R_PointToAngle2(0, 0, player.cmd.forwardmove*FRACUNIT, -player.cmd.sidemove*FRACUNIT)
		if player.mo.fuckyou == nil
			player.mo.fuckyou = 0
		end
		if player.mo.mommysonc == nil
			player.mo.mommysonc = 0
		end
		if player.mo.mommysonc == 1
		and player.mo.momz > 0
			local a = P_SpawnGhostMobj(player.mo)
			a.fuse = 7
		end
		if player.mo.momz < 0
			player.mo.mommysonc = 0
		end
		//for wallcamflip
		if player.mo.skin == "sonc"
		and player.mo.wallcamflipp
		and (player.cmd.buttons & BT_SPIN)
		and not P_IsObjectOnGround(player.mo)
		and not (player.cmd.buttons & BT_JUMP)
		and player.atwall == 1
			P_SetObjectMomZ(player.mo, 15*FRACUNIT)// set this to a negative number and death will happen :smug:
			P_Thrust(player.mo, trueangle, -19*FRACUNIT) //put this to a positive number and death will occur
			player.mo.angle = R_PointToAngle2(0, 0, player.mo.momx, player.mo.momy) -- the optional shit
			player.mo.mommysonc = 1//lol you dont actually die shut up. --Trystan //you will --Trevor
			player.mo.state = S_PLAY_ROLL --:sob:
			S_StartSound(player.mo, sfx_jump)
			player.drawangle = trueangle
		end
		//not for wallcamflip
		if player.mo.skin == "sonc"
		and (player.cmd.buttons & BT_SPIN)
		and not P_IsObjectOnGround(player.mo)		
		and player.atwall == 1
		and not (player.cmd.buttons & BT_JUMP)
			P_SetObjectMomZ(player.mo, 15*FRACUNIT)// set this to a negative number and death will happen :smug:
			P_Thrust(player.mo, trueangle, -19*FRACUNIT) //put this to a positive number and death will occur
			player.mo.mommysonc = 1
			player.mo.state = S_PLAY_ROLL --:sob:
			S_StartSound(player.mo, sfx_jump)
			player.drawangle = trueangle
		end
		if player.mo.skin == "sonc"
		and not (player.cmd.buttons & BT_SPIN)
		and not P_IsObjectOnGround(player.mo)
		and player.atwall == 1
		and not (player.mo.state == S_PLAY_FLOU)
			player.mo.fuckyou = 1
			P_SlideMove(player.mo)
			P_SpawnSkidDust(player, 20*FRACUNIT)
			player.mo.state = S_PLAY_WALK
			player.mo.frame = 3
		end
		if not S_SoundPlaying(player.mo, sfx_s3k7e)
		and player.mo.fuckyou == 1
		and player.mo.state == S_PLAY_WALK
		and player.atwall == 1
		and not P_IsObjectOnGround(player.mo)
		and player.mo.skin == "sonc"
			S_StartSound(player.mo, sfx_s3k7e)
		end
		if P_IsObjectOnGround(player.mo)
			player.mo.fuckyou = 0
		end
		if player.atwall == 1
		and player.mo.skin == "sonc"
			player.charability = 0
			player.powers[pw_tailsfly] = 0
		end
		if player.notagain == nil
			player.notagain = false
		end
	end
end)

//Command/I/O stuff (stolen with credit and permission lol)
local function writeCvar(file, soncdata)
    if player == consoleplayer then
        local file = io.openlocal("client/soncdata.dat")
        io.openlocal("client/soncdata.dat", "r")
        file:close()
    end
end

local function readCvar(file, soncdata)
    local value = file:read("*l")
    if file then
        COM_BufInsertText(consoleplayer, soncdata .. ' "' .. value .. '"')
    else
        print(soncdata.." not found.")
    end
end

local function saveConfig(soncdata)
    -- Open the file ("w" means we will write data to it)
    local file = io.openlocal(soncdata, "soncdata")

    writeCvar(file, "soncdata")
        
    file:close() -- We're done, close the file now
end

COM_AddCommand("wallcamflip", function(player, arg1)
  local file = io.openlocal("client/soncdata.dat", "w")
    if arg1 == "1" or arg1 == "on" or arg1 == "yes"
        if not player.mo then return end
        player.mo.wallcamflipp = 1
    file:write("wallcamflip 1")
    elseif arg1 == "0" or arg1 == "off" or arg1 == "no"
        player.mo.wallcamflipp = 0
    file:write("wallcamflip 0")
    /*elseif not arg1 == "1" or arg1 == "on" or arg1 == "yes"
    /and not arg1 == "0" or arg1 == "off" or arg1 == "no"
        P_KillMobj(player.mo)
        file:write("2")(Trevor)
        print("You didnt state a reason... death.")*/
    file:close()
    end
end)

addHook("PlayerSpawn", function(player)
    if (player.mo and player.mo.valid and player.mo.skin == "sonc")
        local file = io.openlocal("client/soncdata.dat", "r")
		COM_BufInsertText(player, file:read("*l"))
		file:close()
    end
end)

addHook("PlayerCanDamage", function(player)
	if player.mo.skin == "sonc"
	and player.mo.state == S_PLAY_RIDE
	and player.ilikegusher == 1
		return true
	end
end)

addHook("AbilitySpecial", function(player)
    if player.mo.skin ~= "sonc" -- Skin check.
    and not player.pflags & PF_THOKKED then -- Do not Flounce if you already did Flounce!
        return
    end
    player.flounce = true -- Flounce!
    return true -- Override the normal jump ability.
end)

addHook("SpinSpecial", function(player)
    if player.flounce
	and not (player.notagain) then
        player.whirr = true
        return true
    end
    if player.whirr then
        return true
    end
end)

addHook("PlayerThink", function(player)
    if player.flounce then
        if not player.prevflounce then
            P_ResetPlayer(player)
            player.rotangle = player.drawangle
            player.prevflounce = true
            player.acceleration = FixedMul(player.mo.scale, skins[player.mo.skin].acceleration/2)
            player.whirr = false
        end
		if player.std == nil
			player.std = false //what the fuck are you thinking i meant sonc trigger dash you dirty mind
		end
		if player.stdtime == nil
			player.stdtime = 19*TICRATE//dont you dare
		end
		if player.std == true //heck nah you are big bad mind
			player.stdtime = $1 - 1*TICRATE
		end
        if not player.whirr then
            player.rotangle = $ + ANG15
            player.mo.momz = $ + gravity/2
            if P_IsObjectOnGround(player.mo) then
                player.mo.momz = -player.prevmomz
            else
                player.prevmomz = player.mo.momz
            end
		//if your fast
        elseif player.whirr 
		and player.speed > player.runspeed/8
		and player.stdtime > 0 
		and player.speed > 30*FRACUNIT
            P_SetObjectMomZ(player.mo, 3*FRACUNIT/2, true)
			player.std = true
            player.rotangle = $ + ANG30
            player.drawangle = player.rotangle
        else
            player.whirr = false
            player.flounce = false
        end
		//if your slow
		if player.whirr 
		and player.speed > player.runspeed/8
		and player.stdtime > 0 
		and player.speed < 30*FRACUNIT
			P_InstaThrust(player.mo, player.mo.angle, 30*FRACUNIT)
			P_SetObjectMomZ(player.mo, 3*FRACUNIT/2, true)
			player.std = true
            player.rotangle = $ + ANG30
            player.drawangle = player.rotangle
		end
		if player.stdtime == 0*TICRATE
			player.std = false
			player.stdtime = 19*TICRATE//dont you dare
			player.notagain = true
		end
        P_SpawnMobjFromMobj(player.mo, FixedMul(cos(player.rotangle+ANGLE_90), player.mo.radius*2), FixedMul(sin(player.rotangle+ANGLE_90), player.mo.radius*2), 0, MT_SPARK)
        P_SpawnMobjFromMobj(player.mo, FixedMul(cos(player.rotangle-ANGLE_90), player.mo.radius*2), FixedMul(sin(player.rotangle-ANGLE_90), player.mo.radius*2), 0, MT_SPARK)
    end
    if not (player.cmd.buttons & BT_JUMP) and not player.whirr and player.flounce then
		player.pflags = $|PF_THOKKED
        player.flounce = false
    end
	if P_IsObjectOnGround(player.mo)
	and not (player.mo.eflags & MFE_JUSTHITFLOOR)
		player.notagain = false
	end
    if not player.flounce and player.prevflounce then
        P_ResetPlayer(player)
		player.pflags = $|PF_THOKKED
        player.prevflounce = false
    else
        player.acceleration = FixedMul(player.mo.scale, skins[player.mo.skin].acceleration)
	end
	if not S_SoundPlaying(player.mo, sfx_s3kba)
	and player.flounce
	and player.mo.state == S_PLAY_FLOU
	and not P_IsObjectOnGround(player.mo)
	and player.mo.skin == "sonc"
		S_StartSound(player.mo, sfx_s3kba)
	end
end)

addHook("PlayerCanDamage", function(player, mo)
    if player.flounce or player.whirr then
        return true
    end
end)

addHook("ThinkFrame", function(player)
    for player in players.iterate do
        if player.flounce 
		and not (player.pflags & PF_THOKKED) then
            player.drawangle = player.rotangle
            if not player.whirr then
                if P_IsObjectOnGround(player.mo) then
                    player.mo.momz = -player.prevmomz
                else
                    player.prevmomz = player.mo.momz
                end
                player.mo.state = S_PLAY_FLOU
            else
                player.mo.state = S_PLAY_PAIN
            end
        end
    end
end)

addHook("MobjMoveBlocked", function(mobj)
    if not (mobj.player and mobj.skin == "sonc") return end
    mobj.player.lastlinehit = -1
    mobj.player.lastsidehit = -1
    P_SlideMove(mobj)
    mobj.player.powers[pw_pushing] = 3
    local p = mobj.player
    local line = lines[mobj.player.lastlinehit]
    if line and line.valid
        if (line.frontsector)
            if (line.frontsector.ceilingheight == line.frontsector.floorheight) and (mobj.z > line.frontsector.ceilingheight)
                return
            end
			if mobj.player.flounce then
				S_StartSound(mobj, sfx_s3k9e)
				P_Thrust(mobj, (R_PointToAngle2(mobj.x,mobj.y,P_ClosestPointOnLine(mobj.x,mobj.y,line))+FixedAngle(180*FRACUNIT)), mobj.player.speed-mobj.player.speed/6) 
				S_StartSound(mobj, sfx_s3k9e)
			end
			if (mobj.player.pflags & PF_SPINNING)
			and mobj.skin == "sonc"
			and P_IsObjectOnGround(mobj)
				S_StartSound(mobj, sfx_s3k9e)
				P_Thrust(mobj, (R_PointToAngle2(mobj.x,mobj.y,P_ClosestPointOnLine(mobj.x,mobj.y,line))+FixedAngle(180*FRACUNIT)), mobj.player.speed-mobj.player.speed/6) 
				S_StartSound(mobj, sfx_s3k9e)
			end
		end
	end
end)

//kick my nuts into a bazillion pieces
// :fearful: what the fuck
addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo.skin == "sonc"
		and (player.speed < 4*FRACUNIT)
			player.charability2 = CA2_NONE
		end
		if player.mo.homhom == nil
			player.mo.homhom = 0
		end
		if (player.speed > 4*FRACUNIT)
		and (player.mo.skin == "sonc")
			player.charability2 = CA2_SPINDASH
		end
		if not (player.cmd.buttons & BT_USE)
			player.homhom = 0
		end
		if player.mo.skin == "sonc"
		and (player.pflags & PF_SPINNING)
			player.mo.homhom = 1
		end
		/*if (player.cmd.buttons & BT_USE)
		and player.mo.skin == "sonc"
		and (player.speed > 2)
		and (player.pflags & PF_SPINNING)
			player.pflags = $|PF_GODMODE
		elseif player.mo.skin == "sonc"
		and not (player.pflags & PF_SPINNING)
		and P_IsObjectOnGround(player.mo)
			player.pflags = $1 & ~PF_GODMODE
		end
		if not P_IsObjectOnGround(player.mo)
			player.pflags = $1 & ~PF_GODMODE
		end*/
		if player.mo.skin == "sonc"
		and (player.pflags & PF_STARTDASH)
			player.pflags = $1 & ~PF_STARTDASH
		end
	end
end)

/*addHook("MobjCollide", function(player, enemy)
	if player.homhom == 1
	and enemy
	and P_IsObjectOnGround(player)
	and P_IsObjectOnGround(enemy)
	and (player.player.pflags & PF_SPINNING)
		P_Thrust(player, R_PointToAngle2(enemy.x, enemy.y+FixedAngle(180*FRACUNIT)), player.player.speed-player.player.speed/6) 
	end
end)*/ //didnt work

addHook("PlayerCanDamage", function(player)
	if player.mo.skin == "sonc"
	and (player.pflags & PF_SPINNING)
		return false
	end
end)