LTBOOL CParticleExplosionFX::UpdateEmitter(MovingObject* pObject) { if (!m_pClientDE || !pObject || pObject->m_dwPhysicsFlags & MO_RESTING) return LTFALSE; LTBOOL bRet = LTFALSE; LTVector vNewPos; if (UpdateMovingObject(LTNULL, pObject, &vNewPos)) { ClientIntersectInfo info; LTBOOL bBouncedOnGround = LTFALSE; uint32 dwFlags = (INTERSECT_HPOLY | INTERSECT_OBJECTS | IGNORE_NONSOLID); bRet = BounceMovingObject(LTNULL, pObject, &vNewPos, &info, dwFlags, bBouncedOnGround); pObject->m_vLastPos = pObject->m_vPos; pObject->m_vPos = vNewPos; if (m_pClientDE->GetPointStatus(&vNewPos) == LT_OUTSIDE) { pObject->m_dwPhysicsFlags |= MO_RESTING; pObject->m_vPos = pObject->m_vLastPos; } } return bRet; }
LTBOOL CParticleExplosionFX::UpdateEmmitter(MovingObject* pObject) { if (!m_pClientDE || !pObject || pObject->m_PhysicsFlags & MO_RESTING) return LTFALSE; LTBOOL bRet = LTFALSE; LTVector vNewPos; if (UpdateMovingObject(LTNULL, pObject, &vNewPos)) { ClientIntersectInfo info; bRet = BounceMovingObject(LTNULL, pObject, &vNewPos, &info); VEC_COPY(pObject->m_LastPos, pObject->m_Pos); VEC_COPY(pObject->m_Pos, vNewPos); if (m_pClientDE->Common()->GetPointStatus(&vNewPos) == LT_OUTSIDE) { pObject->m_PhysicsFlags |= MO_RESTING; VEC_COPY(pObject->m_Pos, pObject->m_LastPos); } } return bRet; }
DBOOL CShellCasingFX::Update() { if (!m_hObject || !m_pClientDE) return DFALSE; if (m_pClientDE->GetTime() > m_fExpireTime) return DFALSE; if (m_bInVisible) { m_bInVisible = DFALSE; m_pClientDE->SetObjectFlags(m_hObject, FLAG_VISIBLE); } if (m_bResting) return DTRUE; DRotation rRot; // If velocity slows enough, and we're on the ground, just stop bouncing and just wait to expire. if (m_movingObj.m_PhysicsFlags & MO_RESTING) { m_bResting = DTRUE; // Stop the spinning... m_pClientDE->SetupEuler(&rRot, 0, m_fYaw, 0); m_pClientDE->SetObjectRotation(m_hObject, &rRot); /* // Shell is at rest, we can add a check here to see if we really want // to keep it around depending on detail settings... HLOCALOBJ hObjs[1]; DDWORD nNumFound, nBogus; m_pClientDE->FindObjectsInSphere(&m_movingObj.m_Pos, 64.0f, hObjs, 1, &nBogus, &nNumFound); // Remove thyself... if (nNumFound > 15) return DFALSE; */ } else { if (m_fPitchVel != 0 || m_fYawVel != 0) { DFLOAT fDeltaTime = m_pClientDE->GetFrameTime(); m_fPitch += m_fPitchVel * fDeltaTime; m_fYaw += m_fYawVel * fDeltaTime; m_pClientDE->SetupEuler(&rRot, m_fPitch, m_fYaw, 0.0f); m_pClientDE->SetObjectRotation(m_hObject, &rRot); } } DVector vNewPos; if (UpdateMovingObject(DNULL, &m_movingObj, &vNewPos)) { ClientIntersectInfo info; SurfaceType eType = SURFTYPE_UNKNOWN; if (BounceMovingObject(DNULL, &m_movingObj, &vNewPos, &info, &eType)) { if (m_nBounceCount > 0) { char sType[10]; char sFile[MAX_CS_FILENAME_LEN]; switch(eType) { // case SURFTYPE_FLESH: _mbscpy((unsigned char*)sType, (const unsigned char*)"Flesh"); break; case SURFTYPE_GLASS: _mbscpy((unsigned char*)sType, (const unsigned char*)"Glass"); break; case SURFTYPE_METAL: _mbscpy((unsigned char*)sType, (const unsigned char*)"Metal"); break; case SURFTYPE_PLASTIC: _mbscpy((unsigned char*)sType, (const unsigned char*)"Plastic"); break; case SURFTYPE_TERRAIN: _mbscpy((unsigned char*)sType, (const unsigned char*)"Terrain"); break; case SURFTYPE_LIQUID: _mbscpy((unsigned char*)sType, (const unsigned char*)"Water"); break; case SURFTYPE_WOOD: _mbscpy((unsigned char*)sType, (const unsigned char*)"Wood"); break; case SURFTYPE_STONE: default: _mbscpy((unsigned char*)sType, (const unsigned char*)"Stone"); break; } sprintf(sFile, "Sounds\\Weapons\\ShellDrops\\%s\\Shell%d.wav", sType, GetRandom(1, 2)); PlaySoundFromPos(&vNewPos, sFile, 150.0f, SOUNDPRIORITY_MISC_LOW); } // Adjust the bouncing.. m_fPitchVel = GetRandom(-MATH_CIRCLE * 2, MATH_CIRCLE * 2); m_fYawVel = GetRandom(-MATH_CIRCLE * 2, MATH_CIRCLE * 2); m_nBounceCount--; if (m_nBounceCount <= 0) { m_movingObj.m_PhysicsFlags |= MO_RESTING; } } VEC_COPY(m_movingObj.m_Pos, vNewPos); if (m_pClientDE->GetPointStatus(&vNewPos) == DE_OUTSIDE) { return DFALSE; } m_pClientDE->SetObjectPos(m_hObject, &vNewPos); } return DTRUE; }
LTBOOL CShellCasingFX::Update() { if (!m_hObject || !m_pClientDE) return LTFALSE; if (g_pGameClientShell->IsServerPaused()) { return LTTRUE; } m_fElapsedTime += g_pGameClientShell->GetFrameTime(); m_fDieTime -= g_pGameClientShell->GetFrameTime(); if (m_fDieTime <= 0.0f) return LTFALSE; // Update object scale if necessary... LTVector vScale; m_pClientDE->GetObjectScale(m_hObject, &vScale); if (vScale != m_vFinalScale) { if (m_fElapsedTime <= g_vtShellScaleTime.GetFloat()) { LTVector vScaleRange = (m_vFinalScale - m_vInitialScale); vScale = m_vInitialScale + (vScaleRange * (m_fElapsedTime/g_vtShellScaleTime.GetFloat())); if (vScale > m_vFinalScale) { vScale = m_vFinalScale; } m_pClientDE->SetObjectScale(m_hObject, &vScale); } else { m_pClientDE->SetObjectScale(m_hObject, &m_vFinalScale); } } if (m_bResting) return LTTRUE; LTRotation rRot; g_pLTClient->GetObjectRotation(m_hObject, &rRot); // If velocity slows enough, and we're on the ground, just stop bouncing and just wait to expire. if (m_movingObj.m_dwPhysicsFlags & MO_RESTING) { m_bResting = LTTRUE; // Stop the spinning... rRot.Rotate(rRot.Up(), m_fYaw); g_pLTClient->SetObjectRotation(m_hObject, &rRot); // Shell is at rest, we can add a check here to see if we really want // to keep it around depending on detail settings... //HLOCALOBJ hObjs[1]; //uint32 nNumFound, nBogus; //m_pClientDE->FindObjectsInSphere(&m_movingObj.m_vPos, 64.0f, hObjs, 1, &nBogus, &nNumFound); // Remove thyself... //if (nNumFound > 15) return LTFALSE; } else { if (m_fPitchVel != 0 || m_fYawVel != 0) { LTFLOAT fDeltaTime = g_pGameClientShell->GetFrameTime(); m_fPitch += m_fPitchVel * fDeltaTime; m_fYaw += m_fYawVel * fDeltaTime; rRot.Rotate(rRot.Up(), m_fYaw); rRot.Rotate(rRot.Right(), m_fPitch); g_pLTClient->SetObjectRotation(m_hObject, &rRot); } } LTVector vNewPos; if (UpdateMovingObject(LTNULL, &m_movingObj, vNewPos)) { ClientIntersectInfo info; LTBOOL bBouncedOnGround = LTFALSE; if (BounceMovingObject(LTNULL, &m_movingObj, vNewPos, &info, INTERSECT_HPOLY, true, bBouncedOnGround)) { // If we hit the sky/invisible surface we're done... SurfaceType eType = GetSurfaceType(info); if (eType == ST_SKY || eType == ST_INVISIBLE) { return LTFALSE; } if (m_nBounceCount >= MAX_BOUNCE_COUNT) { if (!(m_movingObj.m_dwPhysicsFlags & MO_LIQUID)) { SURFACE* pSurf = g_pSurfaceMgr->GetSurface(eType); if (pSurf) { // Play appropriate sound... if (pSurf->szShellImpactSnds[0]) { g_pClientSoundMgr->PlaySoundFromPos(vNewPos, pSurf->szShellImpactSnds[0], pSurf->fShellSndRadius, SOUNDPRIORITY_MISC_LOW); } } } } // Adjust the bouncing.. m_fPitchVel *= 0.75f; m_fYawVel *= -0.75f; m_nBounceCount--; if (m_nBounceCount <= 0) { m_movingObj.m_dwPhysicsFlags |= MO_RESTING; } } m_movingObj.m_vPos = vNewPos; if (g_pCommonLT->GetPointStatus(&vNewPos) == LT_OUTSIDE) { return LTFALSE; } g_pLTClient->SetObjectPos(m_hObject, &vNewPos); } return LTTRUE; }