// Demo Yellow (Attraction) Shield Monitor - Ported by MIDIMan
// Use with LUA_DBOX

freeslot(
	"SPR_DBXY",
	"MT_DEMOBOX_YELLOW",
	"S_DEMOBOX_YELLOW_IDLE",
	"S_DEMOBOX_YELLOW_BREAK1",
	"S_DEMOBOX_YELLOW_BREAK2",
	"S_DEMOBOX_YELLOW_BREAK3",
	"S_DEMOBOX_YELLOW_BREAK4",
	"S_DEMOBOX_YELLOW_BREAK5",
	"S_DEMOBOX_YELLOW_BREAK6"
)

// Give the player the monitor's rings as soon as it breaks
addHook("MobjDeath", function(target, inflictor, source, damagetype)
	if not (target and target.valid) then return end
	
	if netgame or multiplayer then
		if source and source.valid and source.player then
			target.target = source
		elseif inflictor and inflictor.valid and inflictor.player then
			target.target = inflictor
		else
			return
		end
	
		A_GiveShield(target, SH_ATTRACT, var2)
	end
end, MT_DEMOBOX_YELLOW)

mobjinfo[MT_DEMOBOX_YELLOW] = {
	//$Name Demo Attraction Shield
	//$Sprite DBXYA0
	//$Category Monitors
	doomednum = 460,
	spawnstate = S_DEMOBOX_YELLOW_IDLE,
	spawnhealth = 1,
	seesound = sfx_shield,
	painstate = S_DEMOBOX_YELLOW_IDLE,
	deathstate = S_DEMOBOX_YELLOW_BREAK1,
	deathsound = sfx_pop,
	radius = 16*FRACUNIT,
	height = 32*FRACUNIT,
	flags = MF_SOLID|MF_SHOOTABLE|MF_MONITOR|MF_GRENADEBOUNCE
}

states[S_DEMOBOX_YELLOW_IDLE] =	{SPR_DBXY,	A,	2,	nil,	0,	0,	S_DEMOBOX_FLICKER}

states[S_DEMOBOX_YELLOW_BREAK1] =	{SPR_DBXY,	B,	2,	A_DemoFall,			0,			0,	S_DEMOBOX_YELLOW_BREAK2}
states[S_DEMOBOX_YELLOW_BREAK2] =	{SPR_DBXY,	C,	2,	A_Scream,			0,			0,	S_DEMOBOX_YELLOW_BREAK3}
states[S_DEMOBOX_YELLOW_BREAK3] =	{SPR_DBXY,	D,	2,	nil,				0,			0,	S_DEMOBOX_YELLOW_BREAK4}
states[S_DEMOBOX_YELLOW_BREAK4] =	{SPR_DBXY,	E,	2,	nil,				0,			0,	S_DEMOBOX_YELLOW_BREAK5}
states[S_DEMOBOX_YELLOW_BREAK5] =	{SPR_DBXY,	F,	16,	nil,				0,			0,	S_DEMOBOX_YELLOW_BREAK6}
states[S_DEMOBOX_YELLOW_BREAK6] =	{SPR_DBXY,	F,	48,	A_DemoGiveShield,	SH_ATTRACT,	0,	S_DEMOBOX_DEAD}
