freeslot(
"S_STTAURA",
"MT_STTVOLT", 
"MT_STTVOLTAURA", --Full Power Aura
"MT_STTAUTOVOLT", --Automatic frame advancing item
"MT_STTTRAIL", --Damaging Trail
"MT_STTRINGRANGE", --Ring attract
"MT_SPARKEFF",
"MT_SPARKHURT") --For Kirby
mobjinfo[MT_STTRINGRANGE] = {
	spawnstate = S_INVISIBLE,
	radius = 256*FRACUNIT,
	height = 320*FRACUNIT,
	flags = MF_NOGRAVITY|MF_NOCLIPHEIGHT
}
--LMAO, SUS. >:D
freeslot("sfx_susfx1", "sfx_susfx2", "sfx_susfx3", "sfx_susfx4", "sfx_susfx5", "sfx_susfx6", "sfx_susfx7", "sfx_susfx8", "sfx_susfx9", "sfx_susfxa", "sfx_susfxb", "sfx_susfxc", "sfx_susfxd", "sfx_susfxe") 
sfxinfo[sfx_susfx1].caption = "Electricity"
sfxinfo[sfx_susfx2].caption = "Crackling electricity"
sfxinfo[sfx_susfx3].caption = "Blast of electricity"
sfxinfo[sfx_susfx4].caption = "Static electricity"
sfxinfo[sfx_susfx5].caption = "Voltage electricity"
sfxinfo[sfx_susfx6].caption = "Surging electricity"
sfxinfo[sfx_susfx7].caption = "Powered electricity"
sfxinfo[sfx_susfx8].caption = "Thundrous electricity"
sfxinfo[sfx_susfx9].caption = "Inazuma is jealous"
sfxinfo[sfx_susfxa].caption = "Amped up electricity"
sfxinfo[sfx_susfxb].caption = "Charged electricity"
sfxinfo[sfx_susfxc].caption = "Zapping electricity"
sfxinfo[sfx_susfxd].caption = "Discharging electricity"
sfxinfo[sfx_susfxe].caption = "Super electricity"
sfxinfo[sfx_susfx3] = {flags = SF_X2AWAYSOUND,}
sfxinfo[sfx_susfxe] = {flags = SF_X4AWAYSOUND,}
sfxinfo[sfx_susfx2] = {flags = SF_NOMULTIPLESOUND,}
sfxinfo[sfx_susfxd] = {flags = SF_NOMULTIPLESOUND,}

--Lightdasher's custom colors merged into LUA_FUNCTIONS
freeslot("SKINCOLOR_SUPER_SURGE_1",
"SKINCOLOR_SUPER_SURGE_2",
"SKINCOLOR_SUPER_SURGE_3",
"SKINCOLOR_SUPER_SURGE_4",
"SKINCOLOR_SUPER_SURGE_5"
)
skincolors[SKINCOLOR_SUPER_SURGE_1] = {
    name = "Super SURGE 1",
    ramp = {2,2,4,5,10,11,12,13,13,14,15,17,17,18,18,18},
    accessible = false
}

skincolors[SKINCOLOR_SUPER_SURGE_2] = {
    name = "Super SURGE 2",
    ramp = {11,11,12,13,17,18,19,20,22,24,25,25,27,28,28,28},
    accessible = false
}

skincolors[SKINCOLOR_SUPER_SURGE_3] = {
    name = "Super SURGE 3",
    ramp = {20,20,20,21,22,23,24,25,26,26,27,27,28,28,28,28},
    accessible = false
}

skincolors[SKINCOLOR_SUPER_SURGE_4] = {
    name = "Super SURGE 4",
    ramp = {23,23,23,24,25,26,27,28,29,29,30,30,31,31,31,31},
    accessible = false
}

skincolors[SKINCOLOR_SUPER_SURGE_5] = {
    name = "Super SURGE 5",
    ramp = {24,24,24,25,26,27,28,29,30,30,31,31,31,31,31,31},
    accessible = false
}

rawset(_G, "SurgeQuake", function(p, intensity, tics)
	if p and not p.stt.noquakes
		if p == displayplayer
		P_StartQuake(intensity, tics)
		end
	end
end)

rawset(_G, "SurgeWaterProofing", function(p)
	local pshield = (p.powers[pw_shield] & SH_NOSTACK)
	return pshield == SH_BUBBLEWRAP or pshield == SH_ELEMENTAL
end)

--Barely used function, but useful.
rawset(_G, "SurgeMaxAura", function(p, s, yu)
	if yu.fullcharge
	or ((s.eflags & MFE_UNDERWATER) and not SurgeWaterProofing(p))
	or (p.cmd.buttons & BT_CUSTOM1)
		if yu.eleccharging > 104
		yu.eleccharging = 51
		end
		return false
	else
		yu.supercharge = 0
		yu.fullcharge = true
		S_StartSound(s, sfx_cdfm55)
		p.pflags = $ & ~PF_THOKKED
		return true
	end
end)

--Seperate functions for laziness purposes.

rawset(_G, "SurgeVoltSpawn", function(p, s, yu, startframe, endframe, color, trail)
if yu.nohb
return
end
	local ghs
	for d = -1,1,2
		if P_IsObjectOnGround(s) and s.standingslope
			ghs = P_SpawnMobj(s.x+FixedMul((P_RandomRange(9, 35)*s.scale*d), cos(s.angle+ANGLE_90)), s.y+FixedMul((P_RandomRange(9, 35)*s.scale*d), sin(s.angle+ANGLE_90)), s.z+8*s.scale, MT_STTVOLT)
		else
			ghs = P_SpawnMobj(s.x+(s.momx/2)+FixedMul((P_RandomRange(9, 35)*s.scale*d), cos(s.angle+ANGLE_90)), s.y+(s.momy/2)+FixedMul((P_RandomRange(9, 35)*s.scale*d), sin(s.angle+ANGLE_90)), s.z+s.momz+8*s.scale, MT_STTVOLT)
		end
			ghs.scale = s.scale
			ghs.eflags = s.eflags
			ghs.angle = R_PointToAngle2(s.x, s.y, (s.x+s.momx), (s.y+s.momy))-((ANG2*3)*d)
			ghs.momx = s.momx/4 ghs.momy = s.momy/4 ghs.momz = s.momz-(s.momz/2)
			ghs.blendmode = AST_ADD
			
			if yu.trailframe > endframe
			yu.trailframe = startframe
			end
			
			if d == 1
			ghs.frame = yu.trailframe|FF_FULLBRIGHT|FF_HORIZONTALFLIP|FF_PAPERSPRITE
			else
			ghs.frame = yu.trailframe|FF_FULLBRIGHT|FF_PAPERSPRITE
			end
			
			if ((s.momz*P_MobjFlip(s)) < -4*s.scale)
				P_Thrust(ghs, s.angle+ANGLE_90, 1*s.scale*d)
			else
				P_Thrust(ghs, s.angle+ANGLE_90, 3*s.scale*d)
			end
			if s.eflags & MFE_VERTICALFLIP
			ghs.spriteyoffset = -46*FRACUNIT
			end
			
			if color --Though Surge only ever uses blue electricity.
			ghs.colorized = true
			ghs.color = color
			end
			if p.ctfteam and p.ctfteam == 1 and G_GametypeHasTeams() --Nvm.
			ghs.color = SKINCOLOR_RED
			ghs.colorized = true
			end				

				local ghs2 = P_SpawnGhostMobj(ghs)
				ghs2.frame = ghs.frame
				ghs2.fuse = 12
				ghs2.tics = 30
				ghs2.colorized = true
				ghs2.color = ghs.color
				S_StartSound(s, sfx_susfxd)
			
			if d == 1 and trail and (p.speed > 28*s.scale)
				if ((p.pflags & PF_JUMPED) or (p.pflags & PF_SPINNING) or (p.panim == PA_RUN))
				SurgeTrail(ghs, p, s, yu) --Spawn damaging trails on top of this.
				S_StartSound(s, sfx_susfxd)
				end
			end
	 end
end)

rawset(_G, "SurgeTrail", function(s, p, t, yu)
if not (t and t.valid)
or yu.nohb
return
end
	local ghs = P_SpawnMobjFromMobj(t, 0, 0, 6*FRACUNIT, MT_STTTRAIL)
	if yu.voltdash --Bigger for voltdash
		ghs.scalespeed = $/2
	else
		ghs.scalespeed = $/4
	end
	ghs.fuse = 60
	ghs.scale = t.scale/2
	ghs.tics = 61		
	ghs.destscale = $*99
	ghs.target = t
	ghs.tracer = t
	ghs.frame = P_RandomRange(L, O)|TR_TRANS40|FF_FULLBRIGHT
	ghs.blendmode = AST_ADD
	if p.ctfteam and p.ctfteam == 1 and G_GametypeHasTeams()
	ghs.color = SKINCOLOR_RED
	ghs.colorized = true
	end
end)

rawset(_G, "SurgeAuraSpawn", function(p, s, yu, startframe, endframe, color)
		S_StartSound(s, sfx_susfx2) --The flags allow us to keep spamming this without stacking it
		local ghs = P_SpawnMobj(s.x, s.y, s.z, MT_STTVOLTAURA)
			ghs.scale = s.scale
			ghs.eflags = s.eflags
			ghs.dispoffset = 1
			ghs.momx = s.momx ghs.momy = s.momy ghs.momz = s.momz
			if yu.voltframe > endframe
			yu.voltframe = startframe
			end
			ghs.frame = yu.voltframe|FF_FULLBRIGHT		
			ghs.flags = $|MF_SCENERY
			
			if s.eflags & MFE_VERTICALFLIP
			ghs.spriteyoffset = -46*FRACUNIT
			end
			ghs.blendmode = AST_ADD
			if color
			ghs.colorized = true
			ghs.color = color
			end
			if p.ctfteam and p.ctfteam == 1 and G_GametypeHasTeams()
			ghs.color = SKINCOLOR_RED
			ghs.colorized = true
			end			
end)
