ItsMods

Full Version: Player visible on screen.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
playerIsVisible(player)
{
    cpi = 3.141592654 * 2 / 360;
    angle = self.angles[1] * cpi;
    sy = sin(angle);
    cy = cos(angle);
    angle = self.angles[0] * cpi;
    sp = sin(angle);
    cp = cos(angle);
    forward = (cp*cy, cp*sy, sp*-1);
    return BulletTracePassed(self getTagOrigin("j_head"), player getTagOrigin("j_head"), false, self) && vectordot(player.origin-self.origin, forward) >= 0.01;
}

Combine this with some aimbot code and profit? (it's not 360 degrees so it looks more realistic but you probably got to figure out the smooth aiming yourself) Note that this is an actual snippet of code you might see in a real aimbot hack.

Pseudo-code:
Code:
if(self playerIsVisible(somePlayer))
{
    //Do something
}
Good job on the function, but it seems way to complicated.

This is a function treyarch made:
Code:
//Example: qBool = within_fov( level.player.origin, level.player.angles, target1.origin, cos( 45 ) );
within_fov( start_origin, start_angles, end_origin, fov )
{
    normal = VectorNormalize( end_origin - start_origin );
    forward = AnglesToForward( start_angles );
    dot = VectorDot( forward, normal );

    return dot >= fov;
}
Would this also work in mw2 ?
(10-03-2011, 06:13)OrangePL Wrote: [ -> ]Would this also work in mw2 ?

probably
(10-03-2011, 06:13)OrangePL Wrote: [ -> ]Would this also work in mw2 ?

Code:
PointinFov(position)
{
    dot = vectordot(anglestoforward(self.angles),vectornormalize(position-self.origin));
    return dot >= 0.766;
}

I used the value that I found in a gsc file for the fov = 80(0.766).