AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [FIXED]How can I get the origin that in front of the entity (https://forums.alliedmods.net/showthread.php?t=226218)

wgwgkg 09-15-2013 03:22

[FIXED]How can I get the origin that in front of the entity
 
I have tried velocity_by_aim but it doesn't work.
The aim to do that is to create a entity in front of the player:)
But how can I do this?

ConnorMcLeod 09-15-2013 04:27

Re: How can I get the origin that in front of the entity
 
velocity_by_aim + player origin should work

Try this :

PHP Code:

GetPlayerFrontOriginiddistanceorigin[3] )
{
    new 
Float:temp[3];
    
pev(idpev_originorigin);
    
pev(idpev_view_ofstemp);
    
origin[2] += temp[2];
    
velocity_by_aim(iddistancetemp);
    
xs_vec_add(origintemporigin);


Usage :
PHP Code:

{
    new 
Float:origin[3];
    
GetPlayerFrontOrigin(id150origin);



wgwgkg 09-15-2013 04:45

Re: How can I get the origin that in front of the entity
 
It does not work!
Actually, I want the function compatible with other entity such as NPC

Black Rose 09-15-2013 06:20

Re: [FIXED]How can I get the origin that in front of the entity
 
I don't know if it'll work because I don't know if ents have view_ofs or v_angle. You'll just have to try. Works with players.

Code:
stock PointByAim(ent, vel, Float:retPoint[3]) {     #if !defined _engine_included && !defined _fakemeta_included     #assert You need to include engine or fakemeta! #endif         new Float:entOrigin[3], Float:entOffsets[3];     #if defined _engine_included     if ( ! is_valid_ent(ent) ) { #else     if ( ! pev_valid(ent) ) { #endif         log_amx("[PointByAim] Entity %d is not valid", ent);         return;     }     #if defined _engine_included     entity_get_vector(ent, EV_VEC_origin, entOrigin);     entity_get_vector(ent, EV_VEC_view_ofs, entOffsets); #else     pev(ent, pev_origin, entOrigin);     pev(ent, pev_view_ofs, entOffsets); #endif         entOrigin[0] += entOffsets[0];     entOrigin[1] += entOffsets[1];     entOrigin[2] += entOffsets[2];     #if defined _engine_included     entity_get_vector(ent, EV_VEC_v_angle, entOffsets); #else     pev(ent, pev_v_angle, entOffsets); #endif         angle_vector(entOffsets, ANGLEVECTOR_FORWARD, entOffsets);         retPoint[0] = entOrigin[0] + entOffsets[0] * vel;     retPoint[1] = entOrigin[1] + entOffsets[1] * vel;     retPoint[2] = entOrigin[2] + entOffsets[2] * vel; }

.Dare Devil. 09-15-2013 08:43

Re: [FIXED]How can I get the origin that in front of the entity
 
PHP Code:

stock angle_to_velocityFloat:angle[3], const Float:distanceFloat:outorigin[3] )
{
    static 
Float:v_forward[3]
    
angle_vector(angleANGLEVECTOR_FORWARDv_forward)
    
outorigin[0] = v_forward[0] * distanceoutorigin[1] = v_forward[1] * distanceoutorigin[2] = v_forward[2] * distance



ConnorMcLeod 09-15-2013 10:44

Re: How can I get the origin that in front of the entity
 
Quote:

Originally Posted by wgwgkg (Post 2034910)
I have tried velocity_by_aim but it doesn't work.
The aim to do that is to create a entity in front of the player:)
But how can I do this?


Quote:

Originally Posted by wgwgkg (Post 2034940)
It does not work!
Actually, I want the function compatible with other entity such as NPC


Nice.


All times are GMT -4. The time now is 19:15.

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