void CProjectileFX::HandleTouch(CollisionInfo *pInfo) { if (!m_pClientDE || !pInfo || !pInfo->m_hObject || !g_pGameClientShell) return; // Let it get out of our bounding box... CMoveMgr* pMoveMgr = g_pPlayerMgr->GetMoveMgr(); if (pMoveMgr) { // Don't colide with the move mgr object... HLOCALOBJ hMoveObj = pMoveMgr->GetObject(); if (pInfo->m_hObject == hMoveObj) return; // Don't colide with the player object... HLOCALOBJ hPlayerObj = m_pClientDE->GetClientObject(); if (pInfo->m_hObject == hPlayerObj) return; } // See if we want to impact on this object... uint32 dwUsrFlags; g_pCommonLT->GetObjectFlags(pInfo->m_hObject, OFT_User, dwUsrFlags); if (dwUsrFlags & USRFLG_IGNORE_PROJECTILES) return; LTBOOL bIsWorld = IsMainWorld(pInfo->m_hObject); // Don't impact on non-solid objects... uint32 dwFlags; g_pCommonLT->GetObjectFlags(pInfo->m_hObject, OFT_Flags, dwFlags); if (!bIsWorld && !(dwFlags & FLAG_SOLID)) return; // See if we hit the sky... if (bIsWorld) { SurfaceType eType = GetSurfaceType(pInfo->m_hPoly); if (eType == ST_SKY) { m_bWantRemove = LTTRUE; return; } else if (eType == ST_INVISIBLE) { // Keep going, ignore this object... return; } } Detonate(pInfo); }
void CHeadBobMgr::UpdateHeadBob() { CMoveMgr* pMoveMgr = g_pPlayerMgr->GetMoveMgr(); if (!pMoveMgr) return; LTBOOL bZoomed = g_pPlayerMgr->IsZoomed(); uint32 dwPlayerFlags = g_pPlayerMgr->GetPlayerFlags(); // This frame time is used since unlike ClientDE::GetFrameTime() the // max value is controlled by the game... LTFLOAT fFrameTime = g_pGameClientShell->GetFrameTime(); LTFLOAT fTime = g_pLTClient->GetTime(); LTBOOL bRunning = (LTBOOL) !!(dwPlayerFlags & BC_CFLG_RUN); LTFLOAT fMoveDist = pMoveMgr->GetVelocity().Mag() * fFrameTime; LTBOOL bFootstep = LTFALSE; LTBOOL bLeftFoot = LTFALSE; LTFLOAT fPace = 0.0f; if (pMoveMgr->GetVehicleMgr()->IsVehiclePhysics()) { fPace = MATH_CIRCLE * g_vtVehiclePaceAdjust.GetFloat(); } else if (bRunning) { fPace = MATH_CIRCLE * g_vtRunPaceAdjust.GetFloat(); } else { fPace = MATH_CIRCLE * g_vtWalkPaceAdjust.GetFloat(); } // Make sure bob phase and sway phase start at the right values... if (m_fBobAmp == 0.0f) { m_fBobPhase = 0.0f; m_fSwayPhase = 0.0f; } else // Normal processing... { // Bob phase should be between MATH_PI and MATH_CIRCLE so that the // sin(m_fBobPhase) is always between -1 and 0... m_fBobPhase += (fFrameTime * fPace); if (m_fBobPhase > MATH_CIRCLE) { m_fBobPhase -= MATH_PI; } else if (m_fBobPhase < MATH_PI) { m_fBobPhase += MATH_PI; } m_fSwayPhase += (fFrameTime * fPace); if (m_fSwayPhase > MATH_CIRCLE) { m_fSwayPhase -= MATH_CIRCLE; } } // See if it is time to play a footstep sound... if ((m_fSwayPhase > MATH_CIRCLE * 0.25f) && (m_fSwayPhase <= MATH_CIRCLE * 0.75f)) { if (s_bCanDoLeftFootstep) { bLeftFoot = LTFALSE; bFootstep = LTTRUE; s_bCanDoLeftFootstep = LTFALSE; s_bCanDoRightFootstep = LTTRUE; } } else if (m_fSwayPhase > MATH_CIRCLE * 0.75f) { if (s_bCanDoRightFootstep) { bLeftFoot = LTTRUE; bFootstep = LTTRUE; s_bCanDoLeftFootstep = LTTRUE; s_bCanDoRightFootstep = LTFALSE; } } LTBOOL bMoving = LTFALSE; LTFLOAT t; uint32 dwTestFlags = (BC_CFLG_MOVING); // | BC_CFLG_DUCK); if (fMoveDist > 0.1f) { bMoving = !!(dwPlayerFlags & dwTestFlags); } // If we're not moving, decay the head bob... if (!bMoving) { s_fBobStartTime = -1.0f; if (s_fBobDecayStartTime < 0.0f) { // Calculate what the current bobamp percent is... t = (1.0f - m_fBobAmp / g_vtMaxBobAmp.GetFloat()); s_fBobDecayStartTime = fTime - (g_vtBobDecayTime.GetFloat() * t); } LTFLOAT fDur = (fTime - s_fBobDecayStartTime); if (fDur <= g_vtBobDecayTime.GetFloat()) { t = fDur / g_vtBobDecayTime.GetFloat(); // 0 to 1 t = WaveFn_SlowOff(t); t = 1.0f - t; // 1 to 0 m_fBobAmp = t * g_vtMaxBobAmp.GetFloat(); if (m_fBobAmp < 0.0f) { m_fBobAmp = 0.0f; } } else { m_fBobAmp = 0.0f; } } else // We're moving... { s_fBobDecayStartTime = -1.0f; // If we just started bobing, ramp up the bob... if (s_fBobStartTime < 0.0f) { // Calculate what the current bobamp percent is... t = m_fBobAmp / g_vtMaxBobAmp.GetFloat(); s_fBobStartTime = fTime - (g_vtBobDecayTime.GetFloat() * t); } LTFLOAT fDur = (fTime - s_fBobStartTime); if (fDur <= g_vtBobDecayTime.GetFloat()) { t = fDur / g_vtBobDecayTime.GetFloat(); // 0 to 1 t = WaveFn_SlowOn(t); m_fBobAmp = t * g_vtMaxBobAmp.GetFloat(); if (m_fBobAmp > g_vtMaxBobAmp.GetFloat()) { m_fBobAmp = g_vtMaxBobAmp.GetFloat(); } } else { m_fBobAmp = g_vtMaxBobAmp.GetFloat(); } } // Update the bob... if (!bZoomed) { m_fBobHeight = g_vtBobV.GetFloat() * m_fBobAmp * (float)sin(m_fBobPhase); } // Update the weapon model bobbing... IClientWeaponBase *pClientWeapon = g_pPlayerMgr->GetCurrentClientWeapon(); if ( pClientWeapon && !bZoomed ) { LTFLOAT fSwayHeight = g_vtSwayV.GetFloat() * m_fBobAmp * (float)sin(m_fSwayPhase * 2); LTFLOAT fSwayWidth = g_vtSwayH.GetFloat() * m_fBobAmp * (float)sin(m_fSwayPhase - (MATH_PI/3)); // No weapon bob if vehicle mode... if (pMoveMgr->GetVehicleMgr()->IsVehiclePhysics()) { fSwayWidth = fSwayHeight = 0.0f; } fSwayHeight *= g_vtWeaponSway.GetFloat(); fSwayWidth *= g_vtWeaponSway.GetFloat(); pClientWeapon->UpdateBob(fSwayWidth, fSwayHeight); } // Update the head cant... if (!bZoomed && !pMoveMgr->GetVehicleMgr()->IsVehiclePhysics()) { LTFLOAT fRollAdjust = g_vtRollAdjust.GetFloat() * (float)sin(m_fSwayPhase); // Turn head bob up/down... fRollAdjust *= g_vtHeadBobAdjust.GetFloat(); if (m_fBobAmp == 0.0f) { fRollAdjust = 0.0f; } g_pPlayerMgr->SetRoll(fRollAdjust); } // Play foot step sounds at the appropriate time... if (bMoving && bFootstep) { CCharacterFX* pCharFX = pMoveMgr->GetCharacterFX(); if (pCharFX) { SurfaceType eSurf = pMoveMgr->GetStandingOnSurface(); eSurf = (eSurf == ST_UNKNOWN ? pCharFX->GetLastSurface() : eSurf); LTVector vPos; g_pLTClient->GetObjectPos(pMoveMgr->GetObject(), &vPos); pCharFX->PlayMovementSound(vPos, eSurf, bLeftFoot); } } }