Difference between revisions of "L4D2 Level Design/Weapon and Item Spawning"

From Valve Developer Community
Jump to: navigation, search
m
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{otherlang2
+
{{lang|L4D2 Level Design/Weapon and Item Spawning}}
|ru=L4D2 Level Design/Weapon and Item Spawning:ru
 
}}
 
  
 
{{L4D2 level intro menu}}__toc__
 
{{L4D2 level intro menu}}__toc__
Weapon placement capability in L4D2 maps has been expanded and enhanced. While you can still place specific weapon and item entities as in L4D1, the new <code>weapon_spawn</code> allows more flexibility by allowing the A.I. Director to procedurally generate your player's arsenal. Another benefit of using these new spawn entities is that they will provide matching items for both versus/scavenge teams.  
+
Weapon placement capability in L4D2 maps has been expanded and enhanced. While you can still place specific weapon and item entities as in L4D1, the new [[weapon_spawn]] allows more flexibility by allowing the A.I. Director to procedurally generate your player's arsenal. Another benefit of using these new spawn entities is that they will provide matching items for both versus/scavenge teams.  
  
 
== Placing Weapon Spawners ==
 
== Placing Weapon Spawners ==
 
+
Activate the the {{Hammer entity}} and select the [[weapon_spawn]] entity from the '''Objects''' drop-down menu.<br>
Activate the the {{Hammer entity}} and select the <code>[[weapon_spawn]]</code> entity from the '''Objects''' drop-down menu.  
+
This entity is a random spawn point for a set of possible weapons based on tier or weapon type.<br>
 +
The [[info_director|Director]] will randomly pick which weapon_spawn and [[weapon_item_spawn]] should be spawned. Sometimes nothing will spawn. The [[info_map_parameters]] entity can be used to determine how the map should be populated with items.
  
 
Using the 3D view, navigate to the starting area in the map and click to place a weapon spawn on the table. You should see an older weapon spawn in the instance. Just place it next to it.
 
Using the 3D view, navigate to the starting area in the map and click to place a weapon spawn on the table. You should see an older weapon spawn in the instance. Just place it next to it.
Line 14: Line 13:
 
[[File:L4D2_weapon_1place.png|frame|right|Weapon spawning Entity]]
 
[[File:L4D2_weapon_1place.png|frame|right|Weapon spawning Entity]]
  
Although it appears in the Hammer viewport as an M16 rifle for placement purposes, what it spawns as during gameplay will vary.  
+
Although it appears in the Hammer viewport as an M16 rifle for placement purposes, what it spawns during gameplay will vary.<br>
 +
You can add a "Helper Model" to the entity, to pick what model you want to see. This can be achieved by editing the [[FGD]] file, as explained in this [https://steamcommunity.com/sharedfiles/filedetails/?id=1685639284 Steam Guide]
  
 
Let's restrict this weapon spawn to tier 1 primary, so we can save tier 2 for later in the map. With the recently placed weapon_spawn entity selected, open the '''Properties''' window and click on the '''Selection''' field.  
 
Let's restrict this weapon spawn to tier 1 primary, so we can save tier 2 for later in the map. With the recently placed weapon_spawn entity selected, open the '''Properties''' window and click on the '''Selection''' field.  
Line 20: Line 20:
 
   
 
   
 
As you can see from the drop-down, you can similarly limit it to a certain type of weapon, such as any shotgun, any pistol, etc.{{clr}}
 
As you can see from the drop-down, you can similarly limit it to a certain type of weapon, such as any shotgun, any pistol, etc.{{clr}}
 +
===Direct Weapon Spawners===
 +
If you are building a survival map in which [[weapon_spawn]] and [[weapon_item_spawn]] does not work, you can determine a specific weapon to always spawn in the same spot using the following entities:
 +
{{note|These work on default maps as well, but the Director will not decide whether to spawn them or not.}}
 +
* [[weapon_autoshotgun_spawn]]
 +
* [[weapon_grenade_launcher_spawn]]
 +
* [[weapon_hunting_rifle_spawn]]
 +
* [[weapon_pistol_magnum_spawn]]
 +
* [[weapon_pistol_spawn]]
 +
* [[weapon_pumpshotgun_spawn]]
 +
* [[weapon_rifle_ak47_spawn]]
 +
* [[weapon_rifle_desert_spawn]]
 +
* [[weapon_rifle_m60_spawn]]
 +
* [[weapon_rifle_sg552_spawn]]
 +
* [[weapon_rifle_spawn]]
 +
* [[weapon_shotgun_chrome_spawn]]
 +
* [[weapon_shotgun_spas_spawn]]
 +
* [[weapon_smg_mp5_spawn]]
 +
* [[weapon_smg_silenced_spawn]]
 +
* [[weapon_smg_spawn]]
 +
* [[weapon_sniper_awp_spawn]]
 +
* [[weapon_sniper_military_spawn]]
 +
* [[weapon_sniper_scout_spawn]]
 +
 +
===Mounted weapons===
 +
Mounted guns are also available, which overheat when used for too long. They are usually placed in fortified locations such as Finales or abandoned military outposts.<br>
 +
The minigun overheats after 20 seconds and cools down for 3 seconds. The machine gun takes 15 seconds to overheat and 60 seconds to cool down.
 +
*[[prop_minigun_l4d1]]
 +
*[[prop_mounted_machine_gun]].
  
 
== Melee weapons ==
 
== Melee weapons ==
  
Placing melee weapons procedurally works in much the same way using the <code>[[weapon_melee spawn]]</code> entity. Go ahead and place one of these and open up the '''Properties''' dialog.
+
Placing melee weapons procedurally works in much the same way using the [[weapon_melee_spawn]] entity. Go ahead and place one of these and open up the '''Properties''' dialog.
 
   
 
   
 
The weapons that you want to allow to spawn at this location have to be included in the text field. Names include:
 
The weapons that you want to allow to spawn at this location have to be included in the text field. Names include:
  
* <code>golfclub</code>
+
* <code>Any</code> – director will place any melee weapon listed in the Missionfile's "meleeweapons" string.
 +
* <code>baseball_bat</code>
 +
* <code>cricket_bat</code>
 +
* <code>crowbar</code>
 +
* <code>electric_guitar</code>
 
* <code>fireaxe</code>
 
* <code>fireaxe</code>
 
* <code>frying_pan</code>
 
* <code>frying_pan</code>
 +
* <code>golfclub</code>
 +
* <code>katana</code>
 +
* <code>knife</code>
 
* <code>machete</code>
 
* <code>machete</code>
* <code>baseball_bat</code>
+
* <code>pitchfork</code>
* <code>crowbar</code>
+
* <code>shovel</code>
* <code>cricket_bat</code>
 
 
* <code>tonfa</code>
 
* <code>tonfa</code>
* <code>katana</code>
 
* <code>electric_guitar</code>
 
* <code>riotshield</code>
 
* <code>Any</code> – director will place any available melee weapon
 
  
 
You may also list multiple specific melee weapons separated by a comma, and the director will select from among that subset of weapons:
 
You may also list multiple specific melee weapons separated by a comma, and the director will select from among that subset of weapons:
Line 44: Line 74:
 
  crowbar,fireaxe,machete
 
  crowbar,fireaxe,machete
  
''Note: the riot shield lays flat at a different orientation than most of the other weapons: 90 0 0 rather than 0 0 90.''
+
You may even have additional custom melee weapons by crating a working weapon model and then creating a melee weapon script in "scripts/melee". Copy an existing one as a base and modify it to make it easier for you.<br>
 +
The name of that script, without extention, is the name to use in the missionfile to allow it at all, and the weapon_melee_spawn entity.
  
 
== Item spawning ==
 
== Item spawning ==
  
Item spawning works in much the same way, with the <code>weapon_item_spawn</code> providing a way to spawn any one of a set of items. Let's go ahead and add a couple to the arsenal on the table.
+
Item spawning works in much the same way, with [[weapon_item_spawn]] providing a way to spawn any one of a set of items. Let's go ahead and add a couple to the arsenal on the table.
 
   
 
   
 
Under '''Properties''', you can specify the items that you wish to allow by changing their value to <code>1</code>.  
 
Under '''Properties''', you can specify the items that you wish to allow by changing their value to <code>1</code>.  
Similarly, laser sights and ammo upgrade packs are placed using the <code>upgrade_spawn</code> entity.
+
Similarly, laser sights and ammo upgrade packs are placed using the [[upgrade_spawn]] entity.
 +
 
 +
===Predetermined Item Spawners===
 +
For Predetermined item spawn points, use the following entities.
 +
 
 +
* [[weapon_adrenaline_spawn]]
 +
* [[weapon_ammo_spawn]]
 +
* [[weapon_chainsaw_spawn]]
 +
* [[weapon_defibrillator_spawn]]
 +
* [[weapon_first_aid_kit_spawn]]
 +
* [[weapon_gascan_spawn]]
 +
* [[weapon_item_spawn]]
 +
* [[weapon_melee_spawn]]
 +
* [[weapon_molotov_spawn]]
 +
* [[weapon_pain_pills_spawn]]
 +
* [[weapon_pipe_bomb_spawn]]
 +
* [[weapon_scavenge_item_spawn]]
 +
* [[weapon_upgradepack_explosive_spawn]]
 +
* [[weapon_upgradepack_incendiary_spawn]]
 +
* [[weapon_vomitjar_spawn]]
 +
The following items require FGD file edits to use properly. How to do so can be found on this [https://steamcommunity.com/sharedfiles/filedetails/?id=1685639284 Steam Guide]
 +
* [[upgrade_ammo_explosive]] - Deployed explosive ammunition.
 +
* [[upgrade_ammo_incendiary]] - Deployed incendiary ammunition.
 +
* [[upgrade_laser_sight]] - laser sight box.
 +
==Carryable Objects==
 +
Although Oxygen Tanks, Propane Tanks and Firework Crates have their own entities, they're spawned as [[Prop_physics]] instead.
 +
 
 +
Place a [[Prop_physics]] entity into your map and use any of the following models to spawn their carryable counterpart:
 +
* models/props_junk/propanecanister001a.mdl
 +
* models/props_junk/explosive_box001.mdl
 +
* models/props_equipment/oxygentank01.mdl
 +
 
 +
Gascans can be spawned using [[weapon_gascan_spawn]]
  
 
== Test run ==
 
== Test run ==

Latest revision as of 21:26, 17 August 2021

English Русский 简体中文

Weapon placement capability in L4D2 maps has been expanded and enhanced. While you can still place specific weapon and item entities as in L4D1, the new weapon_spawn allows more flexibility by allowing the A.I. Director to procedurally generate your player's arsenal. Another benefit of using these new spawn entities is that they will provide matching items for both versus/scavenge teams.

Placing Weapon Spawners

Activate the the Entity tool Mt-entities.png and select the weapon_spawn entity from the Objects drop-down menu.
This entity is a random spawn point for a set of possible weapons based on tier or weapon type.
The Director will randomly pick which weapon_spawn and weapon_item_spawn should be spawned. Sometimes nothing will spawn. The info_map_parameters entity can be used to determine how the map should be populated with items.

Using the 3D view, navigate to the starting area in the map and click to place a weapon spawn on the table. You should see an older weapon spawn in the instance. Just place it next to it.

Weapon spawning Entity

Although it appears in the Hammer viewport as an M16 rifle for placement purposes, what it spawns during gameplay will vary.
You can add a "Helper Model" to the entity, to pick what model you want to see. This can be achieved by editing the FGD file, as explained in this Steam Guide

Let's restrict this weapon spawn to tier 1 primary, so we can save tier 2 for later in the map. With the recently placed weapon_spawn entity selected, open the Properties window and click on the Selection field. From the drop down menu, select "Any tier 1 primary".

As you can see from the drop-down, you can similarly limit it to a certain type of weapon, such as any shotgun, any pistol, etc.

Direct Weapon Spawners

If you are building a survival map in which weapon_spawn and weapon_item_spawn does not work, you can determine a specific weapon to always spawn in the same spot using the following entities:

Note.png Note: These work on default maps as well, but the Director will not decide whether to spawn them or not.

Mounted weapons

Mounted guns are also available, which overheat when used for too long. They are usually placed in fortified locations such as Finales or abandoned military outposts.
The minigun overheats after 20 seconds and cools down for 3 seconds. The machine gun takes 15 seconds to overheat and 60 seconds to cool down.

Melee weapons

Placing melee weapons procedurally works in much the same way using the weapon_melee_spawn entity. Go ahead and place one of these and open up the Properties dialog.

The weapons that you want to allow to spawn at this location have to be included in the text field. Names include:

  • Any – director will place any melee weapon listed in the Missionfile's "meleeweapons" string.
  • baseball_bat
  • cricket_bat
  • crowbar
  • electric_guitar
  • fireaxe
  • frying_pan
  • golfclub
  • katana
  • knife
  • machete
  • pitchfork
  • shovel
  • tonfa

You may also list multiple specific melee weapons separated by a comma, and the director will select from among that subset of weapons:

crowbar,fireaxe,machete

You may even have additional custom melee weapons by crating a working weapon model and then creating a melee weapon script in "scripts/melee". Copy an existing one as a base and modify it to make it easier for you.
The name of that script, without extention, is the name to use in the missionfile to allow it at all, and the weapon_melee_spawn entity.

Item spawning

Item spawning works in much the same way, with weapon_item_spawn providing a way to spawn any one of a set of items. Let's go ahead and add a couple to the arsenal on the table.

Under Properties, you can specify the items that you wish to allow by changing their value to 1. Similarly, laser sights and ammo upgrade packs are placed using the upgrade_spawn entity.

Predetermined Item Spawners

For Predetermined item spawn points, use the following entities.

The following items require FGD file edits to use properly. How to do so can be found on this Steam Guide

Carryable Objects

Although Oxygen Tanks, Propane Tanks and Firework Crates have their own entities, they're spawned as Prop_physics instead.

Place a Prop_physics entity into your map and use any of the following models to spawn their carryable counterpart:

  • models/props_junk/propanecanister001a.mdl
  • models/props_junk/explosive_box001.mdl
  • models/props_equipment/oxygentank01.mdl

Gascans can be spawned using weapon_gascan_spawn

Test run

Item spawning

Go ahead and run your map. Each time you reload it, you should see a different collections of weapons, with the exception of the L4D1 shotgun in the original instance. That will remain the same since it is a weapon_pumpshotgun_spawn.

Note.png Note:  If you want to have that older weapon_pumpshotgun_spawn not appear in the Left 4 Dead 2 version of the map, but still want to keep it in the .VMF, you can create a logic_auto in the L4D2 .VMF and have it kill the pump shotgun.