Cleanup is going to take awhile, so the site is back up but editing has been disabled.

Spawning Random Hostages

From HalfLife 2 Knowledge Base

Jump to: navigation, search

Starting Hostages in random locations at map spawn

This tutorial explains how to get your hostages in a hostage rescue map to spawn in different locations each time the map is started.

Requires the use of the following entities:

hostage entity
logic_auto
logic_case
point_teleport


First create the location where the hostage will start with a hostage_entity. Select the hostage entity and go to its object properites. Turn off smart edit and click on the add button. This will bring up a dialog box called "New Keyvalue". Add the following info in the fields:

 Key : "targetname" 
 Value : "hostage1"

The targetname entry for the hostage is not in the fgd.


Create a point_teleport entry and set "Entity to Teleport" to "hostage1". Place this where you want a one of the location you want the hostage to randomly spawn at. Duplicate this entity and rename them to "teleport2", "teleport3", etc. Place each of them in the other possible spwan locations. Each point_teleport should be placed so that the middle of the entity is 1 inch from the floor so that the hostage won't teleport 8 inches in the air and wait there until rescued.


Now create a logic_case. Go to the outputs section. Add a new output and set it to the following:

 "My output named" : "OnCase01"
 "Target Entities Named" : "teleport1"
 "Via this input" : "teleport"

Create an output for the rest of the point_teleport entries, use "OnCase2", "OnCase3", etc.

Return to the Class Info section. Name the logic_case "teleport_case". Then for each "OnCase" used add a string value. It doesn't matter what you type, it's just important that there is a something there. The logic_case selects a random case by the values placed here. With out these values, the entity will randomly pick one value when the map is first loaded and will use that same value each time it called to pick a random case.


Finally create a logic_auto entity. Create a new output with the following options:

 "My output named" : "OnMapSpawn"
 "Target Entities Named" : "teleport_case"
 "Via this input" : "PickRandom"


Now when the map spawns your hostage will randomly teleport to one of the point_teleport entities you created. There is a slight delay at the start each round before the hostage teleport. Best practice to avoid this visual hickup is to place each of the teleport locations and the hostage enties out of view of all of the player starts and to place


Orginal Author: Cannonfodder

Edited By: GRASH

Edits: Included more detail information. Rewrote sections to make it easier to use -Grash 6/5/05


Personal tools