states[S_KINGPIGCROWN1].sprite = SPR_KPCW
states[S_KINGPIGCROWN1].tics = -1
states[S_KINGPIGCROWN1].frame = A
states[S_KINGPIGCROWN2].sprite = SPR_KPCW
states[S_KINGPIGCROWN2].frame = B
states[S_KINGPIGCROWN2].tics = -1

//cosmetics shindig
if Cosmetics
Cosmetics.SkinOffsets["blues"] = -2
Cosmetics.SkinOffsets["chuck"] = 6
Cosmetics.SkinOffsets["redbird"] = 2
Cosmetics.SkinOffsets["hal"] = 5
Cosmetics.SkinOffsets["bombbird"] = 15
Cosmetics.SkinOffsets["matilda"] = 7
Cosmetics.AddHat("King Pig's Crown (Classic)", "Robofox", "KPCWA0", S_KINGPIGCROWN1, false, nil)
Cosmetics.AddHat("King Pig's Crown (Toons)", "Robofox", "KPCWB0", S_KINGPIGCROWN2, false, nil)
end

if not(kirbyabilitytable) //kirby abilitys
	rawset(_G, "kirbyabilitytable", {})
end
kirbyabilitytable["redbird"] = 7 //tornado, cuz mighty feathers lets red "fly"
kirbyabilitytable["chuck"] = 8 //wheel, fast like chuck
kirbyabilitytable["blues"] = 2 // ice, cuz they can break ice/glass, i don't have many choices otherwise
kirbyabilitytable["hal"] = 10 //sword, i dunno
kirbyabilitytable["bombbird"] = 4 //bomb, it's pretty easy to tell why
kirbyabilitytable["matilda"] = 4 //bomb, haha egg bombs

//colors!

//classic/chrome matilda
skincolors[SKINCOLOR_VANILLATAN] = {
	name = "VanillaTan",
	ramp = {80,81,82,0,1,2,2,2,4,7,8,9,10,11,12,13},
	invcolor = SKINCOLOR_WHITE,
    invshade = 13,
    chatcolor = V_WHITEMAP,
    accessible = true
}
// female white bird/toons matilda
skincolors[SKINCOLOR_MAKEUPWHITE] = {
	name = "MakeupWhite",
	ramp = {208,200,209,0,1,2,2,2,4,7,8,9,10,11,12,13},
	invcolor = SKINCOLOR_WHITE,
    invshade = 13,
    chatcolor = V_WHITEMAP,
    accessible = true
}

//tony (ab seasons: on finn ice)
skincolors[SKINCOLOR_FINNISHCOUSIN] = {
	name = "FinnishCousin",
	ramp = {0,1,3,120,120,140,140,140,140,140,170,171,172,173,137,143},
	invcolor = SKINCOLOR_BLUE,
    invshade = 9,
    chatcolor = V_BLUEMAP,
    accessible = true
}

//bomb's supercolor: super silver isn't gonna cut it.
skincolors[SKINCOLOR_SUPERCARBON] = {
	name = "Super_Carbon",
	ramp = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
	invcolor = SKINCOLOR_WHITE,
    invshade = 14,
    chatcolor = V_GRAYMAP,
    accessible = false
}

skincolors[SKINCOLOR_SUPERCARBON1] = {
	name = "Super_Carbon 1",
	ramp = {0,0,1,1,1,1,7,8,16,16,16,17,17,18,18,18},
	invcolor = SKINCOLOR_WHITE,
    invshade = 14,
    chatcolor = V_GRAYMAP,
    accessible = false
}

skincolors[SKINCOLOR_SUPERCARBON2] = {
	name = "Super_Carbon 2",
	ramp = {0,1,3,7,16,16,18,18,18,20,20,22,22,26,26,28},
	invcolor = SKINCOLOR_WHITE,
    invshade = 14,
    chatcolor = V_GRAYMAP,
    accessible = false
}

skincolors[SKINCOLOR_SUPERCARBON3] = {
	name = "Super_Carbon 3",
	ramp = {7,16,16,18,18,18,20,20,22,22,22,25,25,27,27,28},
	invcolor = SKINCOLOR_WHITE,
    invshade = 14,
    chatcolor = V_GRAYMAP,
    accessible = false
}

skincolors[SKINCOLOR_SUPERCARBON4] = {
	name = "Super_Carbon 4",
	ramp = {18,18,20,20,22,22,22,25,25,25,26,26,28,28,28,29},
	invcolor = SKINCOLOR_WHITE,
    invshade = 14,
    chatcolor = V_GRAYMAP,
    accessible = false
}

skincolors[SKINCOLOR_SUPERCARBON5] = {
	name = "Super_Carbon 5",
	ramp = {7,16,16,18,18,18,20,20,22,22,22,25,25,27,27,28},
	invcolor = SKINCOLOR_WHITE,
    invshade = 14,
    chatcolor = V_GRAYMAP,
    accessible = false
}

skincolors[SKINCOLOR_SUPERCARBON6] = {
	name = "Super_Carbon 6",
	ramp = {0,1,3,7,16,16,18,18,18,20,20,22,22,26,26,28},
	invcolor = SKINCOLOR_WHITE,
    invshade = 14,
    chatcolor = V_GRAYMAP,
    accessible = false
}

//https://mb.srb2.org/addons/how-to-make-supercolors-into-animated-colors.2826/
//thanks for the code!
addHook("ThinkFrame", do
    skincolors[SKINCOLOR_SUPERCARBON].ramp = skincolors[SKINCOLOR_SUPERCARBON1 + abs( ( (leveltime >> 2) % 9) - 4)].ramp
end)

assert(hudobjs != nil, "Where's the object table?")

local function checkformap(gamemap, name, act, rain, sky, bonus, rings)//it is what it is
if mapheaderinfo[gamemap].lvlttl == name
and mapheaderinfo[gamemap].actnum == act
and mapheaderinfo[gamemap].weather == rain
and mapheaderinfo[gamemap].skynum == sky
and mapheaderinfo[gamemap].bonustype == bonus
and mapheaderinfo[gamemap].startrings == rings
return true //that's the map
else
return false// NO
end
end

//joseph helped rewrite this lol
local drawlist = {
	birds = {
		angle = 8,
		spritestring = "STND",
		patches = {"redbird","blues","chuck","bombbird","matilda", "hal"}
		}
}
local function SpawnTitleShots(v,drawlisttype)// the importent part
	local _momx = v.RandomRange(4,12)
	local _momy = v.RandomRange(2,12)
	local randomtype = v.RandomRange(1,table.maxn(drawlist[drawlisttype].patches)) 
	local _y = 192 - v.RandomRange(0,128)// weirdness
	table.insert(hudobjs, {
		drawtype = "sprite2",
		angle = drawlist[drawlisttype].angle,
		align = "fixed",
		string = drawlist[drawlisttype].spritestring,
		accely = FRACUNIT/10,
		fuse = 120,
		flags = V_SNAPTOBOTTOM|V_SNAPTOLEFT,
		x = -10*FU,
		y = FRACUNIT * _y,
		momy = (-FRACUNIT/2) * _momy,
		momx = (FRACUNIT/2) * _momx,
		scale = FRACUNIT/3,
		func = function(v, obj)
			if obj.drawtype == "sprite" //objects spin
				obj.rollangle = $+FixedAngle(6*FU)
			end
			if obj.drawtype == "sprite2" and obj.fuse == 119
				obj.skin = drawlist[drawlisttype].patches[randomtype]
				obj.color = skins[drawlist[drawlisttype].patches[randomtype]].prefcolor
				end
		end
	})
end

local function spawnReward(v, frame)
	local _momx = v.RandomRange(4,12)
	local _momy = v.RandomRange(2,12)
	local _y = 192 - v.RandomRange(0,128)
	table.insert(hudobjs, {
		drawtype = "sprite",
		string = "ABCR",
		frame = frame,
		flags = V_SNAPTOBOTTOM|V_SNAPTOLEFT,
		accely = FRACUNIT/10,
		fuse = 120,
		flags = V_SNAPTOBOTTOM|V_SNAPTOLEFT,
		x = 0,
		y = FRACUNIT * _y,
		momy = (-FRACUNIT/2) * _momy,
		momx = (FRACUNIT/2) * _momx,
		scale = FRACUNIT/3,
		func = function(v, obj)
			obj.rollangle = $+FixedAngle(6*FU)
		end
	})
end

table.insert(hudobjs, {
	flags = V_SNAPTOTOP|V_SNAPTORIGHT,
	align = "right",
	x = 320,
	func = function(v, obj)
		if (v.RandomRange(0,35)) < 2
			SpawnTitleShots(v, "birds")
		elseif (v.RandomRange(0,100)) < 2 and gamecomplete
		if checkformap(27, "Black Core", 3, PRECIP_NONE, 22, 1, 10)//SRB2
		spawnReward(v, 0)
		elseif checkformap(16, "RUN", 0, PRECIP_NONE, 136, 0, 0)//SolSest1
		spawnReward(v, 1)
		end
		end
	end,
})
// end of joseph's rewrite, thanks man
