Tutorial: Using models for health/hev chargers in vanilla Half-Life Last edited 7 months ago2024-04-18 11:50:25 UTC

You are viewing an older revision of this wiki page. The current revision may be more detailed and up-to-date. Click here to see the current revision of this page.
This tutorial will show you how you can use models (.mdl) for the health/HEV chargers (func_healthcharger/func_recharge), which are normally brush entities. You need to use ZHLT compilers (or its descendants) to properly swap the brush entities' brush models with .mdl files. See the accompanying vault item for models and a sample .rmf using the methods described in this tutorial.

This tutorial requires no custom coding and is intended to work entirely within the confines of vanilla Half-Life's behaviour. Therefore switching skins the usual way or controller bones is out of scope of this tutorial.

The gobbledygook

You can safely skip this section. Go ahead. :)

We will be exploiting the overlap in the way the engine handles brush models and studio models. Interestingly in the engine code, the way the engine loads and handles the two have overlaps with regards to the properties. The relevant ones are listed below:
Keyvalue Brush model Studio model
frame Normal or activated texture (0,1) Progress of current animation (0-255)
skin Contents (empty, solid ,water, etc) Skin
As you can see, the way the engine switches texture differs between brush and studio models. With that in mind, we need to prepare our studio model to cater to the way the engine handles brush models. As the health/HEV chargers change the frame value between 0 and 1, the studio model therefore has to be in an animation sequence where at 0/255th of the animation sequence the model shows the ON state, and at 1/255th the OFF state. This translates to using duplicate polygons for the ON/OFF states parented to different bones that moves in the sequence instead of using skin groups.

And for the brush entities, the model keyvalue can be set to point to a .mdl file, but care should be given to ensure it's precached before being referenced by an earlier entity. Using ZHLT's zhlt_usemodel guarantees this. Also, most (but not all!) brush entities will accept key values intended for studio models (and cycler entity) such as body, sequence, framerate etc. For this tutorial we will be setting our sequence value this way.

Preparing the model

In order to have the model work for brush entities, it needs to have an animation where the 0/255th of the timeline represents the ON state and 1/255th of the timeline represents the OFF state. For this we need: To get the faces to be where it needs to be at the exact fractions of the sequence you can use 2 methods: Besides this, having another, idle animation with the ON material in front and skin groups is recommended for versatility, but not required for this tutorial.
This tutorial will not be touching on modeling or animation aspects. Please consult The303's modeling tutorial for modeling for GoldSrc.
A model from the vault. The OFF faces are hidden behind the modelA model from the vault. The OFF faces are hidden behind the model
On the second frame, the faces switch place and remains there till the end.On the second frame, the faces switch place and remains there till the end.

Using the models in the map

This tutorial supposes that the models you've prepared in the previous section has the following sequences:

Part A: Template entity[ies]

  1. Create a monster_furniture or cycler entity for each model you want to use. Give it a name.
  2. Set the entity's model to one of the models.
  3. Put this entity someplace inaccessible in the map.

Part B: func_healthcharger/ func_recharge entities

  1. Create ONLY ONE origin brush (i.e. brush with User posted image ORIGIN texture) for each entity. The center of the brush should be flush to the wall, and the vertical center should be 56u above the floor.
  2. Tie this brush to entity (func_healthcharger/func_recharge).
  3. Set the entity's angles (Pitch Yaw Roll) to face perpendicularly away from the wall.
  4. Turn off SmartEdit mode and add the following keyvalues:
    • zhlt_usemodel = <name of template entity>
    • sequence = 1 (index of the sequence with the animation setup earlier)

Part C: Lighting and clipping

Result

See the linked vault item below for sample.

References

Vault

Loading embedded content: Vault Item #6897

Comments

You must log in to post a comment. You can login or register a new account.