Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

DP SV CUSTOMIZEENTITYFORCLIENT

From Quake Wiki

Field definitions:

.float() customizeentityforclient; // self = this entity, other = client entity

Allows qc to modify an entity before it is sent to each client, the function returns TRUE if it should send, FALSE if it should not, and is fully capable of editing the entity's fields, this allows cloaked players to appear less transparent to their teammates, navigation markers to only show to their team, etc.

Tips on writing customize functions:

  • It is a good idea to return FALSE early in the function if possible to reduce cpu usage, because this function may be called many thousands of times per frame if there are many customized entities on a 64+ player server.
  • You are free to change anything in self, but please do not change any other entities (the results may be very inconsistent).

Example ideas for use of this extension:

  • Making icons over teammates' heads which are only visible to teammates. For exasmple:
float() playericon_customizeentityforclient = 
{
    return self.owner.team == other.team;
};
  • Making cloaked players more visible to their teammates than their enemies. For example:
float() player_customizeentityforclient = 
{
    if (self.items & IT_CLOAKING)
    {
        if (self.team == other.team)
            self.alpha = 0.6;
        else
            self.alpha = 0.1;
    }
    return TRUE;
};
  • Making explosion models that face the viewer (does not work well with chase_active). For example:
float() explosion_customizeentityforclient = 
{
    self.angles = vectoangles(other.origin + other.view_ofs - self.origin);
    self.angles_x = 0 - self.angles_x;
};

Implementation notes:

Entity customization should be done before per-client culling (visibility for instance) because the entity may be doing setorigin to display itself in different locations on different clients, may be altering its .modelindex, .effects and other fields important to culling, so customized entities increase cpu usage (non-customized entities can use all the early culling they want however, as they are not changing on a per client basis).