Non-playable characters or NPCs play vital roles in any video game. Whether they are enemies, allies, bullet fodder, or plot devices, the world would be boring without them. The Half-Life series focuses on story-driven gameplay with the help of NPC interaction. This chapter will provide you with a solid foundation for controlling NPC movement.
In this chapter, we will cover the following topics:
This chapter will take you through some of the different types of NPC movement. For a more detailed look, refer to the example map: ch9_example.vmf
. The possibilities are endless, but let's see what we can do!
One of the many useful tools at your disposal is the Model Viewer. It, like other tools, is located in the bin
folder. Because Valve packages all their game files into ZIP-like files called Valve Pack Files (VPK), we need to unpack the models before we can view them.
There is a program called GCFScape available at http://nemesis.thewavelength.net/index.php?p=26 that can browse the packed game files and extract them to proper folders. Run GCFScape and open the hl2_misc_dir.vpk
file in the h12
folder located at common/Half-Life 2
.
Inside the VPK file, you will see a list of folders that mimic the Steam folder's structure. We want to access the models so we can check out their animations. For this, browse to the models
folder, and extract the models
folder to your common/Half-Life2/hl2/models
folder by right-clicking on it and selecting Extract.
Extract the models
folder into the common/Half-Life 2/ep2
folder. A dialog box will appear showing the status of the extraction. Once the extraction is complete, you can close GCFScape.
Double-click on the HLMV.bat
file in the commonHalf-Life 2in
folder to launch the Half-Life Model Viewer. Go to File | Load Model to browse for a model. Browse to the commonHalf-Life 2hl2modelshumansgroup01
folder and select male01.mdl
.
When the model is loaded, you can rotate, pan, zoom, and adjust the lighting to get whatever view you would like. To rotate the model along the z and y axis, left-click on the inside of the circle (not visible at first) and move the mouse around. (The dashed circle will turn green when your mouse is clicked inside the circle.)
To rotate the model along the x axis, left-click on the outside of the circle (the dashed outline will now be yellow, signifying that your mouse is outside the circle).
To pan the model around, hold the Shift key while left-clicking anywhere on the screen.
Right-click and move the mouse up to zoom in and down to zoom out.
Pressing the Ctrl key while left-clicking will move the light source around.
Once you're comfortable with manipulating the view, click on the Sequence tab to view a set of animations for that model.
One of the great things about the Model Viewer is its ability to play models' animations. The Sequence tab is where you control the animations you'll see.
Select an animation from the top drop-down menu to watch the model act it out. There is a slider to the right of each animation selection; manipulating these will blend each selected animation. The slider beneath the drop-down menus controls the speed of the animations.
The sliders to the right control other parts of the body not associated with the animations. You can, for example, make the NPC look in a certain direction or change the direction of his torso.
That's all we need to know about the Model Viewer right now. Let's get these NPCs moving, shall we?
3.133.123.126