Advertisement
dcomicboy

create projectile

Jul 7th, 2012
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. LTBOOL CWeapon::CreateProjectile(LTRotation & rRot, WeaponFireInfo & info)
  2. {
  3. if (!m_pAmmoData->pProjectileFX || !(m_pAmmoData->pProjectileFX->szClass[0])) return LTFALSE;
  4.  
  5. ObjectCreateStruct theStruct;
  6. INIT_OBJECTCREATESTRUCT(theStruct);
  7.  
  8. // set the starting rotation
  9. theStruct.m_Rotation = rRot;
  10.  
  11. // move the start position along the line of fire a little
  12. if ( MATH_EPSILON < m_pAmmoData->pProjectileFX->fFireOffset )
  13. {
  14. // determine the new point
  15. LTVector vNewFirePos;
  16. vNewFirePos = info.vPath;
  17. vNewFirePos *= m_pAmmoData->pProjectileFX->fFireOffset;
  18. vNewFirePos += info.vFirePos;
  19.  
  20. // see if there is any geometry in the way
  21. IntersectInfo iInfo;
  22. IntersectQuery qInfo;
  23. qInfo.m_From = info.vFirePos;
  24. qInfo.m_To = vNewFirePos;
  25. qInfo.m_Direction = info.vPath;
  26. qInfo.m_Flags = INTERSECT_OBJECTS | IGNORE_NONSOLID | INTERSECT_HPOLY;
  27. qInfo.m_FilterFn = SpecificObjectFilterFn;
  28. qInfo.m_PolyFilterFn = LTNULL;
  29. qInfo.m_pUserData = info.hFiredFrom;
  30.  
  31. if ( LTTRUE == g_pLTServer->IntersectSegment( &qInfo, &iInfo ) )
  32. {
  33. // hit something, just put the fire position at the original
  34. theStruct.m_Pos = info.vFirePos;
  35. }
  36. else
  37. {
  38. // hit nothing, use the new fire position
  39. theStruct.m_Pos = vNewFirePos;
  40. }
  41. }
  42. else
  43. {
  44. theStruct.m_Pos = info.vFirePos;
  45. }
  46.  
  47. HCLASS hClass = g_pLTServer->GetClass(m_pAmmoData->pProjectileFX->szClass);
  48.  
  49. UBER_ASSERT1( hClass, "Unable to retreive class: %s", m_pAmmoData->pProjectileFX->szClass );
  50.  
  51. if (hClass)
  52. {
  53. CProjectile* pProj = (CProjectile*)g_pLTServer->CreateObject(hClass, &theStruct);
  54. if (pProj)
  55. {
  56. if( !pProj->Setup(this, info) )
  57. {
  58. g_pLTServer->RemoveObject( pProj->m_hObject );
  59. return LTFALSE;
  60. }
  61.  
  62. // Create a stimulus for AIs to notice projectile.
  63.  
  64. pProj->CreateDangerStimulus( info.hFiredFrom );
  65.  
  66. return LTTRUE;
  67. }
  68. }
  69.  
  70. return LTFALSE;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement