VERC: TriAPI based team overlays Last edited 22 years ago2002-09-26 01:42:00 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 article was recovered from an archive and needs to be reviewed

  1. The formatting may be incorrect as it was automatically converted to WikiCode from HTML, it needs to be revised and reformatted
  2. Some information may be out of date as it was written before Half-Life was available on Steam
  3. After the article is re-formatted and updated for Steam HL, remove this notice
  4. Please do not remove the archive notice from the bottom of the article.
  5. Some archive articles are no longer useful, or they duplicate information from other tutorials and entity guides. In this case, delete the page after merging any relevant information into other pages. Contact an admin to delete a page.
TriAPI Based Team Overlays

Function

names are in RED

File
names are in ORANGE
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;

gEngfuncs.GetViewAngles( ( float *)angles
);

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 )

continue;

// if they are this player, then continue

if ( player == thisplayer )

continue;

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 ))

return;

// Create a triangle, sigh

gEngfuncs.pTriAPI->RenderMode(
kRenderTransAdd );

gEngfuncs.pTriAPI->CullFace(
TRI_NONE );

gEngfuncs.pTriAPI->Begin(
TRI_QUADS );

//
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->Brightness(
1.0 );

gEngfuncs.pTriAPI->TexCoord2f(
1, 1 );

point = org;

gEngfuncs.pTriAPI->Vertex3fv(
point );

gEngfuncs.pTriAPI->TexCoord2f(
1, 0 );

point = org + up * size;

gEngfuncs.pTriAPI->Vertex3fv(
point );

gEngfuncs.pTriAPI->TexCoord2f(
0, 0 );

point = org + right * size
+ up * size;

gEngfuncs.pTriAPI->Vertex3fv(
point );

gEngfuncs.pTriAPI->TexCoord2f(
0, 1 );

point = org + right * size;

gEngfuncs.pTriAPI->Vertex3fv(
point );

gEngfuncs.pTriAPI->End();

gEngfuncs.pTriAPI->RenderMode(
kRenderTransAdd );

}

}

}

}

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!
-Mazor
mazor579@hotmail.com (Link: mazor579-at-hotmail.com)
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.

Comments

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