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

fm_is_ent_visible stock


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
isotonic
AlliedModders Donor
Join Date: Jun 2011
Location: Moscow, Russia
Old 12-30-2015 , 18:42   fm_is_ent_visible stock
Reply With Quote #1

Quote:
Originally Posted by fakemeta_util.inc
PHP Code:
stock bool:fm_is_ent_visible(indexentityignoremonsters 0) {
    new 
Float:start[3], Float:dest[3];
    
pev(indexpev_originstart);
    
pev(indexpev_view_ofsdest);
    
xs_vec_add(startdeststart);

    
pev(entitypev_origindest);
    
engfunc(EngFunc_TraceLinestartdestignoremonstersindex0);

    new 
Float:fraction;
    
get_tr2(0TR_flFractionfraction);
    if (
fraction == 1.0 || get_tr2(0TR_pHit) == entity)
        return 
true;

    return 
false;

Why do we have to check fraction first? We initially set proper distance for traceline, don't we?..
__________________

Last edited by isotonic; 12-30-2015 at 18:44.
isotonic is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-31-2015 , 06:04   Re: fm_is_ent_visible stock
Reply With Quote #2

Likely a sanity check. It should be okay to remove it since you are checking against a specific provided entity.
__________________
Arkshine is offline
isotonic
AlliedModders Donor
Join Date: Jun 2011
Location: Moscow, Russia
Old 12-31-2015 , 09:06   Re: fm_is_ent_visible stock
Reply With Quote #3

Thank you!

Now I will use that stock:
PHP Code:
// fakemeta_util.inc code with some replaced natives
stock fm_is_ent_visibleindexentityignoremonsters ) {
    new 
Float:start[3], Float:dest[3]
    
entity_get_vectorindexEV_VEC_originstart )
    
entity_get_vectorindexEV_VEC_view_ofsdest )
    
xs_vec_addstartdeststart )

    const 
GLOBAL_TRACERESULT_HANDLE 0

    entity_get_vector
entityEV_VEC_origindest )
    
engfuncEngFunc_TraceLinestartdestignoremonstersindexGLOBAL_TRACERESULT_HANDLE )

    return 
get_tr2GLOBAL_TRACERESULT_HANDLETR_pHit ) == entity

__________________
isotonic 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 13:16.


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