Raised This Month: $ Target: $400
 0% 

Solved in_view_cone of entity


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 07-03-2020 , 12:23   Re: in_view_cone of entity
Reply With Quote #6

Quote:
Originally Posted by Bugsy View Post
in_view_cone() + visible check should be enough.

Have you confirmed the correct 2 player variables are used to get the origins?
i used this to get data
PHP Code:
public clcmd_origin(id)
{
    static 
Float:fOrigin[3], Float:fAngle[3], iEyeOrigin[3]
    
get_user_origin(idiEyeOriginOrigin_Eyes)
    
pev(idpev_originfOrigin)
    
pev(idpev_anglesfAngle)
    
server_print("Eye Origin: %i.0, %i.0, %i.0"iEyeOrigin[0], iEyeOrigin[1], iEyeOrigin[2])
    
server_print("Origin: %0.1f, %0.1f, %0.1f"fOrigin[0], fOrigin[1], fOrigin[2])
    
server_print("Angle: %0.1f, %0.1f, %0.1f"fAngle[0], fAngle[1], fAngle[2])

    
pev(idpev_view_ofsfAngle)    
    
server_print("View Offset: %0.1f, %0.1f, %0.1f"fAngle[0], fAngle[1], fAngle[2])

    
pev(idpev_v_anglefAngle)    
    
server_print("View Angle: %0.1f, %0.1f, %0.1f"fAngle[0], fAngle[1], fAngle[2])

    
client_print(idprint_chat"[Console] Origin Saved. Check Console")

and get this result
Code:
Eye Origin: 1698.0, 2137.0, -1907.0
Origin: 1698.7, 2137.0, -1924.9
Angle: -0.5, -92.8, 0.0
View Offset: 0.0, 0.0, 17.0
View Offset: 1.6, -92.8, 0.00
and the data I got at that position that I want to use is
PHP Code:
new const Float:NPC_Origin[][3] = 
{
    {
1707.02154.0, -1924.9}

}

new const 
Float:NPC_Angle[][3] =
{
    {-
2.3, -89.00.0}
}

new const 
Float:NPC_VAngle[][3] =
{
    {
1.6, -92.80.0}
}

new const 
Float:NPC_ViewOfs[][3] =
{
    {
0.00.017.0}

PHP Code:
public Spawn_NPC(id)
{
    ...

    
set_pev(entpev_anglesNPC_Angle[0])
    
set_pev(entpev_view_ofsNPC_VAngle[0])
    
set_pev(entpev_v_angleNPC_ViewOfs[0])

    ...
}

public 
Zombie_Think(ent)
{
    ....

    
pev(g_PlayerIDpev_originfVicOrigin)
    
pev(entpev_originfOrigin)
    
    if(
bRunning)
    {
        if(
distance 270.0)
            
set_pev(entpev_iuser1STATE_ATTACK)
    }
    else 
    {
        if(
fm_is_visible(entfVicOrigin) && fm_is_in_viewcone(entfVicOrigin) && !is_wall_between_points(fOriginfVicOrigin0))
            
client_print(0print_center"Detected")
    }

    ...    

I tried but it still didn't work didn't work. I walk in front of it, nothing happened
is_wall_between_points work normally because of my previous code, it did not dectect when I behind object.

Quote:
Originally Posted by Natsheh View Post
TIP : when you're using is_wall_between_points in zombie think set the third Param the zombie entity index to ignore the zombie otherwise it might give you always false results. Since also when you're creating the zombie you dont give him the monster flag.
The zombie I used have flags FL_MONSTER and FL_MONSTERCLIP so I think I should put it as 0 (I updated it later on, adding those flags)
__________________
My plugin:

Last edited by Celena Luna; 07-03-2020 at 12:28.
Celena Luna is offline
 



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 17:12.


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