precache Last edited 2 weeks ago2024-10-16 15:07:39 UTC

A step the game engine takes when loading a game. It just means loading the resources that the map uses, like models, sprites, sounds, etc., into memory, and make it available for entities to use. Entities usually precache their own resources, like an NPC's models and sounds, or the model/sprite/sound files you entered in an entity's attributes when it asks for such file paths in the map editor's Object Properties.

A precache error usually means the path is not valid e.g. the file doesn't exist. For a path entered via entity attributes it could mean you're using absolute path instead of a relative path, or simply that you mistyped; in particular, using backslashes (\) for path separators instead of forward slashes (/). For an innate resource (e.g. an NPC's innate model), it could mean the file is corrupt or missing requiring you to fix the game/mod's installation.

Advanced precaching

Advanced entity usage in a map, such as spawning an ephemeral entity directly (whose resources are usually precached by the parent entity creating those entities), or using an external file path as the model value for brush entities, can cause precache errors (i.e. the resources are not precached before being used) which can lead to a crash. The remedy is to have an entity further up the entity list that precaches the resource for it. An env_sprite or ambient_generic entity works well for this. To ensure these entities are further up the entity list from the entities that want to use them, simply cut the latter entity in the map editor, and then paste them at the same spot. But a more robust solution is to use the zhlt_usemodel keyvalue if both precaching and non-caching uses the model keyvalue; this ensures that the precaching entity is always listed before any entity using its model.

Comments

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