AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Math Help (https://forums.alliedmods.net/showthread.php?t=29647)

Cheap_Suit 06-09-2006 17:17

Math Help
 
Code:
get_user_origin(temp, temp, 0) //where his at get_user_origin(temp, temp, 3) //where his aiming
Is there anyway you can find out if a player is close from that line?

GHW_Chronic 06-09-2006 17:25

well depends on what u want to do. In the case that you specified, if you are simply finding a player between his aiming and his end aiming you can simply do get_user_aiming. If you are trying to find out if a player is on a line that is not from a player's crosshairs to a player's end aim point, you could circle through 1-get_maxplayers() and see if they are on the line with simple algebra.

Cheap_Suit 06-09-2006 17:32

Im trying to find out if the user is close to that line. Like in is_user_visible.

GHW_Chronic 06-09-2006 17:35

then y not use is_user_visible? maybe I am misunderstanding.

Cheap_Suit 06-09-2006 17:37

not working

GHW_Chronic 06-09-2006 17:45

I thought someone had told me one time that they had fixed it because instead of doing

Code:

if(!visible)
  return 0;

return 1;

they had done

Code:

if(!visible)
  return 1;

return 1;

but they caught it and fixed it. Maybe they de-fixed it. Maybe someone lied to me.

VEN 06-10-2006 04:06

So you want to find a distance from the closest line point to the player?

By the way is_in_viewcone and is_visible is broken (<1.75) but you can use fm_is_visible and fm_is_in_viewcone from the Fakemeta Utilities

Cheap_Suit 06-11-2006 11:58

Code:

<Aim>
|
| o <- Victim
|
|
|
<Attacker>

Finding the distance of a player from that line.

I total forgot about your Fakemeta Utilities, going to try that..

Greenberet 06-11-2006 12:27

atm i only know one way:

you have an triangle here.

A = Attacker
B = AIM
C = VICTIM

a = distance(aim, victim)
b = distance(attacker, victim)
c = distance(attacker, aim )

hc = distance from line to victim

so something like this could work:

s = (a+b+c)/2
area = sqrt(s *(s-a)*(s-b)*(s-c))

area = c * hc /2
hc = 2 * area / c

maybe this is not the best way, but it is a way ;)

KoST 06-11-2006 12:53

http://upload.wikimedia.org/wikipedi...reieck.svg.png

http://upload.wikimedia.org/math/f/9...a733bec657.png


All times are GMT -4. The time now is 08:03.

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