Raised This Month: $ Target: $400
 0% 

Where player aim -> Same angle to object.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 12-30-2008 , 13:28   Where player aim -> Same angle to object.
Reply With Quote #1

how to do that?
__________________
xPaw is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-30-2008 , 14:24   Re: Where player aim -> Same angle to object.
Reply With Quote #2

What do you mean? Do you mean getting the aiming origin?
If so, use fakemeta_util's stock:
PHP Code:
stock fm_get_aimorigin(indexFloat:origin[3])
{
    new 
Float:start[3], Float:view_ofs[3];
    
pev(indexpev_originstart);
    
pev(indexpev_view_ofsview_ofs);
    
xs_vec_add(startview_ofsstart);
    
    new 
Float:dest[3];
    
pev(indexpev_v_angledest);
    
engfunc(EngFunc_MakeVectorsdest);
    
global_get(glb_v_forwarddest);
    
xs_vec_mul_scalar(dest9999.0dest);
    
xs_vec_add(startdestdest);
    
    
engfunc(EngFunc_TraceLinestartdest0index0);
    
get_tr2(0TR_vecEndPosorigin);
    
    return 
1;

If not, please explain exactly what you want.
__________________
O o
/¯________________________
| IMMA FIRIN' MAH LAZOR!!!
\_¯¯¯
Dores is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 12-30-2008 , 14:28   Re: Where player aim -> Same angle to object.
Reply With Quote #3

yes i want get where player is watching, and in same view(angle) set the entity, i mean entity will rotate like a player, for example how it works with MOVETYPE_FOLLOW.
__________________
xPaw is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 12-30-2008 , 14:34   Re: Where player aim -> Same angle to object.
Reply With Quote #4

You'd have to get the forward vector. Here's an example:

Code:
/* Assume id is passed to this function */ new Float:Origin[3],Float:Angle[3],Float:Forward[3],Float:Result[3] pev(id,pev_origin,Origin) pev(id,pev_v_angle,Angle)         engfunc(EngFunc_MakeVectors,Angle) global_get(glb_v_forward,Forward)         Result[0] = Origin[0] + Forward[0] * 100 Result[1] = Origin[1] + Forward[1] * 100 /* This will leave it on the same z axis,     but if you want it to go up and down,     uncomment the line after and comment     this one */ Result[2] = Origin[2] //Result[2] = Origin[2] + Forward[2] * 100 engfunc(EngFunc_SetOrigin,Index,Result)

You can also make it go to the right, up, etc, using glb_v_right and glb_v_up.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Old 12-30-2008, 14:37
Dores
This message has been deleted by Dores. Reason: No wait....
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-30-2008 , 14:46   Re: Where player aim -> Same angle to object.
Reply With Quote #5

Instead of the user's origin, I would suggest using the origin from his eyes:
PHP Code:
#include <amxmodx>
#include <fakemeta_util>

#define VERSION "1.0"

#define HEAD_POSITION    8
#define DESIRED_DISTANCE    100 // Change this to whatever.

new g_entid;

public 
plugin_init()
{
    
register_plugin"Moving an entity by the aim"VERSION"Dores" );
    
register_forwardFM_PlayerPreThink"Forward_PreThink" );
    
register_clcmd"say /ent""Cmd_Create" );
}

public 
Cmd_Createid )
{
    new 
Float:aimorigin];
    
fm_get_aim_originidaimorigin );
    
    
g_entid fm_create_entity"info_target" );
    
set_pevg_entidpev_classname"BlaBla" );
    
set_pevg_entidpev_movetypeMOVETYPE_FOLLOW );
    
set_pevg_entidpev_ownerid );
    
    
// ETC. - Create entity with your likings.
    
    
    
return PLUGIN_HANDLED;
}

public 
Forward_PreThinkid )
{
    if( !
is_user_aliveid ) )
        return 
FMRES_IGNORED;
    
    static 
Float:start], Float:Forward], Float:end];
    
engfuncEngFunc_GetBonePositionidHEAD_POSITIONstart );
    
pevidpev_v_angleForward );
    
engfuncEngFunc_MakeVectorsForward );
    
global_getglb_v_forwardForward );
    
end] = start] + Forward] * DESIRED_DISTANCE;
    
end] = start] + Forward] * DESIRED_DISTANCE;
    
end] = start]; // Height of the eyes.
    
engfuncEngFunc_SetOriging_entidend ); // Update the ent's origin.
    
    
return FMRES_IGNORED;

__________________
O o
/¯________________________
| IMMA FIRIN' MAH LAZOR!!!
\_¯¯¯

Last edited by Dores; 12-30-2008 at 19:29.
Dores is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 12-30-2008 , 15:03   Re: Where player aim -> Same angle to object.
Reply With Quote #6

no guys thats not that. i want that entity will be rotating like my player model rotataing
if i'm watching to right, the entity will watch there too.

EDIT:
going try that
PHP Code:
new Float:vAngles[3];

pev(idpev_anglesvAngles);

//set the angles of the model to be the same as the player
set_pev(modelpev_anglesvAngles); 
__________________

Last edited by xPaw; 12-30-2008 at 15:16.
xPaw is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-30-2008 , 17:17   Re: Where player aim -> Same angle to object.
Reply With Quote #7

You can only do that if the model is an entity.

Maybe try view angles:
PHP Code:
new Float:flAngles] ; pevidpev_v_angleflAngles );
set_pevmodelpev_v_angleflAngles ); 
__________________
O o
/¯________________________
| IMMA FIRIN' MAH LAZOR!!!
\_¯¯¯
Dores is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 12-30-2008 , 18:35   Re: Where player aim -> Same angle to object.
Reply With Quote #8

I think you have to get the player's v_angles then set the entity's angle using that.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 12-30-2008 , 19:31   Re: Where player aim -> Same angle to object.
Reply With Quote #9

Quote:
Originally Posted by Hawk552 View Post
I think you have to get the player's v_angles then set the entity's angle using that.
Sounds reasonable.
__________________
O o
/¯________________________
| IMMA FIRIN' MAH LAZOR!!!
\_¯¯¯
Dores is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 12-31-2008 , 05:34   Re: Where player aim -> Same angle to object.
Reply With Quote #10

i used that what i posted above, and it worked perfect
__________________
xPaw 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 12:44.


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