diff --git a/left4dead2/modes/l4d1coop.txt b/left4dead2/modes/l4d1coop.txt index db2e4528..f8c9b337 100644 --- a/left4dead2/modes/l4d1coop.txt +++ b/left4dead2/modes/l4d1coop.txt @@ -33,7 +33,7 @@ z_gun_swing_coop_max_penalty 999999999 z_gun_swing_coop_min_penalty 999999999 z_max_survivor_damage 100 - z_tank_autoshotgun_dmg_scale 0.75 + z_tank_autoshotgun_dmg_scale 1 z_use_tolerance 0.98 } } \ No newline at end of file diff --git a/left4dead2/modes/l4d1survival.txt b/left4dead2/modes/l4d1survival.txt index 59384167..b9aba973 100644 --- a/left4dead2/modes/l4d1survival.txt +++ b/left4dead2/modes/l4d1survival.txt @@ -36,7 +36,7 @@ z_female_boomer_spawn_chance 100 z_finale_spawn_safety_range 600 z_max_survivor_damage 100 - z_tank_autoshotgun_dmg_scale 0.75 + z_tank_autoshotgun_dmg_scale 1 z_use_tolerance 0.98 } } \ No newline at end of file diff --git a/left4dead2/modes/tankrun.txt b/left4dead2/modes/tankrun.txt index f820bf41..468bcdd2 100644 --- a/left4dead2/modes/tankrun.txt +++ b/left4dead2/modes/tankrun.txt @@ -24,6 +24,7 @@ pipe_bomb_timer_duration 1 survivor_allow_crawling 1 survivor_revive_duration 3 + survivor_revive_health 50 tank_burn_duration 20 tank_burn_duration_expert 30 tank_burn_duration_hard 25 diff --git a/left4dead2/scripts/vscripts/community1.nut b/left4dead2/scripts/vscripts/community1.nut index 5b5ed37c..101f65a6 100644 --- a/left4dead2/scripts/vscripts/community1.nut +++ b/left4dead2/scripts/vscripts/community1.nut @@ -106,10 +106,9 @@ MutationState <- function LeftSafeAreaThink() { - local player = null; - while ( player = Entities.FindByClassname( player, "player" ) ) + for ( local player; player = Entities.FindByClassname( player, "player" ); ) { - if ( ( !player.IsValid() ) || ( NetProps.GetPropInt( player, "m_iTeamNum" ) != 2 ) ) + if ( NetProps.GetPropInt( player, "m_iTeamNum" ) != 2 ) continue; if ( ResponseCriteria.GetValue( player, "instartarea" ) == "0" ) @@ -118,27 +117,21 @@ function LeftSafeAreaThink() SessionState.LeftSafeAreaThink = false; break; } - else - continue; } } function OnGameEvent_round_start_post_nav( params ) { - local spawner = null; - while ( spawner = Entities.FindByClassname( spawner, "info_zombie_spawn" ) ) + for ( local spawner; spawner = Entities.FindByClassname( spawner, "info_zombie_spawn" ); ) { - if ( spawner.IsValid() ) - { - local population = NetProps.GetPropString( spawner, "m_szPopulation" ); - - if ( population == "boomer" || population == "hunter" || population == "smoker" || population == "jockey" - || population == "charger" || population == "spitter" || population == "new_special" || population == "church" - || population == "tank" || population == "witch" || population == "witch_bride" || population == "river_docks_trap" ) - continue; - else - spawner.Kill(); - } + local population = NetProps.GetPropString( spawner, "m_szPopulation" ); + + if ( population == "boomer" || population == "hunter" || population == "smoker" || population == "jockey" + || population == "charger" || population == "spitter" || population == "new_special" || population == "church" + || population == "tank" || population == "witch" || population == "witch_bride" || population == "river_docks_trap" ) + continue; + else + spawner.Kill(); } if ( Director.GetMapName() == "c1m1_hotel" ) @@ -155,8 +148,7 @@ function OnGameEvent_player_left_safe_area( params ) if ( !player ) return; - local instartarea = ResponseCriteria.GetValue( player, "instartarea" ); - if ( instartarea == "1" ) + if ( ResponseCriteria.GetValue( player, "instartarea" ) == "1" ) { SessionOptions.cm_MaxSpecials = 0; SessionState.LeftSafeAreaThink = true; @@ -248,11 +240,7 @@ function Update() LeftSafeAreaThink(); if ( Director.GetCommonInfectedCount() > 0 ) { - local infected = null; - while ( infected = Entities.FindByClassname( infected, "infected" ) ) - { - if ( infected.IsValid() ) - infected.Kill(); - } + for ( local infected; infected = Entities.FindByClassname( infected, "infected" ); ) + infected.Kill(); } } diff --git a/left4dead2/scripts/vscripts/community2.nut b/left4dead2/scripts/vscripts/community2.nut index f7a85d85..dc66d743 100644 --- a/left4dead2/scripts/vscripts/community2.nut +++ b/left4dead2/scripts/vscripts/community2.nut @@ -17,7 +17,7 @@ DirectorOptions <- ChargerLimit = 0 JockeyLimit = 0 - ProhibitBosses = 1 //tanks still spawn at finales though + ProhibitBosses = true //tanks still spawn at finales though MegaMobSize = 0 // convert items that aren't useful @@ -38,17 +38,13 @@ DirectorOptions <- function OnGameEvent_round_start_post_nav( params ) { - local spawner = null; - while ( spawner = Entities.FindByClassname( spawner, "info_zombie_spawn" ) ) + for ( local spawner; spawner = Entities.FindByClassname( spawner, "info_zombie_spawn" ); ) { - if ( spawner.IsValid() ) - { - local population = NetProps.GetPropString( spawner, "m_szPopulation" ); - - if ( population == "boomer" || population == "spitter" || population == "church" || population == "river_docks_trap" ) - continue; - else - spawner.Kill(); - } + local population = NetProps.GetPropString( spawner, "m_szPopulation" ); + + if ( population == "boomer" || population == "spitter" || population == "church" || population == "river_docks_trap" ) + continue; + else + spawner.Kill(); } } diff --git a/left4dead2/scripts/vscripts/community5.nut b/left4dead2/scripts/vscripts/community5.nut index 93f8e287..98965237 100644 --- a/left4dead2/scripts/vscripts/community5.nut +++ b/left4dead2/scripts/vscripts/community5.nut @@ -7,14 +7,14 @@ DirectorOptions <- { ActiveChallenge = 1 - cm_ShouldHurry = 1 - cm_AllowPillConversion = 0 - cm_AllowSurvivorRescue = 0 + cm_ShouldHurry = true + cm_AllowPillConversion = false + cm_AllowSurvivorRescue = false SurvivorMaxIncapacitatedCount = 0 weaponsToConvert = { - weapon_first_aid_kit = "weapon_pain_pills_spawn" + //weapon_first_aid_kit = "weapon_pain_pills_spawn" weapon_adrenaline = "weapon_pain_pills_spawn" } @@ -52,6 +52,54 @@ DirectorOptions <- } } +function OnGameEvent_player_hurt_concise( params ) +{ + local player = GetPlayerFromUserID( params["userid"] ); + + if ( (!player) || (!player.IsSurvivor()) ) + return; + + if ( NetProps.GetPropInt( player, "m_bIsOnThirdStrike" ) == 0 && player.GetHealth() < (player.GetMaxHealth() / 4) ) + { + player.SetReviveCount( 0 ); + NetProps.SetPropInt( player, "m_isGoingToDie", 1 ); + } +} + +function CheckHealthAfterLedgeHang( userid ) +{ + local player = GetPlayerFromUserID( userid ); + if ( (!player) || (!player.IsSurvivor()) ) + return; + + if ( player.GetHealth() < (player.GetMaxHealth() / 4) ) + { + player.SetReviveCount( 0 ); + NetProps.SetPropInt( player, "m_isGoingToDie", 1 ); + } +} + +function OnGameEvent_revive_success( params ) +{ + local player = GetPlayerFromUserID( params["subject"] ); + + if ( (!params["ledge_hang"]) || (!player) || (!player.IsSurvivor()) ) + return; + + if ( NetProps.GetPropInt( player, "m_bIsOnThirdStrike" ) == 0 ) + EntFire( "worldspawn", "RunScriptCode", "g_ModeScript.CheckHealthAfterLedgeHang(" + params["subject"] + ")", 0.1 ); +} + +function OnGameEvent_bot_player_replace( params ) +{ + local player = GetPlayerFromUserID( params["player"] ); + + if ( (!player) || (NetProps.GetPropInt( player, "m_bIsOnThirdStrike" ) == 1) ) + return; + + StopSoundOn( "Player.Heartbeat", player ); +} + function Update() { DirectorOptions.RecalculateHealthDecay(); diff --git a/left4dead2/scripts/vscripts/l4d1.nut b/left4dead2/scripts/vscripts/l4d1.nut index 6a659a57..6b02232e 100644 --- a/left4dead2/scripts/vscripts/l4d1.nut +++ b/left4dead2/scripts/vscripts/l4d1.nut @@ -92,77 +92,83 @@ function OnGameEvent_round_start_post_nav( params ) EntFire( wep + "_spawn", "Kill" ); foreach( wep, val in DirectorOptions.weaponsToConvert ) { - local wep_spawner = null; - while ( wep_spawner = Entities.FindByClassname( wep_spawner, wep + "_spawn" ) ) + for ( local wep_spawner; wep_spawner = Entities.FindByClassname( wep_spawner, wep + "_spawn" ); ) { - if ( wep_spawner.IsValid() ) + local spawnTable = { - local spawnTable = - { - origin = wep_spawner.GetOrigin(), - angles = wep_spawner.GetAngles().ToKVString(), - targetname = wep_spawner.GetName(), - count = NetProps.GetPropInt( wep_spawner, "m_itemCount" ), - spawnflags = NetProps.GetPropInt( wep_spawner, "m_spawnflags" ) - } - wep_spawner.Kill(); - SpawnEntityFromTable(val, spawnTable); + origin = wep_spawner.GetOrigin(), + angles = wep_spawner.GetAngles().ToKVString(), + targetname = wep_spawner.GetName(), + count = NetProps.GetPropInt( wep_spawner, "m_itemCount" ), + spawnflags = NetProps.GetPropInt( wep_spawner, "m_spawnflags" ) } + wep_spawner.Kill(); + SpawnEntityFromTable(val, spawnTable); } } - if ( SessionState.ModeName == "l4d1coop" || SessionState.ModeName == "l4d1vs" ) + if ( Director.IsL4D1Campaign() ) { - if ( SessionState.MapName == "c8m5_rooftop" || SessionState.MapName == "c9m2_lots" || SessionState.MapName == "c10m5_houseboat" - || SessionState.MapName == "c11m5_runway" || SessionState.MapName == "c12m5_cornfield" ) - { - local finale = Entities.FindByClassname( null, "trigger_finale" ); - if ( finale ) - NetProps.SetPropInt( finale, "m_type", 0 ); - } - else if ( SessionState.MapName == "c10m4_mainstreet" ) - { - local relay = Entities.FindByName( null, "forklift_relay" ); - if ( relay ) - { - EntityOutputs.RemoveOutput( relay, "OnTrigger", "director", "BeginScript", "c10m4_onslaught" ); - EntityOutputs.AddOutput( relay, "OnTrigger", "director", "ForcePanicEvent", "", 9.0, -1 ); - } - EntFire( "onslaught1", "Kill" ); - } - else if ( SessionState.MapName == "c11m4_terminal" ) + DirectorOptions.WaterSlowsMovement <- false; + + if ( SessionState.ModeName == "l4d1coop" || SessionState.ModeName == "l4d1vs" ) { - local van = Entities.FindByName( null, "van_button" ); - if ( van ) - { - EntityOutputs.RemoveOutput( van, "OnPressed", "@director", "", "" ); - EntityOutputs.AddOutput( van, "OnPressed", "@director", "ForcePanicEvent", "", 3.0, -1 ); - } - local relay = Entities.FindByName( null, "alarm_on_relay" ); - if ( relay ) + if ( IsMissionFinalMap() ) { - EntityOutputs.RemoveOutput( relay, "OnTrigger", "@director", "", "" ); - EntityOutputs.RemoveOutput( relay, "OnTrigger", "alarm_safety_relay", "", "" ); - EntityOutputs.AddOutput( relay, "OnTrigger", "@director", "ForcePanicEvent", "", 0.0, -1 ); - EntityOutputs.AddOutput( relay, "OnTrigger", "alarm_off_relay", "Trigger", "", 15.0, -1 ); + if ( SessionState.MapName != "c7m3_port" ) + { + local finale = Entities.FindByClassname( null, "trigger_finale" ); + if ( finale ) + NetProps.SetPropInt( finale, "m_type", 0 ); + } } - EntFire( "van_follow_trigger", "Kill" ); - EntFire( "van_endscript_relay", "Kill" ); - EntFire( "onslaught_hint_trigger", "Kill" ); - } - else if ( SessionState.MapName == "c12m3_bridge" ) - { - local relay = Entities.FindByName( null, "train_engine_relay" ); - if ( relay ) + else { - EntityOutputs.RemoveOutput( relay, "OnTrigger", "director", "BeginScript", "c12m3_onslaught" ); - EntityOutputs.AddOutput( relay, "OnTrigger", "director", "ForcePanicEvent", "", 2.0, -1 ); + if ( SessionState.MapName == "c10m4_mainstreet" ) + { + local relay = Entities.FindByName( null, "forklift_relay" ); + if ( relay ) + { + EntityOutputs.RemoveOutput( relay, "OnTrigger", "director", "BeginScript", "c10m4_onslaught" ); + EntityOutputs.AddOutput( relay, "OnTrigger", "director", "ForcePanicEvent", "", 9.0, -1 ); + } + EntFire( "onslaught1", "Kill" ); + } + else if ( SessionState.MapName == "c11m4_terminal" ) + { + local van = Entities.FindByName( null, "van_button" ); + if ( van ) + { + EntityOutputs.RemoveOutput( van, "OnPressed", "@director", "", "" ); + EntityOutputs.AddOutput( van, "OnPressed", "@director", "ForcePanicEvent", "", 3.0, -1 ); + } + local relay = Entities.FindByName( null, "alarm_on_relay" ); + if ( relay ) + { + EntityOutputs.RemoveOutput( relay, "OnTrigger", "@director", "", "" ); + EntityOutputs.RemoveOutput( relay, "OnTrigger", "alarm_safety_relay", "", "" ); + EntityOutputs.AddOutput( relay, "OnTrigger", "@director", "ForcePanicEvent", "", 0.0, -1 ); + EntityOutputs.AddOutput( relay, "OnTrigger", "alarm_off_relay", "Trigger", "", 15.0, -1 ); + } + EntFire( "van_follow_trigger", "Kill" ); + EntFire( "van_endscript_relay", "Kill" ); + EntFire( "onslaught_hint_trigger", "Kill" ); + } + else if ( SessionState.MapName == "c12m3_bridge" ) + { + local relay = Entities.FindByName( null, "train_engine_relay" ); + if ( relay ) + { + EntityOutputs.RemoveOutput( relay, "OnTrigger", "director", "BeginScript", "c12m3_onslaught" ); + EntityOutputs.AddOutput( relay, "OnTrigger", "director", "ForcePanicEvent", "", 2.0, -1 ); + } + EntFire( "zombie_spawn1", "Kill" ); + EntFire( "onslaught_hint_template", "Kill" ); + } + else if ( SessionState.MapName == "c12m4_barn" ) + EntFire( "window_trigger", "Kill" ); } - EntFire( "zombie_spawn1", "Kill" ); - EntFire( "onslaught_hint_template", "Kill" ); } - else if ( SessionState.MapName == "c12m4_barn" ) - EntFire( "window_trigger", "Kill" ); } } diff --git a/left4dead2/scripts/vscripts/mutation1.nut b/left4dead2/scripts/vscripts/mutation1.nut index c1ef7541..9867452f 100644 --- a/left4dead2/scripts/vscripts/mutation1.nut +++ b/left4dead2/scripts/vscripts/mutation1.nut @@ -6,13 +6,13 @@ DirectorOptions <- { ActiveChallenge = 1 - cm_NoSurvivorBots = 1 + cm_NoSurvivorBots = true cm_CommonLimit = 0 cm_DominatorLimit = 1 cm_MaxSpecials = 2 cm_SpecialRespawnInterval = 60 - cm_AutoReviveFromSpecialIncap = 1 - cm_AllowPillConversion = 0 + cm_AutoReviveFromSpecialIncap = true + cm_AllowPillConversion = false BoomerLimit = 0 MobMaxPending = 0 @@ -47,20 +47,16 @@ DirectorOptions <- function OnGameEvent_round_start_post_nav( params ) { - local spawner = null; - while ( spawner = Entities.FindByClassname( spawner, "info_zombie_spawn" ) ) + for ( local spawner; spawner = Entities.FindByClassname( spawner, "info_zombie_spawn" ); ) { - if ( spawner.IsValid() ) - { - local population = NetProps.GetPropString( spawner, "m_szPopulation" ); - - if ( population == "boomer" || population == "hunter" || population == "smoker" || population == "jockey" - || population == "charger" || population == "spitter" || population == "new_special" || population == "church" - || population == "tank" || population == "witch" || population == "witch_bride" || population == "river_docks_trap" ) - continue; - else - spawner.Kill(); - } + local population = NetProps.GetPropString( spawner, "m_szPopulation" ); + + if ( population == "boomer" || population == "hunter" || population == "smoker" || population == "jockey" + || population == "charger" || population == "spitter" || population == "new_special" || population == "church" + || population == "tank" || population == "witch" || population == "witch_bride" || population == "river_docks_trap" ) + continue; + else + spawner.Kill(); } if ( Director.GetMapName() == "c5m5_bridge" || Director.GetMapName() == "c6m3_port" ) @@ -68,22 +64,18 @@ function OnGameEvent_round_start_post_nav( params ) foreach( wep, val in DirectorOptions.weaponsToConvert ) { - local wep_spawner = null; - while ( wep_spawner = Entities.FindByClassname( wep_spawner, wep + "_spawn" ) ) + for ( local wep_spawner; wep_spawner = Entities.FindByClassname( wep_spawner, wep + "_spawn" ); ) { - if ( wep_spawner.IsValid() ) + local spawnTable = { - local spawnTable = - { - origin = wep_spawner.GetOrigin(), - angles = wep_spawner.GetAngles().ToKVString(), - targetname = wep_spawner.GetName(), - count = NetProps.GetPropInt( wep_spawner, "m_itemCount" ), - spawnflags = NetProps.GetPropInt( wep_spawner, "m_spawnflags" ) - } - wep_spawner.Kill(); - SpawnEntityFromTable(val, spawnTable); + origin = wep_spawner.GetOrigin(), + angles = wep_spawner.GetAngles().ToKVString(), + targetname = wep_spawner.GetName(), + count = NetProps.GetPropInt( wep_spawner, "m_itemCount" ), + spawnflags = NetProps.GetPropInt( wep_spawner, "m_spawnflags" ) } + wep_spawner.Kill(); + SpawnEntityFromTable(val, spawnTable); } } } @@ -104,11 +96,7 @@ function Update() { if ( Director.GetCommonInfectedCount() > 0 ) { - local infected = null; - while ( infected = Entities.FindByClassname( infected, "infected" ) ) - { - if ( infected.IsValid() ) - infected.Kill(); - } + for ( local infected; infected = Entities.FindByClassname( infected, "infected" ); ) + infected.Kill(); } } diff --git a/left4dead2/scripts/vscripts/mutation15.nut b/left4dead2/scripts/vscripts/mutation15.nut index fcf42ff3..d10dfeb8 100644 --- a/left4dead2/scripts/vscripts/mutation15.nut +++ b/left4dead2/scripts/vscripts/mutation15.nut @@ -2,7 +2,7 @@ Msg("Activating Mutation 15\n"); -DirectorOptions <- +DirectorOptions <- { ActiveChallenge = 1 @@ -30,29 +30,81 @@ DirectorOptions <- function OnGameEvent_survival_round_start( params ) { + local validStartNames = { func_button_timed = "OnTimeUp", func_button = "OnPressed", script_func_button = "OnPressed", trigger_finale = "UseStart", prop_door_rotating = "OnOpen" }; + local function GetSurvivalStartEntity() + { + local validIO = { logic_relay = { input = "Trigger", output = "OnTrigger" }, logic_timer = { input = "Enable", output = "OnTimer" } }; + local function CheckOutputs( entity, outputName ) + { + local ent = entity; + local output = outputName; + while ( ent ) + { + local target = null; + local targetOutput = ""; + local nElements = EntityOutputs.GetNumElements( ent, output ); + for ( local i = 0; i < nElements; i++ ) + { + local outputs = {}; + EntityOutputs.GetOutputTable( ent, output, outputs, i ); + local outputTarget = Entities.FindByName( null, outputs.target ); + if ( !outputTarget ) + continue; + + if ( outputTarget.GetClassname() == "info_director" && outputs.input.find( "PanicEvent" ) != null ) + return outputTarget; + else + { + if ( (outputTarget.GetClassname() in validIO) && (outputs.input == validIO[outputTarget.GetClassname()].input) ) + { + target = outputTarget; + targetOutput = validIO[outputTarget.GetClassname()].output; + } + } + } + ent = target; + output = targetOutput; + } + return null; + } + + foreach( classname, output in validStartNames ) + { + for ( local ent; ent = Entities.FindByClassname( ent, classname ); ) + { + if ( !EntityOutputs.HasAction( ent, output ) ) + continue; + + local target = CheckOutputs( ent, output ); + if ( (!target) || (target.GetClassname() != "info_director") ) + continue; + + return ent; + } + } + return null; + } + EntFire( "info_director", "PanicEvent" ); - - if ( SessionState.MapName == "c1m2_steets" ) - EntFire( "store_doors", "Open" ); - else if ( SessionState.MapName == "c7m1_docks" ) + + local startEntity = GetSurvivalStartEntity(); + if ( startEntity ) { - EntFire( "tankdoorin", "Open" ); - EntFire( "tankdoorin_button", "Kill" ); - EntFire( "tank_sound_timer", "Disable" ); - EntFire( "doorsound", "PlaySound" ); - EntFire( "tank_fog", "Enable" ); - EntFire( "tank_fog", "Disable", "", 0.5 ); - EntFire( "big_splash", "Start" ); - EntFire( "big_splash", "Stop", "", 2 ); - EntFire( "coop_tank", "Trigger" ); - EntFire( "radio_game_event", "Kill" ); - EntFire( "tank_door_clip", "Kill" ); - EntFire( "director", "EnableTankFrustration" ); - EntFire( "battlefield_cleared", "UnblockNav", "", 60 ); - EntFire( "tank_car_camera_clip", "Kill" ); + if ( startEntity.GetClassname() == "func_button_timed" || startEntity.GetClassname() == "trigger_finale" ) + { + local nElements = EntityOutputs.GetNumElements( startEntity, validStartNames[startEntity.GetClassname()] ); + for ( local i = 0; i < nElements; i++ ) + { + local outputs = {}; + EntityOutputs.GetOutputTable( startEntity, validStartNames[startEntity.GetClassname()], outputs, i ); + EntFire( outputs.target, outputs.input, outputs.parameter, outputs.delay ); + } + } + else + { + EntFire( startEntity.GetName(), "Unlock" ); + EntFire( startEntity.GetName(), "Press" ); + EntFire( startEntity.GetName(), "Open" ); + } } - else if ( SessionState.MapName == "c11m5_runway" ) - EntFire( "planecrash_trigger", "Trigger", "", 16 ); - else if ( SessionState.MapName == "c12m2_traintunnel" ) - EntFire( "emergency_door", "Open" ); } diff --git a/left4dead2/scripts/vscripts/mutation19.nut b/left4dead2/scripts/vscripts/mutation19.nut index 46e5f353..9c807853 100644 --- a/left4dead2/scripts/vscripts/mutation19.nut +++ b/left4dead2/scripts/vscripts/mutation19.nut @@ -7,9 +7,9 @@ DirectorOptions <- ActiveChallenge = 1 // cm_frustrationTimer = 0 - cm_TankRun = 1 - cm_ShouldHurry = 1 - cm_AutoSpawnInfectedGhosts = 1 + cm_TankRun = true + cm_ShouldHurry = true + cm_AutoSpawnInfectedGhosts = true PreferredSpecialDirection = SPAWN_BEHIND_SURVIVORS BehindSurvivorsSpawnDistance = 2000 @@ -35,6 +35,122 @@ DirectorOptions <- return weaponsToConvert[classname]; } return 0; - } + } +} +function OnGameEvent_round_start_post_nav( params ) +{ + local function CheckOutputs( entity, outputName ) + { + local ent = entity; + local output = outputName; + while ( ent ) + { + local target = null; + local targetOutput = ""; + local nElements = EntityOutputs.GetNumElements( ent, output ); + for ( local i = 0; i < nElements; i++ ) + { + local outputs = {}; + EntityOutputs.GetOutputTable( ent, output, outputs, i ); + local outputTarget = Entities.FindByName( null, outputs.target ); + if ( !outputTarget ) + continue; + + if ( outputs.input == "Unlock" || outputs.input == "Enable" || outputs.input == "SetValueTest" || outputs.input == "MoveToFloor" ) + return outputTarget; + else + { + if ( outputTarget.GetClassname() == "logic_relay" && outputs.input == "Trigger" ) + { + target = outputTarget; + targetOutput = "OnTrigger"; + } + } + } + ent = target; + output = targetOutput; + } + return null; + } + for ( local trigger; trigger = Entities.FindByClassname( trigger, "trigger_multiple" ); ) + { + if ( NetProps.GetPropInt( trigger, "m_bAllowIncapTouch" ) == 0 || !EntityOutputs.HasAction( trigger, "OnEntireTeamStartTouch" ) ) + continue; + + NetProps.SetPropInt( trigger, "m_bAllowIncapTouch", 0 ); + local target = CheckOutputs( trigger, "OnEntireTeamStartTouch" ); + if ( !target ) + continue; + + if ( target.GetClassname() == "logic_relay" ) + { + for ( local button; button = Entities.FindByClassname( button, "func_button" ); ) + { + local nElements = EntityOutputs.GetNumElements( button, "OnPressed" ); + for ( local i = 0; i < nElements; i++ ) + { + local outputs = {}; + EntityOutputs.GetOutputTable( button, "OnPressed", outputs, i ); + if ( outputs.target == target.GetName() ) + { + target = button; + break; + } + } + } + } + else if ( target.GetClassname() == "logic_branch" ) + { + local foundListener = false; + for ( local listener; listener = Entities.FindByClassname( listener, "logic_branch_listener" ); ) + { + for ( local i = 0; i < 16; i++ ) + { + if ( NetProps.GetPropString( listener, "m_nLogicBranchNames[" + i + "]" ) == target.GetName() ) + { + foundListener = true; + break; + } + } + + if ( foundListener ) + { + local nElements = EntityOutputs.GetNumElements( listener, "OnAllTrue" ); + for ( local i = 0; i < nElements; i++ ) + { + local outputs = {}; + EntityOutputs.GetOutputTable( listener, "OnAllTrue", outputs, i ); + if ( outputs.input == "Unlock" ) + { + target = Entities.FindByName( null, outputs.target ); + break; + } + } + break; + } + } + } + + local validOutputs = { func_button_timed = "OnTimeUp", func_button = "OnPressed", script_func_button = "OnPressed", prop_door_rotating = "OnOpen" }; + if ( !target.GetClassname() in validOutputs ) + continue; + + target.ValidateScriptScope(); + local targetScope = target.GetScriptScope(); + targetScope.OverrideTrigger <- trigger; + targetScope.UseEnt <- function() + { + for ( local player; player = Entities.FindByClassname( player, "player" ); ) + { + if ( player.IsSurvivor() && player.IsIncapacitated() ) + { + if ( !OverrideTrigger.IsTouching( player ) ) + player.TakeDamage( player.GetHealth(), 0, null ); + } + } + self.DisconnectOutput( validOutputs[target.GetClassname()], "UseEnt" ); + } + target.ConnectOutput( validOutputs[target.GetClassname()], "UseEnt" ); + } } diff --git a/left4dead2/scripts/vscripts/mutation5.nut b/left4dead2/scripts/vscripts/mutation5.nut index 7d9441c1..08f7e7c6 100644 --- a/left4dead2/scripts/vscripts/mutation5.nut +++ b/left4dead2/scripts/vscripts/mutation5.nut @@ -95,20 +95,16 @@ DirectorOptions <- function OnGameEvent_round_start_post_nav( params ) { - local spawner = null; - while ( spawner = Entities.FindByClassname( spawner, "info_zombie_spawn" ) ) + for ( local spawner; spawner = Entities.FindByClassname( spawner, "info_zombie_spawn" ); ) { - if ( spawner.IsValid() ) - { - local population = NetProps.GetPropString( spawner, "m_szPopulation" ); - - if ( population == "boomer" || population == "hunter" || population == "smoker" || population == "jockey" - || population == "charger" || population == "spitter" || population == "new_special" || population == "church" - || population == "tank" || population == "witch" || population == "witch_bride" || population == "river_docks_trap" ) - continue; - else - spawner.Kill(); - } + local population = NetProps.GetPropString( spawner, "m_szPopulation" ); + + if ( population == "boomer" || population == "hunter" || population == "smoker" || population == "jockey" + || population == "charger" || population == "spitter" || population == "new_special" || population == "church" + || population == "tank" || population == "witch" || population == "witch_bride" || population == "river_docks_trap" ) + continue; + else + spawner.Kill(); } if ( Director.GetMapName() == "c5m5_bridge" || Director.GetMapName() == "c6m3_port" ) @@ -135,11 +131,7 @@ function Update() { if ( Director.GetCommonInfectedCount() > 0 ) { - local infected = null; - while ( infected = Entities.FindByClassname( infected, "infected" ) ) - { - if ( infected.IsValid() ) - infected.Kill(); - } + for ( local infected; infected = Entities.FindByClassname( infected, "infected" ); ) + infected.Kill(); } } diff --git a/left4dead2/scripts/vscripts/tankrun.nut b/left4dead2/scripts/vscripts/tankrun.nut index a1684d28..f92aa2f9 100644 --- a/left4dead2/scripts/vscripts/tankrun.nut +++ b/left4dead2/scripts/vscripts/tankrun.nut @@ -10,8 +10,9 @@ if ( !IsModelPrecached( "models/infected/hulk_l4d1.mdl" ) ) MutationOptions <- { - cm_ShouldHurry = 1 - cm_InfiniteFuel = 1 + cm_ShouldHurry = true + cm_InfiniteFuel = true + cm_AllowPillConversion = false cm_CommonLimit = 0 cm_DominatorLimit = 0 cm_MaxSpecials = 0 @@ -31,11 +32,11 @@ MutationOptions <- MobMaxSize = 0 NoMobSpawns = true EscapeSpawnTanks = false + WaterSlowsMovement = false // convert items that aren't useful weaponsToConvert = { - weapon_defibrillator = "weapon_first_aid_kit_spawn" ammo = "upgrade_laser_sight" } @@ -72,6 +73,7 @@ MutationState <- FinaleStartTime = 0 TriggerRescue = false RescueDelay = 600 + LastAlarmTankTime = 0 LastSpawnTime = 0 SpawnInterval = 20 DoubleTanks = false @@ -83,29 +85,83 @@ MutationState <- SpawnTankThink = false TriggerRescueThink = false LeftSafeAreaThink = false + CheckPrimaryWeaponThink = false FinaleType = -1 } -local triggerFinale = Entities.FindByClassname( null, "trigger_finale" ); -if ( triggerFinale ) - MutationState.FinaleType = NetProps.GetPropInt( triggerFinale, "m_type" ); - -if ( MutationState.FinaleType != 4 ) +if ( IsMissionFinalMap() ) { - function GetNextStage() + local triggerFinale = Entities.FindByClassname( null, "trigger_finale" ); + if ( triggerFinale ) + MutationState.FinaleType = NetProps.GetPropInt( triggerFinale, "m_type" ); + + TankRunHUD <- {}; + function SetupModeHUD() { - if ( SessionState.TriggerRescue ) + TankRunHUD = { - SessionOptions.ScriptedStageType = STAGE_ESCAPE; - TankRunHUD.Fields.rescue_time.flags = TankRunHUD.Fields.rescue_time.flags | HUD_FLAG_NOTVISIBLE; - return; + Fields = + { + rescue_time = { slot = HUD_MID_TOP, name = "rescue", special = HUD_SPECIAL_TIMER0, flags = HUD_FLAG_COUNTDOWN_WARN | HUD_FLAG_BEEP | HUD_FLAG_ALIGN_CENTER | HUD_FLAG_NOTVISIBLE }, + } + } + HUDSetLayout( TankRunHUD ); + } + + if ( MutationState.FinaleType != 4 ) + { + function GetNextStage() + { + if ( SessionState.TriggerRescue ) + { + SessionOptions.ScriptedStageType = STAGE_ESCAPE; + TankRunHUD.Fields.rescue_time.flags = TankRunHUD.Fields.rescue_time.flags | HUD_FLAG_NOTVISIBLE; + return; + } + if ( SessionState.FinaleStarted ) + { + SessionOptions.ScriptedStageType = STAGE_DELAY; + SessionOptions.ScriptedStageValue = -1; + } + } + } + + function OnGameEvent_finale_start( params ) + { + if ( SessionState.MapName == "c6m3_port" ) + { + SessionOptions.cm_TankLimit = 8; + SessionState.TanksDisabled = false; + SessionState.SpawnTankThink = true; } - if ( SessionState.FinaleStarted ) + + if ( SessionState.FinaleType == 4 ) + return; + + SessionState.DoubleTanks = true; + SessionState.SpawnInterval = 40; + SessionState.FinaleStarted = true; + SessionState.FinaleStartTime = Time(); + SessionState.TriggerRescueThink = true; + + HUDManageTimers( 0, TIMER_COUNTDOWN, SessionState.RescueDelay ); + TankRunHUD.Fields.rescue_time.flags = TankRunHUD.Fields.rescue_time.flags & ~HUD_FLAG_NOTVISIBLE; + } + + function OnGameEvent_gauntlet_finale_start( params ) + { + if ( SessionState.MapName == "c5m5_bridge" || SessionState.MapName == "c13m4_cutthroatcreek" ) { - SessionOptions.ScriptedStageType = STAGE_DELAY; - SessionOptions.ScriptedStageValue = -1; + SessionOptions.cm_TankLimit = 8; + SessionState.TanksDisabled = false; + SessionState.SpawnTankThink = true; } } + + function OnGameEvent_finale_vehicle_leaving( params ) + { + SessionState.SpawnTankThink = false; + } } function AllowTakeDamage( damageTable ) @@ -113,7 +169,7 @@ function AllowTakeDamage( damageTable ) if ( !damageTable.Attacker || !damageTable.Victim || !damageTable.Inflictor ) return true; - if ( damageTable.Attacker.IsPlayer() && damageTable.Victim.IsPlayer() ) + if ( damageTable.Victim.IsPlayer() && damageTable.Attacker.IsPlayer() ) { if ( damageTable.Attacker.IsSurvivor() && damageTable.Victim.GetZombieType() == 8 ) { @@ -137,10 +193,12 @@ function TriggerRescueThink() function SpawnTankThink() { + if ( SessionOptions.cm_TankLimit == 0 ) + return; + if ( (SessionState.TanksAlive < 8) && ((Time() - SessionState.LastSpawnTime) >= SessionState.SpawnInterval || SessionState.LastSpawnTime == 0) ) { - local success = ZSpawn( { type = 8 } ); - if ( success ) + if ( ZSpawn( { type = 8 } ) ) { if ( SessionState.DoubleTanks ) ZSpawn( { type = 8 } ); @@ -151,10 +209,9 @@ function SpawnTankThink() function LeftSafeAreaThink() { - local player = null; - while ( player = Entities.FindByClassname( player, "player" ) ) + for ( local player; player = Entities.FindByClassname( player, "player" ); ) { - if ( ( !player.IsValid() ) || ( NetProps.GetPropInt( player, "m_iTeamNum" ) != 2 ) ) + if ( NetProps.GetPropInt( player, "m_iTeamNum" ) != 2 ) continue; if ( ResponseCriteria.GetValue( player, "instartarea" ) == "0" ) @@ -163,8 +220,6 @@ function LeftSafeAreaThink() SessionState.SpawnTankThink = true; break; } - else - continue; } } @@ -179,30 +234,87 @@ function BileHurtTankThink() function CheckDifficultyForTankHealth( difficulty ) { local health = [2000, 3000, 4000, 5000]; - - if ( SessionState.MapName == "c1m1_hotel" ) - SessionState.TankHealth = (health[difficulty] / 5); - else - SessionState.TankHealth = health[difficulty]; + SessionState.TankHealth = health[difficulty]; } -function OnGameEvent_round_start_post_nav( params ) +if ( Director.IsFirstMapInScenario() ) { - local spawner = null; - while ( spawner = Entities.FindByClassname( spawner, "info_zombie_spawn" ) ) + function CheckPrimaryWeaponThink() { - if ( spawner.IsValid() ) + local startArea = null; + local startPos = null; + for ( local survivorSpawn; survivorSpawn = Entities.FindByClassname( survivorSpawn, "info_survivor_position" ); ) { - local population = NetProps.GetPropString( spawner, "m_szPopulation" ); - - if ( population == "tank" || population == "river_docks_trap" ) + local area = NavMesh.GetNearestNavArea( survivorSpawn.GetOrigin(), 100, false, false ); + if ( (area) && (area.HasSpawnAttributes( 128 ) || area.HasSpawnAttributes( 2048 )) ) + { + startArea = area; + startPos = survivorSpawn.GetOrigin(); + break; + } + } + + if ( !startPos ) + return; + + for ( local weapon; weapon = Entities.FindByClassnameWithin( weapon, "weapon_*", startPos, 1200 ); ) + { + if ( weapon.GetOwnerEntity() ) continue; - else - spawner.Kill(); + + local weaponName = weapon.GetClassname(); + local primaryNames = [ "smg", "rifle", "shotgun", "sniper", "grenade" ]; + if ( weaponName == "weapon_spawn" ) + { + weaponName = NetProps.GetPropString( weapon, "m_iszWeaponToSpawn" ); + if ( weaponName.find( "pistol" ) != null ) + continue; + primaryNames.append( "any" ); + } + + foreach( name in primaryNames ) + { + if ( weaponName.find( name ) != null ) + return; + } } + + local itemNames = [ "weapon_pistol_spawn", "weapon_pistol_magnum_spawn", "weapon_spawn", "weapon_melee_spawn" ]; + foreach( name in itemNames ) + { + local item = Entities.FindByClassnameNearest( name, startPos, 600 ); + if ( item ) + { + local nearestArea = NavMesh.GetNearestNavArea( item.GetOrigin(), 100, false, false ); + if ( nearestArea ) + startArea = nearestArea; + break; + } + } + + local w = [ "any_smg", "tier1_shotgun" ]; + for ( local i = 0; i < 2; i++ ) + SpawnEntityFromTable( "weapon_spawn", { spawn_without_director = 1, weapon_selection = w[i], count = 5, spawnflags = 3, origin = (startArea.FindRandomSpot() + Vector(0,0,50)), angles = Vector(RandomInt(0,90),RandomInt(0,90),90) } ); } - local ammo = null; - while ( ammo = Entities.FindByModel( ammo, "models/props/terror/ammo_stack.mdl" ) ) + + function OnGameplayStart() + { + SessionState.CheckPrimaryWeaponThink = true; + } +} + +function OnGameEvent_round_start_post_nav( params ) +{ + for ( local spawner; spawner = Entities.FindByClassname( spawner, "info_zombie_spawn" ); ) + { + local population = NetProps.GetPropString( spawner, "m_szPopulation" ); + + if ( population == "tank" || population == "river_docks_trap" ) + continue; + else + spawner.Kill(); + } + for ( local ammo; ammo = Entities.FindByModel( ammo, "models/props/terror/ammo_stack.mdl" ); ) ammo.Kill(); if ( SessionState.MapName == "c5m5_bridge" || SessionState.MapName == "c6m3_port" || SessionState.MapName == "c13m4_cutthroatcreek" ) @@ -213,7 +325,7 @@ function OnGameEvent_round_start_post_nav( params ) else if ( SessionState.MapName == "c7m1_docks" ) { EntFire( "tank_touch_test", "Kill" ); - EntFire( "tankdoorout_button", "AddOutput", "spawnflags 0" ); + EntFire( "tankdoorout_button", "Unlock" ); } CheckDifficultyForTankHealth( GetDifficulty() ); @@ -236,48 +348,37 @@ function OnGameEvent_player_left_safe_area( params ) return; } - local instartarea = ResponseCriteria.GetValue( player, "instartarea" ); - if ( instartarea == "1" ) + if ( ResponseCriteria.GetValue( player, "instartarea" ) == "1" ) SessionState.LeftSafeAreaThink = true; else SessionState.SpawnTankThink = true; } -function OnGameEvent_finale_start( params ) +function OnGameEvent_player_incapacitated( params ) { - if ( SessionState.MapName == "c6m3_port" ) - { - SessionOptions.cm_TankLimit = 8; - SessionState.TanksDisabled = false; - SessionState.SpawnTankThink = true; - } - - if ( SessionState.FinaleType == 4 ) + local player = GetPlayerFromUserID( params["userid"] ); + if ( (!player) || (!player.IsSurvivor()) ) return; - SessionState.DoubleTanks = true; - SessionState.SpawnInterval = 40; - SessionState.FinaleStarted = true; - SessionState.FinaleStartTime = Time(); - SessionState.TriggerRescueThink = true; - - HUDManageTimers( 0, TIMER_COUNTDOWN, SessionState.RescueDelay ); - TankRunHUD.Fields.rescue_time.flags = TankRunHUD.Fields.rescue_time.flags & ~HUD_FLAG_NOTVISIBLE; + player.ReviveFromIncap(); } -function OnGameEvent_gauntlet_finale_start( params ) +function ReviveFromLedgeHang( userid ) { - if ( SessionState.MapName == "c5m5_bridge" || SessionState.MapName == "c13m4_cutthroatcreek" ) - { - SessionOptions.cm_TankLimit = 8; - SessionState.TanksDisabled = false; - SessionState.SpawnTankThink = true; - } + local player = GetPlayerFromUserID( userid ); + if ( (!player) || (!player.IsSurvivor()) ) + return; + + player.ReviveFromIncap(); } -function OnGameEvent_finale_vehicle_leaving( params ) +function OnGameEvent_player_ledge_grab( params ) { - SessionState.SpawnTankThink = false; + local player = GetPlayerFromUserID( params["userid"] ); + if ( (!player) || (!player.IsSurvivor()) ) + return; + + EntFire( "worldspawn", "RunScriptCode", "g_ModeScript.ReviveFromLedgeHang(" + params["userid"] + ")", 0.1 ); } function OnGameEvent_mission_lost( params ) @@ -323,6 +424,15 @@ function OnGameEvent_player_no_longer_it( params ) } } +function OnGameEvent_triggered_car_alarm( params ) +{ + if ( (SessionState.TanksAlive < 8) && ((Time() - SessionState.LastAlarmTankTime) >= SessionState.SpawnInterval || SessionState.LastAlarmTankTime == 0) ) + { + if ( ZSpawn( { type = 8 } ) ) + SessionState.LastAlarmTankTime = Time(); + } +} + function OnGameEvent_tank_spawn( params ) { local tank = GetPlayerFromUserID( params["userid"] ); @@ -392,26 +502,43 @@ function Update() TriggerRescueThink(); if ( SessionState.BileHurtTankThink ) BileHurtTankThink(); + if ( SessionState.CheckPrimaryWeaponThink ) + { + CheckPrimaryWeaponThink(); + SessionState.CheckPrimaryWeaponThink = false; + } if ( Director.GetCommonInfectedCount() > 0 ) { - local infected = null; - while ( infected = Entities.FindByClassname( infected, "infected" ) ) - { - if ( infected.IsValid() ) - infected.Kill(); - } + for ( local infected; infected = Entities.FindByClassname( infected, "infected" ); ) + infected.Kill(); } } -TankRunHUD <- {}; -function SetupModeHUD() -{ - TankRunHUD = +local tankrun_rules = +[ { - Fields = - { - rescue_time = { slot = HUD_MID_TOP, name = "rescue", special = HUD_SPECIAL_TIMER0, flags = HUD_FLAG_COUNTDOWN_WARN | HUD_FLAG_BEEP | HUD_FLAG_ALIGN_CENTER | HUD_FLAG_NOTVISIBLE }, - } + name = "RevivedByFriendOverride", + criteria = [ [ "Concept", "RevivedByFriend" ] ], + responses = [ { scenename = "" } ], + group_params = g_rr.RGroupParams({ permitrepeats = true }) + }, + { + name = "PlayerIncapacitatedOverride", + criteria = [ [ "Concept", "PlayerIncapacitated" ] ], + responses = [ { scenename = "" } ], + group_params = g_rr.RGroupParams({ permitrepeats = true }) + }, + { + name = "PlayerHelpOverride", + criteria = [ [ "Concept", "PlayerHelp" ] ], + responses = [ { scenename = "" } ], + group_params = g_rr.RGroupParams({ permitrepeats = true }) + }, + { + name = "PlayerLedgeHangStartOverride", + criteria = [ [ "Concept", "PlayerLedgeHangStart" ] ], + responses = [ { scenename = "" } ], + group_params = g_rr.RGroupParams({ permitrepeats = true }) } - HUDSetLayout( TankRunHUD ); -} +] +g_rr.rr_ProcessRules( tankrun_rules );