Raised This Month: $ Target: $400
 0% 

Vector Calculation


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 10-15-2008 , 21:59   Vector Calculation
Reply With Quote #1

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
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 01:41.


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