local function BetterDeaths(target, inflictor, source, damagetype)
	local NOTME = {}
NOTME["adventuresonic"]=true
NOTME["xsonic"]=true
NOTME["xsonicserious"]=true
NOTME["xsonicc"]=true
NOTME["sms"]=true
target.player.death_reason = damagetype
if damagetype == 131 then
local player = target.player
player.mo.rollangle = $ + ANGLE_11hh
end
if damagetype == 3 then
S_StartSound(target, 25, target.player)
end
if inflictor.valid then
if inflictor.type == MT_LASER then
target.player.deathreason = 2
end
if source.type == MT_FBOMB then
target.player.deathreason = 2
end
if source.type == MT_METALSONIC_BATTLE then
target.player.deathreason = 3
end
if source.type == MT_FANG then
target.player.deathreason = 131
end
end
end

local function DeathAnimationContinue(player)
	local NOTME = {}
NOTME["adventuresonic"]=true
NOTME["xsonic"]=true
NOTME["xsonicserious"]=true
NOTME["xsonicc"]=true
if player.playerstate == PST_DEAD then
if not (NOTME[player.mo.skin] == true ) then
if player.death_reason == 131 then
player.mo.rollangle = $ - ANG2
end
if player.death_reason == 129 then
player.mo.rollangle = $ + ANG1
player.mo.momz = 0
end
if player.death_reason == 130 then
player.mo.rollangle = $ + ANG2
player.mo.momz = 0
end
if player.death_reason == 2 then
player.mo.rollangle = $ + ANGLE_11hh
player.mo.color = SKINCOLOR_BLACK
player.mo.colorized = true
P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z, MT_SMOKE)
end
if player.death_reason == 3 then
player.mo.rollangle = $ + ANGLE_11hh
player.mo.colortics = $ + 1
if player.mo.colortics == 1  then
player.mo.color = SKINCOLOR_WHITE
end
if player.mo.colortics == 2 then
player.mo.color = SKINCOLOR_YELLOW
end
if player.mo.colortics == 3 then
player.mo.colortics = 0
end
player.mo.colorized = true
end
end
end
end

local function ResetValues(player)
player.mo.rollangle = 0
player.mo.color = player.skincolor
player.mo.colorize = false
player.mo.colortics = 0
end
 
addHook("MobjDeath", BetterDeaths, MT_PLAYER)
addHook("PlayerThink", DeathAnimationContinue)
addHook("PlayerSpawn", ResetValues)