; STAGE DISPLAY

add:
{
	"origin" "-4554 9731 -435"
	"targetname" "TheCurrentLevelPlugin"
	"min" "1"
	"max" "6"
	"startvalue" "1"
	"classname" "math_counter"
}

modify:
{
	match:
	{
		"targetname" "saving_relay1"
		"classname" "logic_relay"
	}
	insert:
	{
		"OnTrigger" "TheCurrentLevelPlugin,SetValue,1,0,1"
	}
}
modify:
{
	match:
	{
		"targetname" "saving_relay2"
		"classname" "logic_relay"
	}
	insert:
	{
		"OnTrigger" "TheCurrentLevelPlugin,SetValue,2,0,1"
	}
}
modify:
{
	match:
	{
		"targetname" "saving_relay3"
		"classname" "logic_relay"
	}
	insert:
	{
		"OnTrigger" "TheCurrentLevelPlugin,SetValue,3,0,1"
	}
}
modify:
{
	match:
	{
		"targetname" "saving_relay4"
		"classname" "logic_relay"
	}
	insert:
	{
		"OnTrigger" "TheCurrentLevelPlugin,SetValue,4,0,1"
	}
}
modify:
{
	match:
	{
		"targetname" "saving_relay5"
		"classname" "logic_relay"
	}
	insert:
	{
		"OnTrigger" "TheCurrentLevelPlugin,SetValue,5,0,1"
	}
}
modify:
{
	match:
	{
		"targetname" "saving_relay6"
		"classname" "logic_relay"
	}
	insert:
	{
		"OnTrigger" "TheCurrentLevelPlugin,SetValue,6,0,1"
	}
}

;------------------
; Admin Room Stuff
;------------------

modify:
{
	match:
	{
		"classname" "func_button"
		"OnPressed" "consola,Command,sm_slay @all,4,-1"
	}
	delete:
	{
		"OnPressed" "consola,Command,sm_slay @all,4,-1"
	}
	insert:
	{
		"OnPressed" "player,SetHealth,0,4,-1"
	}
}

add:
{
	"angles" "0 270 0"
	"model" "*258"
	"wait" "1"
	"unlocked_sound" "0"
	"unlocked_sentence" "0"
	"speed" "1"
	"spawnflags" "1025"
	"sounds" "0"
	"rendermode" "1"
	"renderfx" "0"
	"rendercolor" "255 255 0"
	"renderamt" "255"
	"origin" "-4393 9848.2 -422"
	"movedir" "0 0 0"
	"min_use_angle" "0.8"
	"locked_sound" "0"
	"locked_sentence" "0"
	"lip" "0"
	"health" "0"
	"fadescale" "1"
	"fademindist" "-1"
	"disablereceiveshadows" "0"
	"classname" "func_button"
	"hammerid" "4491"
	"OnPressed" "consola,Command,say |Admin Room| ***Admin has changed difficulty to LEVEL 6 ***,0,-1"
	"OnPressed" "spawny_1,Trigger,,0,-1"
	"OnPressed" "player,SetHealth,0,4,-1"
	"OnPressed" "consola,Command,say |Admin Room| *** ADMIN SLAYING EVERYONE ***,4,-1"
	"OnPressed" "saving_relay6,FireUser1,,0,-1"
}


;-------------------------
; BARBOSSA FIXES
; Triggers origin 36 unit 
; inside the ground
;-------------------------

modify:
{
    match:
    {
        "targetname" "zombie_barbossa_kill"
    }
    replace:
    {
        "origin" "-12367.5 14778 -863"
    }
}
 
modify:
{
    match:
    {
        "targetname" "zombie_barbossa_speed"
    }
    replace:
    {
        "origin" "-12367.5 14778 -867"
    }
}
 
modify:
{
    match:
    {
        "targetname" "zombie_barbossa_predek"
    }
    replace:
    {
        "origin" "-12360.5 14778.5 -855.75"
    }
}
 
modify:
{
    match:
    {
        "targetname" "zombie_barbossa_zadek"
    }
    replace:
    {
        "origin" "-12360 14778.5 -855.75"
    }
}
 
modify:
{
    match:
    {
        "targetname" "zombie_barbossa_prava"
    }
    replace:
    {
        "origin" "-12359.5 14778.5 -855.75"
    }
}
 
modify:
{
    match:
    {
        "targetname" "zombie_barbossa_leva"
    }
    replace:
    {
        "origin" "-12359 14778.5 -855.75"
    }
}
 
modify:
{
    match:
    {
        "targetname" "zombie_barbossat_knife"
    }
    replace:
    {
        "origin" "-12359.3 14778.1 -854.25"
    }
}

; This trigger is recreated below
; modify:
; {
;     match:
;     {
;         "model" "*418"
;         "classname" "trigger_multiple"
;     }
;     replace:
;     {
;         "origin" "-12354 14778.5 -853.25"
;     }
; }


;--------------------------
; EVENT - July 2021
; MULTIPLE BARBOSSA
;--------------------------

;*******************
; Template the item
;*******************

filter:
{
	"model" "*418"
	"origin" "-12354 14778.5 -885.25"
	"classname" "trigger_multiple"
	"hammerid" "7561041"
}
add:
{
	"model" "*418"
	"StartDisabled" "0"
	"spawnflags" "1"
	"targetname" "zombie_barbossa_strip"
	"origin" "-12354 14778.5 -853.25"
	"filtername" "zombi"
	"classname" "trigger_once"
	"OnStartTouch" "zbrane_strip,StripWeaponsAndSuit,,0,1"
}

add:
{
	"targetname" "Template_BarbossaItem"
	"origin" "-12392 14824 -888"
	"Template01" "zombie_barbossa_strip"
	"Template02" "zm_barbossa_hitbox"
	"Template03" "zombie_barbossa_kill"
	"Template04" "zombie_barbossa_zadek"
	"Template05" "zombie_barbossa_leva"
	"Template06" "zombie_barbossa_predek"
	"Template07" "zombie_barbossa_prava"
	"Template08" "zombie_barbossa"
	"Template09" "zombie_barbossat_knife"
	"Template10" "zombie_barbossa_push"
	"Template11" "zombie_barbossa_speed"
	"Template12" "zombie_barbossa_spawner"
	"Template13" "zombie_barbossa_maker2"
	"Template14" "zombie_barbossa_set"
	"Template15" "zombie_barbossa_set2"
	"Template16" "zombie_barbossa_ui"
	"spawnflags" "0"
	"classname" "point_template"
}



;***********************
; Bomb unique instances
;***********************

add:
{
	"origin" "-12294 14778 -844"
	"targetname" "zombie_barbossa_relay_koule"
	"StartDisabled" "0"
	"spawnflags" "0"
	"classname" "logic_relay"
	"OnSpawn" "!self,Trigger,,0,1"
	"OnSpawn" "!self,Kill,,6,1"
	"OnTrigger" "zombie_barbossa_koule,Break,,5,1"
}

modify:
{
    match:
    {
        "targetname" "zombie_barbossa_set2"
		"classname" "logic_relay"
    }
	delete:
    {
        "OnTrigger" "zombie_barbossa_koule,Break,,5,-1"
    }
}

modify:
{
    match:
    {
        "targetname" "zombie_barbossa_template_2"
		"classname" "point_template"
    }
    replace:
    {
        "spawnflags" "0"
    }
	insert:
    {
        "Template04" "zombie_barbossa_relay_koule"
    }
}


modify:
{
    match:
    {
        "targetname" "bb_track_incomm8"
		"classname" "path_track"
    }
	delete:
    {
        "OnPass" "zombie_barbossa_koule,Break,,6,1"
    }
	insert:
    {
        "OnPass" "zombie_barbossa_koule*,Break,,6,1"
    }
}


modify:
{
    match:
    {
        "targetname" "zombie_barbossa_kill"
		"classname" "trigger_hurt"
    }
	delete:
    {
		; Remove target input so the trigger doesnt need to get a unique name
		; And can be targetted from outside
    	"OnStartTouch" "zombie_barbossa_kill,Kill,,0,-1"
    }	
	insert:
    {
        "OnStartTouch" "!self,Kill,,0,-1"
        "OnStartTouch" "zombie_barbossa_relay_koule*,CancelPending,,0,-1"
    }
}



;***************************
; Multiple Barbossa Counter
;***************************

add:
{
	"origin" "0 0 0"
	"targetname" "THIS_IS_MY_LOGIC_AUTO"
	"StartDisabled" "0"
	"spawnflags" "1"
	"classname" "logic_relay"
	"OnSpawn" "Bossa_Event_Init,FireUser1,,0,1"
	"OnSpawn" "Bossa_Event_CounterInfo,GetValue,,12,1"
	"OnSpawn" "Bossa_Event_SpawnNewOne,Trigger,,20,1"
}

; Relay to spawn a Barbossa

add:
{
	"origin" "0 0 0"
	"targetname" "Bossa_Event_SpawnNewOne"
	"StartDisabled" "0"
	"spawnflags" "0"
	"classname" "logic_relay"
	"OnTrigger" "Template_BarbossaItem,ForceSpawn,,1,-1"
}

; Permanent entity stuff

add:
{
	"targetname" "Bossa_Event_Init"
	"origin" "2552 -2536 840"
	"classname" "info_target"
	"OnUser1" "Template_PermBossaEventMode,ForceSpawn,,0,1"
	"OnUser1" "Bossa_Event_CounterInfo,AddOutput,classname info_target,0.03,1"
	"OnUser1" "Bossa_Event_BranchChanged,AddOutput,classname info_target,0.03,1"
	"OnUser1" "!self,Kill,,0.06,1"
}

add:
{
	"targetname" "Template_PermBossaEventMode"
	"origin" "2552 -2536 776"
	"Template01" "Bossa_Event_BranchChanged"
	"Template02" "Bossa_Event_CounterInfo"
	"spawnflags" "2"
	"classname" "point_template"
	"OnEntitySpawned" "!self,Kill,,0,-1"
}

add:
{
	"origin" "0 0 0"
	"targetname" "Bossa_Event_CounterInfo"
	"startvalue" "1"
	"StartDisabled" "0"
	"min" "1"
	"max" "16"
	"classname" "math_counter"
	"OutValue" "!self,GetValue,,0.05,-1"
	
	"OnGetValue" "Bossa_Event_CaseInfo,InValue,,0,-1"

	"OnGetValue" "Bossa_Event_CounterPicked,SetHitMax,,0,-1"
	"OnGetValue" "Bossa_Event_Compare,SetValueCompare,,0,-1"
}


; Branch executed in Kraken god
; Set 3 barbossa if no admin set a specific amount of barbossa prior to that stage

add:
{
	"targetname" "Bossa_Event_BranchChanged"
	"origin" "0 0 0"
	"InitialValue" "0"
	"classname" "logic_branch"
	"OnFalse" "Bossa_Event_CounterInfo,SetValueNoFire,3,0,-1"
}

modify:
{
	match:
	{
		"targetname" "saving_relay6"
		"classname" "logic_relay"
	}
	insert:
	{
		"OnTrigger" "Bossa_Event_BranchChanged,Test,,3,1"
	}
}



;++++++++++++++++++++++++++++++++++
; Barbossa Knife
; Picking one increase the counter
;++++++++++++++++++++++++++++++++++

modify:
{
    match:
    {
        "targetname" "zombie_barbossat_knife"
		"classname" "weapon_knife"
    }
	delete:
    {
		"OnPlayerPickup" "barbossa_port,Enable,,0.5,-1"
    }	
	insert:
    {
        "OnPlayerPickup" "!activator,AddOutput,origin -13286 13367 -1064,0,1"
        "OnPlayerPickup" "Bossa_Event_CounterPicked,Add,1,0,1"
        "OnPlayerPickup" "Bossa_Event_SpawnNewOne,Trigger,,0,1"
    }
}


add:
{
	"origin" "0 0 0"
	"targetname" "Bossa_Event_CounterPicked"
	"startvalue" "0"
	"StartDisabled" "0"
	"min" "0"
	"max" "1"
	"classname" "math_counter"
	"OnHitMax" "barbossa_port,Enable,,0,-1"
	"OnHitMax" "Bossa_Event_SpawnNewOne,CancelPending,,0.1,-1"
}

;+++++++++++++++++++++++++++
; Message and admin buttons
;+++++++++++++++++++++++++++

add:
{
	"targetname" "Bossa_Event_Compare"
	"origin" "0 0 0"
	"InitialValue" "0"
	"CompareValue" "1"
	"classname" "logic_compare"
	"OnEqualTo" "Bossa_Event_Admin_Subtract,FireUser1,Dummy,0,-1"
	"OnNotEqualTo" "Bossa_Event_Admin_Subtract,FireUser2,Dummy,0,-1"
}
add:
{
	"targetname" "Bossa_Event_Compare"
	"origin" "0 0 0"
	"InitialValue" "0"
	"CompareValue" "16"
	"classname" "logic_compare"
	"OnEqualTo" "Bossa_Event_Admin_Add,FireUser1,Dummy,0,-1"
	"OnNotEqualTo" "Bossa_Event_Admin_Add,FireUser2,Dummy,0,-1"
}

add:
{
	"model" "*137"
	"targetname" "Bossa_Event_Admin_Subtract"
	"wait" "0.5"
	"unlocked_sound" "0"
	"unlocked_sentence" "0"
	"speed" "1"
	"spawnflags" "1025"
	"sounds" "0"
	"rendermode" "1"
	"renderfx" "0"
	"rendercolor" "0 255 0"
	"renderamt" "255"
	"origin" "-4393 10232.2 -422"
	"movedir" "0 0 0"
	"min_use_angle" "0.8"
	"locked_sound" "0"
	"locked_sentence" "0"
	"lip" "0"
	"health" "0"
	"fadescale" "1"
	"fademindist" "-1"
	"disablereceiveshadows" "0"
	"classname" "func_button"
	"hammerid" "276910"
	"OnPressed" "Bossa_Event_CounterInfo,Subtract,1,0,-1"
	"OnPressed" "consola,Command,say |Admin Room| *** REMOVED ONE BARBOSSA ***,0,-1"
	"OnPressed" "Bossa_Event_BranchChanged,SetValue,1,0,1"
	"OnUser1" "!self,Color,255 0 0,0,-1"
	"OnUser1" "!self,Lock,,0,-1"
	"OnUser2" "!self,Color,0 255 0,0,-1"
	"OnUser2" "!self,Unlock,,0,-1"
}

add:
{
	"model" "*137"
	"targetname" "Bossa_Event_Admin_Add"
	"wait" "0.5"
	"unlocked_sound" "0"
	"unlocked_sentence" "0"
	"speed" "1"
	"spawnflags" "1025"
	"sounds" "0"
	"rendermode" "1"
	"renderfx" "0"
	"rendercolor" "0 255 0"
	"renderamt" "255"
	"origin" "-4393 10168.2 -422"
	"movedir" "0 0 0"
	"min_use_angle" "0.8"
	"locked_sound" "0"
	"locked_sentence" "0"
	"lip" "0"
	"health" "0"
	"fadescale" "1"
	"fademindist" "-1"
	"disablereceiveshadows" "0"
	"classname" "func_button"
	"hammerid" "276911"
	"OnPressed" "Bossa_Event_CounterInfo,Add,1,0,-1"
	"OnPressed" "consola,Command,say |Admin Room| *** ADDED ONE BARBOSSA ***,0,-1"
	"OnPressed" "Bossa_Event_BranchChanged,SetValue,1,0,1"
	"OnUser1" "!self,Color,255 0 0,0,-1"
	"OnUser1" "!self,Lock,,0,-1"
	"OnUser2" "!self,Color,0 255 0,0,-1"
	"OnUser2" "!self,Unlock,,0,-1"
}

add:
{
	"origin" "0 0 0"
	"targetname" "Bossa_Event_CaseInfo"
	"Case01" "1"
	"Case02" "2"
	"Case03" "3"
	"Case04" "4"
	"Case05" "5"
	"Case06" "6"
	"Case07" "7"
	"Case08" "8"
	"Case09" "9"
	"Case10" "10"
	"Case11" "11"
	"Case12" "12"
	"Case13" "13"
	"Case14" "14"
	"Case15" "15"
	"Case16" "16"
	"classname" "logic_case"
	"OnCase01" "consola,Command,say *** Max Barbossa = 1 ***,0,-1"
	"OnCase02" "consola,Command,say *** Max Barbossa = 2 ***,0,-1"
	"OnCase03" "consola,Command,say *** Max Barbossa = 3 ***,0,-1"
	"OnCase04" "consola,Command,say *** Max Barbossa = 4 ***,0,-1"
	"OnCase05" "consola,Command,say *** Max Barbossa = 5 ***,0,-1"
	"OnCase06" "consola,Command,say *** Max Barbossa = 6 ***,0,-1"
	"OnCase07" "consola,Command,say *** Max Barbossa = 7 ***,0,-1"
	"OnCase08" "consola,Command,say *** Max Barbossa = 8 ***,0,-1"
	"OnCase09" "consola,Command,say *** Max Barbossa = 9 ***,0,-1"
	"OnCase10" "consola,Command,say *** Max Barbossa = 10 ***,0,-1"
	"OnCase11" "consola,Command,say *** Max Barbossa = 11 ***,0,-1"
	"OnCase12" "consola,Command,say *** Max Barbossa = 12 ***,0,-1"
	"OnCase13" "consola,Command,say *** Max Barbossa = 13 ***,0,-1"
	"OnCase14" "consola,Command,say *** Max Barbossa = 14 ***,0,-1"
	"OnCase15" "consola,Command,say *** Max Barbossa = 15 ***,0,-1"
	"OnCase16" "consola,Command,say *** Max Barbossa = 16 ***,0,-1"
}
;Remove a safe spot on Kraken stage
add:
{
    "model" "*139"
    "classname" "trigger_teleport"
    "targetname" "teleport_lvl5_nakrakena"
    "origin" "9768 12226.5 -1675"
    "spawnflags" "1"
    "StartDisabled" "1"
    "target" "mapa5_port"
    "CheckDestIfClearForPlayer" "0"
    "UseLandmarkAngles" "1"
}
add:
{
    "model" "*139"
    "classname" "trigger_teleport"
    "targetname" "teleport_lvl5_nakrakena"
    "origin" "9768 12226.5 -1827"
    "spawnflags" "1"
    "StartDisabled" "1"
    "target" "mapa5_port"
    "CheckDestIfClearForPlayer" "0"
    "UseLandmarkAngles" "1"
}
