//Diagonal Gas Jet by Endless
freeslot(
	"MT_DGAS",
	"S_DGAS",
	"S_DGAS2",
	"S_DGAS3",
	"S_DGAS4",
	"S_DGAS5",
	"S_DGAS6",
	"S_DGAS7",
	"S_DGAS8",
	"SPR_DGAS"
)

local RB_DGASFLAGS_NOSOUND = 8

addHook("MapThingSpawn", function(mo, mthing)
	if not (mo and mo.valid
	and mthing and mthing.valid)
		return
	end
	
	if (mthing.options & MTF_EXTRA)
		mo.scale = 2*FRACUNIT
	end 
end, MT_DGAS)

addHook("TouchSpecial", function(special,toucher)

	local player = toucher.player
	
	if not (special and special.valid and toucher and toucher.valid) then return end
	
	if player.gastouch == nil then
		player.gastouch = 0
	end
	
	if player and player.valid then
		player.gastouch = 1
	if toucher and toucher.valid then
		P_DoSpring(special,toucher)
	end
end
return true
end, MT_DGAS)

addHook("PlayerThink", function(player)

	if player.gastouch == nil then
		player.gastouch = 0
	end

	if player.mo and player.mo.valid and
	player.gastouch > 32 or (P_IsObjectOnGround(player.mo)) or (player.mo.eflags & MFE_JUSTHITFLOOR) then
		player.gastouch = 0
		end

	if player and player.valid and player.gastouch > 0 then
		local dusttrail = P_SpawnMobj(player.mo.x + P_RandomRange(-30, 30) * FRACUNIT, player.mo.y + P_RandomRange(-30, 30) * FRACUNIT, player.mo.z, MT_PARTICLE)
		dusttrail.colorized = false
		player.gastouch = $ + 1
	if (leveltime%3==0) and not (gametyperules & GTR_FRIENDLY)
		dusttrail.color, dusttrail.colorized = player.mo.color, true
		end
	end
end)

mobjinfo[MT_DGAS] = {
	//$Name Diagonal Gas Jet
	//$Sprite DUSTA0
	//$Category Springs and Fans
	//$Flags1Text Double distance
	//$Flags8Text No sounds
	//$Arg0 Play sound?
	//$Arg0Type 11
	//$Arg0Enum {0="Yes"; 1="No";}
	doomednum = 546,
	spawnstate = S_DGAS,
	spawnhealth = 1,
	reactiontime = 0,
	painsound = sfx_steam2,
	painchance = 1,
	deathsound = sfx_steam1,
	speed = 0,
	radius = 32*FRACUNIT,
	height = 32*FRACUNIT,
	mass = 18*FRACUNIT,
	damage = 30*FRACUNIT,
	raisestate = S_DGAS2,
	flags = MF_SPRING|MF_SPECIAL
	
}

states[S_DGAS] =	{SPR_STEM,	A,	2,	A_None,	0,	0,	S_DGAS2}
states[S_DGAS2] =	{SPR_STEM,	B,	2,	A_Pain,	0,	0,	S_DGAS3}
states[S_DGAS3] =	{SPR_STEM,	C,	2,	A_Shockwave,	MT_DUST,	0,	S_DGAS4}
states[S_DGAS4] =	{SPR_STEM,	D,	2,	A_None,	0,	0,	S_DGAS5}
states[S_DGAS5] =	{SPR_STEM,	E,	2,	A_None,	0,	0,	S_DGAS6}
states[S_DGAS6] =	{SPR_STEM,	F,	2,	A_None,	0,	0,	S_DGAS7}
states[S_DGAS7] =	{SPR_STEM,	G,	2,	A_None,	0,	0,	S_DGAS8}
states[S_DGAS8] =	{SPR_STEM,	TR_TRANS90|A,	2,	A_None,	0,	0,	S_DGAS}