Okay, so here is what I have:
- The origin of Player1's head.
- The origin of where Player1 is looking.
- The origin of Player2's head.
- The distance from Player1's head to where Player1 is looking.
- The distance from Player1's head to Player2's head.
What I'm trying to do:
Find the origin along Player1's line of sight where the distance from Player1's head to this origin is equal to the distance from Player1's head to Player2's head.
Here is my code:
Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta_util>
#define BONE_HEAD 8
new bool:g_aiming[33];
public plugin_init()
{
register_plugin("Aim Test", "0.1", "Exolent");
register_forward(FM_PlayerPreThink, "FwdPlayerPreThink");
register_clcmd("say /aim", "CmdAim");
}
public client_connect(client)
{
g_aiming[client] = false;
}
public FwdPlayerPreThink(client)
{
if( !g_aiming[client]
|| !is_user_alive(client) ) return;
static players[32], pnum;
get_players(players, pnum, "a");
if( !pnum ) return;
static Float:angles[3];
static Float:origin[3];
engfunc(EngFunc_GetBonePosition, client, BONE_HEAD, origin, angles);
static Float:aim_origin[3];
fm_get_aim_origin(client, aim_origin);
new Float:aim_dist = get_distance_f(aim_origin, origin);
static message[256];
formatex(message, sizeof(message) - 1, "Aim Distance: %f", aim_dist);
static Float:head_origin[3], victim, Float:head_dist;
for( new i = 0; i < pnum; i++ )
{
victim = players[i];
if( victim == client ) continue;
engfunc(EngFunc_GetBonePosition, victim, BONE_HEAD, head_origin, angles);
if( !fm_is_in_viewcone(client, head_origin) ) continue;
head_dist = get_distance_f(origin, head_origin);
// calculate the other origin here
format(message, sizeof(message) - 1, "%s^nHead Distance: %f", message, head_dist);
}
set_hudmessage(255, 255, 255, 0.2, 0.3, 0, 0.0, 0.1, 0.0, 0.0, 1);
show_hudmessage(client, "%s", message);
}
public CmdAim(client)
{
g_aiming[client] = !g_aiming[client];
}
Okay, so here is what I have (code):
- The origin of Player1's head (origin).
- The origin of where Player1 is looking (aim_origin).
- The origin of Player2's head (head_origin).
- The distance from Player1's head to where Player1 is looking (aim_dist).
- The distance from Player1's head to Player2's head (head_dist).
Here is a visual of what I'm trying to accomplish:
[img]http://img511.**************/img511/1010/aimoriginrf0.png[/img]
I've been trying 4 different ways for about an hour and I still can't get it to work
__________________