;------------------------------------------------------------
; Stripper version display
;------------------------------------------------------------
modify:
{
	match:
	{
        "origin" "-6872 1144 -3448"
        "classname" "logic_auto"
	}
	insert:
	{
        "OnMapSpawn" "cmd,Command,say << STRIPPER 3 APPLIED >>,10,-1"
	}
}

;------------------------------------------------------------
; Fix health settings so I can display bosshud
;------------------------------------------------------------
modify:
{
	match:
	{
        "origin" "-6872 1144 -3448"
        "classname" "logic_auto"
	}
	delete:
	{
        "OnMapSpawn" "glasshealth,AddHealth,1500,0,-1"
	}
}
modify:
{
	match:
	{
        "origin" "-6160 1316 -2188"
        "classname" "trigger_once"
	}
	insert:
	{
        "OnStartTouch" "glasshealth,SetHealth,1575,25,1"
        "targetname" "sephi_hp_add"
	}
}

;-----------------------------------------
; Sets Sephiroths breakhealth super high
;-----------------------------------------
modify:
{
	match:
	{
        "targetname" "glasshealth"
        "origin" "-4891.5 1856 -2191.5"
        "classname" "func_breakable"
	}
	replace:
	{
        "health" "999999"
	}
}

;----------------------------------------------------------------------------------
; Fixing the teleportation situtation from different minigame to minigame
;----------------------------------------------------------------------------------

; Removes all 3 game_texts to use 1 game_text only
filter:
{
    "origin" "-6944 1072 -3448"
    "targetname" "simon_says_text"
    "classname" "game_text"
}
filter:
{
    "origin" "-6944 1048 -3448"
    "targetname" "rope_text"
    "classname" "game_text"
}
filter:
{
    "origin" "-6944 1072 -3448"
    "targetname" "simon_says_text"
    "classname" "game_text"
}

; Adds 1 game_text back that controls the minigame messages on top
add:
{
    "origin" "-6944 1072 -3448"
    "y" "0.4"
    "x" "-1"
    "targetname" "minigame_gametext"
    "spawnflags" "1"
    "message" "NONE"
    "holdtime" "3"
    "fxtime" "0.25"
    "fadeout" "1"
    "fadein" "1"
    "effect" "0"
    "color2" "90 90 90"
    "color" "255 255 255"
    "channel" "1"
    "classname" "game_text"
}

; Removes all the AFK teleports in the map
filter:
{
    "targetname" "tele_all_sphere_trigger"
    "origin" "-5434 40 -2684"
    "classname" "trigger_teleport"
}
filter:
{
    "targetname" "tele_all_rope_trigger"
    "origin" "-5405 40 -2684"
    "classname" "trigger_teleport"
}
filter:
{
    "targetname" "tele_all_squash_trigger"
    "origin" "-5392 40 -2684"
    "classname" "trigger_teleport"
}
filter:
{
    "targetname" "tele_all_simon_trigger"
    "origin" "-5440 40 -2684"
    "classname" "trigger_teleport"
}

; Adds 1 back to control the AFK teleportation
add:
{
    "model" "*267"
    "targetname" "map_teleportation"
    "target" "NONE"
    "StartDisabled" "1"
    "spawnflags" "1"
    "origin" "-5434 40 -2684"
    "classname" "trigger_teleport"
}

; Removes all the Human & Zombie teleportation when jumping down from the ramp
filter:
{
    "targetname" "tele_human_simon_trigger"
    "origin" "-3972 1888 -3096"
    "classname" "trigger_teleport"
}
filter:
{
    "targetname" "tele_zm_simon_trigger"
    "origin" "-3972 1888 -3096"
    "classname" "trigger_teleport"
}
filter:
{
    "targetname" "tele_human_rope_trigger"
    "origin" "-3972 1888 -3097"
    "classname" "trigger_teleport"
}
filter:
{
    "targetname" "tele_zm_rope_trigger"
    "origin" "-3972 1888 -3097"
    "classname" "trigger_teleport"
}
filter:
{
    "targetname" "tele_humans_squash_trigger"
    "origin" "-3972 1888 -3100"
    "classname" "trigger_teleport"
}
filter:
{
    "targetname" "tele_zm_squash_trigger"
    "origin" "-3972 1888 -3100"
    "classname" "trigger_teleport"
}

; Adds 2 back to control where Humans & Zombies goes to what minigame
add:
{
    "model" "*173"
    "targetname" "teleport_humans_to_minigame"
    "target" "NONE"
    "StartDisabled" "0"
    "spawnflags" "1"
    "origin" "-3972 1888 -3100"
    "filtername" "humans"
    "classname" "trigger_teleport"
    "OnStartTouch" "minigame_gametext,Display,,0,1"
}
add:
{
    "model" "*172"
    "targetname" "teleport_zombies_to_minigame"
    "target" "NONE"
    "StartDisabled" "0"
    "spawnflags" "1"
    "origin" "-3972 1888 -3100"
    "filtername" "zombies"
    "classname" "trigger_teleport"
}

; Sets up the logic for the minigames
; Case 1 = Squasher
; Case 2 = Skipping rope
; Case 3 = Simon Says
modify:
{
	match:
	{
        "origin" "-6872 1120 -3448"
        "targetname" "games"
        "classname" "logic_case"
	}
	delete:
	{
        "OnCase01" "tele_human_simon_trigger,Enable,,0,-1"
        "OnCase01" "tele_zm_simon_trigger,Enable,,0,-1"
        "OnCase02" "tele_zm_rope_trigger,Enable,,0,-1"
        "OnCase02" "tele_human_rope_trigger,Enable,,0,-1"
        "OnCase03" "tele_humans_squash_trigger,Enable,,0,-1"
        "OnCase03" "tele_zm_squash_trigger,Enable,,0,-1"
	}
	insert:
	{
        "OnCase01" "teleport_humans_to_minigame,AddOutput,target squash_humans_tele,0,-1"
        "OnCase01" "teleport_zombies_to_minigame,AddOutput,target squash_zm_tele,0,-1"
        "OnCase01" "map_teleportation,AddOutput,target squash_zm_tele,0,-1"
        "OnCase01" "minigame_gametext,AddOutput,message The Squasher,0,-1"
        "OnCase01" "cmd,Command,say << The picked minigame will be The Squasher >>,4,-1"

        "OnCase02" "teleport_humans_to_minigame,AddOutput,target teleport_skipping_rope_ct,0,-1"
        "OnCase02" "teleport_zombies_to_minigame,AddOutput,target teleport_skipping_rope_t,0,-1"
        "OnCase02" "map_teleportation,AddOutput,target teleport_skipping_rope_t,0,-1"
        "OnCase02" "minigame_gametext,AddOutput,message Skipping Rope,0,-1"
        "OnCase02" "cmd,Command,say << The picked minigame will be Skipping Rope >>,4,-1"

        "OnCase03" "teleport_humans_to_minigame,AddOutput,target tele_human_simon,0,-1"
        "OnCase03" "teleport_zombies_to_minigame,AddOutput,target tele_zm_simon,0,-1"
        "OnCase03" "map_teleportation,AddOutput,target tele_zm_simon,0,-1"
        "OnCase03" "minigame_gametext,AddOutput,message Sephiroth Says,0,-1"
        "OnCase03" "cmd,Command,say << The picked minigame will be Sephiroth Says >>,4,-1"
	}
}

;---------------------------------------------------------------------------------------------------------------------------------
; Applies the new targetnames for the teleportation triggers into the old triggers in the map & fixes some minor issues
;---------------------------------------------------------------------------------------------------------------------------------

; The squasher minigame start trigger
modify:
{
	match:
	{
        "origin" "-586 -1392 -3712"
        "classname" "trigger_once"
	}
	delete:
	{
        "OnStartTouch" "tele_all_squash_trigger,Disable,,16,-1"
        "OnStartTouch" "tele_all_squash_trigger,Enable,,15,-1"
	}
	insert:
	{
        "OnStartTouch" "map_teleportation,Enable,,15,-1"
        "OnStartTouch" "map_teleportation,Disable,,87,-1"
	}
}

; The skipping rope minigame start trigger
modify:
{
	match:
	{
        "origin" "-670.99 1674 -2740"
        "classname" "trigger_once"
	}
	delete:
	{
        "OnStartTouch" "tele_all_rope_trigger,Enable,,15,-1"
        "OnStartTouch" "tele_all_rope_trigger,Disable,,16,-1"
	}
	insert:
	{
        "OnStartTouch" "map_teleportation,Enable,,15,-1"
	}
}
modify:
{
	match:
	{
        "origin" "-624.512 1670.95 -2772"
        "targetname" "skipping_relay"
        "classname" "logic_relay"
	}
	insert:
	{
        "OnTrigger" "map_teleportation,Disable,,85,-1"
	}
}

; The simon says minigame start trigger
modify:
{
	match:
	{
        "origin" "-586 -1392 -3712"
        "classname" "trigger_once"
	}
	delete:
	{
        "OnStartTouch" "tele_all_simon_trigger,Enable,,15,1"
        "OnStartTouch" "tele_all_simon_trigger,Disable,,16,1"
	}
	insert:
	{
        "OnStartTouch" "map_teleportation,Enable,,15,-1"
        "OnStartTouch" "map_teleportation,Disable,,80,-1"
	}
}

;---------------------------------------------------------------------------------------------------------
; Fixes so zombies also are teleported to the sphere and can watch the humans dodge
;---------------------------------------------------------------------------------------------------------
modify:
{
	match:
	{
        "origin" "-3530.5 -917 -2584"
        "classname" "trigger_teleport"
	}
	insert:
	{
        "OnStartTouch" "map_teleportation,AddOutput,target sphere_tele_zm,0,-1"
        "OnStartTouch" "map_teleportation,Enable,,10,-1"
	}
}

;-----------------------------------------------------------
; Fixing bad outputs on the last teleporter trigger
;-----------------------------------------------------------
modify:
{
	match:
	{
        "origin" "-5524.5 -785.5 -2884"
        "classname" "trigger_once"
	}
	delete:
	{
        "OnStartTouch" "tele_all_end,Enable,,0,-1"
	}
	insert:
	{
        "OnStartTouch" "tele_all_end,Enable,,10,-1"
	}
}

;------------------------------
; Forgotten team filter fixes
;------------------------------
modify:
{
	match:
	{
        "targetname" "tele_humans_rope_to_end"
        "origin" "-663 1956 -2724"
        "classname" "trigger_teleport"
	}
	insert:
	{
        "filtername" "humans"
	}
}
modify:
{
	match:
	{
        "targetname" "squash_tele_end"
        "origin" "-585 -1391 -3684"
        "classname" "trigger_teleport"
	}
	insert:
	{
        "filtername" "humans"
	}
}

;---------------------------------------------------
; Forgotten flags for client on trigger_teleports
;---------------------------------------------------
modify:
{
	match:
	{
        "targetname" "tele_zm_arena"
        "origin" "-498.5 3714 -2407.5"
        "classname" "trigger_teleport"
	}
	replace:
	{
        "spawnflags" "1"
	}
}

;-----------------------------------------------------------------------------------------------------------
; Missing output destination for zombies on the skipping rope minigame & making the trigger start disable
;-----------------------------------------------------------------------------------------------------------
modify:
{
	match:
	{
        "targetname" "tele_zm_rope_to_end"
        "origin" "-663 1958 -2724"
        "classname" "trigger_teleport"
	}
	insert:
	{
        "target" "endtp"
	}
	replace:
	{
                "StartDisabled" "1"
	}
}

;-----------------------------------------------------------
; Fixes the trigger_multiple and making it a trigger_once
;-----------------------------------------------------------
modify:
{
	match:
	{
        "origin" "-3971.5 1887 -3092"
        "classname" "trigger_multiple"
	}
	replace:
	{
        "classname" "trigger_once"
	}
	delete:
	{
        "OnStartTouch" "!activator,SetFogController,fog_off,0,-1"
        "OnEndTouch" "!activator,SetFogController,fog_master,0,-1"
        "OnStartTouch" "rain_bg_sound,StopSound,,0,-1"
        "OnStartTouch" "rain,Alpha,0,20,-1"
        "OnStartTouch" "night_clouds,Disable,,20,-1"
        "OnStartTouch" "night,Disable,,20,-1"
        "OnStartTouch" "sun,TurnOn,,20,-1"
        "OnStartTouch" "seph_hurry,PlaySound,,0,-1"
        "OnStartTouch" "seph_hurry,FadeOut,5,15,-1"
	}
	insert:
	{
        "OnStartTouch" "!activator,SetFogController,fog_off,0,1"
        "OnEndTouch" "!activator,SetFogController,fog_master,0,1"
        "OnStartTouch" "rain_bg_sound,StopSound,,0,1"
        "OnStartTouch" "rain,Alpha,0,20,1"
        "OnStartTouch" "night_clouds,Disable,,20,1"
        "OnStartTouch" "night,Disable,,20,1"
        "OnStartTouch" "sun,TurnOn,,20,1"
        "OnStartTouch" "seph_hurry,PlaySound,,0,1"
        "OnStartTouch" "seph_hurry,FadeOut,5,15,1"
	}
}

;----------------------------------------------------------------------------------------
; Removal of adminroom buttons as it doesnt work without applying permanent entities
;----------------------------------------------------------------------------------------
filter:
{
    "targetname" "admin_says"
    "origin" "-4106 832 -3600"
    "classname" "func_button"
}
filter:
{
    "targetname" "admin_squash"
    "origin" "-4256 650 -3600"
    "classname" "func_button"
}
filter:
{
    "targetname" "admin_rope"
    "origin" "-4402 832 -3600"
    "classname" "func_button"
}

;-------------------------------------------------------------------------------------------
; Delay the attacks of the simon says minigame. It is too fast for players to react
;-------------------------------------------------------------------------------------------

; Normal speed
modify:
{
	match:
	{
        "origin" "-592 372 -2538.51"
        "targetname" "z_time"
        "classname" "logic_timer"
	}
	replace:
	{
        "RefireTime" "3.5"
	}
}

; Faster speed
modify:
{
	match:
	{
        "origin" "-590.126 348 -2539.51"
        "targetname" "z_time2"
        "classname" "logic_timer"
	}
	replace:
	{
        "RefireTime" "3"
	}
}

;---------------------------------------------------------------------------------------------------------
; If Sephiroth boss somehow manages to die too early. Kill laser entities that prevents a soft lock
;---------------------------------------------------------------------------------------------------------
modify:
{
	match:
	{
        "targetname" "glasshealth"
        "origin" "-4891.5 1856 -2191.5"
        "classname" "func_breakable"
	}
	insert:
	{
        "OnBreak" "dimension_FFVII_last_boss2,Kill,,0,-1"
        "OnBreak" "Sephiroth_Final_Laser_Maker_top,Kill,,0,-1"
        "OnBreak" "Sephiroth_Final_Laser_Maker_under,Kill,,0,-1"
        "OnBreak" "bullet_remover,Kill,,0,-1"
        "OnBreak" "Sephiroth_Final_Laser_Case,Kill,,0,-1"
        "OnBreak" "Sephiroth_Final_Animation_Case,Kill,,0,-1"
        "OnBreak" "Sephiroth_Laser_Timer,Disable,,0,-1"
        "OnBreak" "Sephiroth_Laser_Timer,Kill,,0.1,-1"
        "OnBreak" "break_relay,Trigger,,0,-1"
	}
}

;--------------------------------------------------------------------------------------------------------------------------------------
; Makes a failsafe incase too many players makes it to the end of sphere level. To prevent server from crashing from too many edicts
;--------------------------------------------------------------------------------------------------------------------------------------

; Limited to 10 spawns only for the laser items
modify:
{
	match:
	{
        "origin" "-4777.08 4155.45 -3614.97"
        "targetname" "wep_zlaser"
        "classname" "weapon_knife"
	}
	delete:
	{
        "OnPlayerPickup" "!activator,AddOutput,targetname humans_laser,0.05,-1"
        "OnPlayerPickup" "laser_maker,ForceSpawn,,0.02,-1"
	}
	insert:
	{
        "OnPlayerPickup" "!activator,AddOutput,targetname humans_laser,0.05,10"
        "OnPlayerPickup" "laser_maker,ForceSpawn,,0.02,10"
	}
}













;-------------
; Heal item
;-------------
modify:
{
	match:
	{
        "targetname" "curacion2"
        "origin" "-6916.85 5952.12 -3484.23"
        "classname" "trigger_multiple"
	}
	delete:
	{
        "OnStartTouch" "!activator,AddOutput,health 150,0,-1"
	}
	insert:
	{
        "OnStartTouch" "!activator,AddOutput,health 250,0,-1"
	}
}