state statnum15_state

	setvar sectorid 0
	whilevarvarn sectorid NUMSECTORS 
	{
		headspritesect spriteid sectorid
		whilevarn spriteid -1 
		{
			getactorvar[spriteid].se_xvel tx_can
			getactorvar[spriteid].obj_statnum tmp
			ifvare tmp 15 ifvarn se_xvel 0 ifvarvare se_xvel tx_can { setactorvar[spriteid].stat14_kill 1 }
			nextspritesect spriteid spriteid
		}
		addvar sectorid 1
	}
	
	setvarvar in1 obj_hitag
	ifvare obj_lotag 1 setvar in2 SPARK1 else
	ifvare obj_lotag 2 setvar in2 SPARK2 else
	ifvare obj_lotag 3 setvar in2 SPARK3 else
	ifvare obj_lotag 4 setvar in2 SPARK4 else
	ifvare obj_lotag 5 setvar in2 SPARK5 else
	ifvare obj_lotag 6 setvar in2 SPARK6 else
	ifvare obj_lotag 7 setvar in2 SPARK7 else
	ifvare obj_lotag 8 setvar in2 SCRAP_PART else
	ifvare obj_lotag 9 setvar in2 SCRAP2_PART else
	ifvare obj_lotag 10 { setvar in2 GLASS_PART state spawn_multiply setvar in2 SCRAP_PART } else
	ifvare obj_lotag 11 setvar in2 GLASS_PART2 else
	ifvare obj_lotag 12 setvar in2 GLASS_PART3 else
	ifvare obj_lotag 13 setvar in2 GLASS_PART4 else
	ifvare obj_lotag 14 setvar in2 GLASS_PART5 else
	ifvare obj_lotag 15 setvar in2 JIBS9 else
	ifvare obj_lotag 16 
	{
		getactor[THISACTOR].htang htang
		setvar in1 1
		setvar in2 JIBS7
		state spawn_multiply
		setactorvar[RETURN].htangsaved htang
		setactorvar[RETURN].htextrasaved paextra
		ifwasweapon RADIUSEXPLOSION { setactorvar[RETURN].explosionvar 1 }

		setvar in1 10
		setvar in2 JIBS9
		state spawn_multiply
						
		setvar in1 1
		setvar in2 JIBS8
		state spawn_multiply
		setactorvar[RETURN].htangsaved htang
		setactorvar[RETURN].htextrasaved paextra
		ifwasweapon RADIUSEXPLOSION { setactorvar[RETURN].explosionvar 1 }
				
		setvar in1 2
		setvar in2 JIBS10
		state spawn_multiply
		setactorvar[RETURN].htangsaved htang
		setactorvar[RETURN].htextrasaved paextra
		ifwasweapon RADIUSEXPLOSION { setactorvar[RETURN].explosionvar 1 }
				
		setvar in1 2
		setvar in2 JIBS11
		state spawn_multiply
		setactorvar[RETURN].htangsaved htang
		setactorvar[RETURN].htextrasaved paextra
		ifwasweapon RADIUSEXPLOSION { setactorvar[RETURN].explosionvar 1 }
				
		setvar in1 1
		setvar in2 JIBS12
		state spawn_multiply
		setactorvar[RETURN].htangsaved htang
		setactorvar[RETURN].htextrasaved paextra
		ifwasweapon RADIUSEXPLOSION { setactorvar[RETURN].explosionvar 1 }
				
		ifrnd 64 { sound FLSHDOR1 } else ifrnd 64 { sound FLSHDOR2 }
		ifrnd 127 { sound FLSHSTP1 sound FLSHSTP2 }
		state bloodspraystate
		state bloodspraystate
	}
	ifvare obj_lotag 17
	{
		setvarvar in1 obj_hitag
		setvar in2 GLASS_PART
		state spawn_multiply
		setvarvar in1 obj_hitag
		setvar in2 GLASS_PART2
		state spawn_multiply
		setvarvar in1 obj_hitag
		setvar in2 GLASS_PART3
		state spawn_multiply
		setvarvar in1 obj_hitag
		setvar in2 GLASS_PART4
		state spawn_multiply
		setvarvar in1 obj_hitag
		setvar in2 GLASS_PART5
		state spawn_multiply
	}
	ifvare obj_lotag 18 
	{
		getactor[THISACTOR].htang htang
		setvar in1 1
		setvar in2 JIBS7
		state spawn_multiply
		setactorvar[RETURN].htangsaved htang
		setactorvar[RETURN].htextrasaved paextra
		ifwasweapon RADIUSEXPLOSION { setactorvar[RETURN].explosionvar 1 }

		setvar in1 10
		setvar in2 JIBS9
		state spawn_multiply
						
		setvar in1 1
		setvar in2 JIBS8
		state spawn_multiply
		setactorvar[RETURN].htangsaved htang
		setactorvar[RETURN].htextrasaved paextra
		ifwasweapon RADIUSEXPLOSION { setactorvar[RETURN].explosionvar 1 }
				
		setvar in1 1
		setvar in2 JIBS12
		state spawn_multiply
		setactorvar[RETURN].htangsaved htang
		setactorvar[RETURN].htextrasaved paextra
		ifwasweapon RADIUSEXPLOSION { setactorvar[RETURN].explosionvar 1 }
				
		ifrnd 64 { sound FLSHDOR1 } else ifrnd 64 { sound FLSHDOR2 }
		ifrnd 127 { sound FLSHSTP1 sound FLSHSTP2 }
		state bloodspraystate
		state bloodspraystate
	}
	ifvarn obj_lotag 16 
	ifvarn obj_lotag 17
	ifvarn obj_lotag 18
	{
		setvarvar utl_tmp1 in1
		whilevarn utl_tmp1 0
		{
			getactor[THISACTOR].pal pal
			espawnvar in2
			setactor[RETURN].pal pal
			getactor[RETURN].x x
			getactor[RETURN].y y
			getactor[RETURN].z z
			randvar peractor 300
			ifrnd 128 mulvar peractor -1
			addvarvar x peractor
			randvar peractor 300
			ifrnd 128 mulvar peractor -1
			addvarvar y peractor
			randvar peractor 8000
			ifrnd 128 mulvar peractor -1
			addvarvar z peractor
			setactor[RETURN].x x
			setactor[RETURN].y y
			setactor[RETURN].z z
			subvar utl_tmp1 1
		}
	}
	
	ifvare obj_sparks2 1 setvar in2 SPARK1 else
	ifvare obj_sparks2 2 setvar in2 SPARK2 else
	ifvare obj_sparks2 3 setvar in2 SPARK3 else
	ifvare obj_sparks2 4 setvar in2 SPARK4 else
	ifvare obj_sparks2 5 setvar in2 SPARK5 else
	ifvare obj_sparks2 6 setvar in2 SPARK6 else
	ifvare obj_sparks2 7 setvar in2 SPARK7 else
	ifvare obj_sparks2 8 setvar in2 SCRAP_PART else
	ifvare obj_sparks2 9 setvar in2 SCRAP2_PART else
	ifvare obj_sparks2 10 { setvar in2 GLASS_PART state spawn_multiply setvar in2 SCRAP_PART } else
	ifvare obj_sparks2 11 setvar in2 GLASS_PART2 else
	ifvare obj_sparks2 12 setvar in2 GLASS_PART3 else
	ifvare obj_sparks2 13 setvar in2 GLASS_PART4 else
	ifvare obj_sparks2 14 setvar in2 GLASS_PART5 else
	ifvare obj_sparks2 15 setvar in2 JIBS9 
	
	ifvarg obj_sparks2 0 {
		setvarvar utl_tmp1 in1
		whilevarn utl_tmp1 0
		{
			getactor[THISACTOR].pal pal
			espawnvar in2
			setactor[RETURN].pal pal
			getactor[RETURN].x x
			getactor[RETURN].y y
			getactor[RETURN].z z
			randvar peractor 300
			ifrnd 128 mulvar peractor -1
			addvarvar x peractor
			randvar peractor 300
			ifrnd 128 mulvar peractor -1
			addvarvar y peractor
			randvar peractor 8000
			ifrnd 128 mulvar peractor -1
			addvarvar z peractor
			setactor[RETURN].x x
			setactor[RETURN].y y
			setactor[RETURN].z z
			subvar utl_tmp1 1
		}
	}

	ifvarn obj_sound -1 soundvar obj_sound
	setvar active 0
	setvar stat14_kill 0
	ifvarand obj_zvel 8 { setactor[THISACTOR].extra 1 setactor[THISACTOR].htextra -1 } else killit
ends

state sprite_to_actor //event_game
ifvare obj_statnum 15
{	
	setactor[THISACTOR].cstat stat14_cstat
	ifvarl stat14_cstat 0 
	{ ifvarand stat14_cstat 257 ifvarand obj_zvel 4 { xorvar stat14_cstat 257 setactor[THISACTOR].cstat stat14_cstat } }
	else
	{
		ifvarand stat14_cstat 16
		{
			ifvarand stat14_cstat 2048 nullop else
			{
			getactor[THISACTOR].sectnum tmp
			getsector[tmp].floorshade shade
			setactor[THISACTOR].shade shade
			}
		} 
	}

	getactor[THISACTOR].htextra htextra

	ifvarand obj_zvel 2
	{
		getactor[THISACTOR].cstat stat14_cstat
		ifvarand stat14_cstat 256 nullop else
		{
			setvar stat14_rad 1536
			findnearactorvar EXPLOSION3 stat14_rad spriteid
			ifvarn spriteid -1 state statnum15_state
			findnearactorvar EXPLOSION4 stat14_rad spriteid
			ifvarn spriteid -1 state statnum15_state
			findnearactorvar EXPLOSION6 stat14_rad spriteid
			ifvarn spriteid -1 state statnum15_state
		}
	}
	ifvarand obj_zvel 3
	{
		ifvare stat14_kill 1 state statnum15_state
		ifvarn htextra -1
		{	
			ifvarand obj_zvel 1
			{
				getactor[THISACTOR].htpicnum htpicnum 
				ifvare htpicnum 2595 { ifvarvarg htextra obj_extra { state statnum15_state } } else setactor[THISACTOR].htextra 0
			}
			ifvarand obj_zvel 2
			{	
				getactor[THISACTOR].htpicnum htpicnum 	
				switch htpicnum
					case PR_NAPALM
					case TCHERNMISSLE
					case ALTNAPALM
					case FIREBALL
					case TNTFLOOR
					case REMOTEFLOOR
					case PROXIMITYFLOOR
					case ALTTESLA
					case STAFFPROJ
					case RADIUSEXPLOSION
					ifvarg obj_extra 0
					{
						addvar obj_count 1
						ifvarvare obj_count obj_extra state statnum15_state else
						ifvarvarg obj_count obj_extra state statnum15_state
						setactor[THISACTOR].htextra -1
					} else
					state statnum15_state
					break
				endswitch
			}
			ifvare obj_zvel 3 state statnum15_state //1+2
			ifvarand obj_zvel 4 state statnum15_state //иначе не работает при obj_zvel = 7
		}
	} 
	ifvarand obj_zvel 4
	{
		ifvare active 1
			state statnum15_state
		
	}
} 
ifvare obj_statnum 16
{
	getplayer[THISACTOR].posx px
	getplayer[THISACTOR].posy py
	getplayer[THISACTOR].posz pz
	getplayer[THISACTOR].cursectnum psector
	getplayer[THISACTOR].ang pang
	getplayer[THISACTOR].horiz phoriz
	subvar phoriz 100
	mulvar phoriz -2048
	cos mycos pang
	sin mysin pang
	ifvarn psector -1 hitscan px py pz psector mycos mysin phoriz RETURN RETURN obj_sprid RETURN RETURN RETURN 0x81c10030h //2208432128 // 4294901808 //1+64+128+256+32768 = 33217
	
	ifpdistl 1280 ifp palive ifvarvare obj_sprid THISACTOR
	{
		ifhitspace
		{	
			ifvare buttonhit 0
			{
				ifvare se_xvel 0
				ifvarn button_off 1
				{
						ifvarvarn VAR_SKULLKEY 1
						ifvare obj_zvel 1
						{
							quote 137
							soundonce 473
						} else
						ifvarvarn VAR_EYEKEY 1
						ifvare obj_zvel 2
						{
							quote 137
							soundonce 473
						} else
						ifvarvarn VAR_FIREKEY 1
						ifvare obj_zvel 3
						{
							quote 137
							soundonce 473
						} else
						ifvarvarn VAR_DAGGERKEY 1
						ifvare obj_zvel 4
						{
							quote 137
							soundonce 473
						} else
						ifvarvarn VAR_SPIDERKEY 1
						ifvare obj_zvel 5
						{
							quote 137
							soundonce 473
						} else
						ifvarvarn VAR_MOONKEY 1
						ifvare obj_zvel 6
						{
							quote 137
							soundonce 473
						}
						else
						{
							ifvarn obj_sound 0 { soundvar obj_sound }
							ifaction 0 
							{ 
								getactor[THISACTOR].picnum picnum
								addvarvar picnum obj_picplus 
								setactor[THISACTOR].picnum picnum
								action ONE 
							} else 
							ifaction ONE 
							{ 
							    getactor[THISACTOR].picnum picnum
								subvarvar picnum obj_picplus 
								setactor[THISACTOR].picnum picnum
								action 0 
							}
							
							state rx_cansetactive
							operateactivators obj_lotag THISACTOR
							operaterespawns obj_lotag
							operatemasterswitches obj_lotag
							ifvare obj_owner 1 { setvar button_off 1 } 
						}
				} 
				else
				{	
					ifvarn active 0
					ifvarn button_off 1
					{
							operateactivators obj_lotag THISACTOR
							operaterespawns obj_lotag
							operatemasterswitches obj_lotag
							ifvarn obj_sound 0 { soundvar obj_sound }
							ifaction 0 { 
							action ONE 
							getactor[THISACTOR].picnum picnum
							addvarvar picnum obj_picplus 
							setactor[THISACTOR].picnum picnum
							} else ifaction ONE 
							{ 
							action 0 
							getactor[THISACTOR].picnum picnum
							subvarvar picnum obj_picplus 
							setactor[THISACTOR].picnum picnum
							}
							state rx_cansetactive
							ifvare obj_owner 1 { setvar button_off 1 } 
					}
				}
				setvar buttonhit 1
			}
		}
		else
		{
			checkactivatormotion obj_lotag ifvare RETURN 0 setvar buttonhit 0
		}
	}
}
ifvare obj_statnum 17
{
	ifvare active 1
	{
		ifvare obj17action 0 
		{ 
			getactor[THISACTOR].picnum picnum
			addvarvar picnum obj_picplus 
			setactor[THISACTOR].picnum picnum
			setvar obj17action 1 
		} else 
		ifvare obj17action 1 
		{ 
			getactor[THISACTOR].picnum picnum
			subvarvar picnum obj_picplus 
			setactor[THISACTOR].picnum picnum
			setvar obj17action 0 
		}
		setvar active 0
	}
}
ends