Raised This Month: $51 Target: $400
 12% 

Solved [L4D2] how to filter glass in TR_TraceRayFilterEx? about player visible


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
little_froy
Senior Member
Join Date: May 2021
Old 09-15-2023 , 09:11   [L4D2] how to filter glass in TR_TraceRayFilterEx? about player visible
Reply With Quote #1

here is my code, I want to implement a function to detect if a player is visible to another player.

Code:
bool is_visible_to(int client, int target)
{
    float self_pos[3];
    float target_pos[3];
    float look_at[3];
    float vec_angles[3];
    GetClientEyePosition(client, self_pos);
    GetClientEyePosition(target, target_pos);
    MakeVectorFromPoints(self_pos, target_pos, look_at);
    GetVectorAngles(look_at, vec_angles);
    Handle trace = TR_TraceRayFilterEx(self_pos, vec_angles, MASK_VISIBLE, RayType_Infinite, trace_entity_filter, target);
    bool result = TR_DidHit(trace) && TR_GetEntityIndex(trace) == target;
    delete trace;
    return result;
}

bool trace_entity_filter(int entity, int contentsMask, any data)
{
    if(entity == data)
    {
        return true;
    }
    if(entity > 0 && entity <= MaxClients)
    {
        return false;
    }
    char class_name[PLATFORM_MAX_PATH];
    GetEntityClassname(entity, class_name, sizeof(class_name));
    return strcmp(class_name, "infected") != 0 && strcmp(class_name, "witch") != 0 && strncmp(class_name, "prop_dynamic", 12) != 0 && strncmp(class_name, "func_breakable", 14) != 0;
}
I found that issue, the glass(map c11m1_greenhouse, classname "prop_physics", image attached below) did hit the trace, but there is no survivor glow, so it's "visible" but my function return false. how can I filter something such like this?

Note:
I tried L4D2_IsVisibleToPlayer in left4dhooks, it can't meet my needs cause when someone are not alive and spectating another one, the "eye position" not follow.
Attached Thumbnails
Click image for larger version

Name:	屏幕截图 2023-09-15 205652.jpg
Views:	63
Size:	82.5 KB
ID:	201545  

Last edited by little_froy; 09-16-2023 at 02:33.
little_froy is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 09-15-2023 , 13:03   Re: [L4D2] how to filter glass in TR_TraceRayFilterEx? about player visible
Reply With Quote #2

You wanna not include CONTENTS_WINDOW in your trace mask,
Never really used MASK_VISIBLE macro, I just build own.
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 09-15-2023 , 13:37   Re: [L4D2] how to filter glass in TR_TraceRayFilterEx? about player visible
Reply With Quote #3

I looked again at my trace filter code, I used this

PHP Code:
GetEntProp(iEntityProp_Data"m_iEFlags")) & (1<<25
to filter entity glass like that EFL_DONTBLOCKLOS
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
little_froy
Senior Member
Join Date: May 2021
Old 09-15-2023 , 22:05   Re: [L4D2] how to filter glass in TR_TraceRayFilterEx? about player visible
Reply With Quote #4

Quote:
Originally Posted by Lux View Post
I looked again at my trace filter code, I used this

PHP Code:
GetEntProp(iEntityProp_Data"m_iEFlags")) & (1<<25
to filter entity glass like that EFL_DONTBLOCKLOS
thank you so much.
it works, but also filter doors

Last edited by little_froy; 09-15-2023 at 22:06.
little_froy 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 18:50.


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