Left 4 Dead 2

Left 4 Dead 2

Not enough ratings
Turret System - Basic Usage
By Rectus
This guide describes basic usage of the VScript Turret System.

The Turret System add-on comes with four pre-made turrets. To spawn them, both instance files and entity groups are included.

The add-on includes a demo map (turretsystem_demo.vmf) to showcase how turrets can be added. The map can be run directly from the add-on with map turretsystem_demo.
   
Award
Favorite
Favorited
Unfavorite
Notice
This guide is intended for mod developers. To play with the turrets check out the Gnome Guardians Mutation:
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=507377833
Unpacking the add-on
Note: You will need the GCFScape[nemesis.thewavelength.net] tool to unpack the content.

To download the Turret System Add-on, subscrive to it on the Workshop.
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=510573647

After subscribing to the add-on and lauching Left 4 Dead 2, find the add-on in the Steam\SteamApps\common\left 4 dead 2\left4dead2\addons\workshop\ directory.


Open the add-on .vpk file using GCFScape.

Copy the directories materials, models and scripts into the Steam\SteamApps\common\left 4 dead 2\left4dead2\ directory. The content of these directories will also have to be added to any add-ons realesed with the turret system, except from a few files: turretsystem_demo_spawn_entitygroups.nut and the models and materials for the turret crates.

If you want to add turrets directly to a map, also extract the files from mapsrc/instance/ to the directory or a subdirectory of where you have your map (Steam\SteamApps\common\left 4 dead 2\sdk_content\mapsrc\ by default).
Adding turrets to maps using instances.
Instances are used to include separate .vmf files into maps. The turret instance files contain the entities needed for each turret.

To place a turret, add a func_instance entity to the map where you want the turret to spawn. Open up its properties, and use the VMF Filename to find the instance file.

If all the assets were unpacled correctly, an orange tinted turret should appear on the entity.



For the scripts to be able to address individual turrets, the entities inside each instance need unique names with common pre- or postfixes. With the default instance settings, they will be generated correctly. If you want to give the turrets manual names, make sure that the Fix Up name is unique for every turret.

Advanced spawning

For more complex scenarios, the turrets can also be spawned using point_template entities. To do that, the turret parts can be copied over to the main map, and each turret part be added to the point_template. The naming convension still applies, but the point_template will automatically handle postfixes.
Adding static turrets to mutations
The turrets are originally designed to be spawned for mutations using VScript based Entity Groups. Entity Groups are most commonly spawned by placing an info_item_position entiy as a marker, either by directly placing it in a custom map with Hammer, or by using the Entity Placement Tool to place it in any map, and then using one of the many spawning methods.

Entity Placement Tool

Please see this Dev Wiki article on how to use the Entity Placement Tool:
https://developer.valvesoftware.com/wiki/L4D2_EMS/Appendix:_Spawning

To get a preview of the turret, set the template Entity group to the file name of the turret group. The groups can be found under Steam\SteamApps\common\left 4 dead 2\left4dead2\scripts\vscripts\entitygroups\.

The Target Name needs to be set correctly for the spawning systen to find the positions.


Turret
Target Name
Entity Group
Spawn Table
Minigun
turretsystem_mg_turret_spawn
turretsystem_mg_turret_group.nut
TurretsystemMgTurret
Flame
turretsystem_flame_turret_spawn
turretsystem_flame_turret_group.nut
TurretsystemFlameTurret
Laser
turretsystem_laser_turret_spawn
turretsystem_laser_turret_group.nut
TurretsystemLaserTurret
Flak
turretsystem_flak_turret_spawn
turretsystem_flak_turret_group.nut
TurretsystemFlakTurret


Static Mutation Spawning

To spawn the placed turrets in a map on load, the turret group names are placed in the MapSpawns table in the Map Script.
4 Comments
Rectus  [author] 5 Mar, 2018 @ 5:30am 
Cant really switch out the AK, but you could probably make a carriable turret that takes the secondary slot.
ARAPAWA 5 Mar, 2018 @ 5:00am 
I would like to carry a turret instead of ak 47 And easily.
Rectus  [author] 7 Sep, 2015 @ 7:32am 
Thanks!
Mad Filter 7 Sep, 2015 @ 7:30am 
Damn awesome guide!