AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [L4D2] how to filter glass in TR_TraceRayFilterEx? about player visible (https://forums.alliedmods.net/showthread.php?t=343911)

little_froy 09-15-2023 09:11

[L4D2] how to filter glass in TR_TraceRayFilterEx? about player visible
 
1 Attachment(s)
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.

Lux 09-15-2023 13:03

Re: [L4D2] how to filter glass in TR_TraceRayFilterEx? about player visible
 
You wanna not include CONTENTS_WINDOW in your trace mask,
Never really used MASK_VISIBLE macro, I just build own.

Lux 09-15-2023 13:37

Re: [L4D2] how to filter glass in TR_TraceRayFilterEx? about player visible
 
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

little_froy 09-15-2023 22:05

Re: [L4D2] how to filter glass in TR_TraceRayFilterEx? about player visible
 
Quote:

Originally Posted by Lux (Post 2810103)
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


All times are GMT -4. The time now is 23:31.

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