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

How to Set Aim Origin.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 05-02-2011 , 01:05   How to Set Aim Origin.
Reply With Quote #1

I am making NPC.
but how can NPC aim the player ?.

How to Set Aim origin from NPC to Player ?
dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-02-2011 , 03:34   Re: How to Set Aim Origin.
Reply With Quote #2

How To: Make a perfect NPC
__________________

SonicSonedit is offline
pRoxxxDD
Junior Member
Join Date: Feb 2011
Location: Ukraine
Old 05-02-2011 , 03:59   Re: How to Set Aim Origin.
Reply With Quote #3

From CHR Engine:
PHP Code:
stock entity_set_aim(ent,const Float:origin2[3],bone=0)
{
    if(!
pev_valid(ent))
        return 
0;

    static 
Float:origin[3]
    
origin[0] = origin2[0]
    
origin[1] = origin2[1]
    
origin[2] = origin2[2]

    static 
Float:ent_origin[3], Float:angles[3]

    if(
bone)
        
engfunc(EngFunc_GetBonePosition,ent,bone,ent_origin,angles)
    else
        
pev(ent,pev_origin,ent_origin)

    
origin[0] -= ent_origin[0]
    
origin[1] -= ent_origin[1]
    
origin[2] -= ent_origin[2]

    static 
Float:v_length
    v_length 
vector_length(origin)

    static 
Float:aim_vector[3]
    
aim_vector[0] = origin[0] / v_length
    aim_vector
[1] = origin[1] / v_length
    aim_vector
[2] = origin[2] / v_length

    
static Float:new_angles[3]
    
vector_to_angle(aim_vector,new_angles)

    
new_angles[0] *= -1

    
if(new_angles[1]>180.0new_angles[1] -= 360
    
if(new_angles[1]<-180.0new_angles[1] += 360
    
if(new_angles[1]==180.0 || new_angles[1]==-180.0new_angles[1]=-179.999999

    set_pev
(ent,pev_angles,new_angles)
    
set_pev(ent,pev_fixangle,1)

    return 
1;

__________________
pRoxxxDD is offline
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 05-02-2011 , 04:19   Re: How to Set Aim Origin.
Reply With Quote #4

oh thank pRoxxxDD. I did it
dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
pRoxxxDD
Junior Member
Join Date: Feb 2011
Location: Ukraine
Old 05-02-2011 , 05:10   Re: How to Set Aim Origin.
Reply With Quote #5

Thank GHW_Chronic, he made it. =)
__________________
pRoxxxDD is offline
usaexelent
Senior Member
Join Date: Nov 2009
Location: Lithuania
Old 11-19-2012 , 05:04   Re: How to Set Aim Origin.
Reply With Quote #6

And how do you do the same, just with speed, I mean that npc will turn little by little to the aim origin.
__________________
and once again
usaexelent is offline
Send a message via Skype™ to usaexelent
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 11:41.


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