;------------------------------------------------
;replace physics level system with perm entities
;------------------------------------------------
add:
{
	"classname" "info_target"
	"targetname" "Stage_CounterInit"
	"spawnflags" "0"
	"OnUser1" "Stage_CounterTemplate,ForceSpawn,,0,1"
	"OnUser1" "Stage_Counter,AddOutput,classname info_target,0.03,1"
	"OnUser1" "!self,Kill,,0.06,1"
}

add:
{
	"classname" "point_template"
	"targetname" "Stage_CounterTemplate"
	"Template01" "Stage_Counter"
	"spawnflags" "2"
}

add:
{
	"classname" "math_counter"
	"targetname" "Stage_Counter"
	"startvalue" "1"
	"StartDisabled" "0"
	"min" "1"
	"max" "5"
	"OnGetValue" "Stage_Case,InValue,,0,-1"
}

add:
{
	"classname" "logic_case"
	"targetname" "Stage_Case"
	"Case01" "1"
	"Case02" "2"
	"Case03" "3"
	"Case04" "4"
	"Case05" "5"
	"OnCase01" "relay_normal,Trigger,,0.02,-1"
	"OnCase02" "relay_hard,Trigger,,0.02,-1"
	"OnCase03" "relay_extreme,Trigger,,0.02,-1"
	"OnCase04" "relay_l4,Trigger,,0.02,-1"
	"OnCase05" "relay_l5,Trigger,,0.02,-1"
}

modify:
{
	match:
	{
		"classname" "logic_auto"
	}
	insert:
	{
		"OnMapSpawn" "Stage_CounterInit,FireUser1,,0,1"
		"OnMapSpawn" "Stage_Counter,GetValue,,0.02,1"
	}
}

;------------------------------------
;change stage triggers to new system
;------------------------------------
modify:
{
	match:
	{
		"classname" "func_button"
		"hammerid" "332556"
	}
	delete:
	{
		"OnPressed" "map_reset,Trigger,,0,-1"
	}
	insert:
	{
		"OnPressed" "Stage_Counter,SetValue,1,0,-1"
	}
}

modify:
{
	match:
	{
		"classname" "trigger_multiple"
		"targetname" "l5_win"
	}
	delete:
	{
		"OnStartTouch" "map_reset,Trigger,,0,1"
	}
	insert:
	{
		"OnStartTouch" "Stage_Counter,SetValue,1,0,1"
	}
}

modify:
{
	match:
	{
		"classname" "func_button"
		"hammerid" "332550"
	}
	delete:
	{
		"OnPressed" "l_r1,Trigger,,0,-1"
	}
	insert:
	{
		"OnPressed" "Stage_Counter,SetValue,2,0,-1"
	}
}

modify:
{
	match:
	{
		"classname" "trigger_once"
		"targetname" "t_o6"
	}
	delete:
	{
		"OnTrigger" "l_r1,Trigger,,0,-1"
	}
	insert:
	{
		"OnTrigger" "amb1,PlaySound,,0,-1"
		"OnTrigger" "Stage_Counter,SetValue,2,0,-1"
	}
}

modify:
{
	match:
	{
		"classname" "func_button"
		"hammerid" "332536"
	}
	delete:
	{
		"OnPressed" "l_r2,Trigger,,0,-1"
	}
	insert:
	{
		"OnPressed" "Stage_Counter,SetValue,3,0,-1"
	}
}

modify:
{
	match:
	{
		"classname" "trigger_once"
		"targetname" "level2_change"
	}
	delete:
	{
		"OnTrigger" "l_r2,Trigger,,0,-1"
	}
	insert:
	{
		"OnTrigger" "Stage_Counter,SetValue,3,0,-1"
		"OnTrigger" "amb1,PlaySound,,0,-1"
	}
}

modify:
{
	match:
	{
		"classname" "func_button"
		"hammerid" "1100216"
	}
	delete:
	{
		"OnPressed" "l4_change,Trigger,,0,-1"
	}
	insert:
	{
		"OnPressed" "Stage_Counter,SetValue,4,0,-1"
	}
}

modify:
{
	match:
	{
		"classname" "trigger_once"
		"targetname" "l3_end"
	}
	delete:
	{
		"OnTrigger" "l4_change,Trigger,,0,1"
		"OnStartTouch" "amb1,PlaySound,,1,-1"
	}
	insert:
	{
		"OnTrigger" "Stage_Counter,SetValue,4,0,1"
		"OnTrigger" "amb1,PlaySound,,0,1"
	}
}

modify:
{
	match:
	{
		"classname" "func_button"
		"hammerid" "1348021"
	}
	delete:
	{
		"OnPressed" "l5_change,Trigger,,0,-1"
	}
	insert:
	{
		"OnPressed" "Stage_Counter,SetValue,5,0,-1"
	}
}

modify:
{
	match:
	{
		"classname" "trigger_multiple"
		"targetname" "l4_end"
	}
	delete:
	{
		"OnStartTouch" "l5_change,Trigger,,0,1"
	}
	insert:
	{
		"OnStartTouch" "Stage_Counter,SetValue,5,0,1"
		"OnStartTouch" "amb1,PlaySound,,0,1"
	}
}

;----------------------------------------------
;cleanup old level system + edict optimization
;----------------------------------------------
filter:
{
	"classname" "func_physbox"
	"targetname" "/dif_box.*/"
}

filter:
{
	"classname" "func_brush"
	"targetname" "/dif_brush_(normal|hard|extreme|l4|l5)/"
}

filter:
{
	"classname" "trigger_multiple"
	"targetname" "/trigger_(normal|hard|extreme|l4|l5)/"
}

modify:
{
	match:
	{
		"classname" "logic_auto"
	}
	delete:
	{
		"OnNewGame" "dif_box,EnableMotion,,0,-1"
		"OnNewGame" "dif_box1,EnableMotion,,0,-1"
		"OnNewGame" "dif_box2,EnableMotion,,0,-1"
		"OnNewGame" "dif_box3,EnableMotion,,0,1"
		"OnNewGame" "dif_box4,EnableMotion,,0,-1"
	}
}

filter:
{
	"classname" "logic_relay"
	"targetname" "map_reset"
}

filter:
{
	"classname" "logic_relay"
	"targetname" "/l_(r1|r2)/"
}

filter:
{
	"classname" "logic_relay"
	"targetname" "/(l4|l5)_change/"
}

;------------------------------------
;move stage text to center of screen
;------------------------------------
modify:
{
	match:
	{
		"classname" "game_text"
		"targetname" "server_text1"
	}
	replace:
	{
		"x" "-1.0"
	}
}

;------------------
;change stage text
;------------------
modify:
{
	match:
	{
		"classname" "game_text"
		"targetname" "server_text1"
	}
	replace:
	{
		"message" "** STAGE 1 - THE ROAD TO CHERNOBYL **"
	}
}

modify:
{
	match:
	{
		"classname" "trigger_once"
		"targetname" "t_o7"
	}
	delete:
	{
		"OnTrigger" "server_text1,AddOutput,message **STAGE 2**POLTERGEIST FIGHT,0,-1"
	}
	insert:
	{
		"OnTrigger" "server_text1,AddOutput,message ** STAGE 2 - POLTERGEIST FIGHT **,0,-1"
	}
}

modify:
{
	match:
	{
		"classname" "trigger_once"
		"targetname" "l3_start"
	}
	delete:
	{
		"OnTrigger" "server_text1,AddOutput,message **STAGE 3**ROAD TO PRIPYAT,0,-1"
	}
	insert:
	{
		"OnTrigger" "server_text1,AddOutput,message ** STAGE 3 - ROAD TO PRIPYAT **,0,-1"
	}
}

modify:
{
	match:
	{
		"classname" "trigger_once"
		"targetname" "l4_start"
	}
	delete:
	{
		"OnTrigger" "server_text1,AddOutput,message **STAGE 4**PRIPYAT,0,-1"
	}
	insert:
	{
		"OnTrigger" "server_text1,AddOutput,message ** STAGE 4 - PRIPYAT **,0,-1"
	}
}

modify:
{
	match:
	{
		"classname" "trigger_once"
		"targetname" "l5_start"
	}
	delete:
	{
		"OnTrigger" "server_text1,AddOutput,message **STAGE 5**WIN OR DIE,0,-1"
	}
	insert:
	{
		"OnTrigger" "server_text1,AddOutput,message ** STAGE 5 - WIN OR DIE **,0,-1"
	}
}

;-------------------------------------------------------------
;extend teleport to displacement near gravity truck stage 4/5
;-------------------------------------------------------------
add:
{
	"model" "*384"
	"classname" "trigger_teleport"
	"targetname" "global_tp12"
	"target" "l4_boss_tele1"
	"StartDisabled" "1"
	"spawnflags" "1"
	"origin" "-6361.94 -12672.1 -14495"
}

modify:
{
	match:
	{
		"targetname" "l3_lab"
		"classname" "trigger_once"
		"hammerid" "783934"
	}
	insert:
	{
		"OnTrigger" "lab_door3_push,Enable,,10,-1"
		"OnTrigger" "lab_door3_push,Disable,,11,-1"
	}
}

add:
{
	"model" "*232"
	"targetname" "lab_door3_push"
	"StartDisabled" "0"
	"speed" "300"
	"spawnflags" "1"
	"pushdir" "0 90 0"
	"origin" "8577.3 -9133.2 -1324.3"
	"angles" "0 0 0"
	"alternateticksfix" "0"
	"classname" "trigger_push"
	"hammerid" "820372"
}

;---------------------------------
;fix pool teleport avoidance spot
;---------------------------------
add:
{
	"model" "*295"
	"targetname" "l4_tp2"
	"target" "l4_tp1"
	"StartDisabled" "1"
	"spawnflags" "1"
	"origin" "-9217.53 -8895 -14597.5"
	"classname" "trigger_teleport"
}

add:
{
	"model" "*295"
	"targetname" "l4_tp2"
	"target" "l4_tp1"
	"StartDisabled" "1"
	"spawnflags" "1"
	"origin" "-9217.53 -9337 -14597.5"
	"classname" "trigger_teleport"
}

;------------------------
;fix stage 3 push angles
;------------------------
modify:
{
	match:
	{
		"targetname" "bloodsucker_push"
	}
	delete:
	{
		"angles" "0 90 0"
	}
}

;-------------------------------------------------------
;fix stage 5 phase 1 boss fight teleport avoidance spot
;-------------------------------------------------------
add:
{
	"model" "*351"
	"targetname" "controller_tp"
	"target" "controller_tp_1"
	"StartDisabled" "1"
	"spawnflags" "1"
	"origin" "-9424 -9080 -14603"
	"landmark" "controller_tp3"
	"filtername" "ct_filter"
	"classname" "trigger_teleport"
}



;; _

;; music volume

modify:
{
	match:
	{
		"message" "stalker_soundtrack/05_wasteland2_str_r.mp3"
		"classname" "ambient_generic"
	}
	replace:
	{
		"message" "#stalker_soundtrack/05_wasteland2_str_r.mp3"
	}
}
modify:
{
	match:
	{
		"message" "stalker_soundtrack/hospital.mp3"
		"classname" "ambient_generic"
	}
	replace:
	{
		"message" "#stalker_soundtrack/hospital.mp3"
	}
}
modify:
{
	match:
	{
		"message" "stalker_soundtrack/l4_start_song.mp3"
		"classname" "ambient_generic"
	}
	replace:
	{
		"message" "#stalker_soundtrack/l4_start_song.mp3"
	}
}
modify:
{
	match:
	{
		"message" "stalker_soundtrack/level2_boss_music.mp3"
		"classname" "ambient_generic"
	}
	replace:
	{
		"message" "#stalker_soundtrack/level2_boss_music.mp3"
	}
}
modify:
{
	match:
	{
		"message" "stalker_soundtrack/level4_boss_song.mp3"
		"classname" "ambient_generic"
	}
	replace:
	{
		"message" "#stalker_soundtrack/level4_boss_song.mp3"
	}
}
modify:
{
	match:
	{
		"message" "stalker_soundtrack/level5_boss_song (mp3cut.ru).mp3"
		"classname" "ambient_generic"
	}
	replace:
	{
		"message" "#stalker_soundtrack/level5_boss_song (mp3cut.ru).mp3"
	}
}
modify:
{
	match:
	{
		"message" "stalker_soundtrack/level5_end_song (1).mp3"
		"classname" "ambient_generic"
	}
	replace:
	{
		"message" "#stalker_soundtrack/level5_end_song (1).mp3"
	}
}
modify:
{
	match:
	{
		"message" "stalker_soundtrack/level5_prypiat_song.mp3"
		"classname" "ambient_generic"
	}
	replace:
	{
		"message" "#stalker_soundtrack/level5_prypiat_song.mp3"
	}
}
modify:
{
	match:
	{
		"message" "stalker_soundtrack/level5_start_song (1).mp3"
		"classname" "ambient_generic"
	}
	replace:
	{
		"message" "#stalker_soundtrack/level5_start_song (1).mp3"
	}
}
modify:
{
	match:
	{
		"message" "stalker_soundtrack/pripyat_day.mp3"
		"classname" "ambient_generic"
	}
	replace:
	{
		"message" "#stalker_soundtrack/pripyat_day.mp3"
	}
}
modify:
{
	match:
	{
		"message" "stalker_soundtrack/stalker_cop_end_song.mp3"
		"classname" "ambient_generic"
	}
	replace:
	{
		"message" "#stalker_soundtrack/stalker_cop_end_song.mp3"
	}
}