Tutorial: Using models for health/HEV chargers in vanilla Half-Life Last edited 2 months ago2024-09-16 09:50:53 UTC

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.

As 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 by an earlier entity. Using ZHLT's zhlt_usemodel keyvalue guarantees this. Also, most (but not all!) brush entities will accept key values intended for studio models (e.g. cycler entity) such as body, sequence, framerate etc. For this tutorial we will be setting our sequence value this way. Most importantly, angles (Pitch Yaw Roll) rotates the entity for func_healthcharger/func_recharge and thus can be used to orient the models properly.

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: Other important properties: Optional properties (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. Place down a brush the size of the normal health/HEV charger (32w 48h 8d) where you want them to be. You can even use prefabs, provided they are of the basic single brush variety.
  2. Turn the brush into an ORIGIN brush: apply the User posted image ORIGIN texture to all faces of the brush.
  3. Tie the brush to entity (func_healthcharger/func_recharge).
  4. Set the entity's angles (Pitch Yaw Roll) to face perpendicularly away from the wall.
  5. Turn off SmartEdit mode and add the following keyvalues:
    • zhlt_usemodel = <name of template entity>
    • sequence = 1 (index of the sequence as set up earlier)

Part C: Lighting and clipping

Result

No props; these are the actual, fully-functional `func_healthcharger`/ `func_recharge` entities.No props; these are the actual, fully-functional func_healthcharger/ func_recharge entities.
See also the linked vault below.

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.