Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LTBOOL CWeapon::CreateProjectile(LTRotation & rRot, WeaponFireInfo & info)
- {
- if (!m_pAmmoData->pProjectileFX || !(m_pAmmoData->pProjectileFX->szClass[0])) return LTFALSE;
- ObjectCreateStruct theStruct;
- INIT_OBJECTCREATESTRUCT(theStruct);
- // set the starting rotation
- theStruct.m_Rotation = rRot;
- // move the start position along the line of fire a little
- if ( MATH_EPSILON < m_pAmmoData->pProjectileFX->fFireOffset )
- {
- // determine the new point
- LTVector vNewFirePos;
- vNewFirePos = info.vPath;
- vNewFirePos *= m_pAmmoData->pProjectileFX->fFireOffset;
- vNewFirePos += info.vFirePos;
- // see if there is any geometry in the way
- IntersectInfo iInfo;
- IntersectQuery qInfo;
- qInfo.m_From = info.vFirePos;
- qInfo.m_To = vNewFirePos;
- qInfo.m_Direction = info.vPath;
- qInfo.m_Flags = INTERSECT_OBJECTS | IGNORE_NONSOLID | INTERSECT_HPOLY;
- qInfo.m_FilterFn = SpecificObjectFilterFn;
- qInfo.m_PolyFilterFn = LTNULL;
- qInfo.m_pUserData = info.hFiredFrom;
- if ( LTTRUE == g_pLTServer->IntersectSegment( &qInfo, &iInfo ) )
- {
- // hit something, just put the fire position at the original
- theStruct.m_Pos = info.vFirePos;
- }
- else
- {
- // hit nothing, use the new fire position
- theStruct.m_Pos = vNewFirePos;
- }
- }
- else
- {
- theStruct.m_Pos = info.vFirePos;
- }
- HCLASS hClass = g_pLTServer->GetClass(m_pAmmoData->pProjectileFX->szClass);
- UBER_ASSERT1( hClass, "Unable to retreive class: %s", m_pAmmoData->pProjectileFX->szClass );
- if (hClass)
- {
- CProjectile* pProj = (CProjectile*)g_pLTServer->CreateObject(hClass, &theStruct);
- if (pProj)
- {
- if( !pProj->Setup(this, info) )
- {
- g_pLTServer->RemoveObject( pProj->m_hObject );
- return LTFALSE;
- }
- // Create a stimulus for AIs to notice projectile.
- pProj->CreateDangerStimulus( info.hFiredFrom );
- return LTTRUE;
- }
- }
- return LTFALSE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement