;------------
; Logic_auto
;------------
modify:
{
    match:
    {
        "classname" "logic_auto"
    }
    insert:
    {
		"OnMapSpawn" "moon_lord_hitbox,AddOutput,angles 90 0 0,0,-1"
	}
}
;-----------------------
; Fixes annouce message
;-----------------------
modify:
{
    match:
    {
        "targetname" "spawn_trigger"
    }
    delete:
    {
		"OnStartTouch" "console,Command,< Special thanks to: friezi - Kaemon - Moltard - Ripper - Rognus - Xehanort -  xen - zaCade >,4,1"
    }
    insert:
    {
		"OnStartTouch" "console,Command,say < Special thanks to: friezi - Kaemon - Moltard - Ripper - Rognus - Xehanort - xen - zaCade >,4,1"
    }
}
;-----------------------
; Fixes annouce message
;-----------------------
modify:
{
    match:
    {
        "origin" "-2368 3456 -3616"
		"classname" "trigger_once"
    }
    delete:
    {
		"OnStartTouch" "console,Command,< Special thanks to: friezi - Kaemon - Moltard - Ripper - Rognus - Xehanort - xen - zaCade >,4,1"
    }
    insert:
    {
		"OnStartTouch" "console,Command,say < Special thanks to: friezi - Kaemon - Moltard - Ripper - Rognus - Xehanort - xen - zaCade >,4,1"
    }
}
;---------------------
; Fixes death message
;---------------------
modify:
{
    match:
    {
        "targetname" "pumpking_hitbox"
    }
    delete:
    {
		"OnBreak" "console,Command,say < Pumpking was defeated >,0,1"
    }
    insert:
    {
		"OnBreak" "console,Command,say < Pumpking was defeated! >,0,1"
    }
}
;--------------------
; Fixes long message
;--------------------
modify:
{
    match:
    {
        "origin" "10356 -11332 168"
		"targetname" "guide_path15"
    }
    delete:
    {
		"OnPass" "console,Command,say < Anyways I will open the backdoor soon for you so you can advance through the Forest biome >,3,1"
    }
    insert:
    {
		"OnPass" "console,Command,say < Anyways I will open the backdoor for you soon >,3,1"
    }
}
;------------------------------------
; Fixes fire sound so it stops again
;------------------------------------
modify:
{
    match:
    {
        "classname" "logic_relay"
		"origin" "15328.5 -8966 2156.93"
		"targetname" "item_fire_relay_use"
    }
    delete:
    {
		"OnTrigger" "sound_fire,StopSound,,9,-1"
    }
    insert:
    {
		"OnTrigger" "sound_fire,Volume,0,9,-1"
    }
}
;--------------------------------------
; Fixes freeze sound so it stops again
;--------------------------------------
modify:
{
    match:
    {
        "origin" "15641.5 -9529.11 2292.44"
		"targetname" "item_freeze_relay_use"
    }
    delete:
    {
		"OnTrigger" "freeze_water_sound,StopSound,,9,-1"
    }
    insert:
    {
		"OnTrigger" "freeze_water_sound,Volume,0,9,-1"
    }
}
;-------------------------
; Fixes zombie speed item
;-------------------------
modify:
{
    match:
    {
		"targetname" "Item_zombie_speed_trigger"
    }
    delete:
    {
		"OnStartTouch" "speed,ModifySpeed,1,6,-1"
		"OnStartTouch" "speed,ModifySpeed,2,0,-1"
    }
    insert:
    {
		"OnStartTouch" "speed,ModifySpeed,1,3,-1"
		"OnStartTouch" "speed,ModifySpeed,1.3,0,-1"
    }
}
;---------------------------------------------------------------------------
; Adds a brush to prevent stuck players in between props - corruption biome
;---------------------------------------------------------------------------
add:
{
	"model" "*123"
	"targetname" "prevent_stuck_1"
	"spawnobject" "0"
	"spawnflags" "0"
	"rendermode" "0"
	"renderfx" "0"
	"rendercolor" "255 255 255"
	"renderamt" "255"
	"propdata" "0"
	"pressuredelay" "0"
	"physdamagescale" "1.0"
	"PerformanceMode" "0"
	"origin" "7690 -9080 148.15"
	"nodamageforces" "0"
	"minhealthdmg" "0"
	"material" "0"
	"health" "0"
	"gibdir" "0 0 0"
	"explosion" "0"
	"ExplodeRadius" "0"
	"explodemagnitude" "0"
	"ExplodeDamage" "0"
	"disableshadows" "0"
	"disablereceiveshadows" "0"
	"classname" "func_breakable"
}
;---------------------------------------------------------------------------
; Adds a brush to prevent stuck players in between props - corruption biome
;---------------------------------------------------------------------------
add:
{
	"model" "*123"
	"targetname" "prevent_stuck_2"
	"spawnobject" "0"
	"spawnflags" "0"
	"rendermode" "0"
	"renderfx" "0"
	"rendercolor" "255 255 255"
	"renderamt" "255"
	"propdata" "0"
	"pressuredelay" "0"
	"physdamagescale" "1.0"
	"PerformanceMode" "0"
	"origin" "7720.5 -8978.93 148.37"
	"nodamageforces" "0"
	"minhealthdmg" "0"
	"material" "0"
	"health" "0"
	"gibdir" "0 0 0"
	"explosion" "0"
	"ExplodeRadius" "0"
	"explodemagnitude" "0"
	"ExplodeDamage" "0"
	"disableshadows" "0"
	"disablereceiveshadows" "0"
	"classname" "func_breakable"
}
;---------------------------------------------------------------------------
; Adds a brush to prevent stuck players in between props - jungle biome
;---------------------------------------------------------------------------
add:
{
	"model" "*173"
	"targetname" "prevent_stuck_3"
	"spawnobject" "0"
	"spawnflags" "0"
	"rendermode" "0"
	"renderfx" "0"
	"rendercolor" "255 255 255"
	"renderamt" "255"
	"propdata" "0"
	"pressuredelay" "0"
	"physdamagescale" "1.0"
	"PerformanceMode" "0"
	"origin" "9328 -2144 -32"
	"nodamageforces" "0"
	"minhealthdmg" "0"
	"material" "0"
	"health" "0"
	"gibdir" "0 0 0"
	"explosion" "0"
	"ExplodeRadius" "0"
	"explodemagnitude" "0"
	"ExplodeDamage" "0"
	"disableshadows" "0"
	"disablereceiveshadows" "0"
	"classname" "func_breakable"
	"angles" "0 90 0"
}
;-------------------------------------
; Kills the stuck prevention later on
;-------------------------------------
modify:
{
    match:
    {
        "origin" "9296 -5792 320"
    }
    insert:
    {
		"OnStartTouch" "prevent_stuck_1,Kill,,0,1"
		"OnStartTouch" "prevent_stuck_2,Kill,,0,1"
    }
}
;-------------------------------------
; Kills the stuck prevention later on
;-------------------------------------
modify:
{
    match:
    {
        "targetname" "bee_hive_trigger_1"
    }
    insert:
    {
		"OnStartTouch" "prevent_stuck_3,Kill,,0,1"
    }
}
;---------------------------------------------------------------------------------------
; Makes the zombies teleport 5 seconds after the bridge is spawned instead of instantly
;---------------------------------------------------------------------------------------
modify:
{
    match:
    {
        "origin" "9215.9 7130.41 -6416"
		"classname" "trigger_once"
    }
    delete:
    {
		"OnStartTouch" "tp_12,Enable,,11,1"
    }
    insert:
    {
		"OnStartTouch" "tp_12,Enable,,15,1"
		"OnStartTouch" "fix_stuck_tp_SHINO,Enable,,15,1"
    }
}
;----------------------------------------------------------
; Reduces the hp slightly on the second phase of Queen Bee
;----------------------------------------------------------
modify:
{
    match:
    {
        "targetname" "Bee_Queen_v2_hp_add"
    }
    delete:
    {
		"OnStartTouch" "Bee_Queen_boss_v2_counter,Add,300,0,-1"
		"OnStartTouch" "!self,Kill,,1,1"
    }
    insert:
    {
		"OnStartTouch" "Bee_Queen_boss_v2_counter,Add,250,0,-1"
    }
}
;--------------------------------------
; Fixes the amazing glitch shino found
;--------------------------------------
add:
{
	"model" "*119"
	"targetname" "fix_stuck_tp_SHINO"
	"target" "beehive_dest"
	"StartDisabled" "1"
	"spawnflags" "1"
	"origin" "9216 -1248 -6192"
	"classname" "trigger_teleport"
}
























;-----------------------------------------------------------------
; Remakes the entire ending if the portal gun wasnt at the ending
;-----------------------------------------------------------------
;--------------------
; Adds a logic_relay
;--------------------
add:
{
	"origin" "15103 -8864 2176"
	"targetname" "Moon_lord_kill_fail_relay"
	"spawnflags" "0"
	"classname" "logic_relay"
	"OnTrigger" "console,Command,say < Moon Lord will judge us in 20 seconds! >,0,1"
	"OnTrigger" "console,Command,say < Moon Lord will judge us in 15 seconds! >,5,1"
	"OnTrigger" "console,Command,say < Moon Lord will judge us in 10 seconds! >,10,1"
	"OnTrigger" "console,Command,say < Moon Lord will judge us in 5 seconds! >,15,1"
	"OnTrigger" "console,Command,say < Moon Lord judges you unworthy >,20,1"
	"OnTrigger" "moon_lord_hitbox,Kill,,20,1"
	"OnTrigger" "moon_lord_hitbox,SetDamageFilter,Filter_Nada,20,1"
	"OnTrigger" "teleport_humans_to_cage,Enable,,21,1"
	"OnTrigger" "moon_lord_beam_particle,Start,,23,1"
	"OnTrigger" "end_hurt_fake,Enable,,24,1"
}
;----------------------------------------------
; Adds a trigger_hurt to humans in zombie cage
;----------------------------------------------
add:
{
	"model" "*322"
	"targetname" "end_hurt_fake"
	"StartDisabled" "1"
	"spawnflags" "1"
	"origin" "-3408 3456 -3104"
	"nodmgforce" "0"
	"damagetype" "0"
	"damagemodel" "0"
	"filtername" "human_filter"
	"damagecap" "9999999"
	"damage" "99999"
	"classname" "trigger_hurt"
}
;--------------------------------------------------------------
; Adds a trigger to teleport humans from punish to zombie cage
;--------------------------------------------------------------
add:
{
	"model" "*95"
    "targetname" "teleport_humans_to_cage"
	"target" "zombie_last_dest"
	"origin" "-2462.68 3535.07 -3328"
	"StartDisabled" "1"
	"spawnflags" "1"
	"classname" "trigger_teleport"
}
;------------------------------------
; Adds a logic_relay for fail ending
;------------------------------------
add:
{
	"origin" "15103 -8864 2176"
	"targetname" "fail_ending_relay"
	"spawnflags" "1"
	"classname" "logic_relay"
	"OnTrigger" "env_fade,AddOutput,rendercolor 0 0 0,0,1"
	"OnTrigger" "console,Command,say < You don't have it? >,0,1"
	"OnTrigger" "console,Command,say < Prepare to be punished >,5,1"
	"OnTrigger" "env_fade,Fade,,6,1"
	"OnTrigger" "fail_tp,Enable,,9,1"
	"OnTrigger" "console,Command,say < Where are we!? >,11,1"
	"OnTrigger" "console,Command,say < Moon Lord appeared! >,14,1"
	"OnTrigger" "console,Command,say < KILL HIM! >,15.30,1"
	"OnTrigger"	"moon_lord_hitbox,SetDamageFilter,human_filter,15.10,1"
	"OnTrigger" "Moon_lord_kill_fail_relay,Trigger,,16,1"
	"OnTrigger" "moon_lord_hp_trigger,Enable,,14,-1"
	"OnTrigger" "moon_lord_template,ForceSpawn,,15,1"
	"OnTrigger" "env_fade,Fade,,12,1"
	"OnTrigger" "env_fade,AddOutput,rendercolor 246 249 250,12,1"
	"OnTrigger" "env_fade,AddOutput,holdtime 1,12,1"
	"OnTrigger" "env_fade,AddOutput,duration 2,12,1"
	"OnTrigger" "tp_22,Enable,,11,1"
}
;---------------------------------------
; Adds a new trigger_teleport at ending
;---------------------------------------
add:
{
	"model" "*300"
	"targetname" "fail_tp"
	"target" "dest_15"
	"StartDisabled" "1"
	"spawnflags" "1"
	"origin" "9216 -3136 -9088"
	"filtername" "human_filter"
	"classname" "trigger_teleport"
}
;-----------------------------------------------
; Adds a targetname and disabled the old ending
;-----------------------------------------------
modify:
{
    match:
    {
		"classname" "trigger_once"
		"hammerid" "298519"
    }
    insert:
    {
		"targetname" "ending_credits"
    }
    replace:
    {
		"StartDisabled" "1"
    }
}
---------------------------------------------------------------
; Triggers the fail relay if no portal gun makes it to the end
;--------------------------------------------------------------
modify:
{
    match:
    {
        "targetname" "Golem_phase_2_hitbox"
    }
    insert:
    {
		"OnBreak" "fail_ending_relay,Trigger,,15,1"
    }
}
;--------------------------------------------------------------
; Makes the fail relay disabled and enables the ending credits
;--------------------------------------------------------------
modify:
{
    match:
    {
        "targetname" "end_trigger"
    }
    insert:
    {
		"OnStartTouch" "ending_credits,Enable,,0,1"
		"OnStartTouch" "fail_ending_relay,Disable,,0,1"
    }
}
;------------------------------------------
; Adds a trigger to give hp to moonlord boss
;------------------------------------------
add:
{
	"model" "*95"
    "targetname" "moon_lord_hp_trigger"
	"StartDisabled" "1"
	"spawnflags" "1"
	"origin" "-2462.68 3535.07 -3328"
	"classname" "trigger_once"
	"OnStartTouch" "moon_lord_hp_counter,add,800,0,1"
}
;----------------------------------
; Adds a math_counter for moonlord
;----------------------------------
add:
{
	"origin" "7934.55 -12733.9 424.281"
	"targetname" "moon_lord_hp_counter"
	"startvalue" "300"
	"StartDisabled" "0"
	"min" "0"
	"max" "999999"
	"classname" "math_counter"
	"OnHitMin" "moon_lord_hitbox,Break,,0,-1"
}
;---------------------------
; Adds a hitbox to moonlord
;---------------------------
add:
{
	"model" "*89"
	"targetname" "moon_lord_hitbox"
	"spawnobject" "0"
	"spawnflags" "0"
	"rendermode" "10"
	"renderfx" "0"
	"rendercolor" "255 255 255"
	"damagefilter" "Filter_Nada"
	"renderamt" "255"
	"propdata" "0"
	"pressuredelay" "0"
	"physdamagescale" "1.0"
	"PerformanceMode" "0"
	"origin" "-4480 3456 -3424"
	"nodamageforces" "0"
	"minhealthdmg" "0"
	"material" "0"
	"health" "9999999"
	"gibdir" "0 0 0"
	"explosion" "0"
	"ExplodeRadius" "0"
	"explodemagnitude" "0"
	"ExplodeDamage" "0"
	"disableshadows" "0"
	"disablereceiveshadows" "0"
	"classname" "func_breakable"
	"OnHealthChanged" "moon_lord_hp_counter,Subtract,3,0,-1"
	"OnBreak" "console,Command,say < Moon Lord judges you worthy >,0,1"
	"OnBreak" "ending_credits_fake,Enable,,2,1"
	"OnBreak" "Moon_lord_kill_fail_relay,CancelPending,,0,1"
	"OnBreak" "teleport_humans_to_cage,Kill,,0,1"
}
;---------------------------------------------------------------
; Adds a new ending trigger after the false defeat of moon Lord
;---------------------------------------------------------------
add:
{
	"model" "*95"
	"StartDisabled" "1"
	"spawnflags" "1"
	"origin" "-2368 3456 -3616"
	"classname" "trigger_once"
	"targetname" "ending_credits_fake"
	"OnStartTouch" "console,Command,say < WE ACTUALLY DID IT! >,0,1"
	"OnStartTouch" "console,Command,say < Looks like Moon Lord lets us live!! >,2,1"
	"OnStartTouch" "console,Command,say < Map created by Hobbitten >,6,1"
	"OnStartTouch" "console,Command,say < He's going to kill all the Zombies! >,13,1"
	"OnStartTouch" "end_hurt,Enable,,18,1"
	"OnStartTouch" "console,Command,say < Thank you for playing my map! >,3,1"
	"OnStartTouch" "death_ray_effect,PlaySound,,16.60,1"
	"OnStartTouch" "moon_lord_beam_particle,Start,,17,1"
	"OnStartTouch" "console,Command,< Special thanks to: friezi - Kaemon - Moltard - Ripper - Rognus - Xehanort - xen - zaCade >,4,1"
}
