Left 4 Dead 2/Scripting/Expanded Mutation System/GnomeHunter Player Spawns

From Valve Developer Community
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.


Setting up the Entity Placement Tool

In this tutorial you will learn how to place entities into a map using a tool called the Entity Placement Tool. This tool will allow you to navigate a map within the game engine and place entities in the world that will be used by your Mutation.

In order to access the tool you must launch the game with the -tools command:

left4dead2.exe -tools

It is suggested that you also run the game with a large window since the tool requires a lot of screen real estate:

left4dead2.exe -tools -sw -width 1920 -height 1200

After the game loads, select the tool from the Tools menu:

Starting the placement tool.jpg

Once you are in the Placement Tool select File -> New

New file.jpg

Browse to the BSP for our game mode: C5M2_park
New file dialog.jpg

After the BSP loads, the Placement Tool will create a default working file named C5M2_park_entities.txt. We do not want to work in the default file but one for the Mutation we're building. In the File menu, select Save As and save the file with our Mutation name added:

C5M2_park_entities_gnomehunter.txt

Placing player start entities

For this tutorial we're going to place the player start entities in the gazebo in the park. Press F10 to switch to the engine viewport. It may be useful to remove the other survivors during editing. You can do so with this command (NOTE: in order to execute that command you must have sv_cheats 1 set):

nb_delete_all

You may also want to stop the director from spawning new infected with this command:

director_stop

Navigate to the gazebo. Or you can set your player position directly with this command:

setpos -7174.512695 -3880.317139 -14.845871;setang 24.727911 91.204346 -0.000109

Gazebo start.jpg

Next, switch back to tool mode [f10] and create a template for the new entities you are about to create. For this you'll be working in the Template Properties dialog in the lower right of the tools screen. You'll need to check the Use Template flag in the template properties, check Auto-Unique Targetnames (this will add a unique number to newly created entity names), name your target entity playerstart and finally check the box for Snap To Surface so your entities will snap to the ground.

Playerstart template properties.jpg


Entities that are created will now use the properties in the template. Click on Create Nodes in the Entity Report dialog, which is near the top-left of the tool window:

Create node.jpg

You will now be able to place entities in the world, and should see a green player start entity out in front of the player.

Placing player start.jpg


Place four player start entities in the gazebo and then hit the ESC key. You should now see four entities listed in your entity report dialog, all with unique names:

Playerstart entity report.jpg

Save your file and you're done! When your Mutation is loaded these info_item_position entities will automatically be spawned in your map. You can verify this by loading your Mutation in C5M2_Park.bsp and typing find_ent info_item_position and seeing if you find your player start entities:

Simple tools find ent.jpg

Now you're ready to change your simple Mutation to use these entities to teleport players to their start positions.

Modifying your Mutation to use new spawn points

Now that you have created your spawn points you can write VScript code to use them.

sm_utilities.nut contains a function called TeleportPlayersToStartPoints( spawnpointName ) which you can use to teleport players to new positions.

The mutation system will call a function titled DoMapSetup() if one is provided. Create the function and add the teleport call:


TeleportPlayersToStartPoints( "playerstart_*")


function OnGameplayStart()
{
	// gameplay start code goes here!
	// Teleport players out of the start room to their start positions
	TeleportPlayersToStartPoints( "playerstart_*") 
}


And that's it! When you play your Mutation in the c5m2_park map, Survivors should no longer spawn in the safe room but out in the gazebo instead.

NOTE: You cannot test your Mutation in tools mode. To test your Mutation, exit the game engine and then start it up again without the -tools switch in your command line.

NEXT -->