state particles_game

ifactor SECTOREFFECTOR // Light of particles in polymer
{
	getactorvar[THISACTOR].movelightse peractor
	ifvare peractor 1
	{
		getactor[THISACTOR].lotag lotag
		ifvare lotag 49
		{
			getactorvar[THISACTOR].fire_id tmp
			getactorvar[tmp].active tmp2
			ifvare tmp2 1
			{
			getactor[tmp].x x
			getactor[tmp].y y
			getactor[tmp].z z
			getactor[tmp].sectnum sectnum
			
			setactor[THISACTOR].x x
			setactor[THISACTOR].y y
			ifspawnedby BURNINGGUY { subvar z 6144 }
			ifspawnedby BURNINGGUYDEAD { subvar z 1024 }
			ifspawnedby PROXIMITYFLOOR 
			{ 
				subvar z 128
				addvar COUNTER 128
				sin light_radius COUNTER
				divvar light_radius 12
				setactor[THISACTOR].hitag light_radius 
			}
			ifspawnedby REMOTEFLOOR
			{
				subvar z 128
				addvar COUNTER 128
				sin light_radius COUNTER
				divvar light_radius 12
				setactor[THISACTOR].hitag light_radius 
			}
			ifspawnedby EXPLOSION5
			{
				subvar z 128
				getactor[THISACTOR].hitag light_radius 
				subvar light_radius 96
				setactor[THISACTOR].hitag light_radius 
			}
			ifspawnedby EXPLOSION6
			{
				subvar z 128
				getactor[THISACTOR].hitag light_radius 
				subvar light_radius 128
				setactor[THISACTOR].hitag light_radius 
			}

			setactor[THISACTOR].z z
			setactor[THISACTOR].sectnum sectnum
			} else killit
		}
	}
}

ifactor FLARE
{
	getactorvar[THISACTOR].flarealtproj tmp
	ifvare tmp 1
	{
		addvar COUNTER 1
		ifvare COUNTER 8
		{	
			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 FLAREFIRE
			setprojectile[FLARE].sxrepeat -1
			setprojectile[FLARE].syrepeat -1
			
			setactorvar[THISACTOR].flarealtproj 0
		}
	}
	setactorvar[THISACTOR].active 1
	ifaction 0
	{
		espawn SMALLSMOKE
		setvar light_radius 1024
		setvar red 208
		setvar green 38
		setvar blue 38
		state spawnlight
		action ACTIVE
	}
}
ifactor PLASMAPROJ
{

ifpdistl 1152 { setactor[THISACTOR].xrepeat 0 setactor[THISACTOR].yrepeat 0 } else { setactor[THISACTOR].xrepeat 32 setactor[THISACTOR].yrepeat 32 }

	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 1024
		setvar red 0
		setvar green 64
		setvar blue 255
		state spawnlight
		setvar peractor 1
	}
}

ifactor TNTFLOOR { addvar detonatecount 1 }
ifactor SPRAYFLOOR { addvar detonatecount 1 }
ifactor EXPLOSION2
{
	ifspawnedby TNTFLOOR nullop else
	{
		findnearactor ZOMBIE 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor HERETIC 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor EVILHAND 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor COMMANDER 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor RECON 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor TANK 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor PIGCOP 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor LIZMAN 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor ROTATEGUN 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor GREENSLIME 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor NEWBEAST 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS1 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS2 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS3 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS4 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearsprite APLAYER 1024 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[THISACTOR].flamedamage 25 }
	}
}
ifactor EXPLOSION3
{
	ifspawnedby TNTFLOOR nullop else
	{
		findnearactor ZOMBIE 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor HERETIC 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor EVILHAND 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor COMMANDER 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor RECON 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor TANK 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor PIGCOP 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor LIZMAN 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor ROTATEGUN 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor GREENSLIME 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor NEWBEAST 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS1 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS2 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS3 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearactor BOSS4 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } else
		findnearsprite 2 2048 spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[THISACTOR].flamedamage 25 }
	}
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 3072
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}
ifactor EXPLOSION6
{
	ifspawnedby TNTFLOOR nullop else
	{
		ifspawnedby PR_NAPALM setvar DIST 2304 else setvar DIST 1024
		findnearactorvar ZOMBIE DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar HERETIC DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar EVILHAND DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar COMMANDER DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar RECON DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar TANK DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar PIGCOP DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar LIZMAN DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar ROTATEGUN DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar GREENSLIME DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar NEWBEAST DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar BOSS1 DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar BOSS2 DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar BOSS3 DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar BOSS4 DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
		findnearspritevar APLAYER DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp ifspawnedby SPRAYFLOOR addvar tmp 6 else ifspawnedby FLARE addvar tmp 4 else addvar tmp 2 setactorvar[spriteid].flamedamage tmp } }
	}
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 3072
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}

ifactor PR_NAPALM
{
	addvar COUNTER 1
	ifvare COUNTER 3
	{
		setvar COUNTER 0
		ifaction FRAME1 action FRAME2 else
		ifaction FRAME2 action FRAME3 else
		ifaction FRAME3 action FRAME1
	}
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 2048
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}

ifactor NEWSCRAP1
{
	addvar COUNTER 1
	ifvare COUNTER 3
	{
		setvar COUNTER 0
		ifaction FRAME_FRAME1 action FRAME_FRAME2 else
		ifaction FRAME_FRAME2 action FRAME_FRAME3 else
		ifaction FRAME_FRAME3 action FRAME_FRAME4 else
		ifaction FRAME_FRAME4 action FRAME_FRAME5 else
		ifaction FRAME_FRAME5 killit
	}
	ifspawnedby FLAREFIRE
	{
		setactorvar[THISACTOR].active 1
		ifvare peractor 0
		{
			espawn SMALLSMOKE
			setvar light_radius 512
			setvar red 208
			setvar green 38
			setvar blue 38
			state spawnlight
			setvar peractor 1
		}
	} else
	ifspawnedby STAFFALTPROJ
	{
		setactorvar[THISACTOR].active 1
		ifvare peractor 0
		{
			espawn SMALLSMOKE
			setvar light_radius 512
			setvar red 0
			setvar green 64
			setvar blue 255
			state spawnlight
			setvar peractor 1
		}
	}
}
ifactor ALTNAPALM
{
	addvar COUNTER 1
	ifvare COUNTER 3
	{
		setvar COUNTER 0
		ifaction FRAME1 action FRAME2 else
		ifaction FRAME2 action FRAME3 else
		ifaction FRAME3 action FRAME1
	}	
	state newfirestate
	getactor[THISACTOR].z z
	subvar z 2048
	setactor[RETURN].z z
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 2048
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}
ifactor ALTTESLA
{
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 3072
		setvar red 0
		setvar green 64
		setvar blue 255
		state spawnlight
		setvar peractor 1
	}
}
ifactor STAFFPROJ 
{ 
	ifrnd 128 state newfirestate 
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 2048
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}
ifactor FLAME
{
	addvar COUNTER 1
	ifvare COUNTER 2
	{
		setvar COUNTER 0
		ifaction FRAME_FRAME1 action FRAME_FRAME2 else
		ifaction FRAME_FRAME2 action FRAME_FRAME3 else
		ifaction FRAME_FRAME3 action FRAME_FRAME4 else
		ifaction FRAME_FRAME4 action FRAME_FRAME5 else
		ifaction FRAME_FRAME5 action FRAME_FRAME6 else
		ifaction FRAME_FRAME6 action FRAME_FRAME7 else
		ifaction FRAME_FRAME7 action FRAME_FRAME8 else
		ifaction FRAME_FRAME8 killit
	}
	ifinwater killit
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 1536
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}
ifactor FLAME2
{
	addvar COUNTER 1
	ifvare COUNTER 2
	{
		setvar COUNTER 0
		ifaction FLAME2_FRAME1 action FLAME2_FRAME2 else
		ifaction FLAME2_FRAME2 action FLAME2_FRAME3 else
		ifaction FLAME2_FRAME3 action FLAME2_FRAME4 else
		ifaction FLAME2_FRAME4 action FLAME2_FRAME5 else
		ifaction FLAME2_FRAME5 action FLAME2_FRAME6 else
		ifaction FLAME2_FRAME6 action FLAME2_FRAME7 else
		ifaction FLAME2_FRAME7 action FLAME2_FRAME8 else
		ifaction FLAME2_FRAME8 killit
	}
	ifinwater killit
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 1536
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}

ifactor TESLASPARK
{
	addvar COUNTER 1
	ifvare COUNTER 2
	{
		setvar COUNTER 0
		ifaction FRAME_FRAME1 action FRAME_FRAME2 else
		ifaction FRAME_FRAME2 action FRAME_FRAME3 else
		ifaction FRAME_FRAME3 action FRAME_FRAME4 else
		ifaction FRAME_FRAME4 action FRAME_FRAME5 else
		ifaction FRAME_FRAME5 killit
	}
	ifspawnedby ALTTESLA
	{
		addvar COUNTER 1
		ifvare COUNTER 14
		{
			setvar COUNTER 0
			ifaction FRAME_FRAME1 action FRAME_FRAME2 else
			ifaction FRAME_FRAME2 action FRAME_FRAME3 else
			ifaction FRAME_FRAME3 action FRAME_FRAME4 else
			ifaction FRAME_FRAME4 action FRAME_FRAME5 else
			ifaction FRAME_FRAME5 killit
		}
	}
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 512
		setvar red 0
		setvar green 64
		setvar blue 255
		state spawnlight
		setvar peractor 1
	}
}

ifactor STAFFALTPROJ
{
	setprojectile[NEWSCRAP1].pal 1
	state sparkstate state sparkstate
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 2048
		setvar red 0
		setvar green 64
		setvar blue 255
		state spawnlight
		setvar peractor 1
	}
}

ifactor NEWFIRE
{
	ifvare peractor 0
	{
		ifrnd 128 { cstat 4 } else cstat 0
		setvar peractor 1
	}
	addvar COUNTER 1
	ifspawnedby ALTNAPALM 
	{ 
		ifvare COUNTER 2
		{
			setvar COUNTER 0
			ifaction FRAME_FRAME1 action FRAME_FRAME2 else
			ifaction FRAME_FRAME2 action FRAME_FRAME3 else
			ifaction FRAME_FRAME3 action FRAME_FRAME4 else
			ifaction FRAME_FRAME4 action FRAME_FRAME5 else
			ifaction FRAME_FRAME5 action FRAME_FRAME6 else
			ifaction FRAME_FRAME6 action FRAME_FRAME7 else
			ifaction FRAME_FRAME7 killit
		} 
	} else 
	ifspawnedby STAFFPROJ
	{ 
		ifvare COUNTER 1
		{
			setvar COUNTER 0
			ifaction FRAME_FRAME1 action FRAME_FRAME2 else
			ifaction FRAME_FRAME2 action FRAME_FRAME3 else
			ifaction FRAME_FRAME3 action FRAME_FRAME4 else
			ifaction FRAME_FRAME4 killit
		} 
	} else 
	ifvare COUNTER 4
	{
		setvar COUNTER 0
		ifaction FRAME_FRAME1 action FRAME_FRAME2 else
		ifaction FRAME_FRAME2 action FRAME_FRAME3 else
		ifaction FRAME_FRAME3 action FRAME_FRAME4 else
		ifaction FRAME_FRAME4 action FRAME_FRAME5 else
		ifaction FRAME_FRAME5 action FRAME_FRAME6 else
		ifaction FRAME_FRAME6 action FRAME_FRAME7 else
		ifaction FRAME_FRAME7 killit
	}
	ifinwater killit
	
	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 512
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
}
ifactor SPRAYBUNDLE
{
espawn NAPALMSMOKE
getactor[RETURN].x x
getactor[RETURN].y y
getactor[RETURN].ang ang
setvarvar y2 y
addvar y2 -128
rotatepoint x y x y2 ang x3 y3
setactor[RETURN].x x3
setactor[RETURN].y y3

setactor[RETURN].xrepeat 5
setactor[RETURN].yrepeat 5
}
ifactor TNTBUNDLE
{
espawn NAPALMSMOKE
getactor[RETURN].x x
getactor[RETURN].y y
getactor[RETURN].ang ang
setvarvar y2 y
addvar y2 -128
rotatepoint x y x y2 ang x3 y3
setactor[RETURN].x x3
setactor[RETURN].y y3

setactor[RETURN].xrepeat 5
setactor[RETURN].yrepeat 5
}

ends

state particles_killit
ifactor TNTBUNDLE
{
	getactorvar[THISACTOR].detonatetime tmp
	espawn TNTFLOOR
	setactorvar[RETURN].detonatetime tmp
	setvar RETURN 0
}
ifactor SPRAYBUNDLE
{
	getactorvar[THISACTOR].detonatetime tmp
	espawn SPRAYFLOOR
	setactorvar[RETURN].detonatetime tmp
	setvar RETURN 0
}
ifactor FLARE
{

	getactor[THISACTOR].htmovflag spriteid
	getactorvar[THISACTOR].noflarefire tmp2
	setactorvar[THISACTOR].active 0
	addvar spriteid 16384
	ifvarl spriteid 16384 ifvarg spriteid -1
	{ 
		espawn FLAREFIRE
		setactorvar[RETURN].noflarefire tmp2
		setactorvar[RETURN].id_s tmp
	}
	setactorvar[RETURN].id_s spriteid
	setvar RETURN 0
	getactorvar[THISACTOR].flarefulldamage peractor
	ifvare peractor 1
	{
		setvar DIST 1536
		findnearactorvar ZOMBIE DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp addvar tmp 100 setactorvar[spriteid].flamedamage tmp } }
		findnearactorvar HERETIC DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp addvar tmp 100 setactorvar[spriteid].flamedamage tmp } }
		findnearspritevar APLAYER DIST spriteid
		ifvarn spriteid -1 { getactor[spriteid].extra extra ifvarg extra 0 { getactorvar[spriteid].flamedamage tmp addvar tmp 100 setactorvar[spriteid].flamedamage tmp } }
	}
}
ifactor FLAME
{
	getactor[THISACTOR].htmovflag spriteid
	addvar spriteid 16384
	ifvarl spriteid 16384 ifvarg spriteid -1
	{ 	
			getactor[spriteid].picnum picnum
			switch picnum
				case ZOMBIE
				case HERETIC
				case EVILHAND
				case COMMANDER
				case RECON
				case TANK
				case PIGCOP
				case LIZMAN
				case ROTATEGUN
				case GREENSLIME
				case NEWBEAST
				case BOSS1
				case BOSS2
				case BOSS3
				case BOSS4
				case APLAYER
				{ 
					getactor[spriteid].extra extra ifvarg extra 0
					{
						getactorvar[spriteid].flamedamage tmp
						addvar tmp 48
						setactorvar[spriteid].flamedamage tmp
					}
				}
				break
			endswitch 
	}
	setvar RETURN 1
	getplayer[THISACTOR].horiz temp
	subvar temp 100
	mulvar temp -6
	getactor[THISACTOR].z z
	
	getactor[THISACTOR].sectnum sect2
	getsector[sect2].floorz z2
	getsector[sect2].ceilingz z3
	ifvarvarg z z2  { setvarvar z z2 subvarvar z 3072 } else addvarvar z temp
	ifvarvarl z z3  { setvarvar z z3 addvarvar z 3072 } else addvarvar z temp
	setactor[THISACTOR].z z
	ifaction FRAME_FRAME8 setvar RETURN 0
	setactorvar[THISACTOR].active 0
}
ifactor FLAME2
{
	getactor[THISACTOR].htmovflag spriteid
	addvar spriteid 16384
	ifvarl spriteid 16384 ifvarg spriteid -1
	{ 	
			getactor[spriteid].picnum picnum
			switch picnum
				case ZOMBIE
				case HERETIC
				case EVILHAND
				case COMMANDER
				case RECON
				case TANK
				case PIGCOP
				case LIZMAN
				case ROTATEGUN
				case GREENSLIME
				case NEWBEAST
				case BOSS1
				case BOSS2
				case BOSS3
				case BOSS4
				case APLAYER
				{ 
					getactor[spriteid].extra extra ifvarg extra 0
					{
						getactorvar[spriteid].flamedamage tmp
						addvar tmp 48
						setactorvar[spriteid].flamedamage tmp
					}
				}
				break
			endswitch 
	}
	setvar RETURN 1
	getplayer[THISACTOR].horiz temp
	subvar temp 100
	mulvar temp -6
	getactor[THISACTOR].z z
	
	getactor[THISACTOR].sectnum sect2
	getsector[sect2].floorz z2
	getsector[sect2].ceilingz z3
	ifvarvarg z z2  { setvarvar z z2 subvarvar z 3072 } else addvarvar z temp
	ifvarvarl z z3  { setvarvar z z3 addvarvar z 3072 } else addvarvar z temp
	setactor[THISACTOR].z z
	ifaction FLAME2_FRAME8 setvar RETURN 0
	setactorvar[THISACTOR].active 0
}
ifactor PLASMAPROJ
{
	iffloordistl 5
	{
		setvar zdist 0
		state teslasparkstate
		state teslasparkstate
		state teslasparkstate
		state teslasparkstate
		setprojectile[TESLASPARK].vel 96
		setprojectile[TESLASPARK].drop 0
	} 
	else
	{
		randvar zdist 1024
		ifrnd 128 mulvar zdist -1
		subvar zdist 1024
		setprojectile[TESLASPARK].vel 64
	}
	state teslasparkstate
	state teslasparkstate
	state teslasparkstate
	state teslasparkstate
	state teslasparkstate
	state teslasparkstate
	state teslasparkstate
	state teslasparkstate
	setvar RETURN 0
	setactorvar[THISACTOR].active 0
	
	getactor[THISACTOR].htmovflag tmp
	addvar tmp 16384
	ifvarl tmp 16384 ifvarg tmp -1
	{ setactorvar[tmp].teslahitenable 1 }
}
ifactor ALTTESLA
{
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	state altteslasparkstate
	setvar RETURN 0
	setactorvar[THISACTOR].active 0
}
ifactor TESLASPARK { setactorvar[THISACTOR].active 0 }
ifactor ALTNAPALM
{
	setactorvar[THISACTOR].active 0
	getactorvar[THISACTOR].napalmammo np_ammo
	quake 36
	stopsound EARTHQUAKE
	ifvarg np_ammo 3
	{
		subvar np_ammo 2
		espawn FIREBALL
		setactorvar[RETURN].napalmammo np_ammo
		setactor[RETURN].xrepeat 24
		setactor[RETURN].yrepeat 24
		espawn FIREBALL 
		setactorvar[RETURN].napalmammo np_ammo
		setactor[RETURN].xrepeat 24
		setactor[RETURN].yrepeat 24
	} 
	else
	ifvare np_ammo 3
	{
		espawn FIREBALL
		setactorvar[RETURN].napalmammo 0
		setactor[RETURN].xrepeat 24
		setactor[RETURN].yrepeat 24
		espawn FIREBALL 
		setactorvar[RETURN].napalmammo 0
		setactor[RETURN].xrepeat 24
		setactor[RETURN].yrepeat 24
	} 
	else
	ifvare np_ammo 2
	{
		espawn FIREBALL 
		setactorvar[RETURN].napalmammo 0
		setactor[RETURN].xrepeat 24
		setactor[RETURN].yrepeat 24
	}
	setvar RETURN 0
	setactorvar[THISACTOR].active 0
}

ifactor PR_NAPALM { setactorvar[THISACTOR].active 0 }
ifactor STAFFPROJ { setactorvar[THISACTOR].active 0 }
ifactor STAFFALTPROJ { setactorvar[THISACTOR].active 0 }
ifactor NEWSCRAP1 { setactorvar[THISACTOR].active 0 }
ifactor NEWFIRE { setactorvar[THISACTOR].active 0 }
ifactor EXPLOSION5 { setactorvar[THISACTOR].active 0 }
ifactor EXPLOSION3 { setactorvar[THISACTOR].active 0 }
ifactor EXPLOSION6 { setactorvar[THISACTOR].active 0 }

ends

action NEWSMOKEFRAMES 0 7 1 1 5
actor NEWSMOKE 0 NEWSMOKEFRAMES
sizeat 32 32 cstat 642
ifvare peractor 0 { spawn SHOTSPARK1 setvar peractor 1 }
ifactioncount 7 killit
enda

action NAPALMSMOKEFRAMES 0 2 1 1 15
actor NAPALMSMOKE 0 NAPALMSMOKEFRAMES
cstat 642
ifactioncount 2 killit
enda

actor BLOODPOOL2
sizeat 32 32 cstat 34
getactor[THISACTOR].sectnum tmp
getsector[tmp].lotag lotag
ifvarn lotag 1
{
	getsector[tmp].floorz z
	setactor[THISACTOR].z z
} else killit
ifcount 1560 { killit }
enda

action BLOOD_FLAMES 0 4 1 1 10

actor BLOODDROP
fall sizeat 32 32

ifspritepal 0
{ 
		getactor[THISACTOR].x x
		getactor[THISACTOR].y y
		randvar tmp 2000
		addvar tmp -1000
		addvarvar x tmp
		randvar tmp 2000
		addvar tmp -1000
		addvarvar y tmp
		setactor[THISACTOR].x x
		setactor[THISACTOR].y y
		spritepal 30
}
iffloordistl 1 ifaction 0 { action BLOOD_FLAMES qspawn BLOODPOOL2 }
ifactioncount 4 { killit }
enda

actor BLOODSPRAY
fall
randvar xrepeat 32
addvar xrepeat 8
setvarvar yrepeat xrepeat
setactor[THISACTOR].xrepeat xrepeat
setactor[THISACTOR].yrepeat yrepeat
randvar tmp 4
switch tmp
	case 0 action FRAME_FRAME1 break
	case 1 action FRAME_FRAME2 break
	case 2 action FRAME_FRAME3 break
	case 3 action FRAME_FRAME4 break
	case 4 action FRAME_FRAME5 break
endswitch
iffloordistl 1 { ifrnd 64 { spawn BLOODDROP spawn BLOODPOOL2 } killit  }
enda

action FLY 0 3 5 1 5

move vert1   70  -300
move vert2   70  0
move horz1  150  -75
move horz2  150  0

state np_fire
	iffloordistl 5 
	ifcount 4 
	{ 
		getactorvar[THISACTOR].napalmammo np_ammo
		ifvarg np_ammo 1 subvar np_ammo 2 else subvar np_ammo 1
		setactorvar[THISACTOR].napalmammo np_ammo
		subvar np_ammo 1
		ifvarg np_ammo 0 espawn FIREBALL
		setactorvar[RETURN].napalmammo np_ammo
		setactor[RETURN].xrepeat 20
		setactor[RETURN].yrepeat 20 
	}
ends

useractor notenemy FIREBALL 0 FLY cstat 384 fall
espawn NAPALMSMOKE
setactor[RETURN].xrepeat 18
setactor[RETURN].yrepeat 18
ifaction FLY
{
  ifcount 1  { ifmove 0 { ifrnd 128 { move horz1 geth getv randomangle } } } 
  ifcount 6 { ifmove vert1 move vert2 geth ifmove horz1 move horz2 geth }
}
getactorvar[THISACTOR].napalmammo np_ammo
ifvarand np_ammo 1
{ state np_fire	} else { state np_fire state np_fire }

iffloordistl 5 
{ 
	ifcount 4 
	{ 
		hitradius 1152 16 32 64 128 
		espawn EXPLOSION6 
		setactor[RETURN].xrepeat 32 
		setactor[RETURN].yrepeat 32 
		setactor[RETURN].cstat 128 
		quake 26 stopsound EARTHQUAKE 
		globalsound EXPLODCM
		setactorvar[THISACTOR].active 0
		killit
	}
}
	
ifpdistg 16384 { setactorvar[THISACTOR].active 0 killit }
ifonwater { setactorvar[THISACTOR].active 0 killit }


	setactorvar[THISACTOR].active 1
	ifvare peractor 0
	{
		espawn SMALLSMOKE
		setvar light_radius 2048
		setvar red 255
		setvar green 144
		setvar blue 0
		state spawnlight
		setvar peractor 1
	}
enda

useractor notenemy FLOORSHSHEEL

	fall sizeat 8 8
	ifspritepal 0
	{
		ifrnd 128 { cstat 4 } else cstat 0
		spritepal 30
	}
	ifcount 1560 { killit }
enda

action ATESLAANIM 0 4 1 1 7
useractor notenemy TESLADECAL 
sizeat 32 32 cstat 145
ifaction 0 action ATESLAANIM
ifactioncount 4 killit
enda

useractor notenemy FLOORSHEEL 

	fall sizeat 8 8
	ifspritepal 0
	{
		getactor[THISACTOR].ang ang
		randvar ang 2048
		setactor[THISACTOR].ang ang
		ifrnd 128 { cstat 4 } else cstat 0
		spritepal 30
	}
	ifcount 1560 { killit }
enda

spritenoshade EXPLOSION3
action EXPLOSION3_FRAMES 0 12 1 1 4
useractor notenemy EXPLOSION3 0 EXPLOSION3_FRAMES
sizeat 48 48 cstat 128
ifactioncount 12 killit

ifspawnedby TNTFLOOR
ifspritepal 0 
{ 
	quake 36
	stopsound EARTHQUAKE
	spritepal 30 
}
enda

spritenoshade EXPLOSION4
action EXPLOSION4_FRAMES 0 12 1 1  4
actor EXPLOSION4 1 EXPLOSION4_FRAMES
cstat 128 sizeat 40 40
ifactioncount 12 killit
enda

spritenoshade EXPLOSION6
action EXPLOSION6_FRAMES 0 10 1 1 4
useractor notenemy EXPLOSION6 0 EXPLOSION6_FRAMES
ifactioncount 10 killit

ifspawnedby PR_NAPALM
ifspritepal 0 
{ 
	quake 36
	setactor[THISACTOR].cstat 128
	stopsound EARTHQUAKE
	spritepal 30 
}
enda


spritenoshade FLAREFIRE
useractor notenemy FLAREFIRE sizeat 32 32
setprojectile[NEWSCRAP1].pal 2
getactorvar[THISACTOR].id_s spriteid
getactorvar[THISACTOR].noflarefire tmp
ifvare tmp 1 killit
getactor[spriteid].picnum picnum
switch picnum
case ZOMBIE
case HERETIC
case COMMANDER
case PIGCOP
case LIZMAN
case GREENSLIME
case NEWBEAST
case BOSS1
case BOSS2
case BOSS3
case BOSS4
case APLAYER
getactor[spriteid].extra extra
ifvarg extra 0
ifvarg spriteid -1
{
	setactorvar[spriteid].pfire 1
	getactor[spriteid].z z
	addvar z -4096
	setactor[THISACTOR].z z
  
	getactor[spriteid].x coorx2
	getactor[spriteid].y coory2
	getactor[spriteid].ang ang
  
	ifvare peractor 0
	{ 
		getactor[THISACTOR].x coorx1
		getactor[THISACTOR].y coory1

		setvarvar diffx coorx1
		setvarvar diffy coory1
		subvarvar diffx coorx2
		subvarvar diffy coory2
		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
	}

	setvarvar coorx1 coorx2
    setvarvar coory1 coory2
    addvarvar coorx1 diffx
    addvarvar coory1 diffy
	rotatepoint coorx2 coory2 coorx1 coory1 ang x y
	
	setactor[THISACTOR].x x
	setactor[THISACTOR].y y
	
	addvar FIRECOUNT 1
	ifvarn FIRECOUNT 182
	{
		ifcount 3 { state sparkstate subvar extra 1 resetcount }
		ifvare extra 0 { setactorvar[spriteid].burningguyactive 1 killit }
		setactor[spriteid].extra extra
	}
	ifvare FIRECOUNT 182 { setvar FIRECOUNT 0 killit }
}
else 
{
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	ifrnd 64 { 	state sparkstate
	state sparkstate }
	killit
}
break
default
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	state sparkstate
	ifrnd 64 { 	state sparkstate
	state sparkstate }
	killit
break
endswitch
ifinwater killit
enda