Spawning HL Entities

This is a quick and dirty tutorial on spawning things. Why is a spawning tutorial in the Admin Mod documentation, you ask? Well, we get a lot of questions about how to use the spawning commands, and the almighty second god of Admin Mod, Jaguar, wrote this tutorial back when he first gave Admin Mod spawning capabilities. It is still completely valid today, and barely edited. Praise Jaguar! (We're not worthy!)

 

Jag speaks:

 

So, this tutorial's broken down into two parts:

 

 

Adding stuff onto a map ahead of time

First, you need a map.  I play TFC, so I'm going to use 2fort as an example.  How many people haven't dreamed of plopping down a Xen tree or 3 on the bridge of 2fort?  Well, ok...more of you than I expected, but that's what we're going to do anyways. =P

 

For you CS people, you can just follow along (it's pretty easy), or one of you can write me up an example for CS, which I can include.

 

Anyways, you need 2fort.bsp.  This is found in all server installs, so you should have it if you have a server, in hlserver\tfc\maps.  Before doing anything else, BACK UP THE MAP!  Copy it to 2fort.bak or something.

 

Now, you've got two options: you can edit the .bsp file by hand, or you can export the entities and edit those.

 

Option 1: Editing by hand requires you to have a decent text editor; one that doesn't barf at characters above ASCII 127.  What you need to do is look for the entity information.  2fort.bsp is roughly 2.5 megs; in it, the entity information begins at offset 255800h.  You should see this:

 

{

"wad" "\tffree\tfc\tfc.wad;\tffree\valve\halflife.wad;\tffree\valve\liquids.wad;"

"mapversion" "340"

"mapversion" "220"

"sounds" "1"

"message" "2 Forts Classic"

"skyname" "dusk"

"MaxRange" "4096"

"classname" "worldspawn"

"classname" "worldspawn"

}

 

All of the entities follow in the same format: enclosed in braces ( {} ), with key/value pairs describing the data.

 

Option 2: Exporting the entity list requires Zoner's Half-Life Editing Tools (ZHLET), which you can find here:

 

http://www.valve-erc.com/resources/?page=zhlt

 

Once you've downloaded the tools (and compiled them, if need be), run the ripent.exe tool:

ripent -export (map)

 

  ripent -export d:\hlserver\tfc\maps\2fort.bsp

 

This will create a file in the same directory as the .bsp, but with the extension .ent (eg, in the example, it would create d:\hlserver\tfc\maps\2fort.ent).  This .ent file is the entity list from the .bsp file, and can be edited (IMHO) much easier, allows for easier searching, etc.

 

Moving on...

 

What do these key/value pairs do?  Some of them are obvious.  Some of them are not.  Some of them _seem_ obvious, but are actually not (who would guess that 'maxammo_shells' key on a 'tf_detect' entity actually controls the class limits for team 1?  I wouldn't...)

 

The most comprehensive entity list I've found so far is on Wavelength:

http://www.planethalflife.com/wavelength/levels/entities/index.html

 

(It covers TFC entities...but not CS ones.  Sorry.)  Probably the easiest way to start is to find a map that already has what you want in it, and take a look at its entities, copying as you go.  But for this little example, I'll just give you the entity for a xen_tree:

 

{

"renderamt" "255"

"rendercolor" "0 10 200"

"origin" "0 0 0"

"angles" "0 0 0"

"classname" "xen_tree"

}

 

Oh, but there's a problem.  What are the coordinates of where we want to put it?  You've got three ways to get them:

 

 

Using one of these methods, get the coordinates of where you want to place the xen_tree.  I'm going to go ahead and just use ones I've already gotten: X:0, Y:0, Z:-480.

 

So, update the entity info with your new coordinates (origin) data:

 

{

"renderamt" "255"

"rendercolor" "0 10 200"

"origin" "0 0 -460"

"angles" "0 0 0"

"classname" "xen_tree"

}

 

Put that at the end of the entity list (making sure to be very careful if you're editing the .bsp by hand).  If you're using ripent, then you have to import the .ent file back in ripent -import (map)

 

   ripent -import d:\hlserver\tfc\maps\2fort.bsp

 

Once this is done, load the map up into a server.  A cute li'l xen tree should be awaiting you on the bridge.

The tree can be removed easily...just remove the entity information from the bsp or the ent (being sure to import when done if editing an ent).  Similarly, other trees can be added at other spots, or other entities entirely could be added (more spawn points in CS, ammo packs for TFC in the hldm maps, etc).

 

Adding stuff onto a map at run time

Adding stuff on the fly requires one of two things:

 

 

However, before you can add anything onto a map, (and this is the important bit) it has to already have been precached.  Things can only be precached when the map loads.  In general, this means that the only things you can add onto a map at run-time are things that already exist on the map.

 

It boils down to this: If you want to add a xen tree somewhere at run time, a xen tree must already exist on the map.  It doesn't matter where (it doesn't have to be 'in the map')...but it's got to exist.

 

So, getting back to 2fort, remove the original xen_tree (if necessary), and add this in:

 

{

"renderamt" "255"

"rendercolor" "0 10 200"

"origin" "5000 5000 5000"

"angles" "0 0 0"

"classname" "xen_tree"

}

 

Note the origin; 5000 5000 5000 is well outside the map.  No one will ever see, touch, or interact with this xen tree in any way.  It's only purpose in life is so that we can spawn other xen trees.  Without it, we can't spawn any xen trees at all.

 

With this down, we can now spawn an army of xen trees, anywhere we want.

 

Using sv_cheats, the cmd is 'give xen_tree'.  It'll spawn one wherever you are.

 

Using Admin Mod, the cmd would be 'admin_spawn xen_tree (X) (Y) (Z) (XAngle) (YAngle) (ZAngle)'.  The angles can default to 0, but having a ZAngle of 180 will give you an upside down Xen tree, which is kind of amusing. =)