gamevar st_enemy 0 0
gamevar st_trigger 0 0
gamevar st_respawn 0 0


defstate statnum15
	ifn sprite[i].statnum 15 
	deletesprite i
	else changespritestat i 666	
ends

defstate sk_corr
	switch sprite[i].picnum
			case 7945
			case 7940
			case 6390
			case 6690
			case 6290
			case 7440
			case 8174
			case 7040
			case 7050
			case 6490
			case 6590
			case 7045
			case 8505
			case 7197
			case 7068
			case 7100
			case 20
			case 18
			case 32
				
				//changespritestat i 666
				
				//ifn sprite[i].statnum 666
					deletesprite i
				
			break
		endswitch
ends


defstate skills_corr
	switch sprite[i].picnum
				case Axe_Zombie
				case Earth_Zombie
				case Cultist_w/Tommy
				case Cultist_w/Shotgun
				case HERETIC
				case Eel
				case Brown_Spider
				case GREEN_SPIDER
				case Phantasm
				case Hound
				case GillBeast
				case Flesh_Gargoyle
				case Flesh_Statue
				case BUTCHER
				case BL_Rat
				case MIME
				case BL_Hand
				case CIVILIAN
				case CIVILIAN_STAND
				case SpiderBoss
				case BATSLEEP
				case BAT
				case Cerberus
					set lotag sprite[i].lotag
					/*
						1 - 1
						2 - 2
						3 - 4
						4 - 8
						5 - 16
						
						single - 32 /-----480
						coop - 64
						team - 128
						dm - 256
						
					*/
					ife lotag 2 set sprite[i].lotag 510
					ife lotag 3 set sprite[i].lotag 508
					ife lotag 4 set sprite[i].lotag 504
					ife lotag 5 set sprite[i].lotag 496	
					changespritestat i 0
					
				break
			endswitch
	ends
	
	
	
defstate respawn_corr

//корректировка респавна
set st_enemy i

	ifvarg sprite[st_enemy].yvel 0 {
		for st_trigger allsprites {
			ifvarvare sprite[st_enemy].yvel sprite[st_trigger].xvel {
				ifvare sprite[st_trigger].picnum 18 ifvare sprite[st_trigger].zvel 5 {
					for st_respawn allsprites {
						ifvarvare sprite[st_trigger].yvel sprite[st_respawn].xvel {
						
							ifvare sprite[st_respawn].picnum 7197 {
							addlogvar st_respawn
							addlogvar sprite[st_trigger].yvel
							addlogvar sprite[st_respawn].xvel
							
							set sprite[st_enemy].xvel sprite[st_trigger].xvel
							set sprite[st_enemy].yvel 0

							set sprite[st_respawn].xvel 0
							set sprite[st_respawn].yvel sprite[st_trigger].xvel
							set sprite[st_respawn].zvel 1
							deletesprite st_trigger
							}
						}
					}
				}
			}
		}
	}


ends

defstate st_ambientsound //triggersound bit 2 to musicandsfx
ife sprite[i].picnum 19 ife sprite[i].zvel 2 {
	set sprite[i].picnum 5
	set sprite[i].zvel 1
	set sprite[i].owner 1
}
ends

defstate st_correct
ifvare correction_on 2
{

	//SPRITES //SPRITES //SPRITES //SPRITES //SPRITES //SPRITES //SPRITES //SPRITES //SPRITES
	
	for i allsprites //корректировочный скрипт для спрайтов
	{
		ifvarand bit_option 1 //корректировка некоторых спрайтов
		{
			switch sprite[i].picnum
			case 1247
			set .cstat 0 add sprite[i].z 3042
			break
			case 712 set .hitag 713 break //звук выключателя
			case 6290 { ifvarand .cstat 128 { set .cstat 0 add sprite[i].z 7168 } } break
			case 7945 { ifvarand .cstat 128 { set .cstat 0 add sprite[i].z 6144 } } break
			case 7940 { ifvarand .cstat 128 { set .cstat 0 add sprite[i].z 6144 } } break
			case 6990 { ifvarand .cstat 128 { set .cstat 0 add sprite[i].z 1536 } } break
			case 7289 //heart
			case 5678
			case 5644 //pistol
			case 1405
			case 5929
			case 7698
			case 7706
			case 5936
			case 5626
			case 5932
			case 5660
			case 5639
			case 5679
			case 5667
			case 5804
			case 5928
			case 5879
			case 5641
			case 5704
			case 5724
			case 5930
			case 5931
			case 5937
			case 5700
			case 5738
			case 5728
			case 5880
			case 7613
			case 7615
			case 7672
			case 7673
			case 7674
			case 7675
			case 7676
			case 7677
			case 5663
			case 5739 //shotgun shells
			case 5709 //tnt
			case 7714 //super
			case 5044 //flare
			case 7553 //seed
			case 5949 //akimbo
			case 5646 //tesla
			case 5830 //mirror
			
				set .cstat 0 break 
			
			case 6027 { ifvarand .cstat 128 { set .cstat 0 add sprite[i].z 6144 } } break
			case 7450 { ifvarand .cstat 128 { set .cstat 0 add sprite[i].z 4096 } } break
			case 6083 { ifvarand .cstat 128 { set .cstat 0 add sprite[i].z 8192 } } break
			case 6082 { ifvarand .cstat 128 { set .cstat 0 add sprite[i].z 8192 } } break
			case 7454 { ifvarand .cstat 128 { set .cstat 0 add sprite[i].z 2048 } } break
			case 5625 { ifvarand .cstat 128 { set .cstat 0 add sprite[i].z 3072 } } break
			case 5683 { ifvarand .cstat 128 { set .cstat 0 add sprite[i].z 5120 } } break
			case 5695 { ifvarand .cstat 128 { set .cstat 0 add sprite[i].z 8192 } } break
			case 6129 { ifvarand .cstat 128 { set .cstat 0 add sprite[i].z 4096 } } break
			case 5657 { ifvarand .cstat 128 { set .cstat 0 add sprite[i].z 5120 } } break
			case 8174 { ifvarand .cstat 128 { set .cstat 0 add sprite[i].z 8192 } } break
			case 7642
			case 7643
			case 7644
			case 7645
			case 7646
			case 7647
			case 7648
			case 7649
				set .picnum 1405 break
			case 6028 set .picnum 1247 break
			case 6247 set .picnum 546 break //CRACK1
			case 9117
			case 5873
				deletesprite i  break
			case 5386 //GLASS4
				set .zvel 3
				set .lotag 10
				ifvare .hitag 0 set .hitag 10
				set .yvel 19
				changespritestat i 15
			break
			endswitch	
		}
		ifvarand bit_option 8 //обнуление переменных спрайтов
		{
			ifvarn sprite[i].picnum TRIGGER
			ifvarn sprite[i].picnum TC_LOCKER
			ifvarn sprite[i].picnum MOVER_POINT
			ifvarn sprite[i].picnum MOVER
			ifvarn sprite[i].picnum TRIGGERSOUND
			ifvarn sprite[i].picnum TRIGGERQUOTE
			ifvarn sprite[i].picnum TIMEACTIVATOR
			ifvarn sprite[i].picnum TC_LIGHTING
			ifvarn sprite[i].picnum SECTOREFFECTOR
			ifvarn sprite[i].picnum GPSPEED
			ifvarn sprite[i].picnum MUSICANDSFX
			{
				set .xvel 0
				set .yvel 0
				set .zvel 0
				set .extra -1
				set .lotag 0
				set .hitag 0
			}
		}

		ifvarand bit_option 32 {
			//state respawn_corr
			//state st_ambientsound
			//state skills_corr
			//state sk_corr
			//state statnum15

			/*
			ife sprite[i].picnum 1 ife sprite[i].lotag 24 ife sprite[i].zvel 1 {
				set sprite[i].yvel 30
				addlogvar i
			}  
			*/
			ife sprite[i].statnum 4 {
				addlogvar i
				changespritestat i 0
			}
		}
			
		/*
		ifvarand bit_option 32 //Временный скрипт для спрайтов
		{
			sethighlight 16384 i 14
			switch sprite[i].picnum
		
			//-----Тайлы монстров
			
			case 6290
			case 6390
			case 6990
			case 6865
			case 7100 //
			case 7070
			case 7068
			case 8874
			case 8918
			case 7980 //
			case 7940 //
			case 6490
			case 8505 //
			case 7945 //
			case 6590
			case 6690 //
			case 8180 //
			case 7040
			case 7045
			case 7050
			case 8174 
			
			//-----Тайлы монстров
			
			
			//-----Тайлы итемов
			case DIVING_SUIT
			case CRYSTALL_BALL
			case 5639 //DOCTORS_BAG
			case BOOTS_OF_JUMPING 
			case BEAST_VISION 
			case GUNS_AKIMBO 
			case PROXIMITY_DETONATOR 
			case REMOTE_DETONATOR 
			case BUNDLE_OF_TNT 
			case CASE_OF_TNT 
			case FLARES
			case FLARE_PISTOL 
			case SAWED-OFF 
			case BOX_OF_SHOTGUN_SHELLS 
			case SHOTGUN_SHELLS 
			case TOMMY_GUN 
			case FULL_DRUM_OF_BULLETS 
			case A_FEW_BULLETS 
			case NAPALM_LAUNCHER 
			case GASOLINE_CAN 
			case SPRAY_CAN 
			case TESLA_CANNON 
			case TESLA_CHARGE 
			case LIFE_LEECH 
			case TRAPPED_SOUL 
			case VOODOO_DOLL 
			case LIFE_SEED 
			case MEDICINE_POUCH 
			case INVULNERABILITY 
			case BODY_ARMOR 
			case FIRE_ARMOR 
			case SPIRIT_ARMOR 
			case BASIC_ARMOR 
			case SUPER_ARMOR 
			case LIFE_ESSENCE 
			
			//case SKULL_KEY 
			//case EYE_KEY 
			//case FIRE_KEY 
			//case DAGGER_KEY 
			//case SPIDER_KEY 
			//case MOON_KEY 
			
			case REFLECTIVE_SHOOTS 
			case INVISIBILITY 
			//-----Тайлы итемов
			
			
			//changespritestat i 55 set .xrepeat 64 set .yrepeat 64
			//ifvarn sprite[i].statnum 55 { sethighlight 16384 i 14 } //sethighlight (sprite - 16384, else wall) // (index)  // (?)
			//ifvare sprite[i].statnum 55 { ifvare sprite[i].xvel 0 ifvare sprite[i].yvel 0 deletesprite i else sethighlight 16384 i 14 }

			
			
			ifvarand sprite[i].cstat 128 set .cstat 0
			ifvare .picnum 7945 {
				set tmp sprite[i].z
				addvar tmp 6144
				set sprite[i].z tmp
			} else ifvare .picnum 7040 {
				set tmp sprite[i].z
				addvar tmp 2048
				set sprite[i].z tmp
			} else ifvare .picnum 7045 {
				set tmp sprite[i].z
				addvar tmp 2048
				set sprite[i].z tmp
			} else ifvare .picnum 7050 {
				set tmp sprite[i].z
				addvar tmp 2048
				set sprite[i].z tmp
			} else ifvare .picnum 6990 {
				set tmp sprite[i].z
				addvar tmp 1024
				set sprite[i].z tmp
			} else ifvare .picnum 6865 {
				set tmp sprite[i].z
				addvar tmp 1024
				set sprite[i].z tmp
			} else ifvare .picnum 7980 {
				set tmp sprite[i].z
				addvar tmp 6144
				set sprite[i].z tmp
			} else ifvare .picnum 8505 {
				set tmp sprite[i].z
				addvar tmp 3072
				set sprite[i].z tmp
			} else ifvare .picnum 6690 {
				set tmp sprite[i].z
				addvar tmp 6144
				set sprite[i].z tmp
			} else ifvare .picnum 7940 {
				set tmp sprite[i].z
				addvar tmp 6144
				set sprite[i].z tmp
			} else ifvare .picnum 7100 {
				set tmp sprite[i].z
				addvar tmp 768
				set sprite[i].z tmp
			} else ifvare .picnum 8180 {
				set tmp sprite[i].z
				addvar tmp 8192
				set sprite[i].z tmp
			} else ifvare .picnum 6390 {
				set tmp sprite[i].z
				addvar tmp 4096
				set sprite[i].z tmp
			} else {
				set tmp sprite[i].z
				addvar tmp 7168
				set sprite[i].z tmp
			}
			
			
			
			ifvarn sprite[i].statnum 55
			{	
				//set tmp sprite[i].y
				//addvar tmp 76288
				//set sprite[i].y tmp
			
				//set tmp sprite[i].z
				//addvar tmp 6144
				//set sprite[i].z tmp
				
				//updatesectorz .x .y .z tmp
				//ifvarn tmp -1
					//changespritesect i tmp
					//else sethighlight 16384 i 14
			}
			
			
			
			
			case MUSICANDSFX
			ifvare .xvel 0 ifvare .yvel 0 {
				sethighlight 16384 i 14
				
				set tmp sprite[i].y
				addvar tmp 46592
				set sprite[i].y tmp
			}
			
			break
		endswitch
		}
		*/
		
	}
	
	//SPRITES //SPRITES //SPRITES //SPRITES //SPRITES //SPRITES //SPRITES //SPRITES //SPRITES
	
	
	//--------------------------------------------------------------------------------------------
	
	
	//SECTORS //SECTORS //SECTORS //SECTORS //SECTORS //SECTORS //SECTORS //SECTORS //SECTORS
	
	for i allsectors //корректировочный скрипт для секторов
	{
		ifvarand bit_option 2 //затемнение в 2 раза
		{
			set var_shade sector[i].floorshade
			mulvar var_shade 2
			ifvarvarg var_shade 55 setvar var_shade 55
			set sector[i].floorshade var_shade
			   
			set var_shade sector[i].ceilingshade
			mulvar var_shade 2
			ifvarvarg var_shade 55 setvar var_shade 55
			set sector[i].ceilingshade var_shade 
		}
		ifvarand bit_option 4 
		{
			ifvare sector[i].lotag 600
			{
				set sector[i].lotag 20
				set sector[i].ceilingz sector[i].floorz 
			}
		}
		ifvarand bit_option 16
		{
			set sector[i].visibility 5 
		}
		
		/*
		ifvarand bit_option 32 //временный скрипт для секторов
		{
		
		set tmp sector[i].floorz
		add tmp 4608
		set sector[i].floorz tmp
		
		
		set tmp sector[i].ceilingz
		add tmp 4608
		set sector[i].ceilingz tmp
		
			ifvarg sector[i].floorpicnum 9694
			{
				set tmp sector[i].floorpicnum
				add tmp 768
				set sector[i].floorpicnum tmp
			}
			ifvarg sector[i].ceilingpicnum 9694
			{
			set tmp sector[i].ceilingpicnum
				add tmp 768
				set sector[i].ceilingpicnum tmp
			}
			
			set tmp sector[i].floorpicnum
		addvar tmp 5120
		set sector[i].floorpicnum tmp
		
		set tmp sector[i].ceilingpicnum
		addvar tmp 5120
		set sector[i].ceilingpicnum tmp
		
		}
		*/
		
	}
	
	//SECTORS //SECTORS //SECTORS //SECTORS //SECTORS //SECTORS //SECTORS //SECTORS //SECTORS
	
	
	//--------------------------------------------------------------------------------------------
	
	
	//WALLS //WALLS //WALLS //WALLS //WALLS //WALLS //WALLS //WALLS //WALLS //WALLS //WALLS
	
	for i allwalls //корректировочный скрипт для стен
	{
		ifvarand bit_option 2 //скрипт затеменения стен
		{
			set var_shade wall[i].shade
			mulvar var_shade 2
			ifvarvarg var_shade 55 setvar var_shade 55
			set wall[i].shade var_shade
		}
		
		
		/*
		ifvarand bit_option 32 //временный скрипт для стен
		{
		
		set tmp wall[i].x
		add tmp 48
		set wall[i].x tmp
		
		set tmp wall[i].y
		add tmp -192
		set wall[i].y tmp
		
				ifvarg wall[i].picnum 9694
				{
				set tmp wall[i].picnum
				add tmp 768
				set wall[i].picnum tmp
				}
			
				set tmp wall[i].picnum
				addvar tmp 5120
				set wall[i].picnum tmp
				
				set tmp wall[i].overpicnum
				addvar tmp 5120
				set wall[i].overpicnum tmp
				
				
		}
		*/
		
	}
	
	//WALLS //WALLS //WALLS //WALLS //WALLS //WALLS //WALLS //WALLS //WALLS //WALLS //WALLS
	
	
	//--------------------------------------------------------------------------------------------
	
	
	//SELECTED SECTORS //SELECTED SECTORS //SELECTED SECTORS //SELECTED SECTORS //SELECTED SECTORS
	
	for i selsectors //корректировочный скрипт для выделенных секторов
	{ 
		/*
		ifvarand bit_option 32 //Временный скрипт для выделенных секторов
		{
		
		
	
			ifvarg highlight_id -1 
			{
			dupsprite highlight_id
			set wallptr sector[i].wallptr
			set wallx wall[wallptr].x
			set wally wall[wallptr].y
			set wallnxt wall[wallptr].point2
			set wallnxt wall[wallnxt].point2
			set wallx2 wall[wallnxt].x
			set wally2 wall[wallnxt].y

			subvarvar wallx2 wallx
			divvarvar wallx2 2
			subvarvar wally2 wally
			divvarvar wally2 2
			addvarvar wallx wallx2
			addvarvar wally wally2
			set sprite[I].x wallx
			set sprite[I].y wally
			
			//addvarvar clonecount 1
			set newxvel sprite[highlight_id].xvel
			//addvarvar newxvel clonecount
			set sprite[I].xvel newxvel
			
			set newyvel sprite[highlight_id].yvel
			//addvarvar newyvel clonecount
			set sprite[I].yvel newyvel
			}
		
		}
		*/
	}

	//SELECTED SECTORS //SELECTED SECTORS //SELECTED SECTORS //SELECTED SECTORS //SELECTED SECTORS

	setvar correction_on 0
	setvar bit_option 0
}
ends