setdefname bloodcm.def
setcfgname bcm.cfg
setgamename BloodCM 12.2016

include blcons/defs.con
include blcons/user.con
include blcons/global.con
include blcons/physics.con
include blcons/phys1.con
//include blcons/bloodmethods.con
include blcons/aiblood.con
include blcons/invis.con
include blcons/hud.con
include blcons/cheats.con
include blcons/particles.con
include blcons/weapons.con
include blcons/sprites.con
include blcons/enemies.con
include blcons/proj_anim.con

onevent EVENT_ENTERLEVEL
	setarray FLICKER3[0] 75
	setarray FLICKER3[1] 100
	setarray FLICKER3[2] 100
	setarray FLICKER3[3] 100
	setarray FLICKER3[4] 100
	setarray FLICKER3[5] 75
	setarray FLICKER3[6] 100
	setarray FLICKER3[7] 100
	setarray FLICKER3[8] 100
	setarray FLICKER3[9] 100
	setarray FLICKER3[10] 100
	setarray FLICKER3[11] 100
	setarray FLICKER3[12] 50
	setarray FLICKER3[13] 100
	setarray FLICKER3[14] 75
	setarray FLICKER3[15] 100
	setarray FLICKER3[16] 100
	setarray FLICKER3[17] 100
	setarray FLICKER3[18] 100
	setarray FLICKER3[19] 50
	setarray FLICKER3[20] 25
	setarray FLICKER3[21] 75
	setarray FLICKER3[22] 75
	setarray FLICKER3[23] 75
	setarray FLICKER3[24] 100
	setarray FLICKER3[25] 100
	setarray FLICKER3[26] 75
	setarray FLICKER3[27] 100
	setarray FLICKER3[28] 100
	setarray FLICKER3[29] 100
	setarray FLICKER3[30] 100
	setarray FLICKER3[31] 100
	setarray FLICKER3[32] 50
	setarray FLICKER3[33] 100
	setarray FLICKER3[34] 100
	setarray FLICKER3[35] 100
	setarray FLICKER3[36] 75
	setarray FLICKER3[37] 100
	setarray FLICKER3[38] 100
	setarray FLICKER3[39] 100
	setarray FLICKER3[40] 100
	setarray FLICKER3[41] 100
	setarray FLICKER3[42] 100
	setarray FLICKER3[43] 100
	setarray FLICKER3[44] 100
	setarray FLICKER3[45] 100
	setarray FLICKER3[46] 50
	setarray FLICKER3[47] 25
	setarray FLICKER3[48] 0
	setarray FLICKER3[49] 25
	setarray FLICKER3[50] 0
	setarray FLICKER3[51] 25
	setarray FLICKER3[52] 0
	setarray FLICKER3[53] 25
	setarray FLICKER3[54] 0
	setarray FLICKER3[55] 50
	setarray FLICKER3[56] 75
	setarray FLICKER3[57] 100
	setarray FLICKER3[58] 100
	setarray FLICKER3[59] 100
	setarray FLICKER3[60] 100
	setarray FLICKER3[61] 100
	setarray FLICKER3[62] 100
	setarray FLICKER3[63] 100
	
	
	setarray FLICKER1[0] 100
	setarray FLICKER1[1] 100
	setarray FLICKER1[2] 100
	setarray FLICKER1[3] 100
	setarray FLICKER1[4] 100
	setarray FLICKER1[5] 0
	setarray FLICKER1[6] 0
	setarray FLICKER1[7] 100
	setarray FLICKER1[8] 0
	setarray FLICKER1[9] 0
	setarray FLICKER1[10] 0
	setarray FLICKER1[11] 0
	setarray FLICKER1[12] 0
	setarray FLICKER1[13] 0
	setarray FLICKER1[14] 100
	setarray FLICKER1[15] 0
	setarray FLICKER1[16] 100
	setarray FLICKER1[17] 100
	setarray FLICKER1[18] 0
	setarray FLICKER1[19] 0
	setarray FLICKER1[20] 100
	setarray FLICKER1[21] 100
	setarray FLICKER1[22] 0
	setarray FLICKER1[23] 100
	setarray FLICKER1[24] 0
	setarray FLICKER1[25] 0
	setarray FLICKER1[26] 100
	setarray FLICKER1[27] 0
	setarray FLICKER1[28] 100
	setarray FLICKER1[29] 100
	setarray FLICKER1[30] 100
	setarray FLICKER1[31] 100
	setarray FLICKER1[32] 0
	setarray FLICKER1[33] 0
	setarray FLICKER1[34] 0
	setarray FLICKER1[35] 0
	setarray FLICKER1[36] 100
	setarray FLICKER1[37] 0
	setarray FLICKER1[38] 100
	setarray FLICKER1[39] 0
	setarray FLICKER1[40] 100
	setarray FLICKER1[41] 100
	setarray FLICKER1[42] 0
	setarray FLICKER1[43] 100
	setarray FLICKER1[44] 0
	setarray FLICKER1[45] 0
	setarray FLICKER1[46] 100
	setarray FLICKER1[47] 100
	setarray FLICKER1[48] 0
	setarray FLICKER1[49] 100
	setarray FLICKER1[50] 100
	setarray FLICKER1[51] 0
	setarray FLICKER1[52] 100
	setarray FLICKER1[53] 0
	setarray FLICKER1[54] 0
	setarray FLICKER1[55] 100
	setarray FLICKER1[56] 0
	setarray FLICKER1[57] 0
	setarray FLICKER1[58] 100
	setarray FLICKER1[59] 100
	setarray FLICKER1[60] 0
	setarray FLICKER1[61] 100
	setarray FLICKER1[62] 100
	setarray FLICKER1[63] 100
	
	setarray FLICKER2[0] 100
	setarray FLICKER2[1] 100
	setarray FLICKER2[2] 75
	setarray FLICKER2[3] 50
	setarray FLICKER2[4] 25
	setarray FLICKER2[5] 0
	setarray FLICKER2[6] 25
	setarray FLICKER2[7] 50
	setarray FLICKER2[8]75
	setarray FLICKER2[9] 50
	setarray FLICKER2[10] 25
	setarray FLICKER2[11] 0
	setarray FLICKER2[12] 25
	setarray FLICKER2[13] 50
	setarray FLICKER2[14] 75
	setarray FLICKER2[15] 50
	setarray FLICKER2[16] 0
	setarray FLICKER2[17] 50
	setarray FLICKER2[18] 25
	setarray FLICKER2[19] 0
	setarray FLICKER2[20] 25
	setarray FLICKER2[21] 50
	setarray FLICKER2[22] 100
	setarray FLICKER2[23] 100
	setarray FLICKER2[24] 75
	setarray FLICKER2[25] 50
	setarray FLICKER2[26] 0
	setarray FLICKER2[27] 25
	setarray FLICKER2[28] 50
	setarray FLICKER2[29] 50
	setarray FLICKER2[30] 100
	setarray FLICKER2[31] 50
	setarray FLICKER2[32] 75
	setarray FLICKER2[33] 100
	setarray FLICKER2[34] 75
	setarray FLICKER2[35] 100
	setarray FLICKER2[36] 50
	setarray FLICKER2[37] 25
	setarray FLICKER2[38] 0
	setarray FLICKER2[39] 25
	setarray FLICKER2[40] 50
	setarray FLICKER2[41] 75
	setarray FLICKER2[42] 75
	setarray FLICKER2[43] 50
	setarray FLICKER2[44] 100
	setarray FLICKER2[45] 100
	setarray FLICKER2[46] 75
	setarray FLICKER2[47] 75
	setarray FLICKER2[48] 50
	setarray FLICKER2[49] 25
	setarray FLICKER2[50] 0
	setarray FLICKER2[51] 25
	setarray FLICKER2[52] 50
	setarray FLICKER2[53] 75
	setarray FLICKER2[54] 50
	setarray FLICKER2[55] 25
	setarray FLICKER2[56] 0
	setarray FLICKER2[57] 0
	setarray FLICKER2[58] 50
	setarray FLICKER2[59] 75
	setarray FLICKER2[60] 100
	setarray FLICKER2[61] 75
	setarray FLICKER2[62] 100
	setarray FLICKER2[63] 100
	
endevent

// Process input

onevent EVENT_PROCESSINPUT
ifvarg inv_count 0 {
	addvar inv_count 1
	ifvarg inv_count 20
		setvar inv_count 0
}
getinput[THISACTOR].bits num
ifvarand num 1073741824
ifp palive
{
	getplayer[THISACTOR].inven_icon tmp
	ifvare tmp 11
	{
		ifvarg BEASTVISIONAM 0
		ifvare inv_count 0
		{ ifvare BEASTVON 0 { sound POWERUP setvar BEASTVON 1 } else { setvar BEASTVON 0 } setvar inv_count 1 } 
	}
	ifvare tmp 9
	{
		ifinwater
		ifvarg DIVINGSUITAM 0
		ifvare inv_count 0
		{ ifvare DIVINGSUITON 0 { sound POWERUP setvar DIVINGSUITON 1 } else { setvar DIVINGSUITON 0 } setvar inv_count 1 } 
	}
	ifvare tmp 8
	{
		ifvarg DOCTORSBAGAM 0 { 
			ifvare inv_count 0 { setvar DOCTORSBAGON 1 } setvar inv_count 1 
		} else state other_item

	}
	ifvare tmp 12
	{
		ifvarg BOOTSOFJUMPINGAM 0
		ifvare inv_count 0
		{ ifvare JBOOTSON 0 { sound POWERUP setvar JBOOTSON 1 } else { setvar JBOOTSON 0 } setvar inv_count 1 } 
	}
	ifvare tmp 10
	{
		ifvarg CRYSTALLBALLAM 0
		ifvare inv_count 0
		{ ifvare CRBALLON 0 { sound POWERUP setvar CRBALLON 1 } else { setvar CRBALLON 0 } setvar inv_count 1 } 
	}
}
		
ifvare CURRWEAP 5 ifvare player[THISACTOR].kickback_pic 0 { ifvarand num 4 nullop else setvar TNTCOUNT 0 }

getplayer[THISACTOR].inven_icon tmp
ifvare tmp 1 { setplayer[THISACTOR].inven_icon 8 } else
ifvare tmp 0 
{ 
ifvarg DOCTORSBAGAM 0 { setplayer[THISACTOR].inven_icon 8 } else
ifvarg DIVINGSUITAM 0 { setplayer[THISACTOR].inven_icon 9 } else
ifvarg CRYSTALLBALLAM 0 { setplayer[THISACTOR].inven_icon 10 } else
ifvarg BEASTVISIONAM 0 { setplayer[THISACTOR].inven_icon 11 } else
ifvarg BOOTSOFJUMPINGAM 0 { setplayer[THISACTOR].inven_icon 12 }

}

	state tommygunprocessinput
	state spraycanprocessinput
	state teslaprocessinput
	
endevent

onevent EVENT_DISPLAYROOMS
ifactor APLAYER
{
	setvarvar camera_x camerax
	setvarvar camera_y cameray
	setvarvar camera_z cameraz
	
	ifvarg DRUNKCOUNT 0
	{
		cos crd hz1
		mulvarvar crd DRUNKCOUNT
		shiftvarr crd 13
		addvarvar cameraang crd
		sin crd hz2
		shiftvarr crd 9
		addvarvar camerahoriz crd
	} 
	ifvare QUAKEACTIVE 1
	{
		setvarvar quake_ang cameraang
		randvar quake_rand 2
		ifrnd 128 mulvar quake_rand -1
		addvarvar cameraang quake_rand
		mulvar quake_rand 64
		ifrnd 128 mulvar quake_rand -1
		addvarvar cameraz quake_rand
	}
	ifvare QUAKEACTIVE 2
	{
		setvarvar quake_ang cameraang
		randvar quake_rand 4
		ifrnd 128 mulvar quake_rand -1
		addvarvar cameraang quake_rand
		mulvar quake_rand 64
		ifrnd 128 mulvar quake_rand -1
		addvarvar cameraz quake_rand
	}
	ifvare QUAKEACTIVE 3
	{
		setvarvar quake_ang cameraang
		randvarvar quake_rand QUAKEAMPL
		ifrnd 128 mulvar quake_rand -1
		addvarvar cameraang quake_rand
		mulvar quake_rand 64
		ifrnd 128 mulvar quake_rand -1
		addvarvar cameraz quake_rand
	}
}

	state tommygundisplayroom
	state shotgundisplayroom
	ifp pducking 
	{ 
		ifvare TIMECOUNT 1	{ addvar cameraz 200 }
		ifvare TIMECOUNT 2	{ addvar cameraz 400 }
		ifvare TIMECOUNT 3	{ addvar cameraz 600 }
		ifvare TIMECOUNT 4	{ addvar cameraz 800 }
		ifvare TIMECOUNT 5	{ addvar cameraz 850 }
		ifvare TIMECOUNT 6	{ addvar cameraz 900 }
		ifvare TIMECOUNT 7	{ addvar cameraz 950 }
		ifvare TIMECOUNT 8	{ addvar cameraz 1000 }
		ifvare TIMECOUNT 9	{ addvar cameraz 900 }
		ifvare TIMECOUNT 10	{ addvar cameraz 700 }
		ifvare TIMECOUNT 11	{ addvar cameraz 500 }
		ifvare TIMECOUNT 12	{ addvar cameraz 300 }
		ifvare TIMECOUNT 13	{ addvar cameraz 250 }
		ifvare TIMECOUNT 14	{ addvar cameraz 200 }
		ifvare TIMECOUNT 15	{ addvar cameraz 150 }
		ifvare TIMECOUNT 16	{ addvar cameraz 100 }
		ifvare TIMECOUNT 17	{ addvar cameraz 50 }
	} else setvar TIMECOUNT 0
	ifvare fataldead 1 
	{ 
		addvar cameraz 6144
	}
endevent

onevent EVENT_GAME

getactor[PLAYERID].statnum astatnum //игрок умирает от динамита и "испаряется", ломая игру, нельзя восстановится
ifvare astatnum 1024 ifvare sprite[PLAYERID].picnum APLAYER {
	ifvarl sprite[PLAYERID].extra 1 {
		ifvarn QUAKETIME 0 { 
			quote 13 
			setvar QUAKEACTIVE 0
			setvar QUAKETIME 0 
		}
		ifhitspace {
			action PSTAND
			spawn CALEBLYINGDEAD
			setvar paaction 0
			resetplayer
		}
	}
}

ifvare deb_menu 2
ifvarg deb_getid 0 {
	
	getactorvar[deb_getid].ai_aistate deb_enemytype
	getactorvar[deb_getid].ai_target deb_targetid
	getactorvar[deb_getid].ai_goalang deb_movtype
	getactorvar[deb_getid].ai_canmove deb_hitid
	getactorvar[deb_getid].ai_debdist deb_savex
	getactorvar[deb_getid].ai_losang deb_savey
	getactorvar[deb_getid].sprXVel deb_evx
	getactorvar[deb_getid].sprYVel deb_evy
}
			

	//hardcode'd actors
		ifactor FIREEXT { cstat 337 } //Огнетушитель
		ifactor EXPLOSION2 { ifspawnedby FIREEXT sound EXPLODCL spawn EXPLOSION4 killit }
		ifactor BULLETHOLE { cstator 194 sizeat  12 12 }
	//hardcode'd actors
	
	state actionsprite_trigger //trigger.con
	
	state sprite_to_actor //obj_statnum, spritetoactor.con

	state enemy_statenum

	state weaponpitchforkgame
	state flaregamestate
	state weaponshotgungame
	state weaponnapalmgame
	state weapondynamitegame
	state weaponspraycangame
	state weaponteslagame
	state weaponhellstaffgame

	state newsectoreffector
	state projectile_anim

	ifactor EXPLOSION4
	{
		findnearactor ZOMBIERISE 2048 spriteid
		ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else

		ifspawnedby TNTFLOOR nullop else ifspawnedby PROXIMITYFLOOR nullop else ifspawnedby REMOTEFLOOR nullop else ifspawnedby ENEMYTNTFLOOR nullop else
		{
			findnearactor ZOMBIE 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor HERETIC 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor EVILHAND 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor FATRAT 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor SPIDER 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor BATSLEEP 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor BAT 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor GARGOYLE 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor BUTCHER 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor GILLBEAST 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor HELLDOG 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor CIVILIAN 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor POD 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor TENTACLE 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor TCHERNOBOG 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			
			findnearsprite APLAYER 1024 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } }
		}
	}
	ifactor EXPLOSION3
	{
		findnearactor ZOMBIERISE 2048 spriteid
		ifvarn spriteid -1 { setactorvar[spriteid].flamedamage 25 } else

		ifspawnedby TNTFLOOR nullop else ifspawnedby PROXIMITYFLOOR nullop else ifspawnedby REMOTEFLOOR nullop else ifspawnedby ENEMYTNTFLOOR nullop else
		{
			findnearactor ZOMBIE 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor HERETIC 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor EVILHAND 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor FATRAT 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor SPIDER 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor BATSLEEP 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor BAT 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor GARGOYLE 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor BUTCHER 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor GILLBEAST 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor HELLDOG 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor CIVILIAN 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor POD 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor TENTACLE 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			findnearactor TCHERNOBOG 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } } else
			
			findnearsprite APLAYER 2048 spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactor[spriteid].extra extra ifvarg extra 0 setactorvar[spriteid].flamedamage 25 } }
		}
	}
	ifactor EXPLOSION6
	{
		findnearactor ZOMBIERISE 2048 spriteid
		ifvarn spriteid -1 { 
			canseespr THISACTOR spriteid fl_see
			ifvare fl_see 1 setactorvar[spriteid].flamedamage 25 
		} else
		ifspawnedby TNTFLOOR nullop else ifspawnedby PROXIMITYFLOOR nullop else ifspawnedby REMOTEFLOOR nullop else ifspawnedby ENEMYTNTFLOOR nullop else
		{
			ifspawnedby PR_NAPALM setvar DIST 2304 else setvar DIST 1024
			findnearactorvar ZOMBIE DIST spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 FATRAT DIST spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 SPIDER DIST spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 BATSLEEP DIST spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 BAT DIST spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 GARGOYLE DIST spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 BUTCHER DIST spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 GILLBEAST DIST spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 HELLDOG DIST spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 CIVILIAN DIST spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 SPIDERNET DIST spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 1 { getactorvar[spriteid].spidernet_damage spidernet_damage ifvare spidernet_damage 0 setactorvar[spriteid].flamedamage 25 } }
			findnearactorvar POD DIST spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 } } } else
			findnearactorvar TENTACLE DIST spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 } } } else
			findnearactorvar TCHERNOBOG DIST spriteid
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 } } } else
			
			findnearspritevar APLAYER DIST spriteid
			ifspawnedby STAFFPROJ nullop else
			ifvarn spriteid -1 { canseespr THISACTOR spriteid fl_see ifvare fl_see 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 } } }
		}
	}
	
	//опции для спрайтов с применением теней сектора

	getactor[THISACTOR].pal pal
	getactor[THISACTOR].statnum astatnum
	ifvarn pal 30
	ifvare astatnum 0
	{
		getactor[THISACTOR].cstat sprite_cst
		ifvarand sprite_cst 2048 nullop else
		ifvarand sprite_cst 16 
		{
			ifvarn sprite_wall -1 ifvarl sprite_dist 200 //если спрайт висит близко к стене
			{
				getwall[sprite_wall].shade sprite_shade
				setactor[THISACTOR].shade sprite_shade
			} else // если далеко от стены, тогда применение тени с пола
			{
				getactor[THISACTOR].sectnum sectnum
				getsector[sectnum].floorshade tmp
				setactor[THISACTOR].shade tmp
			}
		}
		else //применение теней с пола, если сектор со skybox'ом
		{
			getactor[THISACTOR].picnum picnum //фонари
			switch picnum
			case 5626
			case 5813
			case 5905
			case 7613
			case 5760
			case 5761
			case 5744
				cstator 2048
				setactor[THISACTOR].shade -128
			break
			default
			getactor[THISACTOR].sectnum sectnum
			getsector[sectnum].ceilingstat tmp
			ifvarand tmp 1 //иначе спрайт берет тень с потолка
			{
				cstator 2048
				setactor[THISACTOR].shade sector[sectnum].floorshade
			}
			break
			endswitch
		}
	} else
	ifvare astatnum 1
	{
		getactor[THISACTOR].picnum picnum
		switch picnum
		case EXPLOSION3
		case EXPLOSION4
		case EXPLOSION6
		case LAMP03
		case TORCH02
		case LIGHTER1
		case LIGHTER2
		case SKULL1
		case LIGHT4
		case BVASE
		case SHOTSPARK1
		case SPARK1
		case SPARK2
		case SPARK3
		case SPRAYFLOOR
		case FIREBALL
		case ALTTESLA
		case TESLADECAL
		case BLOODFIRE1
		case BLOODFIRE2
		case FLAREFIRE
		case FLARE
		case FLARESHINE
		case PR_NAPALM
		case ALTNAPALM
		case PLASMAPROJ
		case PLASMASHINE
		case STAFFALTPROJ
		case STAFFPROJ
		case SPRAYBUNDLE 
		case LIGHTING
		case FIRESPAWN
		case TCHERNMISSLE
			setactor[THISACTOR].shade -128
		break
		case BURNINGGUY
		case GARGBURNING
		case TREE3
			ifvare lights_on 1 setactor[THISACTOR].shade -128 else
			{
				getactor[THISACTOR].sectnum sectnum
				setactor[THISACTOR].shade sector[sectnum].floorshade
			}
		break
		case ZOMBIE
		case ZOMBIERISE
		case HERETIC
		case FISH
		case SPIDER
		case PHANTASM
		case HELLDOG
		case GILLBEAST
		case GARGOYLE
		case BUTCHER
		case FATRAT
		case EVILHAND
		case CIVILIAN
		case BOSSSPIDER
		case BATSLEEP
		case BAT
		case CERBERUS
		case TCHERNOBOG
		case POD
		case TENTACLE
		case BEAST
		ifvare BEASTVON 0
		{
			ifvare pfire 1 {
				getactor[THISACTOR].sectnum sectnum
				randvar tmp 15
				getsector[sectnum].floorshade enemyshade
				subvarvar enemyshade tmp
				subvar enemyshade 10
				setactor[THISACTOR].shade enemyshade
			} else {
				ifvarn enemyshoot 1
				{
					ifvarn enemy_tesla 1 {
						getactor[THISACTOR].sectnum sectnum
						setactor[THISACTOR].shade sector[sectnum].floorshade
					} else {
						randvar enemyshade 64 
						setactor[THISACTOR].shade enemyshade
					}
				} else setactor[THISACTOR].shade 0
			}
		}
		break
		default
		getactor[THISACTOR].cstat sprite_cst
		ifvarand sprite_cst 2048 nullop else
		ifvarand sprite_cst 16 
		{
			ifvarn sprite_wall -1 ifvarl sprite_dist 200
			{
				getwall[sprite_wall].shade sprite_shade
				setactor[THISACTOR].shade sprite_shade
			} else
			{
				getactor[THISACTOR].sectnum sectnum
				getsector[sectnum].floorshade tmp
				setactor[THISACTOR].shade tmp
			}
		} else //применение теней с пола, если сектор со skybox'ом
		{
			getactor[THISACTOR].sectnum sectnum
			getsector[sectnum].ceilingstat tmp
			ifvarand tmp 1
				setactor[THISACTOR].shade sector[sectnum].floorshade
			
		}
		break
		endswitch
	} 
endevent

onevent EVENT_KILLIT
	getactor[THISACTOR].picnum picnum

	ifvarg picnum 5120
	ifvarn picnum BL_BUTTON1
	ifvarn picnum BL_BUTTON1ON
	ifvarn picnum BL_BUTTON2
	ifvarn picnum BL_BUTTON3
	ifvarn picnum BL_BUTTON4
	ifvarn picnum BL_BUTTON5
	ifvarn picnum BL_BUTTON6
	ifvarn picnum LIGHT_SWITCH
	ifvarn picnum WHEEL
	ifvarn picnum EXITBUTTON
	ifvarn picnum BL_MULTISWITCH
	ifvarn picnum MULTIBUTTON				
	ifvarg se_yvel 0 {

		setvar sectorid 0
		whilevarvarn sectorid NUMSECTORS 
		{
			headspritesect spriteid sectorid
			whilevarn spriteid -1 
			{
				getactorvar[spriteid].se_xvel rx_can
				
				ifvarvare se_yvel rx_can { getactorvar[spriteid].active tmp addvar tmp 1 setactorvar[spriteid].active tmp setactorvar[spriteid].activatedby THISACTOR }
				nextspritesect spriteid spriteid
			}
			addvar sectorid 1
		}
	}

	ifactor SEENINE sound EXPLODCL
	state killit_jibsstate
	state weaponspraycankillit
	state flarekillitstate
	state weapondynamitekillit
	state weaponteslakillit
	state weaponnapalmkillit
	
	ifactor HELLFLAME
	{
		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 FATRAT
					case BATSLEEP
					case BAT
					case GARGOYLE
					case BUTCHER
					case PHANTASM
					case GILLBEAST
					case HELLDOG
					case SPIDER
					case CIVILIAN
					case APLAYER
					case TCHERNOBOG
					case POD
					case TENTACLE
					case BEAST
					{ 
						getactor[spriteid].extra extra ifvarg extra 0
						{
							getactorvar[spriteid].flamedamage tmp
							addvar tmp 8
							setactorvar[spriteid].flamedamage tmp
						}
					}
					break
				endswitch 
		}
	}
	ifactor GUNFIRE
	{
		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 FATRAT
					case BATSLEEP
					case BAT
					case GARGOYLE
					case BUTCHER
					case PHANTASM
					case GILLBEAST
					case HELLDOG
					case SPIDER
					case CIVILIAN
					case APLAYER
					case TCHERNOBOG
					case POD
					case TENTACLE
					case BEAST
					{ 
						getactor[spriteid].extra extra ifvarg extra 0
						{
							getactorvar[spriteid].flamedamage tmp
							addvar tmp 8
							setactorvar[spriteid].flamedamage tmp
						}
					}
					break
				endswitch 
		}
	}
			
	ifactor ZOMBIEHEAD
	{
		ifvarl puntcount 11 {
		espawn ZHEADFLOOR
		setactorvar[RETURN].puntcount puntcount
		setactor[RETURN].yvel active
		setactor[THISACTOR].owner spriteid
		setvar RETURN 0
		} else {
			setvarvar in1 5
			setvar in2 JIBS9
			state spawn_multiply
			setvar RETURN 0
		}
	}

	getactor[THISACTOR].picnum picnum
	switch picnum
	case PLASMAPROJ
	case ALTTESLA
	case ALTNAPALM
	case FLARE
	case TNTBUNDLE
	case REMOTEBUNDLE
	case PROXIMITYBUNDLE
	case STAFFPROJ
	case STAFFALTPROJ
	case SPRAYBUNDLE
	case ZOMBIEHEAD
	case PAIL
	case RADIUSEXPLOSION	
		getactor[THISACTOR].htmovflag wallid
		addvar wallid 32768
		ifvarg wallid -1 ifvarl wallid 16384
		{ 
			state broken_proj
			setvar RETURN 0	
		}
	break
	case PR_NAPALM
		state pr_napalmkillit
	break
	case SHOTSPARK1
	getactor[THISACTOR].htg_t 6 wallid
		ifvarg wallid -1
		{
			getwall[wallid].hitag rx_can
			setvar wallid2 0
			setvarvar wallnum NUMWALLS
			subvar wallnum 1
			whilevarvarn wallid2 wallnum
			{
				getwall[wallid2].hitag tx_can
				ifvarn tx_can 0 ifvarn rx_can 0
				ifvarvare rx_can tx_can
				{
					   setvarvar broken_id wallid2
					   state brokenwalls
				}
				addvar wallid2 1
			}
				
			setvarvar broken_id wallid
			state brokenwalls
		}
	break
	endswitch

	state sprkillit_trigger
	
endevent

onevent EVENT_EGS
	state weapondynamiteegs
endevent
