void CGibFX::CreateLingeringSmoke(int nIndex) { CSFXMgr* psfxMgr = g_pGameClientShell->GetSFXMgr(); if (!psfxMgr) return; CGameSettings* pSettings = g_pInterfaceMgr->GetSettings(); if (!pSettings) return; uint8 nDetailLevel = pSettings->SpecialFXSetting(); if (nDetailLevel == RS_LOW) return; SMCREATESTRUCT sm; char* pTexture = "Sprites\\SmokeTest.spr"; VEC_SET(sm.vColor1, 100.0f, 100.0f, 100.0f); VEC_SET(sm.vColor2, 125.0f, 125.0f, 125.0f); VEC_SET(sm.vMinDriftVel, -10.0f, 25.0f, -10.0f); VEC_SET(sm.vMaxDriftVel, 10.0f, 50.0f, 10.0f); LTFLOAT fVolumeRadius = 10.0f; LTFLOAT fLifeTime = GetRandom(m_fLifeTime * 0.75f, m_fLifeTime); LTFLOAT fRadius = 1500; LTFLOAT fParticleCreateDelta = 0.1f; LTFLOAT fMinParticleLife = 1.0f; LTFLOAT fMaxParticleLife = 5.0f; uint8 nNumParticles = 3; LTBOOL bIgnoreWind = LTFALSE; if (IsLiquid(m_eCode)) { GetLiquidColorRange(m_eCode, &sm.vColor1, &sm.vColor2); pTexture = DEFAULT_BUBBLE_TEXTURE; fRadius = 750.0f; bIgnoreWind = LTTRUE; fMinParticleLife = 1.0f; fMaxParticleLife = 1.5f; } sm.vPos = m_Emitters[nIndex].m_vPos; sm.hServerObj = m_hGib[nIndex]; sm.fVolumeRadius = fVolumeRadius; sm.fLifeTime = fLifeTime; sm.fRadius = fRadius; sm.fParticleCreateDelta = fParticleCreateDelta; sm.fMinParticleLife = fMinParticleLife; sm.fMaxParticleLife = fMaxParticleLife; sm.nNumParticles = nNumParticles; sm.bIgnoreWind = bIgnoreWind; sm.hstrTexture = m_pClientDE->CreateString(pTexture); psfxMgr->CreateSFX(SFX_SMOKE_ID, &sm); m_pClientDE->FreeString(sm.hstrTexture); }
void CGibFX::CreateMiniBloodExplosion(int nIndex) { // Add a mini blood explosion... CSFXMgr* psfxMgr = g_pGameClientShell->GetSFXMgr(); if (!psfxMgr) return; CGameSettings* pSettings = g_pInterfaceMgr->GetSettings(); if (!pSettings) return; uint8 nDetailLevel = pSettings->SpecialFXSetting(); if (nDetailLevel == RS_LOW) return; char* szBlood[2] = { "SpecialFX\\ParticleTextures\\Blood_1.dtx", "SpecialFX\\ParticleTextures\\Blood_2.dtx" }; PARTICLESHOWERCREATESTRUCT ps; ps.vPos = m_Emitters[nIndex].m_vPos; ps.vPos.y += 30.0f; ps.vDir.Init(0, 100, 0); VEC_SET(ps.vColor1, 200.0f, 200.0f, 200.0f); VEC_SET(ps.vColor2, 255.0f, 255.0f, 255.0f); ps.pTexture = szBlood[GetRandom(0,1)];; ps.nParticles = 50; ps.fDuration = 1.0f; ps.fEmissionRadius = 0.3f; ps.fRadius = 800.0f; ps.fGravity = PSFX_DEFAULT_GRAVITY; if (IsLiquid(m_eCode)) { ps.vDir *= 3.0f; ps.fEmissionRadius = 0.2f; ps.fRadius = 700.0f; } psfxMgr->CreateSFX(SFX_PARTICLESHOWER_ID, &ps); // Play appropriate sound... char* pSound = GetGibDieSound(); if (pSound) { g_pClientSoundMgr->PlaySoundFromPos(ps.vPos, pSound, 300.0f, SOUNDPRIORITY_MISC_LOW); } }
CSpecialFX* CGibFX::CreateGibTrail(HLOCALOBJ hObj) { if (!hObj || !m_pClientDE) return LTNULL; CGameSettings* pSettings = g_pInterfaceMgr->GetSettings(); if (!pSettings) return LTNULL; uint8 nDetailLevel = pSettings->SpecialFXSetting(); if (nDetailLevel == RS_LOW) return LTNULL; PTCREATESTRUCT pt; pt.hServerObj = hObj; pt.nType = (uint8) (m_eModelType == eModelTypeHuman ? PT_BLOOD : PT_GIBSMOKE); CSpecialFX* pSFX = debug_new(CParticleTrailFX); if (!pSFX) return LTNULL; pSFX->Init(&pt); pSFX->CreateObject(m_pClientDE); return pSFX; }
LTBOOL CProjectileFX::CreateObject(ILTClient* pClientDE) { if (!CSpecialFX::CreateObject(pClientDE) || !m_hServerObject) return LTFALSE; CGameSettings* pSettings = g_pInterfaceMgr->GetSettings(); if (!pSettings) return LTFALSE; uint8 nDetailLevel = pSettings->SpecialFXSetting(); LTVector vPos; LTRotation rRot; g_pLTClient->GetObjectPos(m_hServerObject, &vPos); g_pLTClient->GetObjectRotation(m_hServerObject, &rRot); //m_pClientDE->CPrint("Client start pos (%.2f, %.2f, %.2f)", vPos.x, vPos.y, vPos.z); //m_fStartTime = m_pClientDE->GetTime(); if (nDetailLevel != RS_LOW) { if (m_nFX & PFX_SMOKETRAIL) { CreateSmokeTrail(vPos, rRot); } if (m_nFX & PFX_LIGHT) { CreateLight(vPos, rRot); } } if (m_nFX & PFX_FLARE) { CreateFlare(vPos, rRot); } if (m_nFX & PFX_FLYSOUND) { CreateFlyingSound(vPos, rRot); } // Do client-side projectiles in multiplayer games... if ( g_pClientMultiplayerMgr->IsConnectedToRemoteServer( )) { // Set the velocity of the "server" object if it is really just a local // object... if (m_bLocal) { VEC_COPY(m_vFirePos, vPos); m_fStartTime = m_pClientDE->GetTime(); LTVector vVel, vF; vF = rRot.Forward(); m_vPath = vF; // Special case of adjusting the projectile speed... LTFLOAT fVel = (LTFLOAT) m_pProjectileFX->nVelocity; if (m_bAltFire) { fVel = (LTFLOAT) m_pProjectileFX->nAltVelocity; } LTFLOAT fMultiplier = 1.0f; if (m_pClientDE->GetSConValueFloat("MissileSpeed", fMultiplier) != LT_NOTFOUND) { fVel *= fMultiplier; } vVel = vF * fVel; g_pPhysicsLT->SetVelocity(m_hServerObject, &vVel); } } return LTTRUE; }
LTBOOL CWeaponFX::CreateObject(ILTClient* pClientDE) { if (!CSpecialFX::CreateObject(pClientDE) || !g_pWeaponMgr) return LTFALSE; CGameSettings* pSettings = g_pInterfaceMgr->GetSettings(); if (!pSettings) return LTFALSE; // Set up our data members... // Set the local client id... uint32 dwId; g_pLTClient->GetLocalClientID(&dwId); m_nLocalId = (uint8)dwId; m_nDetailLevel = pSettings->SpecialFXSetting(); // Fire pos may get tweaked a little... m_vFirePos = CalcFirePos(m_vFirePos); m_vDir = m_vPos - m_vFirePos; m_fFireDistance = m_vDir.Mag(); m_vDir.Norm(); g_pLTClient->AlignRotation(&m_rSurfaceRot, &m_vSurfaceNormal, LTNULL); g_pLTClient->AlignRotation(&m_rDirRot, &m_vDir, LTNULL); SetupExitInfo(); // Calculate if the camera can see the fire position and the impact // position... g_bCanSeeImpactPos = LTTRUE; g_bCanSeeFirePos = LTTRUE; g_bDistantImpactPos = LTFALSE; g_bDistantFirePos = LTFALSE; if (g_vtWeaponFXUseFOVPerformance.GetFloat()) { HOBJECT hCamera = g_pGameClientShell->GetCamera(); LTVector vCameraPos, vU, vR, vF, vDir; LTRotation rCameraRot; g_pLTClient->GetObjectPos(hCamera, &vCameraPos); g_pLTClient->GetObjectRotation(hCamera, &rCameraRot); g_pLTClient->GetRotationVectors(&rCameraRot, &vU, &vR, &vF); vDir = m_vPos - vCameraPos; LTFLOAT fImpactDist = vDir.Mag(); if (fImpactDist > g_vtWeaponFXMaxImpactDist.GetFloat()) { g_bDistantImpactPos = LTTRUE; } vDir.Norm(); LTFLOAT fMul = VEC_DOT(vDir, vF); g_bCanSeeImpactPos = (fMul < g_vtWeaponFXMinImpactDot.GetFloat() ? LTFALSE : LTTRUE); // In multiplayer we need to account for impacts that occur around // our camera that we didn't cause (this is also an issue in single // player, but due to the singler player gameplay dynamics it isn't // as noticeable)... if (!g_bCanSeeImpactPos && IsMultiplayerGame()) { // Somebody else shot this...if the impact is close enough, we // "saw" it... if (m_nLocalId != m_nShooterId && fImpactDist <= g_vtWeaponFXMaxMultiImpactDist.GetFloat()) { g_bCanSeeImpactPos = LTTRUE; } } vDir = m_vFirePos - vCameraPos; if (vDir.Mag() > g_vtWeaponFXMaxFireDist.GetFloat()) { g_bDistantFirePos = LTTRUE; } vDir.Norm(); fMul = VEC_DOT(vDir, vF); g_bCanSeeFirePos = (fMul < g_vtWeaponFXMinFireDot.GetFloat() ? LTFALSE : LTTRUE); } // Determine what container the sfx is in... HLOCALOBJ objList[1]; LTVector vTestPos = m_vPos + m_vSurfaceNormal; // Test a little closer... uint32 dwNum = g_pLTClient->GetPointContainers(&vTestPos, objList, 1); if (dwNum > 0 && objList[0]) { uint32 dwUserFlags; g_pLTClient->GetObjectUserFlags(objList[0], &dwUserFlags); if (dwUserFlags & USRFLG_VISIBLE) { uint16 dwCode; if (g_pLTClient->GetContainerCode(objList[0], &dwCode)) { m_eCode = (ContainerCode)dwCode; } } } // Determine if the fire point is in liquid vTestPos = m_vFirePos + m_vDir; // Test a little further in... dwNum = g_pLTClient->GetPointContainers(&vTestPos, objList, 1); if (dwNum > 0 && objList[0]) { uint32 dwUserFlags; g_pLTClient->GetObjectUserFlags(objList[0], &dwUserFlags); if (dwUserFlags & USRFLG_VISIBLE) { uint16 dwCode; if (g_pLTClient->GetContainerCode(objList[0], &dwCode)) { m_eFirePosCode = (ContainerCode)dwCode; } } } if (IsLiquid(m_eCode)) { m_wImpactFX = m_pAmmo->pUWImpactFX ? m_pAmmo->pUWImpactFX->nFlags : 0; } else { m_wImpactFX = m_pAmmo->pImpactFX ? m_pAmmo->pImpactFX->nFlags : 0; } m_wFireFX = m_pAmmo->pFireFX ? m_pAmmo->pFireFX->nFlags : 0; // Assume alt-fire, silenced, and tracer...these will be cleared by // IgnoreFX if not used... m_wFireFX |= WFX_ALTFIRESND | WFX_SILENCED | WFX_TRACER; // Assume impact ding, it will be cleared if not used... m_wImpactFX |= WFX_IMPACTDING; // Clear all the fire fx we want to ignore... m_wFireFX &= ~m_wIgnoreFX; m_wImpactFX &= ~m_wIgnoreFX; // See if this is a redundant weapon fx (i.e., this client shot the // weapon so they've already seen this fx)... if (g_pGameClientShell->IsMultiplayerGame()) { if (m_pAmmo->eType != PROJECTILE) { if (!m_bLocal && m_nLocalId >= 0 && m_nLocalId == m_nShooterId) { if (m_wImpactFX & WFX_IMPACTDING) { if (g_vtMultiDing.GetFloat()) { PlayImpactDing(); } } return LTFALSE; } } } // Show the fire path...(debugging...) if (g_cvarShowFirePath.GetFloat() > 0) { PLFXCREATESTRUCT pls; pls.vStartPos = m_vFirePos; pls.vEndPos = m_vPos; pls.vInnerColorStart = LTVector(GetRandom(127.0f, 255.0f), GetRandom(127.0f, 255.0f), GetRandom(127.0f, 255.0f)); pls.vInnerColorEnd = pls.vInnerColorStart; pls.vOuterColorStart = LTVector(0, 0, 0); pls.vOuterColorEnd = LTVector(0, 0, 0); pls.fAlphaStart = 1.0f; pls.fAlphaEnd = 1.0f; pls.fMinWidth = 0; pls.fMaxWidth = 10; pls.fMinDistMult = 1.0f; pls.fMaxDistMult = 1.0f; pls.fLifeTime = 10.0f; pls.fAlphaLifeTime = 10.0f; pls.fPerturb = 0.0f; pls.bAdditive = LTFALSE; pls.nWidthStyle = PLWS_CONSTANT; pls.nNumSegments = 2; CSpecialFX* pFX = g_pGameClientShell->GetSFXMgr()->CreateSFX(SFX_POLYLINE_ID, &pls); if (pFX) pFX->Update(); } // If the surface is the sky, don't create any impact related fx... if (m_eSurfaceType != ST_SKY || (m_wImpactFX & WFX_IMPACTONSKY)) { CreateWeaponSpecificFX(); if (g_bCanSeeImpactPos) { if ((m_wImpactFX & WFX_MARK) && ShowsMark(m_eSurfaceType) && (LTBOOL)GetConsoleInt("MarkShow", 1)) { LTBOOL bCreateMark = LTTRUE; if (g_bDistantImpactPos && m_nLocalId == m_nShooterId) { // Assume we'll see the mark if we're zoomed in ;) bCreateMark = g_pGameClientShell->IsZoomed(); } if (bCreateMark) { CreateMark(m_vPos, m_vSurfaceNormal, m_rSurfaceRot, m_eSurfaceType); } } CreateSurfaceSpecificFX(); } PlayImpactSound(); } if (IsBulletTrailWeapon()) { if (IsLiquid(m_eFirePosCode)) { if (m_nDetailLevel != RS_LOW) { CreateBulletTrail(&m_vFirePos); } } } // No tracers under water... if ((LTBOOL)GetConsoleInt("Tracers", 1) && (m_wFireFX & WFX_TRACER) && !IsLiquid(m_eCode)) { CreateTracer(); } if (g_bCanSeeFirePos) { // Only do muzzle fx for the client (not for AIs)... if ((m_wFireFX & WFX_MUZZLE) && (m_nLocalId == m_nShooterId)) { CreateMuzzleFX(); } if (!g_bDistantFirePos && (LTBOOL)GetConsoleInt("ShellCasings", 1) && (m_wFireFX & WFX_SHELL)) { CreateShell(); } if ((m_wFireFX & WFX_LIGHT)) { CreateMuzzleLight(); } } if ((m_wFireFX & WFX_FIRESOUND) || (m_wFireFX & WFX_ALTFIRESND) || (m_wFireFX & WFX_SILENCED)) { PlayFireSound(); } // Only do fly-by sounds for weapons that leave bullet trails... if (IsBulletTrailWeapon()) { PlayBulletFlyBySound(); } return LTFALSE; // Just delete me, I'm done :) }
LTBOOL CParticleTrailSegmentFX::Update() { if (!m_hObject || !m_pClientDE) return LTFALSE; if (!CBaseParticleSystemFX::Update()) return LTFALSE; CGameSettings* pSettings = g_pInterfaceMgr->GetSettings(); if (!pSettings) return LTFALSE; uint8 nDetailLevel = pSettings->SpecialFXSetting(); LTFLOAT fTime = m_pClientDE->GetTime(); if (m_bFirstUpdate) { if (!m_hServerObject) return LTFALSE; m_bFirstUpdate = LTFALSE; m_fStartTime = fTime; m_fLastTime = fTime; // Where is the server (moving) object... LTVector vPos, vTemp; m_pClientDE->GetObjectPos(m_hServerObject, &vPos); // Current position is relative to the particle system's postion (i.e., // each puff of Particle is some distance away from the particle system's /// position)... m_pClientDE->GetObjectPos(m_hObject, &vTemp); VEC_SUB(vPos, vPos, vTemp); VEC_COPY(m_vLastPos, vPos); } // Check to see if we should just wait for last Particle puff to go away... if (m_bWantRemove || (fTime > m_fStartTime + m_fFadeTime)) { if (fTime > m_fLastTime + m_fLifeTime) { return LTFALSE; } LTFLOAT fScale = (m_fLifeTime - (fTime - m_fLastTime)) / m_fLifeTime; LTFLOAT r, g, b, a; m_pClientDE->GetObjectColor(m_hObject, &r, &g, &b, &a); m_pClientDE->SetObjectColor(m_hObject, r, g, b, fScale); return LTTRUE; } // See if it is time to create a new Particle puff... if ((fTime > m_fLastTime + m_fOffsetTime) && m_hServerObject) { LTVector vCurPos, vPos, vDelta, vTemp, vDriftVel, vColor; // Calculate Particle puff position... // Where is the server (moving) object... m_pClientDE->GetObjectPos(m_hServerObject, &vCurPos); // Current position is relative to the particle system's postion (i.e., // each puff of Particle is some distance away from the particle system's /// position)... m_pClientDE->GetObjectPos(m_hObject, &vTemp); VEC_SUB(vCurPos, vCurPos, vTemp); // How long has it been since the last Particle puff? LTFLOAT fTimeOffset = fTime - m_fLastTime; // What is the range of colors? LTFLOAT fRange = m_vColor2.x - m_vColor1.x; // Fill the distance between the last projectile position, and it's // current position with Particle puffs... int nNumSteps = (m_fLastTime > 0) ? (((m_nType & PT_BLOOD) || (m_nType & PT_GIBSMOKE)) ? 20 : 5): 1; if (nDetailLevel != RS_HIGH) { nNumSteps /= 2; } VEC_SUB(vTemp, vCurPos, m_vLastPos); VEC_MULSCALAR(vDelta, vTemp, 1.0f/float(nNumSteps)); VEC_COPY(vPos, m_vLastPos); LTFLOAT fCurLifeTime = 10.0f; if (nDetailLevel == RS_HIGH) { fCurLifeTime /= 2; } LTFLOAT fLifeTimeOffset = fTimeOffset / float(nNumSteps); LTFLOAT fOffset = 0.5f; int nNumPerPuff = GetNumParticles(m_nNumPerPuff); for (int i=0; i < nNumSteps; i++) { // Build the individual Particle puffs... for (int j=0; j < nNumPerPuff; j++) { VEC_COPY(vTemp, vPos); if (m_bIgnoreWind) { VEC_SET(vDriftVel, GetRandom(-m_vDriftOffset.x*2.0f, -m_vDriftOffset.x), GetRandom(5.0f, 6.0f), GetRandom(-m_vDriftOffset.z, m_vDriftOffset.z)); } else { VEC_SET(vDriftVel, g_vWorldWindVel.x + GetRandom(-m_vDriftOffset.x*2.0f, -m_vDriftOffset.x), g_vWorldWindVel.y + GetRandom(5.0f, 6.0f), g_vWorldWindVel.z + GetRandom(-m_vDriftOffset.z, m_vDriftOffset.z)); } vTemp.x += GetRandom(-fOffset, fOffset); vTemp.y += GetRandom(-fOffset, fOffset); vTemp.z += GetRandom(-fOffset, fOffset); GetRandomColorInRange(vColor); m_pClientDE->AddParticle(m_hObject, &vTemp, &vDriftVel, &vColor, fCurLifeTime); } VEC_ADD(vPos, vPos, vDelta); fCurLifeTime += fLifeTimeOffset; } m_fLastTime = fTime; VEC_COPY(m_vLastPos, vCurPos); } return LTTRUE; }
LTBOOL CPolyGridFX::Update() { if(!m_hObject || !m_pClientDE || !m_hServerObject) return LTFALSE; if(m_bWantRemove) return LTFALSE; // Set the flags of the polygrid based on the the server object... uint32 dwServerFlags; g_pCommonLT->GetObjectFlags(m_hServerObject, OFT_Flags, dwServerFlags); if (dwServerFlags & FLAG_VISIBLE) { g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE); } else // We're hidden, no need to update... { g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, 0, FLAG_VISIBLE); return LTTRUE; } // Don't update if not drawn :) uint32 dwFlags; g_pCommonLT->GetObjectFlags(m_hObject, OFT_Flags, dwFlags); if (!(dwFlags & FLAG_WASDRAWN) && !m_bAlwaysUpdate) { return LTTRUE; } // Update the position of the polygrid to reflect the position of the // server object... LTVector vPos; g_pLTClient->GetObjectPos(m_hServerObject, &vPos); g_pLTClient->SetObjectPos(m_hObject, &vPos); // If we're not using polygrids (or special fx are set to the lowest // detail setting), don't update... if (m_bUseGlobalSettings) { CGameSettings* pSettings = g_pInterfaceMgr->GetSettings(); if (!pSettings) return LTTRUE; uint8 nVal = pSettings->SpecialFXSetting(); LTBOOL bOn = pSettings->PolyGrids(); if (!bOn || nVal == RS_LOW) { return LTTRUE; } } //if we are paused we shouldn't bother updating if(g_pGameClientShell->IsServerPaused()) { g_pLTClient->Common()->SetObjectFlags(m_hObject, OFT_Flags, FLAG_PAUSED, FLAG_PAUSED); return LTTRUE; } else { g_pLTClient->Common()->SetObjectFlags(m_hObject, OFT_Flags, 0, FLAG_PAUSED); } // Update the plasma based on the type of plasma... switch (m_nSurfaceType) { case PGSURFACE_PLASMA_FOUR_RING : UpdateFourRingPlasma(); break; case PGSURFACE_PLASMA_NORMAL: UpdatePlasma(); break; case PGSURFACE_WAVE_PROP: UpdateWaveProp(g_pGameClientShell->GetFrameTime()); break; default : //default surface... UpdatePlasma(); break; } if( m_sSurfaceSprite.size( )) { UpdateSurface(); } return LTTRUE; }
LTBOOL CProjectileFX::CreateObject(ILTClient* pClientDE) { if (!CSpecialFX::CreateObject(pClientDE) || !m_hServerObject) return LTFALSE; CGameSettings* pSettings = g_pInterfaceMgr->GetSettings(); if (!pSettings) return LTFALSE; uint8 nDetailLevel = pSettings->SpecialFXSetting(); LTVector vPos; LTRotation rRot; m_pClientDE->GetObjectPos(m_hServerObject, &vPos); m_pClientDE->GetObjectRotation(m_hServerObject, &rRot); if (nDetailLevel != RS_LOW) { if (m_nFX & PFX_SMOKETRAIL) { CreateSmokeTrail(vPos, rRot); } if (m_nFX & PFX_LIGHT) { CreateLight(vPos, rRot); } } if (m_nFX & PFX_FLARE) { CreateFlare(vPos, rRot); } if (m_nFX & PFX_FLYSOUND) { CreateFlyingSound(vPos, rRot); } // Do client-side projectiles in multiplayer games... if (g_pGameClientShell->IsMultiplayerGame()) { // Set the velocity of the "server" object if it is really just a local // object... if (m_bLocal) { VEC_COPY(m_vFirePos, vPos); m_fStartTime = m_pClientDE->GetTime(); LTVector vVel, vU, vR, vF; m_pClientDE->GetRotationVectors(&rRot, &vU, &vR, &vF); VEC_COPY(m_vPath, vF); // Special case of adjusting the projectile speed... LTFLOAT fVel = (LTFLOAT) m_pProjectileFX->nVelocity; if (m_bAltFire) { fVel = (LTFLOAT) m_pProjectileFX->nAltVelocity; } LTFLOAT fMultiplier = 1.0f; if (m_pClientDE->GetSConValueFloat("MissileSpeed", fMultiplier) != LT_NOTFOUND) { fVel *= fMultiplier; } VEC_MULSCALAR(vVel, vF, fVel); m_pClientDE->Physics()->SetVelocity(m_hServerObject, &vVel); } } return LTTRUE; }