Raised This Month: $ Target: $400
 0% 

Strange TraceRay Behavior


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sslice
Senior Member
Join Date: Feb 2005
Location: Texas, USA
Old 05-31-2006 , 01:42   Strange TraceRay Behavior
Reply With Quote #1

Okay, here's my code and then I will explain the situation:
Code:
CBaseEntity *pPlayer = pEntity->GetUnknown()->GetBaseEntity();
Vector eyepos = VFuncs::EyePosition(pPlayer);
QAngle eyeang = VFuncs::EyeAngles(pPlayer);
vector_t *pos = CreateVecFromVector(eyepos);
vector_t *ang = CreateVecFromQAngle(eyeang);

Vector end;
AngleVectors(eyeang, &end);
end.NormalizeInPlace();
end = eyepos + end * MAX_TRACE_LENGTH;

Ray_t ray;
ray.Init(eyepos,end);
trace_t tr;

MyTraceFilterSimpleEntitiesOnly tfilter(pPlayer, MASK_SHOT);
enginetrace->TraceRay(ray, MASK_SHOT, &tfilter, &tr);

if (tr.fraction < 1.0f && tr.surface.flags & SURF_HITBOX)
{
	// we're aiming at a player, check to see if there's
	// anything blocking eyesight (MASK_OPAQUE) in the way
	trace_t tr2;
	MyTraceFilterSimple tfilter2(pPlayer, MASK_OPAQUE|CONTENTS_MONSTER);
	enginetrace->TraceRay(ray, MASK_OPAQUE|CONTENTS_MONSTER, &tfilter2, &tr2);

	target_t *target = (target_t *)malloc(sizeof(target_t));
	target->opaque = (tr2.fraction < 1.0f && tr2.surface.flags & SURF_HITBOX ? false : true);
	target->player = ActivePlayers[tr.m_pEnt->entindex()];

	// for debugging
	sprintf(szBuffer,"\x04TARGET(SteamID = \"%s\", Opaque = %s)\n",
		(target->player ? target->player->GetSteamId() : "BOT"), (target->opaque ? "1" : "0"));
	SayTextToEntIndex(szBuffer,engine->IndexOfEdict(pEntity));
	effects->Sparks(tr.endpos);

	//player->AddSnapshot(pos,ang,type,target);
	return;
}

//player->AddSnapshot(pos,ang,type,0);
Basically, what happens here is whenever you aim at the player's body, everything goes as expected and you get the SayText in your HUD showing you the player's Steam ID. But if you aim up at the head, nothing seems to register almost as if the guy is headless or something.. you can aim a little lower at the neck and it will register as well as every other part of the body, but for some reason the TraceRay thinks the guy is headless.

I've tried several different mask and content macros and cannot figure this one out...
__________________
sslice is offline
L. Duke
Veteran Member
Join Date: Apr 2005
Location: Walla Walla
Old 05-31-2006 , 02:04  
Reply With Quote #2

No collision will occur if the traceline does not hit the bounding box.

TraceLine (a) looks for a bounding box collision (b) checks the model for a hit, if no hit then (c) continue the TraceLine.

For some reason, the CSS player models heads stick out of the bounding box (as do other parts of their bodies, such as feet, at certain times).

I don't know of a solution, unless you can figure out how CSS traces actual gun shots to look for a head shot.

L. Duke is offline
sslice
Senior Member
Join Date: Feb 2005
Location: Texas, USA
Old 05-31-2006 , 02:18  
Reply With Quote #3

Ahh.. that's crazy. Guess I'll have to look for the hit detection code in the SDK or something... or maybe if there's some flag to tell it not to look for the bounding box.
__________________
sslice is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:02.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode