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

[help] how detect that an entity is visible ??? [solved]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LouLouBizou
Member
Join Date: Aug 2006
Location: Toulouse (France)
Old 05-16-2010 , 11:16   [help] how detect that an entity is visible ??? [solved]
Reply With Quote #1

how detect that an entity is visible from another entity ????

like: player can seen player b from this position

any idea ?



i using something like that

new j;
for(j = 1; j <= GetMaxClients(); j++){

if ( IsClientInGame(j) && (client != j) && IsPlayerAlive(j) && (GetClientTeam(client) != GetClientTeam(j)) ){

GetClientAbsOrigin(j, VictimPos);
Distance = GetVectorDistance(MyPos, VictimPos, false);

new Handle:trace = TR_TraceRayFilterEx(MyPos, VictimPos, MASK_ALL, RayType_Infinite, TraceRayDontHitSelf, j);
PrintToChat(client, "ret: %d", TR_GetEntityIndex(trace));
if (TR_GetEntityIndex(trace) == j){
...
}
CloseHandle(trace);
}

}

any help ?
__________________
LouLouBizou alias Don French !



Last edited by LouLouBizou; 05-20-2010 at 07:51.
LouLouBizou is offline
Send a message via MSN to LouLouBizou
LouLouBizou
Member
Join Date: Aug 2006
Location: Toulouse (France)
Old 05-17-2010 , 06:12   Re: how detect that an entity is visible ???
Reply With Quote #2

help
__________________
LouLouBizou alias Don French !


LouLouBizou is offline
Send a message via MSN to LouLouBizou
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 05-17-2010 , 09:50   Re: [help] how detect that an entity is visible ??? [not solved]
Reply With Quote #3

for mypos use GetClientEyePosition instead of GetClientAbsOrigin as this is where you see from.

for the victim you will need to do 2 or more traces for different parts of the body, GetClientAbsOrigin will only work if you can see their feet, GetClientEyePosition will only work if you can see their head, those 2 might be enough or you may need one in the middle of those 2 coords.

you don't need a handle for the trace if you use the results immediately, i think you use a handle if you want to save the results for use later. this also means you don't need the ex version. also since you're not using a handle use TR_GetEntityIndex() without the handle to get the results.

for the data to send to the filter (last parameter in the raytrace call) don't send j send your index

you also need your filter function "TraceRayDontHitSelf". something like this should work.

PHP Code:
public bool:TraceRayDontHitSelf(entitycontentsMaskany:data)
{
    return (
entity != data);


Last edited by blodia; 05-17-2010 at 09:53.
blodia is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 05-20-2010 , 06:54   Re: [help] how detect that an entity is visible ??? [not solved]
Reply With Quote #4

Example from srsmod

PHP Code:
static bool:IsVisibleTo(cliententity// check an entity for being visible to a client
{
    
decl Float:vAngles[3], Float:vOrigin[3], Float:vEnt[3], Float:vLookAt[3];
    
    
GetClientEyePosition(client,vOrigin); // get both player and zombie position
    
GetEntityAbsOrigin(entityvEnt);
    
    
MakeVectorFromPoints(vOriginvEntvLookAt); // compute vector from player to zombie
    
    
GetVectorAngles(vLookAtvAngles); // get angles from vector for trace
    
    // execute Trace
    
new Handle:trace TR_TraceRayFilterEx(vOriginvAnglesMASK_SHOTRayType_Infinite_DI_TraceFilter);
    
    new 
bool:isVisible false;
    if (
TR_DidHit(trace))
    {
        
decl Float:vStart[3];
        
TR_GetEndPosition(vStarttrace); // retrieve our trace endpoint
        
        
if ((GetVectorDistance(vOriginvStartfalse) + TRACE_TOLERANCE) >= GetVectorDistance(vOriginvEnt))
        {
            
isVisible true// if trace ray lenght plus tolerance equal or bigger absolute distance, you hit the targeted zombie
        
}
    }
    else
    {
        
Debug_Print("Zombie Despawner Bug: Player-Zombie Trace did not hit anything, WTF");
        
isVisible true;
    }
    
CloseHandle(trace);
    return 
isVisible;
}

public 
bool:_DI_TraceFilter(entitycontentsMask)
{
    if (
entity <= CLIENT_VALID_LAST || !IsValidEntity(entity)) // dont let WORLD, players, or invalid entities be hit
    
{
        return 
false;
    }
    
    
decl String:class[128];
    
GetEdictClassname(entity, class, sizeof(class)); // also not zombies or witches, as unlikely that may be, or physobjects (= windows)
    
if (StrEqual(class, CLASSNAME_INFECTED, .caseSensitive false)
    || 
StrEqual(class, CLASSNAME_WITCH, .caseSensitive false)
    || 
StrEqual(class, CLASSNAME_PHYSPROPS, .caseSensitive false))
    {
        return 
false;
    }
    
    return 
true;

AtomicStryker is offline
LouLouBizou
Member
Join Date: Aug 2006
Location: Toulouse (France)
Old 05-20-2010 , 07:50   Re: [help] how detect that an entity is visible ??? [not solved]
Reply With Quote #5

Thanks to all, it works
__________________
LouLouBizou alias Don French !


LouLouBizou is offline
Send a message via MSN to LouLouBizou
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 21:13.


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