All pastes #966068 Raw Edit

Someone

public text v1 · immutable
·published 2008-04-01 13:38 UTC
rendered paste body
VOID BoxEsp( int i )
{
	FLOAT hx, hy;
	vec3_t  HeadOrigin = { 0.0f, 0.0f, 60.0f };
	VectorAdd( Game->cg_entities[i].lerpOrigin, HeadOrigin, HeadOrigin );
 
	FLOAT fx, fy;
	vec3_t  FootOrigin = { 0.0f, 0.0f, -10.0f };
	VectorAdd( Game->cg_entities[i].lerpOrigin, FootOrigin, FootOrigin );
 
	if( CG_WorldCoordToScreenCoordFloat( HeadOrigin, &hx, &hy ) && CG_WorldCoordToScreenCoordFloat( FootOrigin, &fx, &fy ) )
	{

		vec3_t MyPos	= Game->cg_entities[Game->cg->clientNum].lerpOrigin;
		vec3_t OthPos	= Game->cg_entities[i].lerpOrigin;

		float dx = MyPos.x - OthPos.x;
		float dy = MyPos.y - OthPos.y;
		float dz = MyPos.z - OthPos.z;

		float distance = sqrt(dx*dx + dy*dy + dz*dz);

		float SCALEFACTOR = 0.5; ////////////////////////// you will need to play with this till it looks satisfactory
			
		// todo: add a player BB width / height to calculate width and height of scaled rect (wont detect prone
		//       since head origin and foot origin will never change)

		// todo: dynamicly calculate head foot offsets
		// todo: smoke a joint and get high
		// todo: rewrite entire calculation based on boundingboxs rather than static offsets :( 

		float x = hx - ( (BB WIDTH) * (SCALEFACTOR * distance));
		float y = hy - ( (BB HEIGHT) * (SCALEFACTOR * distance));
		float w = fx + ( (BB WIDTH) * (SCALEFACTOR * distance));
		float h = fy + ( (BB HEIGHT) * (SCALEFACTOR * distance));

		if( Game->clientInfo[ Game->cg_entities[i].currentState.clientNum ].team != Game->clientInfo[ Game->cg->clientNum ].team )
		{
			DrawRect( x, y, w, h, 1, colorRed );
		}
		else 
		{
			DrawRect( x, y, w, h, 1, colorGreen );
		}
	}
}