//Make sure Chuck D. Head gets his correct signpost visuals with his follower

//Keep the old signpost action in reserves
local ChuckOldSignAction = states[S_KART_SIGN].action or A_PlaySeeSound

//Make the signpost show base Sonic or Hyper Sonic where appropriate
function A_ChuckSignpost(mobj, var1, var2)
	ChuckOldSignAction(mobj, var1, var2) //Perform the old signpost action
	
	//Get the sign itself, don't advance unless this is the final one!
	local sign = mobj.target
	if not sign.valid or sign.movecount != 2 then return end
	
	//We need to be Chuck D. Head!
	if mobj.skin != "chuckdhead" then return end
	
	//Get the player we're going to be dealing with
	local mo = sign.target
	local player = mo and mo.valid and mo.player
	local follower = player and not player.bot and player.follower
	
	//Need to have the Head follower and be Chuck!
	if not (follower and follower.valid
	and mo.skin == "chuckdhead" and follower.sprite == SPR_HEAD) then return end
	mobj.state = S_KART_SIGL
	
	local part = mobj
	local nextpart = mobj.hnext
	while nextpart and nextpart.valid
		part = nextpart
		nextpart = part.hnext
	end
	nextpart = P_SpawnMobjFromMobj(part, 0,0,0, MT_SIGN_PIECE)
	
	part.hnext = nextpart
	nextpart.target = part
	
	nextpart.state = S_SIGN_ERROR
	nextpart.sprite = SPR_HEAD
	nextpart.frame = ($ &~ FF_FRAMEMASK) | D
	nextpart.color = player.followercolor
	
	nextpart.extravalue1 = mobj.extravalue1
	nextpart.extravalue2 = mobj.extravalue2
end

//Assign our new action to the signpost state
states[S_KART_SIGN].action = A_ChuckSignpost
