spritenoshade FLARE
defineprojectile FLARE PROJ_WORKSLIKE 6146
defineprojectile FLARE PROJ_HITRADIUS 0
defineprojectile FLARE PROJ_SPAWNS -1
defineprojectile FLARE PROJ_VEL 200
defineprojectile FLARE PROJ_OFFSET 192
defineprojectile FLARE PROJ_VEL_MULT 6
defineprojectile FLARE PROJ_CLIPDIST 32
defineprojectile FLARE PROJ_XREPEAT 30
defineprojectile FLARE PROJ_YREPEAT 30
defineprojectile FLARE PROJ_CSTAT 130
spritenoshade FLARESHINE
actor FLARESHINE ifcount 1 killit enda

gamevar WEAPON1_SHOOTS -1 1
gamevar WEAPON1_CLIP 0 1
gamevar WEAPON1_SPAWN -1 1
gamevar WEAPON1_FIREDELAY 5 1
gamevar WEAPON1_FIRESOUND FLAREF 1

state qav_initframes1
setvarvar WEAPON1_TOTALTIME qav_maxframes
mulvarvar WEAPON1_TOTALTIME qav_tpf
divvarvar WEAPON1_TOTALTIME 4
setvarvar qav_frame player[THISACTOR].kickback_pic
mulvarvar qav_frame 4
divvarvar qav_frame qav_tpf
ends

state akimbo_xcoord1
ifvarn flakimbo 0 ifvarn flakimbo 1
	{
		setvarvar temp flakimbo
		ifvarl flakimbo -1 
		{ 
			mulvar temp -1 
			setvar tempb 10
			subvarvar tempb temp 
			setvarvar temp tempb 
		}
		mulvar temp -3
		addvarvar xweapon temp
	}
ends

state akimbo_ycoord1
ifvarn flakimbo 0 ifvarn flakimbo 1
	{
		setvarvar temp flakimbo
		ifvarl flakimbo -1 
		{ 
			mulvar temp -1 
			setvar tempb 10
			subvarvar tempb temp 
			setvarvar temp tempb 
		}
		mulvar temp 6
		addvarvar yweapon temp
	}
ends

spritenoshade FLAREFIRE
useractor notenemy FLAREFIRE sizeat 32 32
setprojectile[NEWSCRAP1].pal 0
getactorvar[THISACTOR].id_s spriteid

getactor[spriteid].picnum picnum
switch picnum
case ZOMBIE
case TCHERNOBOG
case HERETIC
case GARGOYLE
case BUTCHER
case CIVILIAN
case BURNINGGUY
case APLAYER
case FATRAT
case EVILHAND
case SPIDER
case GILLBEAST
//case BOSSSPIDER
//case CERBERUS
case POD
case TENTACLE
case BEAST
getactor[spriteid].extra extra
ifvarg extra 0
ifvarg spriteid -1
{
	ifvarl actorvar[spriteid].flarefire_count 10 {
		setactorvar[spriteid].pfire 1
	  
		getactor[spriteid].x coorx2
		getactor[spriteid].y coory2
		getactor[spriteid].z coorz2
		getactor[spriteid].ang ang
	  
		ifvare peractor 0
		{ 
			getactor[THISACTOR].x coorx1
			getactor[THISACTOR].y coory1
			getactor[THISACTOR].z coorz1

			setvarvar diffx coorx1
			setvarvar diffy coory1
			setvarvar diffz coorz1
			subvarvar diffx coorx2
			subvarvar diffy coory2
			subvarvar diffz coorz2
			xorvar ang -1 addvar ang 1 andvar ang 2047
			rotatepoint 0 0 diffx diffy ang diffx diffy
			xorvar ang -1 addvar ang 1 andvar ang 2047
			setvar peractor 1
		}

		getactorvar[spriteid].width width
		ifvarg diffy 0 { ifvarvarg diffy width setvarvar diffy width } else { mulvar width -1 ifvarvarl diffy width setvarvar diffy width }
		setvarvar coorx1 coorx2
		setvarvar coory1 coory2
		addvarvar coorx1 10
		addvarvar coory1 diffy
		rotatepoint coorx2 coory2 coorx1 coory1 ang x y
		
		
		getactor[spriteid].picnum picnum
		ifvare picnum ZOMBIE
		{
			getactor[spriteid].htdispicnum flare_pic
			ifvare flare_pic 6325 { addvarvar coorz2 diffz setvarvar flare_tmp diffz } else
			ifvarg flare_pic 6324 ifvarl flare_pic 6329
			{
				ifvarl flare_tmp 0 addvarvar flare_tmp 768
				addvarvar coorz2 flare_tmp
			} else
			ifvarg flare_pic 6329 ifvarl flare_pic 6336
			{
				ifvarvarg flare_tmp diffz subvarvar flare_tmp 512
				addvarvar coorz2 flare_tmp
			} else ifvare flare_pic 6329 nullop else
			addvarvar coorz2 diffz
		} else addvarvar coorz2 diffz
		
		setactor[THISACTOR].x x
		setactor[THISACTOR].y y
		setactor[THISACTOR].z coorz2
	} else {
		state sparkstate
		state sparkstate
		state sparkstate
		state sparkstate
		state sparkstate
		ifrnd 64 { 	state sparkstate
		state sparkstate }
		getactorvar[spriteid].flarefire_count tmp
		subvar tmp 1
		setactorvar[spriteid].flarefire_count tmp
		killit
	}
		
	addvar FIRECOUNT 1
	ifvare FIRECOUNT 1 { setactorvar[spriteid].flarehit 1 getactorvar[spriteid].flaredamaged flaredamaged addvar flaredamaged 1 setactorvar[spriteid].flaredamaged flaredamaged }
	ifvarn FIRECOUNT 182
	{
		state sparkstate 
		state sparkstate
		state sparkstate
		ifvarn sprite[spriteid].picnum BEAST {
			ifcount 3 
			{ subvar extra 2 resetcount }
		}
		getactorvar[spriteid].flaredamaged flaredamaged
		setvar flaretmp 2
		addvar flaretmp 1
		setvar flaretmp2 182
		subvarvar flaretmp2 FIRECOUNT
		mulvarvar flaretmp flaredamaged
		ifvarvarl extra flaretmp ifvarvarl extra flaretmp2 { setactorvar[spriteid].burninactivenow 1 }
		
		ifvarl extra 1 { setactorvar[spriteid].burningguyactive 1 setactorvar[spriteid].burninactivenow 0 } 
		setactor[spriteid].extra extra
	}
	
	ifvare FIRECOUNT 182 { 
		setvar FIRECOUNT 0 
		setactorvar[spriteid].pfire 0 
		getactorvar[spriteid].flarefire_count tmp
		subvar tmp 1
		setactorvar[spriteid].flarefire_count tmp
		
		killit 
	}
}
else 
{
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	ifrnd 64 { 	state sparkstate
	state sparkstate }
	killit
}
break
case TNTBARREL
getactor[spriteid].extra extra ifvarg extra 0
{
	getactorvar[spriteid].flamedamage flamedamage
	addvar flamedamage 100
	setactorvar[spriteid].flamedamage flamedamage
}
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	ifrnd 64 { 	state sparkstate
	state sparkstate }
	killit
break
case SPIDERNET
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	ifrnd 64 { 	state sparkstate
	state sparkstate }
	setactorvar[spriteid].pfire 1
	killit
break
case TREE1
case TREE3
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	ifrnd 64 { 	state sparkstate
	state sparkstate }
	setactorvar[spriteid].pfire 1
	killit
break
default
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	ifrnd 64 { 	state sparkstate
	state sparkstate }
	killit
break
endswitch
ifinwater killit
enda

state flarealtstate
ifvare CURRWEAP 1
{
	ifvare flarealt 0
	ifvare player[THISACTOR].weapon_pos 0
	ifp palive
	{
		ifvare player[THISACTOR].kickback_pic 0
		ifvarg player[THISACTOR].ammo_amount 1 7
		{
			setplayer[THISACTOR].kickback_pic 1 
			setvar flarealt 1
		}
	}
}
ends

state flareakimbodisplay

setvarvar qav_maxframes 11
setvar qav_tpf 6
state qav_initframes1

switch qav_frame
case 0
setvar tilenumweapon 3171
setvar orientationweapon 0
setvar xweapon 86
setvar yweapon -31
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state
setvar tilenumweapon 3171
setvar orientationweapon 4
setvar xweapon -86
setvar yweapon -31
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 1024
state akimbo_ycoord1
state qav2tc_state
break
case 1
setvar tilenumweapon 3171
setvar orientationweapon 0
setvar xweapon 86
setvar yweapon -31
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state
setvar tilenumweapon 3172
setvar orientationweapon 0
setvar xweapon 70
setvar yweapon -56
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state

setvar tilenumweapon 3171
setvar orientationweapon 4
setvar xweapon -86
setvar yweapon -31
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 1024
state akimbo_ycoord1
state qav2tc_state
break
case 2
setvar tilenumweapon 3168
setvar orientationweapon 0
setvar xweapon 48
setvar yweapon -74
setvar qav_sh -128
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state
setvar tilenumweapon 3171
setvar orientationweapon 0
setvar xweapon 86
setvar yweapon -31
setvar qav_sh -32
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state
setvar tilenumweapon 3173
setvar orientationweapon 0
setvar xweapon 61
setvar yweapon -56
setvar qav_sh -32
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state

setvar tilenumweapon 3171
setvar orientationweapon 4
setvar xweapon -86
setvar yweapon -31
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 1024
state akimbo_ycoord1
state qav2tc_state
break
case 3
setvar tilenumweapon 3169
setvar orientationweapon 0
setvar xweapon 35
setvar yweapon -69
setvar qav_sh -128
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state
setvar tilenumweapon 3174
setvar orientationweapon 0
setvar xweapon 133
setvar yweapon -57
setvar qav_sh -32
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state

setvar tilenumweapon 3171
setvar orientationweapon 4
setvar xweapon -86
setvar yweapon -31
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 1024
state akimbo_ycoord1
state qav2tc_state
break
case 4
setvar tilenumweapon 3170
setvar orientationweapon 0
setvar xweapon 34
setvar yweapon -76
setvar qav_sh -128
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state
setvar tilenumweapon 3174
setvar orientationweapon 0
setvar xweapon 157
setvar yweapon -60
setvar qav_sh -16
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state

setvar tilenumweapon 3171
setvar orientationweapon 4
setvar xweapon -86
setvar yweapon -31
setvar qav_sh -32
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 1024
state akimbo_ycoord1
state qav2tc_state
setvar tilenumweapon 3172
setvar orientationweapon 4
setvar xweapon -70
setvar yweapon -56
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 1024
state akimbo_ycoord1
state qav2tc_state
break
case 5
setvar tilenumweapon 3174
setvar orientationweapon 0
setvar xweapon 161
setvar yweapon -56
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state
setvar tilenumweapon 3168
setvar orientationweapon 0
setvar xweapon -47
setvar yweapon -74
setvar qav_sh -16
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state

setvar tilenumweapon 3171
setvar orientationweapon 4
setvar xweapon -86
setvar yweapon -31
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 1024
state akimbo_ycoord1
state qav2tc_state
setvar tilenumweapon 3173
setvar orientationweapon 4
setvar xweapon -61
setvar yweapon -56
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 1024
state akimbo_ycoord1
state qav2tc_state
break
case 6
setvar tilenumweapon 3174
setvar orientationweapon 0
setvar xweapon 155
setvar yweapon -46
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state
setvar tilenumweapon 3169
setvar orientationweapon 0
setvar xweapon -36
setvar yweapon -69
setvar qav_sh -16
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state

setvar tilenumweapon 3174
setvar orientationweapon 4
setvar xweapon -115
setvar yweapon -52
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 1024
state akimbo_ycoord1
state qav2tc_state
break
case 7
setvar tilenumweapon 3175
setvar orientationweapon 0
setvar xweapon 113
setvar yweapon -38
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state
setvar tilenumweapon 3170
setvar orientationweapon 0
setvar xweapon -32
setvar yweapon -76
setvar qav_sh -16
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state

setvar tilenumweapon 3174
setvar orientationweapon 4
setvar xweapon -132
setvar yweapon -58
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 1024
state akimbo_ycoord1
state qav2tc_state
break
case 8
setvar tilenumweapon 3175
setvar orientationweapon 0
setvar xweapon 95
setvar yweapon -29
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state

setvar tilenumweapon 3174
setvar orientationweapon 4
setvar xweapon -140
setvar yweapon -51
setvar qav_sh -16
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 1024
state akimbo_ycoord1
state qav2tc_state
break
case 9
setvar tilenumweapon 3171
setvar orientationweapon 0
setvar xweapon 87
setvar yweapon -30
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state

setvar tilenumweapon 3174
setvar orientationweapon 4
setvar xweapon -120
setvar yweapon -39
setvar qav_sh -16
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 1024
state akimbo_ycoord1
state qav2tc_state
break
case 10
setvar tilenumweapon 3171
setvar orientationweapon 0
setvar xweapon 87
setvar yweapon -30
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state akimbo_xcoord1
state qav2tc_state

setvar tilenumweapon 3175
setvar orientationweapon 4
setvar xweapon -96
setvar yweapon -30
setvar qav_sh -16
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 1024
state akimbo_ycoord1
state qav2tc_state
break
endswitch
ends

state flaregundisplay

setvarvar qav_maxframes 9
setvar qav_tpf 7
state qav_initframes1

switch qav_frame
case 0
setvar tilenumweapon 3171
setvar orientationweapon 0
setvar xweapon 57
setvar yweapon -30
setvar qav_sh 0
setvarvar qav_pal 0
setvar weapon_zoom 10000
setvar qav_ang 0
state qav2tc_state
break
case 1
setvar tilenumweapon 3171
setvar xweapon 56
setvar yweapon -31
setvar weapon_zoom 10000
state qav2tc_state

setvar tilenumweapon 3172
setvar xweapon 40
setvar yweapon -56
setvar weapon_zoom 10000
state qav2tc_state
break
case 2
setvar tilenumweapon 3168
setvar xweapon 18
setvar yweapon -74
setvarvar qav_sh -128
setvar weapon_zoom 10000
state qav2tc_state
setvar tilenumweapon 3171
setvar xweapon 56
setvar yweapon -31
setvarvar qav_sh -32
setvar weapon_zoom 10000
state qav2tc_state
setvar tilenumweapon 3173
setvar xweapon 31
setvar yweapon -56
setvarvar qav_sh -32
setvar weapon_zoom 10000
state qav2tc_state
break
case 3
setvar tilenumweapon 3169
setvar xweapon 10
setvar yweapon -69
setvarvar qav_sh -128
setvar weapon_zoom 10000
state qav2tc_state
setvar tilenumweapon 3174
setvar xweapon 86
setvar yweapon -57
setvarvar qav_sh -32
setvar weapon_zoom 10000
state qav2tc_state
break
case 4
setvar tilenumweapon 3170
setvar xweapon 0
setvar yweapon -77
setvarvar qav_sh -128
setvar weapon_zoom 10000
state qav2tc_state
setvar tilenumweapon 3174
setvar xweapon 91
setvar yweapon -59
setvarvar qav_sh -16
setvar weapon_zoom 10000
state qav2tc_state
break
case 5
setvar tilenumweapon 3174
setvar xweapon 97
setvar yweapon -47
setvarvar qav_sh 0
setvar weapon_zoom 10000
state qav2tc_state
break
case 6
setvar tilenumweapon 3175
setvar xweapon 82
setvar yweapon -39
setvar weapon_zoom 10000
state qav2tc_state
break
case 7
setvar tilenumweapon 3175
setvar xweapon 68
setvar yweapon -30
setvar weapon_zoom 10000
state qav2tc_state
break
case 8
setvar tilenumweapon 3171
setvar xweapon 57
setvar yweapon -30
setvar weapon_zoom 10000
state qav2tc_state
break
endswitch
ends

state flarefirestate  //EVENT_FIRE
ifvare CURRWEAP 1
{	
	setprojectile[FLARE].spawns -1
	setprojectile[FLARE].hitradius 0
	setprojectile[FLARE].sxrepeat -1
	setprojectile[FLARE].syrepeat -1
	ifvarg flakimbo 1 setvar RETURN -1
	ifvarl flakimbo -1 setvar RETURN -1
}
ends

state flaredofirestate 
ifvare CURRWEAP 1
ifp palive
{
	ifvare flarealt 0
	{
	getplayer[THISACTOR].horiz phoriz
	subvar phoriz 100
	mulvar phoriz -25
	getplayer[THISACTOR].ang ang
	ezshoot phoriz FLARE
	subvar ang 4
	setactor[RETURN].ang ang
	setvar RETURN 0
	} 
	else
	{
		getplayer[THISACTOR].ammo_amount 1 ammo
		ifvarg ammo 7
		{
			setprojectile[FLARE].spawns EXPLOSION6
			setprojectile[FLARE].sxrepeat 32
			setprojectile[FLARE].syrepeat 32
			subvar ammo 8
			setplayer[THISACTOR].ammo_amount 1 ammo
			getplayer[THISACTOR].horiz phoriz
			subvar phoriz 100
			mulvar phoriz -25
			getplayer[THISACTOR].ang ang
			ezshoot phoriz FLARE
			subvar ang 4
			setactor[RETURN].ang ang
			sound FLAREF
			setactorvar[RETURN].flarealtproj 1
			setactorvar[RETURN].noflarefire 1
			ifvarl flakimbo 1 { setvar flarealt 0 }
			setprojectile[FLARE].spawns -1
			setprojectile[FLARE].sxrepeat -1
			setprojectile[FLARE].syrepeat -1
		} else setvar flarealt 0
	}
}
ends

state flaregamestate //EVENT_GAME
ifactor FLARESHINE { ifpdistl 1152 { setactor[THISACTOR].xrepeat 0 setactor[THISACTOR].yrepeat 0 } else { setactor[THISACTOR].xrepeat 32 setactor[THISACTOR].yrepeat 32 } }
ifactor FLARE
{
	getactorvar[THISACTOR].rightshine rightshine
	espawn FLARESHINE
	ifvare rightshine 1 
	{
		getactor[RETURN].xoffset xoffset
		addvar xoffset 24
		setactor[RETURN].xoffset xoffset
	}
	setactor[RETURN].cstat 642
	state sparkstate

	
	getactorvar[THISACTOR].flarealtproj tmp
	ifvare tmp 1
	{
		addvar COUNTER 1
		ifvare COUNTER 5
		{	
			setprojectile[FLARE].spawns EXPLOSION6
			setprojectile[FLARE].sxrepeat 32
			setprojectile[FLARE].syrepeat 32
			
			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			getactor[THISACTOR].ang ang
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar zvel -115
			addvar ang 10
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			setactor[RETURN].ang ang
			
			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			getactor[THISACTOR].ang ang
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar zvel -115
			addvar ang -10
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			setactor[RETURN].ang ang
			
			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			getactor[THISACTOR].ang ang
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar zvel 115
			addvar ang 10
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			setactor[RETURN].ang ang
			
			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			getactor[THISACTOR].ang ang
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar zvel 115
			addvar ang -10
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			setactor[RETURN].ang ang
			

			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar zvel -300
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			
			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar zvel 300
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			
			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			getactor[THISACTOR].ang ang
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar ang -30
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			setactor[RETURN].ang ang
			
			getactor[THISACTOR].xvel xvel
			getactor[THISACTOR].yvel yvel
			getactor[THISACTOR].zvel zvel
			getactor[THISACTOR].ang ang
			eshoot FLARE
			setactorvar[RETURN].noflarefire 1
			setactor[RETURN].xoffset 12
			setactor[RETURN].yoffset -27
			addvar ang 30
			setactor[RETURN].xvel xvel
			setactor[RETURN].yvel yvel
			setactor[RETURN].zvel zvel
			setactor[RETURN].ang ang
			
			killit
			setprojectile[FLARE].spawns -1
			setprojectile[FLARE].sxrepeat -1
			setprojectile[FLARE].syrepeat -1
			
			setactorvar[THISACTOR].flarealtproj 0
		}
	}
		ifvare peractor 0
		{
			espawn SMALLSMOKE
			setvar light_radius 1024
			setvar red 144
			setvar green 50
			setvar blue 20
			state spawnlight
			getactor[THISACTOR].z z
			subvar z 128
			setactor[RETURN].z z
			setvar peractor 1
		}
}
ends

state flarealt_damage
	ifcanseetarget {
		getactorvar[spriteid].flamedamage tmp 
		addvar tmp 100 
		setactorvar[spriteid].flamedamage tmp
			
		ifvarvarn spriteid PLAYERID {
			getactor[spriteid].extra extra
			ifvarg extra 100
				subvar extra 100
			else { setactorvar[spriteid].burningguyactive 1 }
			setactor[spriteid].extra extra
		}
	}
ends

state flarekillitstate
ifactor FLARE {
	getactor[THISACTOR].htmovflag spriteid
	addvar spriteid 16384 
	ifvarn noflarefire 1
	ifvarg spriteid -1 ifvarl spriteid 16384 {
		espawn FLAREFIRE
		setactorvar[RETURN].id_s spriteid 
		getactorvar[spriteid].flarefire_count tmp
		addvar tmp 1
		setactorvar[spriteid].flarefire_count tmp
	}
		
		ifvare noflarefire 1
		{
		
		setvar sectorid 0
		whilevarvarn sectorid NUMSECTORS 
		{
			headspritesect spriteid sectorid
			whilevarn spriteid -1 
			{
				getactor[spriteid].picnum picnum
				switch picnum
				case APLAYER
				case ZOMBIE
				case HERETIC
				case SPIDER
				case BOSSSPIDER
				case BUTCHER
				case GILLBEAST
				case FATRAT
				case EVILHAND
				case FISH
				case HELLDOG
				case BAT
				case BATSLEEP
				case GARGOYLE
				case CIVILIAN
				case TCHERNOBOG
				case BEAST
				case TENTACLE
				case POD
					ldist enemy_zdist THISACTOR spriteid
					ifcanseetarget ifvarl enemy_zdist 1536 				
						state flarealt_damage
				break
				endswitch
				nextspritesect spriteid spriteid
			}
			addvar sectorid 1
		}


	/*
			findnearspritevar APLAYER 768 spriteid
			ifvarn spriteid -1 state flarealt_damage
			findnearactorvar ZOMBIE 768 spriteid
			ifvarn spriteid -1 state flarealt_damage
			findnearactorvar HERETIC 768 spriteid
			ifvarn spriteid -1 state flarealt_damage
			findnearactor EVILHAND 768 spriteid
			ifvarn spriteid -1 state flarealt_damage
			findnearactor FATRAT 768 spriteid
			ifvarn spriteid -1 state flarealt_damage
			findnearactor BUTCHER 768 spriteid
			ifvarn spriteid -1 state flarealt_damage
			findnearactor SPIDER 768 spriteid
			ifvarn spriteid -1 state flarealt_damage
			findnearactor HELLDOG 768 spriteid
			ifvarn spriteid -1 state flarealt_damage
			findnearactor GILLBEAST 768 spriteid
			ifvarn spriteid -1 state flarealt_damage
			findnearactor CIVILIAN 768 spriteid
			ifvarn spriteid -1 state flarealt_damage
	*/			
		}
			
	setvar RETURN 0
}
ends

state flareplayerstate
ifvare player[THISACTOR].kickback_pic 0 { setvar flarealt 0 } //set to 0 after dead

// FLARE AKIMBO

ifvarg flakimbo 1 subvar flakimbo 1
ifvarl flakimbo -1
{
	addvar flakimbo 1
	ifvare flakimbo -1 setvar flakimbo 0
}
ifvare CURRWEAP 1 ifvarg flakimbo 0
ifvare player[THISACTOR].kickback_pic 8
ifp palive
{
    ifvare flarealt 0
	{	
		sound FLAREF
		eshoot FLARE
		setactorvar[RETURN].rightshine 1
		getactor[RETURN].xoffset xoffset
		addvar xoffset 24
		setactor[RETURN].xoffset xoffset
		getplayer[THISACTOR].ammo_amount 1 tmp
		ifvarg tmp 0 subvar tmp 1
		setplayer[THISACTOR].ammo_amount 1 tmp
	} 
	else 
	{ 
		getplayer[THISACTOR].ammo_amount 1 ammo
		ifvarg ammo 7
		{
			setprojectile[FLARE].spawns EXPLOSION6
			setprojectile[FLARE].sxrepeat 32
			setprojectile[FLARE].syrepeat 32
			subvar ammo 8
			setplayer[THISACTOR].ammo_amount 1 ammo
			sound FLAREF
			eshoot FLARE
			setactorvar[RETURN].rightshine 1
			setactorvar[RETURN].flarealtproj 1
			setactorvar[RETURN].noflarefire 1
			ifvarl flakimbo 1 { setvar flarealt 0 }
			setprojectile[FLARE].spawns -1
			setprojectile[FLARE].sxrepeat -1
			setprojectile[FLARE].syrepeat -1
		} else setplayer[THISACTOR].kickback_pic 0
		setvar flarealt 0
	}
}
ends