UTIL_GetDebugColorForRelationship

From Valve Developer Community
Jump to navigation Jump to search

UTIL_GetDebugColorForRelationship is a UTIL provided in the Source code for getting the color of the relationship between AI units.

Note.pngNote:This may require Debug Overlays to be enabled.
Todo: What are Debug Overlays? m_debugOverlays & OVERLAY_*_BIT.


Usage

//-----------------------------------------------------------------------------
// Purpose: Fills in color for debug purposes based on a relationship
// Input  : nRelationship - relationship to test
//			*pR, *pG, *pB - colors to fill
//-----------------------------------------------------------------------------
void UTIL_GetDebugColorForRelationship( int nRelationship, int &r, int &g, int &b )


Will return one of the following RGB values:

  • R=0, G=255, B=0 //Like
  • R=0, G=0, B=255 //Neutral
  • R=255, G=0, B=0 //Hate
  • R=255, G=255, B=0 //Fear
  • R=255, G=255, B=255 //Default


Examples

// Show the relationships to entities around us
int r = 0;
int g = 0;
int b = 0;

int	nRelationship;
CAI_BaseNPC **ppAIs = g_AI_Manager.AccessAIs();

// Rate all NPCs
for ( int i = 0; i < g_AI_Manager.NumAIs(); i++ )
{
	if ( ppAIs[i] == NULL || ppAIs[i] == this )
		continue;
	
	// Get our relation to the target
	nRelationship = IRelationType( ppAIs[i] );

	// Get the color for the arrow
	UTIL_GetDebugColorForRelationship( nRelationship, r, g, b );

	// Draw an arrow
	NDebugOverlay::HorzArrow( GetAbsOrigin(), ppAIs[i]->GetAbsOrigin(), 16, r, g, b, 64, true, 0.0f );
}