Raised This Month: $32 Target: $400
 8% 

Solved Check walll between two players


Post New Thread Reply   
 
Thread Tools Display Modes
Minfas
Member
Join Date: Dec 2017
Old 02-01-2020 , 09:02   Re: Check walll between two players
Reply With Quote #11

Thanks for helping but it's still working through walls.. :\

PHP Code:
float traceVec[3];
float traceDir[3];
SubtractVectors(explosionPosclientPostraceVec);
GetVectorAngles(traceVectraceDir);

Handle trace TR_TraceRayFilterEx(explosionPostraceDirMASK_SOLIDRayType_InfiniteTraceFilterClientsclient);
if(
TR_DidHit(trace))
{
    
PrintToChatAll("hit!");
}

bool TraceFilterClients(int entityint contentsMaskany data)
{
    return 
entity == data// If the entity we collided with is the same as our data (last parameter), return true (filter it)

Minfas is offline
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 02-01-2020 , 10:33   Re: Check walll between two players
Reply With Quote #12

Sorry, a return value of false will filter the entity. I should have referred to the documentation before making an assumption.

PHP Code:
bool TraceFilterClients(int entityint contentsMaskany data)
{
    return 
entity != data;

Kolapsicle is offline
Minfas
Member
Join Date: Dec 2017
Old 02-02-2020 , 08:35   Re: Check walll between two players
Reply With Quote #13

Quote:
Originally Posted by Kolapsicle View Post
Sorry, a return value of false will filter the entity. I should have referred to the documentation before making an assumption.

PHP Code:
bool TraceFilterClients(int entityint contentsMaskany data)
{
    return 
entity != data;

Still same problem
Minfas is offline
Balimbanana
Member
Join Date: Jan 2017
Old 02-02-2020 , 20:22   Re: Check walll between two players
Reply With Quote #14

Just remember that TR_DidHit() will still return true if it hit world. Check what entity index is returned with TR_GetEntityIndex(trace); if it is returning 0 then it hit world, or a wall. If it returns anything other than -1 or 0, then it hit an entity.
Also, you can get the players mins/maxs with something like:
Code:
if (HasEntProp(client,Prop_Send,"m_vecMins")) GetEntPropVector(client,Prop_Send,"m_vecMins",vMins);
else if (HasEntProp(client,Prop_Data,"m_vecMins")) GetEntPropVector(client,Prop_Data,"m_vecMins",vMins);
if (HasEntProp(client,Prop_Send,"m_vecMaxs")) GetEntPropVector(client,Prop_Send,"m_vecMaxs",vMaxs);
else if (HasEntProp(client,Prop_Data,"m_vecMaxs")) GetEntPropVector(client,Prop_Data,"m_vecMaxs",vMaxs);
ScaleVector(vMins, 0.8);
ScaleVector(vMaxs, 0.8);
This will also account for different custom models if you use them, or ModelScale's. The HasEntProp for both Prop_Send and Prop_Data is for multi-game support, some games store player entity properties as Prop_Data, while most others store it as Prop_Send.

Edit: Also, you might want to change to MASK_SHOT because MASK_SOLID will also hit things like brushes and fences. The reason the mins/maxs should be scaled down a little is that it is by bounding box, so even if the edge of a player is by a wall, the trace will hit the wall because the edge of the trace hull did.

Last edited by Balimbanana; 02-02-2020 at 20:36.
Balimbanana is offline
Minfas
Member
Join Date: Dec 2017
Old 02-04-2020 , 10:20   Re: Check walll between two players
Reply With Quote #15

Kolapsicle and Balimbanana thank you for helping, solved!
Minfas 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 09:35.


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