Half-Life Re-imagined competition results on their way...
Check out Skewing textures in Hammer, our newest tutorial!
Say hello to MD_AZMAL, our newest member!

logo

Site Stuff

Reference

Maps

Community

ShoutBOX

Poll

Feeling Blue

What's your favourite shade of blue?

Azure

8

Cobalt

18

Turquoise

4

Cyan

8

Royal

3

Teal

3

Onliners

15 mins

789

15 mins

abbadon

24 mins

Windawz

30 mins

Archie

34 mins

Dimbeak

46 mins

Solokiller

1 hours

Dr. Orange

Affiliates

A gaming and technology blog by TWHL admins Penguinboy and Ant. A music blog by TWHL users Ant and Hugh.

TriAPI based team overlays

By Cale 'Mazor' Dunlap

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