VERC: TriAPI based team overlays Last edited 3 months ago2022-01-27 16:36:21 UTC

This tutorial will show you how to make use of the Triangle API to make team overlays so you blind players that can't tell the difference between skins can finally tell the difference by a green circle above your team mates' heads. All you need to do is open your CLIENT project, open up the tri.cpp file, then go into the HUD_DrawTransparentTriangles() function and add this code anywhere before the closing brace:
// render team overlays
cl_entity_t* thisplayer = gEngfuncs.GetLocalPlayer();
float size = 25;
vec3_t angles, forward, right, up;
AngleVectors(angles, forward, right, up);

// only for teamplay
if (gHUD.m_Teamplay) {
    for (int i = 0; i < MAX_PLAYERS + 1; i++) {
        cl_entity_t* player = gEngfuncs.GetEntityByIndex(i);
        int team = g_PlayerExtraInfo[player->index].teamnumber;
        // they aren't a player, continue the looping
        if (g_PlayerInfoList[i].name == NULL)
        // if they are this player, then continue
        if (player == thisplayer)
        if (g_PlayerExtraInfo[thisplayer->index].teamnumber == team) {
            // render the sprite above their heads
            if (player) {
                vec3_t org;
                vec3_t point;
                org = player->origin;

                // starting position
                org.z += 52;
                org = org + right * -size / 2;

                org + right * size;
                org + up * size;
                if (gHUD.m_hsprCursor == 0) {
                    char sz[256];
                    sprintf(sz, "sprites/flare3.spr");
                    gHUD.m_hsprCursor = SPR_Load(sz);

                if (!gEngfuncs.pTriAPI->SpriteTexture((struct model_s*)gEngfuncs.GetSpritePointer(gHUD.m_hsprCursor), 0))

                // Create a triangle, sigh

                // now draw that tiny quad
                // the triapi calls are pretty similar to opengl
                gEngfuncs.pTriAPI->Color4f(0.0, 1.0, 0.0, 1.0);

                gEngfuncs.pTriAPI->TexCoord2f(1, 1);
                point = org;

                gEngfuncs.pTriAPI->TexCoord2f(1, 0);
                point = org + up * size;

                gEngfuncs.pTriAPI->TexCoord2f(0, 0);
                point = org + right * size + up * size;

                gEngfuncs.pTriAPI->TexCoord2f(0, 1);
                point = org + right * size;

You can change the flare3.spr to any sprite you want. You just need to make sure its there, or it won't work at all. Have fun!
This article was originally published on the Valve Editing Resource Collective (VERC).
TWHL only archives articles from defunct websites. For more information on TWHL's archiving efforts, please visit the TWHL Archiving Project page.


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