Advertisement
Guest User

no. 25 - Is player entity aiming in rect

a guest
Sep 8th, 2010
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. /*
  2. -----------------------------------------
  3. * Game hacking QTS ( Quickie Tip Series )
  4. * no. 25 - Is player entity aiming in rect
  5. -----------------------------------------
  6. * Author: SEGnosis  - GHAnon.net
  7. * Thanks to:
  8. * bitterbanana      - No known site
  9. * Drunken Cheetah   - No known site
  10. * fatboy88      - No known site
  11. * Geek4Ever         - No known site
  12. * learn_more        - www.uc-forum.com
  13. * Novocaine         - http://ilsken.net/blog/?page_id=64
  14. * Philly0494        - No known site
  15. * Roverturbo        - www.uc-forum.com
  16. * SilentKarma       - www.halocoders.com - offline
  17. * Strife        - www.uc-forum.com
  18. * Wieter20      - No known site
  19. */
  20.  
  21. bool C_Entity_Manager::IsPlayerEntityAimingInRect( C_Player_Entity* pEntity, FVect3 vA, float fWidth )
  22. {
  23.     FTrigFunc vTrig;
  24.  
  25.     vTrig.cosine    = cosf( pEntity->m_vView.yaw );
  26.     vTrig.sine  = sinf( pEntity->m_vView.yaw );
  27.  
  28.     FVect3 vDistance;
  29.  
  30.     vA.y -= PMH_CROUCH;
  31.  
  32.     PointDifference( pEntity->m_vPos, vA, vDistance );
  33.  
  34.     double fDistance = PointProduct( vDistance );
  35.     float fHeight = fWidth * 2.5f;
  36.  
  37.     FVect3 vPoint = { pEntity->m_vPos.x + ( vTrig.sine * fDistance ), pEntity->m_vPos.y + ( -pEntity->m_vView.pitch * fDistance ), pEntity->m_vPos.z + ( vTrig.cosine * fDistance ) };
  38.  
  39.     if( vPoint.x >= vA.x-fWidth && vPoint.x <= vA.x+fWidth &&
  40.         vPoint.z >= vA.z-fWidth && vPoint.z <= vA.z+fWidth &&
  41.         vPoint.y >= vA.y        && vPoint.y <= vA.y+fHeight )
  42.         return true;
  43.  
  44.     return false;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement