Left 4 Dead 2/Scripting/Director Scripts/AllowFallenSurvivorItem: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(rephrased old edits)
(Removed "printl" section at the introduction; Merged == Debugging == with introduction)
Line 1: Line 1:
When its DirectorOptions is loaded, this callback for every spawned item from a Fallen Survivor. Arguments given are strings representing a weapon's classname; return''<code>true</code>''to allow Fallen Survivors to have a chance in equipping the weapon.
On DirectorOptions load, this is called for every item a Fallen Survivor can equip. Return ''<code>true</code>'' to allow Fallen Survivors have a chance in equipping an item. Its hard to debug this function as Fallen Survivors are rare to come across in the maps they spawn in (<code>c6m2_bedlam</code>), thus its recommended to use commands that can force spawning of fallen survivors:
 
With the<code style="color:#E5E5E5;">printl</code>function, the arguments are:
{{ExpandBox|<syntaxhighlight lang=js>
Msg("VSCRIPT: Running director_base_addon.nut; VDC's!\n")
 
DirectorOptions <-
{
function AllowFallenSurvivorItem( classname )
{
printl(classname)
}
}
//----------------------------------------------
/*Output:
** VSCRIPT: Running director_base_addon.nut; VDC's!
** weapon_molotov
** weapon_pipe_bomb
** weapon_pain_pills
** weapon_first_aid_kit
*/
</syntaxhighlight>}}
{{note|Despite the name similarity to the [[L4D2_Director_Scripts/AllowWeaponSpawn|AllowWeaponSpawn]] callback, this callback can only disallow existing Fallen Survivor items, and allowing new weapons will not work, unless a custom system is built and then initiated in this callback function.}}
 
=== Debugging ===
Not only that Fallen Survivors spawn in certain maps only, like<code style="color:#E5E5E5;">c10m4_mainstreet</code>(Death Toll - Streets) or<code style="color:#E5E5E5;">c6m2_bedlam</code>(The Passing - Bedlam), they also are too rare to reliably debug any code with them on those maps. With these commands, once set up properly can be used to debug Fallen Survivors efficiently:
{{varcom|start}}
{{varcom|start}}
{{varcom|z_fallen_kill_suppress_time|300|Seconds|When a Fallen Survivor is killed, how long in seconds should pass before another can spawn.}}
{{varcom|z_fallen_kill_suppress_time|300|Seconds|When a Fallen Survivor is killed, how long in seconds should pass before another can spawn.}}
Line 31: Line 6:
{{varcom|z_forcezombiemodelname|common_male01|[[Left_4_Dead_Infected_Populations#List_of_Population-Supported_Infected_Types|Name of a Common's model]]|When<code>z_forcezombiemodel</code>is active, force all Common Infected to use this model. If the model isn't precached, ignore.}}
{{varcom|z_forcezombiemodelname|common_male01|[[Left_4_Dead_Infected_Populations#List_of_Population-Supported_Infected_Types|Name of a Common's model]]|When<code>z_forcezombiemodel</code>is active, force all Common Infected to use this model. If the model isn't precached, ignore.}}
{{varcom|end}}
{{varcom|end}}
__TOC__
 
{{note|Unlike the [[L4D2_Director_Scripts/AllowWeaponSpawn|AllowWeaponSpawn]] callback, this can only disallow items on Fallen Survivor, and not allow any new ones.}}


== Parameters ==
== Parameters ==
Line 43: Line 19:
| string
| string
| classname
| classname
| {{ExpandBox|nostartinglinebreak=1|
| {{ExpandBox|
* weapon_molotov
* weapon_molotov
* weapon_pipe_bomb
* weapon_pipe_bomb
Line 60: Line 36:
|-
|-
|}
|}
== Code Samples ==
== Code Samples ==
=== Health-pack-alypse Fallens ===
=== Health-pack-alypse Fallens ===
Line 65: Line 42:
When ran, Fallen Survivors will ''sometimes'' only spawn with a [[weapon_first_aid_kit]] equipped, and never spawn equipped with any other gear.
When ran, Fallen Survivors will ''sometimes'' only spawn with a [[weapon_first_aid_kit]] equipped, and never spawn equipped with any other gear.
{{ExpandBox|<syntaxhighlight lang=js>
{{ExpandBox|<syntaxhighlight lang=js>
// its now a Health-pack-alypse from the Fallens!
// A Fallen Survivor Healthpack-alypse!
DirectorOptions <-
DirectorOptions <-
{
{

Revision as of 04:00, 10 May 2022

On DirectorOptions load, this is called for every item a Fallen Survivor can equip. Return true to allow Fallen Survivors have a chance in equipping an item. Its hard to debug this function as Fallen Survivors are rare to come across in the maps they spawn in (c6m2_bedlam), thus its recommended to use commands that can force spawning of fallen survivors:

Cvar/Command Parameters or default value Descriptor Effect
z_fallen_kill_suppress_time 300 Seconds When a Fallen Survivor is killed, how long in seconds should pass before another can spawn.
z_fallen_max_count 1 Arbitrary number How many Fallen Survivors can be active at once.
z_forcezombiemodel 0 0 disables, 1 enables Determines ifz_forcezombiemodelnameis allowed to be used.
z_forcezombiemodelname common_male01 Name of a Common's model Whenz_forcezombiemodelis active, force all Common Infected to use this model. If the model isn't precached, ignore.
Note.pngNote:Unlike the AllowWeaponSpawn callback, this can only disallow items on Fallen Survivor, and not allow any new ones.

Parameters

bool AllowFallenSurvivorItem(string classname)

Type Name Arguments Description
string classname

  • weapon_molotov
  • weapon_pipe_bomb
  • weapon_pain_pills
  • weapon_first_aid_kit
Name of a weapon's classname; Only 4 are given.

Expected Returns

Type Description
bool Return true to allow the respective weapon from spawning; false or none is otherwise.

Code Samples

Health-pack-alypse Fallens

L4D2DirectorScript Callbacks-Health-pack-alypseFallens.jpg

When ran, Fallen Survivors will sometimes only spawn with a weapon_first_aid_kit equipped, and never spawn equipped with any other gear.


// A Fallen Survivor Healthpack-alypse!
DirectorOptions <-	
{
  	function AllowFallenSurvivorItem(classname)
	{
		if( classname == "weapon_first_aid_kit" )
		{
			printl("Allowed "+classname);
			return true
		}
		else
		{
			printl("Disallowed "+classname);
			return false
		}
	}
}