Exemplo n.º 1
0
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;
}
LTBOOL CMuzzleFlashFX::Update()
{
    if (!m_pClientDE || m_bHidden) return LTFALSE;

	// If we we're not a player-view muzzle fx,  If our
	// server object has been removed, we should go away...

    if (!m_cs.bPlayerView && !m_hServerObject) return LTFALSE;

	// Set/Clear the FLAG_REALLYCLOSE

	if (m_bUsingParticles && m_Particle.GetObject())
	{
		uint32 dwFlags = m_pClientDE->GetObjectFlags(m_Particle.GetObject());

		if (m_cs.bPlayerView)
		{
			if (g_vtReallyClose.GetFloat())
			{
				m_pClientDE->SetObjectFlags(m_Particle.GetObject(), dwFlags | FLAG_REALLYCLOSE);
			}
			else
			{
				m_pClientDE->SetObjectFlags(m_Particle.GetObject(), dwFlags & ~FLAG_REALLYCLOSE);
			}
		}
		else
		{
			m_pClientDE->SetObjectFlags(m_Particle.GetObject(), dwFlags & ~FLAG_REALLYCLOSE);
		}
	}

	if (m_bUsingScale && m_Scale.GetObject())
	{
		uint32 dwFlags = m_pClientDE->GetObjectFlags(m_Scale.GetObject());

		if (m_cs.bPlayerView)
		{
			m_pClientDE->SetObjectFlags(m_Scale.GetObject(), dwFlags | FLAG_REALLYCLOSE);
		}
		else
		{
			m_pClientDE->SetObjectFlags(m_Scale.GetObject(), dwFlags & ~FLAG_REALLYCLOSE);
		}
	}


	// Update all the fx, and see if we're done...

    LTBOOL bParticleDone = m_bUsingParticles ? !m_Particle.Update()  : LTTRUE;
    LTBOOL bLightDone    = m_bUsingLight     ? !m_Light.Update()     : LTTRUE;
    LTBOOL bScaleDone    = m_bUsingScale     ? !m_Scale.Update()     : LTTRUE;


	// Keep the objects in the correct place...

	if (!m_cs.bPlayerView && m_cs.hParent)
	{
		HOBJECT hObj;
        LTRotation rRot;
        LTVector vPos;

		GetAttachmentSocketTransform(m_cs.hParent, "Flash", vPos, rRot);

		if (m_bUsingScale)
		{
			hObj = m_Scale.GetObject();
			if (hObj)
			{
                m_pClientDE->SetObjectPos(hObj, &vPos);
                m_pClientDE->SetObjectRotation(hObj, &rRot);
			}
		}

		if (m_bUsingParticles)
		{
			hObj = m_Particle.GetObject();
			if (hObj)
			{
                m_pClientDE->SetObjectPos(hObj, &vPos);
                m_pClientDE->SetObjectRotation(hObj, &rRot);
			}
		}

		if (m_bUsingLight)
		{
			hObj = m_Light.GetObject();
			if (hObj)
			{
                m_pClientDE->SetObjectPos(hObj, &vPos);
			}
		}
	}

	return !(bParticleDone && bLightDone && bScaleDone);
}
Exemplo n.º 3
0
LTBOOL CShellCasingFX::Init(SFXCREATESTRUCT* psfxCreateStruct)
{
    if (!psfxCreateStruct) return LTFALSE;

	CSpecialFX::Init(psfxCreateStruct);

	SHELLCREATESTRUCT* pShell = (SHELLCREATESTRUCT*)psfxCreateStruct;

    m_rRot = pShell->rRot;
	m_vStartPos = pShell->vStartPos;
	m_nWeaponId = pShell->nWeaponId;
	m_nAmmoId = pShell->nAmmoId;
	m_dwFlags |= pShell->dwFlags;
	m_vStartVel = pShell->vStartVel;
	m_b3rdPerson = pShell->b3rdPerson;

	m_vInitialScale.Init(1.0f, 1.0f, 1.0f);
	m_vFinalScale.Init(1.0f, 1.0f, 1.0f);

	if (!g_vtShellMaxBounceCountTrack.IsInitted())
	{
		g_vtShellMaxBounceCountTrack.Init(g_pLTClient, "ShellMaxBounceCount", NULL, 3.0);
	}
	if (!g_vtShellMinUpVelocity.IsInitted())
	{
		g_vtShellMinUpVelocity.Init(g_pLTClient, "ShellMinUpVelocity", NULL, 30.0f);
	}
	if (!g_vtShellMaxUpVelocity.IsInitted())
	{
		g_vtShellMaxUpVelocity.Init(g_pLTClient, "ShellMaxUpVelocity", NULL, 75.0f);
	}
	if (!g_vtShellMinRightVelocity.IsInitted())
	{
		g_vtShellMinRightVelocity.Init(g_pLTClient, "ShellMinRightVelocity", NULL, 50.0f);
	}
	if (!g_vtShellMaxRightVelocity.IsInitted())
	{
		g_vtShellMaxRightVelocity.Init(g_pLTClient, "ShellMaxRightVelocity", NULL, 75.0f);
	}
	if (!g_vtShellMinForwardVelocity.IsInitted())
	{
		g_vtShellMinForwardVelocity.Init(g_pLTClient, "ShellMinForwardVelocity", NULL, 20.0f);
	}
	if (!g_vtShellMaxForwardVelocity.IsInitted())
	{
		g_vtShellMaxForwardVelocity.Init(g_pLTClient, "ShellMaxForwardVelocity", NULL, 50.0f);
	}
	if (!g_vtShellMinLifetime.IsInitted())
	{
		g_vtShellMinLifetime.Init(g_pLTClient, "ShellMinLifetime", NULL, 10.0f);
	}
	if (!g_vtShellMaxLifetime.IsInitted())
	{
		g_vtShellMaxLifetime.Init(g_pLTClient, "ShellMaxLifetime", NULL, 15.0f);
	}
	if (!g_vtShellScaleTime.IsInitted())
	{
		g_vtShellScaleTime.Init(g_pLTClient, "ShellScaleTime", NULL, 0.5f);
	}
	if (!g_vtShellMaxScale.IsInitted())
	{
		g_vtShellMaxScale.Init(g_pLTClient, "ShellMaxScale", NULL, 2.0f);
	}
	if (!g_vtShellMinSpinsPerSecond.IsInitted())
	{
		g_vtShellMinSpinsPerSecond.Init(g_pLTClient, "ShellMinSpinsPerSecond", NULL, 2.0f);
	}
	if (!g_vtShellMaxSpinsPerSecond.IsInitted())
	{
		g_vtShellMaxSpinsPerSecond.Init(g_pLTClient, "ShellMaxSpinsPerSecond", NULL, 10.0f);
	}

	m_nBounceCount = (int)g_vtShellMaxBounceCountTrack.GetFloat();

    return LTTRUE;
}
Exemplo n.º 4
0
void CHeadBobMgr::UpdateHeadBob()
{
	if (g_pGameClientShell->IsGamePaused()) return;

	CMoveMgr* pMoveMgr = g_pGameClientShell->GetMoveMgr();
	if (!pMoveMgr) return;

    LTBOOL bZoomed = g_pGameClientShell->IsZoomed();

    uint32 dwPlayerFlags = g_pGameClientShell->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->GetVelMagnitude() * 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...
	CWeaponModel* pWeaponModel = g_pGameClientShell->GetWeaponModel();
	if (pWeaponModel && !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();

		pWeaponModel->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_pGameClientShell->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);
		}
	}
}
Exemplo n.º 5
0
void CHeadBobMgr::UpdateHeadCant()
{
	CMoveMgr* pMoveMgr = g_pGameClientShell->GetMoveMgr();
	if (!pMoveMgr) return;

	CVehicleMgr* pVehicleMgr = pMoveMgr->GetVehicleMgr();
	if (!pVehicleMgr) return;

	LTBOOL bVehicleTurning	= pVehicleMgr->IsTurning();
	int    nVehicleTurnDir	= pVehicleMgr->GetTurnDirection();

	CantType eCantType = eCantNone;
	LTFLOAT fMaxCant = 0.0f, fCantRate = 0.0f;

	if (bVehicleTurning)
	{
		eCantType = nVehicleTurnDir > 0 ? eCantRight : eCantLeft;
	}


	fMaxCant = DEG2RAD(g_vtMaxVehicleHeadCant.GetFloat());
	LTFLOAT fMinCant = fMaxCant * 0.25f;

	LTFLOAT fRoll = g_pGameClientShell->GetRoll();

	switch (eCantType)
	{
		case eCantRight :
		{
			if (fRoll > 0.0)
			{
				fCantRate = g_vtVehicleHeadCantDownRate.GetFloat();
			}
			else
			{
				fCantRate = g_vtVehicleHeadCantUpRate.GetFloat();
			}
		}
		break;
		case eCantLeft :
		{
			if (fRoll < 0.0)
			{
				fCantRate = g_vtVehicleHeadCantDownRate.GetFloat();
			}
			else
			{
				fCantRate = g_vtVehicleHeadCantUpRate.GetFloat();
			}
		}
		break;
		case eCantNone:
		{
			fCantRate = g_vtVehicleHeadCantDownRate.GetFloat();
		}
		break;

		default :
		break;
	}

	if (fabs(fRoll) < fMinCant)
	{
		fCantRate *= 0.5f;
	}

	// This frame time is used since unlike ClientDE::GetFrameTime() the
	// max value is controlled by the game...

	LTFLOAT fFrameTime = g_pGameClientShell->GetFrameTime();

	LTFLOAT fDelta = fCantRate * fFrameTime;

	switch (eCantType)
	{
		case eCantRight :
		{
			fRoll -= fDelta;

			if (fRoll < -fMaxCant)
			{
				fRoll = -fMaxCant;
			}
		}
		break;

		case eCantLeft :
		{
			fRoll += fDelta;

			if (fRoll > fMaxCant)
			{
				fRoll = fMaxCant;
			}
		}
		break;

		case eCantNone:
		default :
		{
			// We are not canting so move us toward zero...

			if (fRoll != 0.0f)
			{
				if (fRoll < 0.0f)
				{
					fRoll += fDelta;

					if (fRoll > 0.0f)
					{
						fRoll = 0.0f;
					}
				}
				else
				{
					fRoll -= fDelta;

					if (fRoll < 0.0f)
					{
						fRoll = 0.0f;
					}
				}
 			}
		}
		break;
	}

	// Let the vehicle mgr adjust the value...

	pVehicleMgr->AdjustCameraRoll(fRoll);

	// Set the new value...

	g_pGameClientShell->SetRoll(fRoll);
}
Exemplo n.º 6
0
void CCharacterHitBox::Update()
{
	AIASSERT( m_pHitBoxUser, m_hObject, "Called with NULL HitBoxUser" );
	AIASSERT( m_hModel, m_hObject, "Called with NULL m_hModel" );
	AIASSERT( m_hObject, m_hObject, "Called with NULL m_hObject" );
	if (!m_hModel || !m_hObject)
	{
		return;
	}

	// Position to move to...
	LTVector vPos;
	bool bUpdateClient = false;

	// KLS 1/23/04 - Follow the visibility node on our model if specified...

	if (m_bFollowVisNode)
	{
		// Get the model's vis node...
		
		HMODELNODE hNode;
		if ( LT_OK == g_pModelLT->GetPhysicsVisNode(m_hModel, hNode) )
		{
			LTTransform tf;

			if ( LT_OK == g_pModelLT->GetNodeTransform(m_hModel, hNode, tf, true) )
			{
				vPos = tf.m_vPos;
	
				// KLS 5/3/04 - If we're following the model's vis node, we want to move
				// the model to follow us...

				LTVector vModelPos;
				g_pLTServer->GetObjectPos(m_hModel, &vModelPos);

				if (vPos.DistSqr(vModelPos) > 0.1f)
				{
					g_pLTServer->SetObjectPos(m_hModel, vPos);
				}
			}
		}
	}
	else  // Use the model's position...
	{
		// Get current model position...
		g_pLTServer->GetObjectPos(m_hModel, &vPos);

		// Make sure the hit box offset is relative to the model...
		
		LTRotation rRot;
		g_pLTServer->GetObjectRotation( m_hModel, &rRot );
		vPos += (rRot * m_vOffset);
	}

	// Get the hitbox's position...
	LTVector vMyPos;
	g_pLTServer->GetObjectPos(m_hObject, &vMyPos);


	// Only move the hitbox if it isn't close to the target position...

	if (vPos.DistSqr(vMyPos) > 0.1)
	{
		bUpdateClient = true;
		g_pLTServer->SetObjectPos(m_hObject, vPos);
 	}

	if( (m_bAnimControlsDims || m_bAnimControlsOffset) && (m_hControllingAnim != INVALID_ANI) )
	{
		HMODELANIM hCurAnim = INVALID_ANI;
		if( LT_OK == g_pModelLT->GetCurAnim( m_hModel, MAIN_TRACKER, hCurAnim ))
		{
			if( hCurAnim != m_hControllingAnim )
			{
				// We changed animations from our controlling anim so default our dims and offset...

				// Set offset first since SetDimsToModel() will update the client
				SetOffset( LTVector(0,0,0) );
				SetDimsToModel();

				// The animation is no longer controlling us...

				m_bAnimControlsDims = m_bAnimControlsOffset = false;
				m_hControllingAnim = INVALID_ANI;
			}	
		}
	}
	
	// Make sure the hit box is at least at the minimum dims...

	LTVector vDims;
	g_pPhysicsLT->GetObjectDims( m_hObject, &vDims );

	if( vDims.x < HB_DIMS_MIN_XZ ||
		vDims.z < HB_DIMS_MIN_XZ )
	{
		vDims.x = vDims.z = HB_DIMS_MIN_XZ;
		g_pPhysicsLT->SetObjectDims( m_hObject, &vDims, 0 );
		bUpdateClient = true;

	}

	if( vDims.y < HB_DIMS_MIN_Y	)
	{
		vDims.y = HB_DIMS_MIN_Y;
		g_pPhysicsLT->SetObjectDims( m_hObject, &vDims, 0 );
		bUpdateClient = true;

	}

	if (bUpdateClient)
	{
		m_pHitBoxUser->UpdateClientHitBox();
	}

	// See if we should show our model node radii...

#ifndef _FINAL
	float fShowNodeRadii = (g_vtShowNodeRadii.GetFloat() ? (IsPlayer(m_hModel) ? g_vtShowPlayerNodeRadii.GetFloat() : 1.0f) : 0.0f);
	if (fShowNodeRadii)
	{
		UpdateNodeRadiusModels();
	}
	else
	{
		RemoveNodeRadiusModels();
	}
#endif
}
Exemplo n.º 7
0
void CPolyGridFX::CreateModelWaves(uint32 nKernalSize, uint32 nBuffer, float fFrameTime)
{
	//maximum number of objects to find intersecting the grid
	static const uint32 knMaxObjToFind = 32;

	//find the radius of our polygrid
	float fPolyRad = m_vDims.Mag();

	//amount to displace for a model
	float fDisplaceAmount = m_fModelDisplace * fFrameTime;

	//just bail if the models aren't going to displace at all
	if(fDisplaceAmount < 0.01f)
		return;

	HLOCALOBJ hFound[knMaxObjToFind];
	uint32 nFound = 0;

	LTVector vPGPos;
	m_pClientDE->GetObjectPos(m_hObject, &vPGPos);

	LTVector vPGDims;
	m_pClientDE->Physics()->GetObjectDims(m_hObject, &vPGDims);

	//now run through all the characters and see which ones intersect
	CSpecialFXList* pCharacterList = g_pGameClientShell->GetSFXMgr()->GetFXList(SFX_CHARACTER_ID);

	LTVector vPGMin = vPGPos - vPGDims;
	LTVector vPGMax = vPGPos + vPGDims;

	for(uint32 nCurrChar = 0; nCurrChar < (uint32)pCharacterList->GetNumItems(); nCurrChar++)
	{
		if(!(*pCharacterList)[nCurrChar])
			continue;

		//determine the HOBJECT of this character
		HOBJECT hChar = (*pCharacterList)[nCurrChar]->GetServerObj();

		if(!hChar)
			continue;

		//get the object position and dimensions
		LTVector vCharPos, vCharDims;
		m_pClientDE->GetObjectPos(hChar, &vCharPos);
		m_pClientDE->Physics()->GetObjectDims(hChar, &vCharDims);

		LTVector vCharMin = vCharPos - vCharDims;
		LTVector vCharMax = vCharPos + vCharDims;

		//if it overlaps, add it to our list
		if( (vPGMin.x < vCharMax.x) && (vPGMax.x > vCharMin.x) &&
			(vPGMin.y < vCharMax.y) && (vPGMax.y > vCharMin.y) &&
			(vPGMin.z < vCharMax.z) && (vPGMax.z > vCharMin.z))
		{
			//they intersect, add it to the list
			hFound[nFound] = hChar;
			nFound++;

			//see if we need to stop looking for objects
			if(nFound >= knMaxObjToFind)
				break;
		}
	}

	//bail if none
	if(nFound == 0)
	{
		//make sure all objects are cleared from the list
		for(uint32 nCurrRemove = 0; nCurrRemove < MAX_MODELS_TO_TRACK; nCurrRemove++)
		{
			m_hTrackedModels[nCurrRemove] = NULL;
		}
		return;
	}

	//precalc info

	//find the orienation of the polygrid
	LTRotation rRot;
	m_pClientDE->GetObjectRotation(m_hObject, &rRot);

	//now get the basis vectors of the object space
	LTVector vRight		= rRot.Right();
	LTVector vForward	= rRot.Forward();

	//make sure the polygrid is valid
	if((m_dwNumPoliesX == 0) || (m_dwNumPoliesY == 0))
		return;

	//find the dimensions of the polygons of the polygrid
	float fXPolySize = (m_vDims.x * 2.0f) / (float)m_dwNumPoliesX;
	float fYPolySize = (m_vDims.z * 2.0f) / (float)m_dwNumPoliesY;

	//bail if not a valid size
	if((fXPolySize < 0.01f) || (fYPolySize < 0.01f))
		return;

	//flag indicating which tracked models should be kept around
	bool bTouchedTrackedModels[MAX_MODELS_TO_TRACK];

	for(uint32 nCurrTrack = 0; nCurrTrack < MAX_MODELS_TO_TRACK; nCurrTrack++)
	{
		bTouchedTrackedModels[nCurrTrack] = false;
	}

	//ok, now we run through all the objects we found and update our grid accordingly
	for(uint32 nCurrObj = 0; nCurrObj < nFound; nCurrObj++)
	{
		//the object we are checking
		HLOCALOBJ hObj = hFound[nCurrObj];

		//now lets see if this is a tracked model, if it is, we know where it was last
		//update and we can create a wave line, otherwise we have no clue, and should
		//track it for the next update
		bool bTracked = false;
		LTVector vPrevPos;

		LTVector vPos;
		m_pClientDE->GetObjectPos(hObj, &vPos);

		//if we aren't currently tracking it, this is where to put it
		uint32 nInsertPos = MAX_MODELS_TO_TRACK - 1;

		for(uint32 nCurrModel = 0; nCurrModel < MAX_MODELS_TO_TRACK; nCurrModel++)
		{
			if(m_hTrackedModels[nCurrModel] == hObj)
			{
				//we found a match, we need to save this value, move
				//it to the front of the list, and update it
				vPrevPos = m_vTrackedModelsPos[nCurrModel];

				//move all the items back so that this will be in the first slot
				for(uint32 nCurrMove = nCurrModel; nCurrMove > 0; nCurrMove--)
				{
					m_hTrackedModels[nCurrMove] = m_hTrackedModels[nCurrMove - 1];
					m_vTrackedModelsPos[nCurrMove] = m_vTrackedModelsPos[nCurrMove - 1];
					bTouchedTrackedModels[nCurrMove] = bTouchedTrackedModels[nCurrMove - 1];
				}

				//update the first element
				m_hTrackedModels[0] = hObj;
				m_vTrackedModelsPos[0] = vPos;
				bTouchedTrackedModels[0] = true;

				//all done
				bTracked = true;
				break;
			}

			//also bail if one of the slots is NULL
			if(m_hTrackedModels[nCurrModel] == NULL)
			{
				nInsertPos = nCurrModel;
			}
		}

		//see if this was tracked or not
		if(!bTracked)
		{
			//was not! We need to add it to the list
			m_hTrackedModels[nInsertPos] = hObj;
			m_vTrackedModelsPos[nInsertPos] = vPos;
			bTouchedTrackedModels[nInsertPos] = true;

			continue;
		}

		//make sure that the model is actually moving
		if((vPrevPos - vPos).MagSqr() < 0.5f)
			continue;

		//ok, we have a model that intersects our polygrid, let us create some waves

		//find out the endpoints of the line that will displace
		float fX1 = vRight.Dot(vPrevPos - vPGPos) + m_vDims.x;
		float fY1 = vForward.Dot(vPrevPos - vPGPos) + m_vDims.z;
		float fX2 = vRight.Dot(vPos - vPGPos) + m_vDims.x;
		float fY2 = vForward.Dot(vPos - vPGPos) + m_vDims.z;

		//now find the greater delta in polygon units
		float fXDelta = (float)fabs(fX1 - fX2) / fXPolySize;
		float fYDelta = (float)fabs(fY1 - fY2) / fYPolySize;

		//increments for the X and Y directions
		float fXInc, fYInc;
		float fCurrX, fCurrY;

		//the variable to use for threshold comparisons
		float *pfCompare;

		//the threshold
		float fThreshold;

		//now scan convert accordingly
		if(fYDelta > fXDelta)
		{
			//make sure Y1 is smaller
			if(fY2 < fY1)
			{
				Swap(fY1, fY2);
				Swap(fX1, fX2);
			}

			fYInc = fYPolySize;
			fXInc = (fX2 - fX1) / (fY2 - fY1) * fYInc;

			fThreshold = fY2 / fYPolySize;
			pfCompare = &fCurrY;
		}
		else
		{
			//make sure Y1 is smaller
			if(fX2 < fX1)
			{
				Swap(fY1, fY2);
				Swap(fX1, fX2);
			}
			fXInc = fXPolySize;
			fYInc = (fY2 - fY1) / (fX2 - fX1) * fXInc;

			fThreshold = fX2 / fXPolySize;
			pfCompare = &fCurrX;
		}

		//start out at the first point
		fCurrY = fY1 / fYPolySize;
		fCurrX = fX1 / fXPolySize;
		fXInc /= fXPolySize;
		fYInc /= fXPolySize;

		float fXFrac;
		float fYFrac;

		uint32 nPrevBuffer = (nBuffer + 1) % 2;

		//we need to scale the displacement amount by the speed at which we are moving
		fDisplaceAmount *= (vPrevPos - vPos).Mag() / (fFrameTime * g_cvarPGDisplaceMoveScale.GetFloat());

		//now scan convert!
		while(*pfCompare < fThreshold)
		{
			//convert this to an integer position
			int32 nXPos = (int32)(fCurrX);
			int32 nYPos = (int32)(fCurrY);

			//handle clipping
			if((nXPos >= (int32)nKernalSize) && (nYPos >= (int32)nKernalSize) &&
				(nXPos < (int32)m_dwNumPoliesX - (int32)nKernalSize - 1) &&
				(nYPos < (int32)m_dwNumPoliesY - (int32)nKernalSize - 1))
			{
				fXFrac = fCurrX - nXPos;
				fYFrac = fCurrY - nYPos;

				m_WaveBuffer[nBuffer].Get(nXPos, nYPos)  += fDisplaceAmount * (1.0f - fXFrac) * (1.0f - fYFrac);
				m_WaveBuffer[nBuffer].Get(nXPos + 1, nYPos) += fDisplaceAmount * fXFrac * (1.0f - fYFrac);
				m_WaveBuffer[nBuffer].Get(nXPos, nYPos + 1) += fDisplaceAmount * (1.0f - fXFrac) * fYFrac;
				m_WaveBuffer[nBuffer].Get(nXPos + 1, nYPos + 1) += fDisplaceAmount * fXFrac * fYFrac;
				
				m_WaveBuffer[nPrevBuffer].Get(nXPos, nYPos)  += fDisplaceAmount * (1.0f - fXFrac) * (1.0f - fYFrac);
				m_WaveBuffer[nPrevBuffer].Get(nXPos + 1, nYPos) += fDisplaceAmount * fXFrac * (1.0f - fYFrac);
				m_WaveBuffer[nPrevBuffer].Get(nXPos, nYPos + 1) += fDisplaceAmount * (1.0f - fXFrac) * fYFrac;
				m_WaveBuffer[nPrevBuffer].Get(nXPos + 1, nYPos + 1) += fDisplaceAmount * fXFrac * fYFrac;
			}

			//move along
			fCurrX += fXInc;
			fCurrY += fYInc;
		}
	}

	//now that we are done, clear out any models that were not touched
	for(uint32 nCurrRemove = 0; nCurrRemove < MAX_MODELS_TO_TRACK; nCurrRemove++)
	{
		if(!bTouchedTrackedModels[nCurrRemove])
			m_hTrackedModels[nCurrRemove] = NULL;
	}
}
Exemplo n.º 8
0
	// Get the appropriate material for rendering slices given shadow and noise settings
	HMATERIAL GetSliceMaterial(bool bShadow, bool bNoise, bool bDirectional)
	{
		bShadow &= (g_cvarVolumetricLightShadow.GetFloat() != 0.0f);
		bNoise &= (g_cvarVolumetricLightNoise.GetFloat() != 0.0f);
		return m_aSliceMaterials[(bShadow ? 1 : 0) | (bNoise ? 2 : 0) | (bDirectional ? 4 : 0)];
	}
Exemplo n.º 9
0
LTBOOL CParticleSystemFX::Update()
{
    if (!m_hObject || !m_pClientDE || m_bWantRemove) return LTFALSE;

    LTFLOAT fTime = m_pClientDE->GetTime();

	// Hide/show the particle system if necessary...

	if (m_hServerObject)
	{
        uint32 dwUserFlags;
		g_pCommonLT->GetObjectFlags(m_hServerObject, OFT_User, dwUserFlags);

		if (!(dwUserFlags & USRFLG_VISIBLE))
		{
			uint32 dwFlags;
			g_pCommonLT->GetObjectFlags(m_hObject, OFT_Flags, dwFlags);

			// Once last puff as disappeared, hide the system (no new puffs
			// will be added...)

			if (dwFlags & FLAG_VISIBLE)
			{
				if (fTime > m_fLastTime + m_cs.fParticleLifetime)
				{
					g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, 0, FLAG_VISIBLE);
				}
			}
			else
			{
				m_fLastTime = fTime;
			}

            return LTTRUE;
		}
		else
		{
			g_pCommonLT->SetObjectFlags(m_hObject, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE);
		}
	}

	// Debugging aid...

	if (s_cvarTweak.GetFloat() > 0)
	{
		TweakSystem();
	}


	if (m_bFirstUpdate)
	{
		m_fLastTime = fTime;
        m_bFirstUpdate = LTFALSE;
	}


	// Make sure it is time to update...

	if (fTime < m_fLastTime + m_fNextUpdate)
	{
        return LTTRUE;
	}


	// Ok, how many to add this frame....(make sure time delta is no more than
	// 15 frames/sec...

	float fTimeDelta = fTime - m_fLastTime;
	fTimeDelta = fTimeDelta > 0.0666f ? 0.0666f : fTimeDelta;
	int nToAdd = (int) floor(m_cs.fParticlesPerSecond * fTimeDelta);
    nToAdd = LTMIN(nToAdd, (int)(MAX_PARTICLES_PER_SECOND * fTimeDelta));

	nToAdd = GetNumParticles(nToAdd);

	m_pClientDE->AddParticles(m_hObject, nToAdd,
		&m_vMinOffset, &m_vMaxOffset,			// Position offset
		&(m_cs.vMinVel), &(m_cs.vMaxVel),		// Velocity
		&(m_cs.vColor1), &(m_cs.vColor2),		// Color
		m_cs.fParticleLifetime, m_cs.fParticleLifetime);


	// Determine when next update should occur...

	if (m_cs.fBurstWait > 0.001f)
	{
		m_fNextUpdate = m_cs.fBurstWait * GetRandom(m_cs.fBurstWaitMin, m_cs.fBurstWaitMax);
	}
	else
	{
		m_fNextUpdate = 0.001f;
	}


	// Rotate the particle system...

	if (m_cs.fRotationVelocity != 0.0f)
	{
        LTRotation rRot;
		g_pLTClient->GetObjectRotation(m_hObject, &rRot);
		rRot.Rotate(rRot.Up(), g_pGameClientShell->GetFrameTime() * m_cs.fRotationVelocity);
		g_pLTClient->SetObjectRotation(m_hObject, &rRot);
	}

	m_fLastTime = fTime;

    return LTTRUE;
}
Exemplo n.º 10
0
LTBOOL CParticleTrailFX::Init(SFXCREATESTRUCT* psfxCreateStruct)
{
    if (!CSpecialFX::Init(psfxCreateStruct)) return LTFALSE;

	PTCREATESTRUCT* pST = (PTCREATESTRUCT*)psfxCreateStruct;
	m_nType  = pST->nType;

    g_cvarSmokeTrailNumPerPuff.Init(g_pLTClient, "SmokeTrailNumPerPuff", LTNULL, 1.0f);
    g_cvarSmokeTrailColor1R.Init(g_pLTClient, "SmokeTrailColor1R", LTNULL, 150.0f);
    g_cvarSmokeTrailColor1G.Init(g_pLTClient, "SmokeTrailColor1G", LTNULL, 150.0f);
    g_cvarSmokeTrailColor1B.Init(g_pLTClient, "SmokeTrailColor1B", LTNULL, 150.0f);
    g_cvarSmokeTrailColor2R.Init(g_pLTClient, "SmokeTrailColor2R", LTNULL, 230.0f);
    g_cvarSmokeTrailColor2G.Init(g_pLTClient, "SmokeTrailColor2G", LTNULL, 230.0f);
    g_cvarSmokeTrailColor2B.Init(g_pLTClient, "SmokeTrailColor2B", LTNULL, 230.0f);
    g_cvarSmokeTrailLifetime.Init(g_pLTClient, "SmokeTrailLifetime", LTNULL, 1.5f);
    g_cvarSmokeTrailLWFadetime.Init(g_pLTClient, "SmokeTrailLWFadetime", LTNULL, 0.2f);
    g_cvarSmokeTrailSWFadetime.Init(g_pLTClient, "SmokeTrailSWFadetime", LTNULL, 0.2f);
    g_cvarSmokeTrailSBFadetime.Init(g_pLTClient, "SmokeTrailSBFadetime", LTNULL, 0.3f);
    g_cvarSmokeTrailSegtime.Init(g_pLTClient, "SmokeTrailSegtime", LTNULL, 0.1f);
    g_cvarSmokeTrailDriftOffsetX.Init(g_pLTClient, "SmokeTrailDriftOffsetX", LTNULL, 0.0f);
    g_cvarSmokeTrailDriftOffsetY.Init(g_pLTClient, "SmokeTrailDriftOffsetY", LTNULL, 20.0f);
    g_cvarSmokeTrailDriftOffsetZ.Init(g_pLTClient, "SmokeTrailDriftOffsetZ", LTNULL, 5.0f);
    g_cvarSmokeTrailParticleRadius.Init(g_pLTClient, "SmokeTrailParticleRadius", LTNULL, 2000.0f);

	if (m_nType & PT_BLOOD)
	{
		m_vDriftOffset.Init(60.0f, 60.0f, 60.0f);

		m_nNumPerPuff	= 1;
		m_vColor1.Init(150.0f, 150.0f, 150.0f);
		m_vColor2.Init(200.0f, 200.0f, 200.0f);

		m_fLifeTime		= 0.3f;
		m_fFadeTime		= 0.25f;

		m_fSegmentTime  = 0.1f;
	}
	else if (m_nType & PT_GIBSMOKE)
	{
		m_vDriftOffset.Init(60.0f, 60.0f, 60.0f);

		m_nNumPerPuff	= 1;
		m_vColor1.Init(100.0f, 100.0f, 100.0f);
		m_vColor2.Init(125.0f, 125.0f, 125.0f);

		m_fLifeTime		= 0.75f;
		m_fFadeTime		= 0.25f;

		m_fSegmentTime  = 0.1f;
	}
	else if ((m_nType & PT_SMOKE) || (m_nType & PT_SMOKE_LONG) || (m_nType & PT_SMOKE_BLACK))
	{
		m_vDriftOffset.Init(
			g_cvarSmokeTrailDriftOffsetX.GetFloat(),
			g_cvarSmokeTrailDriftOffsetY.GetFloat(),
			g_cvarSmokeTrailDriftOffsetZ.GetFloat());

		m_nNumPerPuff = (int)g_cvarSmokeTrailNumPerPuff.GetFloat();

		m_vColor1.Init(
			g_cvarSmokeTrailColor1R.GetFloat(),
			g_cvarSmokeTrailColor1G.GetFloat(),
			g_cvarSmokeTrailColor1B.GetFloat());

		m_vColor2.Init(
			g_cvarSmokeTrailColor2R.GetFloat(),
			g_cvarSmokeTrailColor2G.GetFloat(),
			g_cvarSmokeTrailColor2B.GetFloat());

		m_fLifeTime	= g_cvarSmokeTrailLifetime.GetFloat();
		if ((m_nType & PT_SMOKE) || (m_nType & PT_SMOKE_BLACK))
		{
			m_fLifeTime /= 2.0f; 
		}
	
		if (m_nType & PT_SMOKE)
		{
			m_fFadeTime	= g_cvarSmokeTrailSWFadetime.GetFloat();
		}
		else if (m_nType & PT_SMOKE_LONG)
		{
			m_fFadeTime	= g_cvarSmokeTrailLWFadetime.GetFloat();
		}
		else // Short black
		{
			m_fFadeTime	= g_cvarSmokeTrailSBFadetime.GetFloat();
		}

		m_fSegmentTime = g_cvarSmokeTrailSegtime.GetFloat();
	}

    return LTTRUE;
}
Exemplo n.º 11
0
	// Lock a set of render targets, and associate with a token for later release
	bool LockRenderTarget(uint32 nToken, HRENDERTARGET *pShadowBuffer, HRENDERTARGET *pSliceBuffer)
	{
		// Reset our render target list if our resolution has changed
		if ((m_nCurSliceRes != (uint32)g_cvarVolumetricLightSliceRes.GetFloat()) || 
			(m_nCurShadowRes != (uint32)g_cvarVolumetricLightShadowRes.GetFloat()) || 
			(m_bShadowsEnabled != (g_cvarVolumetricLightShadow.GetFloat() != 0.0f)) || 
			(m_bFloatBuffersEnabled != (g_cvarVolumetricLightFloat.GetFloat() != 0.0f)))
		{
			m_nCurSliceRes = (uint32)g_cvarVolumetricLightSliceRes.GetFloat();
			m_nCurShadowRes = (uint32)g_cvarVolumetricLightShadowRes.GetFloat();
			m_bShadowsEnabled = (g_cvarVolumetricLightShadow.GetFloat() != 0);
			m_bFloatBuffersEnabled = (g_cvarVolumetricLightFloat.GetFloat() != 0);
			FlushRenderTargets();
		}

		// Allocate a new target if necessary
		if (m_aFreeList.empty())
		{
			// Add null buffers to the free list			
			m_aFreeList.push_back(m_aShadowBuffers.size());		
			m_aShadowBuffers.push_back(NULL);
			m_aSliceBuffers.push_back(NULL);
			m_aLockTokens.push_back(0);
		}
		
		// Pull a buffer set from the free list
		uint32 nIndex = m_aFreeList.back();
		m_aFreeList.pop_back();
		m_aLockTokens[nIndex] = nToken;
		
		HRENDERTARGET hShadowBuffer = m_aShadowBuffers[nIndex];

		// Allocate a shadow buffer if necessary
		// Note: These aren't allocated until they're requested so we don't allocate shadow
		// buffers if they're turned off.
		if (m_bShadowsEnabled && (hShadowBuffer == NULL))
		{
			LTRESULT nResult = LT_ERROR;
			nResult = g_pLTRenderer->CreateRenderTarget(m_nCurShadowRes, m_nCurShadowRes, eRTO_DepthBuffer, hShadowBuffer);
			if (nResult != LT_OK)
				return false;
			m_aShadowBuffers[nIndex] = hShadowBuffer;
		}

		HRENDERTARGET hSliceBuffer = m_aSliceBuffers[nIndex];
		
		// Allocate a slice buffer (use floating point precision if possible) if necessary
		if (hSliceBuffer == NULL)
		{
			LTRESULT nResult = LT_ERROR;
			
			LTVector2 vSliceRes = GetSliceBufferRes();
			if (m_bFloatBuffersEnabled)
			{
				nResult = g_pLTRenderer->CreateRenderTarget((uint32)vSliceRes.x, (uint32)vSliceRes.y, eRTO_DepthBuffer | eRTO_FloatBuffer, hSliceBuffer);
				if (nResult != LT_OK)
				{
					// Floating point buffers not supported.  Stop trying to allocate them.
					m_bFloatBuffersEnabled = false;
					g_cvarVolumetricLightFloat.SetFloat(0.0f);
				}
			}
			if (!m_bFloatBuffersEnabled)
			{
				nResult = g_pLTRenderer->CreateRenderTarget((uint32)vSliceRes.x, (uint32)vSliceRes.y, eRTO_DepthBuffer, hSliceBuffer);
				if (nResult != LT_OK)
				{
					g_pLTRenderer->ReleaseRenderTarget(hShadowBuffer);
					return false;
				}
			}
			m_aSliceBuffers[nIndex] = hSliceBuffer;
		}

		// Return those buffers
		*pShadowBuffer = hShadowBuffer;
		*pSliceBuffer = hSliceBuffer;
		
		return true;
	}
Exemplo n.º 12
0
void CLaserBeam::Update(LTVector vBeamStartPos, LTRotation* pRDirRot,
                        LTBOOL b3rdPerson, LTBOOL bDetect)
{
	if (!m_bOn) return;

	// Calculate beam position...

	HOBJECT hCamera = g_pGameClientShell->GetCamera();
	if (!hCamera) return;

    HLOCALOBJ hPlayerObj = g_pLTClient->GetClientObject();
	if (!hPlayerObj) return;

    HOBJECT hFilterList[] = {hPlayerObj, g_pGameClientShell->GetMoveMgr()->GetObject(), LTNULL};

	IntersectQuery qInfo;
	IntersectInfo iInfo;

    LTVector vPos(0, 0, 0);
    LTRotation rRot;
	rRot.Init();

    LTVector vU, vR, vF;

	if (pRDirRot && b3rdPerson)
	{
		vPos = vBeamStartPos;

        g_pLTClient->GetRotationVectors(pRDirRot, &vU, &vR, &vF);
	}
	else
	{
        g_pLTClient->GetObjectRotation(hCamera, &rRot);
        g_pLTClient->GetObjectPos(hCamera, &vPos);

        g_pLTClient->GetRotationVectors(&rRot, &vU, &vR, &vF);

		if (g_cvarLaserBeamDebug.GetFloat() == 0.0f)
		{
			vBeamStartPos += vPos;
		}
		else if (g_cvarLaserBeamDebug.GetFloat() == 1.0f)
		{
			vBeamStartPos = vPos;
		}
		else
		{
            g_pLTClient->GetRotationVectors(pRDirRot, &vU, &vR, &vF);
			vBeamStartPos = vBeamStartPos;
		}

	}


    LTVector vEndPos = vPos + (vF * 10000.0f);

	qInfo.m_From = vPos;
	qInfo.m_To   = vEndPos;

	qInfo.m_Flags = INTERSECT_OBJECTS | IGNORE_NONSOLID;
	qInfo.m_FilterFn = ObjListFilterFn;
	qInfo.m_pUserData = hFilterList;

    if (g_pLTClient->IntersectSegment(&qInfo, &iInfo))
	{
		vEndPos = iInfo.m_Point;
	}


	// Show the light beam...

    LTVector vColor = LTVector(GetRandom(235.0f, 255.0f), GetRandom(35.0f, 55.0f), GetRandom(35.0f, 55.0f));;

    LTFLOAT fAlpha = g_cvarLaserBeamAlpha.GetFloat();

	if (iInfo.m_hObject && bDetect)
	{
        uint32 dwUsrFlgs = 0;
        g_pLTClient->GetObjectUserFlags(iInfo.m_hObject, &dwUsrFlgs);

		if (dwUsrFlgs & USRFLG_CHARACTER)
		{
			fAlpha	= 0.95f;
			vColor.Init(GetRandom(35.0f, 55.0f), GetRandom(235.0f, 255.0f), GetRandom(35.0f, 55.0f));;
		}
	}

    LTFLOAT fWidth = g_cvarLaserBeamThickness.GetFloat();
	fWidth = b3rdPerson ? fWidth*2.0f : fWidth;

	vBeamStartPos += (vF * g_cvarLaserBeamFOffset.GetFloat());
	vBeamStartPos += (vR * g_cvarLaserBeamROffset.GetFloat());
	vBeamStartPos += (vU * g_cvarLaserBeamUOffset.GetFloat());

	PLFXCREATESTRUCT pls;

	if (g_cvarLaserBeamDebug.GetFloat() >= 0.0f)
	{
        // g_pLTClient->CPrint("StartPos = %.2f, %.2f, %.2f", VEC_EXPAND(vBeamStartPos));
        // g_pLTClient->CPrint("EndPos = %.2f, %.2f, %.2f", VEC_EXPAND(vEndPos));
	}

	pls.vStartPos			= vBeamStartPos;
	pls.vEndPos				= vEndPos;
	pls.vInnerColorStart	= vColor;
	pls.vInnerColorEnd		= pls.vInnerColorStart;
    pls.vOuterColorStart    = LTVector(0, 0, 0);
    pls.vOuterColorEnd      = LTVector(0, 0, 0);
	pls.fAlphaStart			= fAlpha;
	pls.fAlphaEnd			= fAlpha;
	pls.fMinWidth			= 0;
	pls.fMaxWidth			= fWidth;
	pls.fMinDistMult		= 1.0f;
	pls.fMaxDistMult		= 1.0f;
	pls.fLifeTime			= 1.0f;
	pls.fAlphaLifeTime		= 1.0f;
	pls.fPerturb			= 0.0f;
    pls.bAdditive           = LTTRUE;
    pls.bAlignFlat          = b3rdPerson ? LTFALSE : LTTRUE;
	pls.nWidthStyle			= PLWS_CONSTANT;
	pls.nNumSegments		= (int)g_cvarLaserBeamNumSegments.GetFloat();

	if (m_LightBeam.HasBeenDrawn())
	{
		// Keep the light beam in the vis list...

		m_LightBeam.SetPos(vBeamStartPos);

		// Hide the beam in portals if 1st person...Also set flag really
		// close to true...

        uint32 dwFlags2, dwFlags;

		dwFlags = m_LightBeam.GetFlags();
		dwFlags2 = m_LightBeam.GetFlags2();

		if (b3rdPerson)
		{
			dwFlags &= ~FLAG_REALLYCLOSE;
			dwFlags2 &= ~FLAG2_PORTALINVISIBLE;
		}
		else
		{
			if (g_cvarLaserBeamDebug.GetFloat() > 1.0f)
			{
				dwFlags |= FLAG_REALLYCLOSE;
                pls.bUseObjectRotation = LTTRUE;
			}
			dwFlags2 |= FLAG2_PORTALINVISIBLE;
		}

		m_LightBeam.SetFlags(dwFlags);
		m_LightBeam.SetFlags2(dwFlags2);

		m_LightBeam.ReInit(&pls);
	}
	else
	{
		m_LightBeam.Init(&pls);
        m_LightBeam.CreateObject(g_pLTClient);
	}


	m_LightBeam.Update();
}
Exemplo n.º 13
0
void CSearcher::Update( )
{
	// Are we actually searching something
	if( !m_bSearching || !m_hTargetObj )
	{
		return;
	}

	HOBJECT hTarget = m_hTargetObj;
	if (m_hTargetHitBox) 
		hTarget = m_hTargetHitBox;
	HOBJECT hObj = g_pPlayerMgr->GetTargetMgr()->GetLockedTarget();

	bool bLookingAtTarget = (hObj == hTarget);
	bool bInRange = (g_pPlayerMgr->GetTargetMgr()->IsTargetInRange());

	float fSearchSkillEffect = g_pPlayerStats->GetSkillModifier(SKL_SEARCH,SearchModifiers::eSearchSpeed);

	m_fTimer -= g_pLTClient->GetFrameTime() * fSearchSkillEffect;
	if (m_fTimer < 0.0f)
		m_fTimer = 0.0f;


	bool bButtonDown = !!g_pLTClient->IsCommandOn( COMMAND_ID_ACTIVATE);

	// Do we still meet the requirements for searching?
	if( m_fTimer <= 0.0f || !bButtonDown || !bLookingAtTarget || !bInRange )
	{

		// Send message to target with the amount of time left...

		CAutoMessage cMsg;

		cMsg.Writeuint8( MID_SEARCH );
		cMsg.WriteObject( m_hTargetObj );
		cMsg.Writefloat( m_fTimer);
		g_pLTClient->SendToServer( cMsg.Read(), MESSAGE_GUARANTEED );

		// Stop searching...
		m_bSearching	= false;
		m_hTargetObj	= LTNULL;
		m_hTargetHitBox	= LTNULL;
		g_pPlayerMgr->GetTargetMgr()->LockTarget(NULL);

		// Let the progress bar hide it's self...

		if( !bButtonDown || !bLookingAtTarget || !bInRange  )
		{
			m_bShowTimeBar	= false;
			g_pPlayerStats->UpdateProgress( 0 );
			g_pHUDMgr->QueueUpdate( kHUDProgressBar );
		}
	}

	// Get the percentage of searching we have done
	
	uint8 nMaxProgress = GetMaxProgress();
	uint8 nVal = uint8( ((m_fRemainingTime+m_fTimer) / m_fTotalTime) * nMaxProgress );

	// Update the meter...
	if( m_bShowTimeBar )
	{
		// Show the progress bar...

		g_pPlayerStats->UpdateMaxProgress( g_vtProgressBarScaleToSkills.GetFloat() > 1.0f ? 100 : nMaxProgress );
		g_pPlayerStats->UpdateProgress( nVal );
		g_pHUDMgr->QueueUpdate( kHUDProgressBar );
	}

	if (!nVal)
	{
		g_pClientSoundMgr->PlaySoundLocal("interface\\snd\\SearchComplete.wav", SOUNDPRIORITY_MISC_MEDIUM);
	}
}
Exemplo n.º 14
0
bool CClientWeaponMgr::ChangeWeapon( HWEAPON hWeapon,
									HAMMO hAmmo /* = NULL */,
                                     int nAmmoAmount /*=-1*/,
                                     bool bPlaySelect /*=true*/,
									 bool bPlayDeselect /*=true*/ )
{

	// Check if the weapon has a dual version that can be switched to...
	HWEAPONDATA hWeaponData = g_pWeaponDB->GetWeaponData( hWeapon, !USE_AI_DATA );
	HWEAPON hDualWeapon = g_pWeaponDB->GetRecordLink( hWeaponData, WDB_WEAPON_rDualWeapon );
	if( CanChangeToWeapon( hDualWeapon ))
	{
		// Change to dual version of weapon...
		hWeapon = hDualWeapon;
	}
	else if( !CanChangeToWeapon( hWeapon ))
		return false;

//	const char* pszName = g_pLTDatabase->GetRecordName(hWeapon);
//	DebugCPrint(0,"%s - %s",__FUNCTION__,pszName);

	// assume we'll be changing weapon and ammo
	bool bChangeWeapon = true;
	bool bChangeAmmo = true;

	if ( m_pCurrentWeapon )
	{
		// If there is a current weapon, determine if we
		// have to switch the weapon, the ammo, or both.
		HWEAPON hCurWeapon = m_pCurrentWeapon->GetWeaponRecord();

		// Do we need to change the weapon?
		if( hWeapon == hCurWeapon )
		{
			bChangeWeapon = false;

			// Make sure a weapon change in progress is aborted...
			if( NULL != m_hRequestedWeapon )
			{
				m_hRequestedWeapon = hCurWeapon;
			}
		}

	}

	// if the specified hAmmo is INVALID, we'll try to find
	// the best ammo to switch to
	HAMMO hNewAmmo = NULL;
	int nNewAmmoAmount = -1;

	// get the best new ammo type
	uint8 nNewWeaponIndex = g_pWeaponDB->GetPlayerWeaponIndex( hWeapon );
	if( (NULL == hAmmo) && (CWM_NO_WEAPON != nNewWeaponIndex) )
	{
		// If we don't want to keep the current ammo get the highest priority ammo...

		if( g_vtKeepCurrentAmmo.GetFloat() < 1.0f )
		{
			hNewAmmo = m_apClientWeapon[ nNewWeaponIndex ]->GetBestAvailableAmmo( );
		}
		else
		{
			hNewAmmo = m_apClientWeapon[nNewWeaponIndex]->GetAmmoRecord();

			// [KLS 5/9/02] Since we're using the ammo record stored in the weapon, make sure
			// that the weapon actually has ammo associated with this record...If not,
			// change to the best available ammo...

			if( g_pPlayerStats->GetAmmoCount( hNewAmmo ) <= 0 )
			{
				hNewAmmo = m_apClientWeapon[ nNewWeaponIndex ]->GetBestAvailableAmmo( );
			}
		}

		if (!hNewAmmo)
		{
			hNewAmmo = g_pWeaponDB->GetRecordLink( hWeaponData, WDB_WEAPON_rAmmoName );
		}

	}
	else
	{
		hNewAmmo = hAmmo;
	}



	// get the amount of ammo
	if ( -1 == nAmmoAmount )
	{
		nNewAmmoAmount = g_pPlayerStats->GetAmmoCount( hNewAmmo );
	}
	else
	{
		nNewAmmoAmount = nAmmoAmount;
	}

	// Do we need to change the ammo?
	if ( m_pCurrentWeapon )
	{
		// If there is a current weapon, determine if we
		// have to switch the weapon, the ammo, or both.
		HAMMO hCurAmmo = m_pCurrentWeapon->GetAmmoRecord();
		if ( hNewAmmo == hCurAmmo )
		{
			bChangeAmmo = false;

			// Make sure a ammo change in progress is aborted...
			if (m_hRequestedAmmo != NULL)
			{
				m_hRequestedAmmo = hCurAmmo;
			}
		}
	}

	bool bSwitchInstantly = bChangeWeapon;


	if ( bChangeWeapon )
	{
		// Handle deselection of current weapon...
		if ( bPlayDeselect )
		{
			if ( CWM_NO_WEAPON != m_nCurClientWeaponIndex )
			{
				// change weapons

				// save the new weapon id.
				m_hRequestedWeapon = hWeapon;
				m_hRequestedAmmo = hNewAmmo;
				if (m_pCurrentWeapon && CanLastWeapon(m_pCurrentWeapon->GetWeaponRecord()))
				{
					m_hLastWeapon = m_pCurrentWeapon->GetWeaponRecord();
				}

				// deselect the weapon
				bool bResult = m_apClientWeapon[ m_nCurClientWeaponIndex ]->Deselect( CallbackHook, this );
				if ( bResult )
				{
					bSwitchInstantly = false;
				}
			}

			//check to see if the our old weapon is linked to a grenade-type...
			if (m_pCurrentWeapon)
			{
				HWEAPONDATA hWpnData = g_pWeaponDB->GetWeaponData(m_pCurrentWeapon->GetWeaponRecord(), !USE_AI_DATA);
				HWEAPON hLinkedWeapon = g_pWeaponDB->GetRecordLink( hWpnData, WDB_WEAPON_rLinkedWeapon  );
				bool bSelect = g_pWeaponDB->GetBool( hWpnData, WDB_WEAPON_bSelectLinked );
				if( bSelect && hLinkedWeapon)
				{
					//OK, it is linked, so deselect that grenade too...
					HWEAPONDATA hLnkWpnData = g_pWeaponDB->GetWeaponData(hLinkedWeapon, !USE_AI_DATA);
					if (g_pWeaponDB->GetBool( hLnkWpnData, WDB_WEAPON_bIsGrenade ) &&
						g_pPlayerStats->GetLastGrenadeRecord() != hLinkedWeapon)
					{
						g_pPlayerStats->LastGrenade();
					}
				}
			}

		}

		if ( bSwitchInstantly )
		{

			if ( m_pCurrentWeapon )
			{
				// deactivate the old weapon, if any
				m_pCurrentWeapon->Deactivate();

			}


			// no current weapon, no need to deselect
			ASSERT( 0 != m_apClientWeapon );
			if (m_pCurrentWeapon && CanLastWeapon(m_pCurrentWeapon->GetWeaponRecord()))
			{
				m_hLastWeapon = m_pCurrentWeapon->GetWeaponRecord();
			}

			m_nCurClientWeaponIndex = g_pWeaponDB->GetPlayerWeaponIndex( hWeapon );
			if( m_nCurClientWeaponIndex != CWM_NO_WEAPON )
			{
				m_pCurrentWeapon = m_apClientWeapon[ m_nCurClientWeaponIndex ];
				m_pCurrentWeapon->Activate();
				m_pCurrentWeapon->Select(!bPlaySelect);

				// instantly switch to the new ammo
				m_pCurrentWeapon->ChangeAmmoImmediate( hNewAmmo , nNewAmmoAmount );

				if( !m_bWeaponsEnabled )
					m_pCurrentWeapon->SetDisable( true );
			}
			else
			{
				m_pCurrentWeapon = NULL;
			}
		}
	}
	else if ( bChangeAmmo && m_pCurrentWeapon )
	{
		// don't need to change the weapon, but we do
		// need to change the ammo
		m_pCurrentWeapon->ChangeAmmoWithReload( hNewAmmo );
	}
	
	// We succesfully started the weapon change process, so let the player mgr handle
	// it...

	//jrg- 9/2/02 - this is getting called both when we start switching and when we finish switching
	//		PlayerMgr is using this to track if we're in mid switch
	g_pPlayerMgr->HandleWeaponChanged( hWeapon, hNewAmmo, (!bChangeWeapon || bSwitchInstantly) );


	return true;
}
Exemplo n.º 15
0
// Change in focus
void    CFolderPlayer::OnFocus(LTBOOL bFocus)
{

	if (bFocus)
	{
		m_bRestoreSkinHead = LTTRUE;

		m_nModNum = -1;
		m_nSkinNum = 0;
		m_nHeadNum = 0;

		int nUpdateRate = GetConsoleInt("UpdateRate",10);
		m_nConnect = 3;
		while (m_nConnect && nUpdateRate < kConnectSpeeds[m_nConnect])
			m_nConnect--;

		nInitConnect = m_nConnect;

		SAFE_STRCPY(m_szPlayerModel,g_vtPlayerModel.GetStr() );
		GetConsoleString("NetPlayerSkin",m_szPlayerSkin,"");
		GetConsoleString("NetPlayerHead",m_szPlayerHead,"");

		if ( !m_szPlayerSkin[0] || !m_szPlayerHead[0] )
		{
			char szTemp[512];
			strcpy(szTemp, m_szPlayerModel);
			if ( strchr(szTemp, ',') )
			{
				*strchr(szTemp, ',') = '_';
				_strlwr(szTemp);
				strcpy(m_szPlayerSkin, g_pModelButeMgr->GetButeMgr()->GetString(szTemp, "Skin0"));
				strcpy(m_szPlayerHead, g_pModelButeMgr->GetButeMgr()->GetString(szTemp, "Head0"));
			} 
		}

		BuildModelList();
		SAFE_STRCPY(m_szPlayerName,g_vtPlayerName.GetStr() );

		if (m_nModNum < 0)
		{
			m_nModNum = 0;
			HSTRING hStr = m_pModelCtrl->GetString(0);
            strcpy(m_szPlayerModel,g_pLTClient->GetStringData(hStr));

		}

		m_nTeam = (int)g_vtPlayerTeam.GetFloat();
		m_nTargetNameSize = (int)g_vtTargetNameSize.GetFloat();
		m_nTargetNameTransparency = (int)(100.0f*g_vtTargetNameTransparency.GetFloat());
		m_bAutoSwitchWeapons =  (LTBOOL)GetConsoleInt("AutoWeaponSwitch",1);
		m_bAutoSwitchAmmo =  (LTBOOL)GetConsoleInt("AutoAmmoSwitch",1);
		m_bIgnoreTaunts =  (LTBOOL)GetConsoleInt("IgnoreTaunts",0);
	
        UpdateData(LTFALSE);
	}
	else
	{
		UpdateData();

		if (nInitConnect != m_nConnect)
		{
			WriteConsoleInt("UpdateRate",kConnectSpeeds[m_nConnect]);
		}

		LTBOOL bChanged = LTFALSE;
		char szTemp[32];
		SAFE_STRCPY(szTemp,g_vtPlayerModel.GetStr() );
		if (strcmp(szTemp,m_szPlayerModel) != 0)
			bChanged = LTTRUE;


		GetConsoleString("NetPlayerSkin",szTemp,"");
		if (strcmp(szTemp,m_szPlayerSkin) != 0)
			bChanged = LTTRUE;

		GetConsoleString("NetPlayerHead",szTemp,"");
		if (strcmp(szTemp,m_szPlayerHead) != 0)
			bChanged = LTTRUE;

		SAFE_STRCPY(szTemp,g_vtPlayerName.GetStr() );
		if (strcmp(szTemp,m_szPlayerName) != 0)
			bChanged = LTTRUE;

		if (m_nTeam != (int)g_vtPlayerTeam.GetFloat())
			bChanged = LTTRUE;

		g_vtPlayerName.SetStr(m_szPlayerName);
		g_vtPlayerModel.SetStr(m_szPlayerModel);
		WriteConsoleString("NetPlayerHead",m_szPlayerHead);
		WriteConsoleString("NetPlayerSkin",m_szPlayerSkin);
        g_vtPlayerTeam.WriteFloat((LTFLOAT)m_nTeam);
        g_vtTargetNameSize.WriteFloat((LTFLOAT)m_nTargetNameSize);
        g_vtTargetNameTransparency.WriteFloat((LTFLOAT)m_nTargetNameTransparency/100.0f);
		WriteConsoleInt("AutoWeaponSwitch",(int)m_bAutoSwitchWeapons);
		WriteConsoleInt("AutoAmmoSwitch",(int)m_bAutoSwitchAmmo);
		WriteConsoleInt("IgnoreTaunts",(int)m_bIgnoreTaunts);

        HLOCALOBJ hPlayerObj = g_pLTClient->GetClientObject();
		if (bChanged && g_pGameClientShell->IsInWorld() && hPlayerObj && g_pGameClientShell->IsMultiplayerGame())
		{
            HSTRING hstrName = g_pLTClient->CreateString(m_szPlayerName);
			if (!hstrName) return;
            HSTRING hstrModel = g_pLTClient->CreateString(m_szPlayerModel);
			if (!hstrModel) return;
            HSTRING hstrSkin = g_pLTClient->CreateString(strchr(m_szPlayerSkin, ',')+1);
			if (!hstrSkin) return;
            HSTRING hstrHead = g_pLTClient->CreateString(strchr(m_szPlayerHead, ',')+1);
			if (!hstrHead) return;

			// Init multiplayer info on server...

            HMESSAGEWRITE hWrite = g_pLTClient->StartMessage(MID_PLAYER_MULTIPLAYER_CHANGE);
            g_pLTClient->WriteToMessageHString(hWrite, hstrName);
            g_pLTClient->WriteToMessageHString(hWrite, hstrModel);
            g_pLTClient->WriteToMessageHString(hWrite, hstrSkin);
            g_pLTClient->WriteToMessageHString(hWrite, hstrHead);
            g_pLTClient->WriteToMessageByte(hWrite, (uint8)m_nTeam);
            g_pLTClient->EndMessage(hWrite);

			g_pLTClient->FreeString(hstrName);
			g_pLTClient->FreeString(hstrModel);
			g_pLTClient->FreeString(hstrSkin);
			g_pLTClient->FreeString(hstrHead);

			ClearModelList();
		}

		g_pLTClient->FreeUnusedModels();

        g_pLTClient->WriteConfigFile("autoexec.cfg");

	}
	CBaseFolder::OnFocus(bFocus);
}
Exemplo n.º 16
0
void CCameraOffsetMgr::ValidateDeltas()
{
	float fMaxVal = g_vtCamMaxPitchOffset.GetFloat();
	if (m_vPitchYawRollDelta.x > fMaxVal)
	{
		m_vPitchYawRollDelta.x = fMaxVal;
	}
	else if (m_vPitchYawRollDelta.x < -fMaxVal)
	{
		m_vPitchYawRollDelta.x = -fMaxVal;
	}

	fMaxVal = g_vtCamMaxYawOffset.GetFloat();
	if (m_vPitchYawRollDelta.y > fMaxVal)
	{
		m_vPitchYawRollDelta.y = fMaxVal;
	}
	else if (m_vPitchYawRollDelta.y < -fMaxVal)
	{
		m_vPitchYawRollDelta.y = -fMaxVal;
	}

	fMaxVal = g_vtCamMaxRollOffset.GetFloat();
	if (m_vPitchYawRollDelta.z > fMaxVal)
	{
		m_vPitchYawRollDelta.z = fMaxVal;
	}
	else if (m_vPitchYawRollDelta.z < -fMaxVal)
	{
		m_vPitchYawRollDelta.z = -fMaxVal;
	}

	fMaxVal = g_vtCamMaxPosXOffset.GetFloat();
	if (m_vPosDelta.x > fMaxVal)
	{
		m_vPosDelta.x = fMaxVal;
	}
	else if (m_vPosDelta.x < -fMaxVal)
	{
		m_vPosDelta.x = -fMaxVal;
	}

	fMaxVal = g_vtCamMaxPosYOffset.GetFloat();
	if (m_vPosDelta.y > fMaxVal)
	{
		m_vPosDelta.y = fMaxVal;
	}
	else if (m_vPosDelta.y < -fMaxVal)
	{
		m_vPosDelta.y = -fMaxVal;
	}

	fMaxVal = g_vtCamMaxPosZOffset.GetFloat();
	if (m_vPosDelta.z > fMaxVal)
	{
		m_vPosDelta.z = fMaxVal;
	}
	else if (m_vPosDelta.z < -fMaxVal)
	{
		m_vPosDelta.z = -fMaxVal;
	}
}
Exemplo n.º 17
0
void CPolygonDebrisFX::CreateDebris(int i, LTVector vPos)
{
	if (i < 0 || i >= m_ds.nNumDebris || i != m_nNumPolies || (m_Polies[i] != LTNULL)) return;

	// Create a poly debris object...

	PLFXCREATESTRUCT pls;

    LTVector vLength = (m_cs.vDir * GetRandom(m_cs.PolyDebrisFX.fMinLength, m_cs.PolyDebrisFX.fMaxLength)) / 2.0f;

    LTVector vMinC1 = m_cs.PolyDebrisFX.vMinColor1;
    LTVector vMaxC1 = m_cs.PolyDebrisFX.vMaxColor1;
    LTVector vMinC2 = m_cs.PolyDebrisFX.vMinColor2;
    LTVector vMaxC2 = m_cs.PolyDebrisFX.vMaxColor2;

	pls.pTexture			= m_cs.PolyDebrisFX.szTexture[0] ? m_cs.PolyDebrisFX.szTexture : LTNULL;
	pls.vStartPos			= vPos - vLength;
	pls.vEndPos				= vPos + vLength;
    pls.vInnerColorStart    = LTVector(GetRandom(vMinC1.x, vMaxC1.x), GetRandom(vMinC1.y, vMaxC1.y), GetRandom(vMinC1.z, vMaxC1.z));
    pls.vInnerColorEnd      = LTVector(GetRandom(vMinC2.x, vMaxC2.x), GetRandom(vMinC2.y, vMaxC2.y), GetRandom(vMinC2.z, vMaxC2.z));
	pls.vOuterColorStart	= pls.vInnerColorStart;
	pls.vOuterColorEnd		= pls.vInnerColorEnd;
	pls.fAlphaStart			= m_cs.PolyDebrisFX.fInitialAlpha;
	pls.fAlphaEnd			= m_cs.PolyDebrisFX.fFinalAlpha;
	pls.fMinWidth			= 0.0f;
	pls.fMaxWidth			= GetRandom(m_cs.PolyDebrisFX.fMinWidth, m_cs.PolyDebrisFX.fMaxWidth);
	pls.fLifeTime			= GetDebrisLife(i);
	pls.fAlphaLifeTime		= GetDebrisLife(i);
	pls.bAdditive			= m_cs.PolyDebrisFX.bAdditive;
	pls.bMultiply			= m_cs.PolyDebrisFX.bMultiply;
	pls.bDontFadeAlphaAtEdge= !m_cs.PolyDebrisFX.bAdditive;
	pls.nWidthStyle			= m_cs.PolyDebrisFX.nStyle > PLWS_CONSTANT ? GetRandom(PLWS_BIG_TO_SMALL, PLWS_CONSTANT) : m_cs.PolyDebrisFX.nStyle;
	pls.bUseObjectRotation	= !m_cs.PolyDebrisFX.bShowTrail;
	pls.bNoZ				= m_cs.PolyDebrisFX.bShowTrail;
	pls.nNumSegments		= 1;

	pls.fMinDistMult		= 1.0f;
	pls.fMaxDistMult		= 1.0f;
	pls.fPerturb			= 0.0f;

	// Scale the width based on the distance the camera is away from the
	// origin of the debris...
	
	HLOCALOBJ hCamera = g_pGameClientShell->GetCamera();
    if (hCamera)
	{
		LTVector vCamPos;
		g_pLTClient->GetObjectPos(hCamera, &vCamPos);

		vCamPos -= vPos;
		LTFLOAT fScaleVal = vCamPos.Mag() / g_cvarPolyDebrisScaleDist.GetFloat();

		fScaleVal = (fScaleVal < g_cvarPolyDebrisMinDistScale.GetFloat() ? g_cvarPolyDebrisMinDistScale.GetFloat() 
			: (fScaleVal > g_cvarPolyDebrisMaxDistScale.GetFloat() ? g_cvarPolyDebrisMaxDistScale.GetFloat() : fScaleVal));

		pls.fMaxWidth *= fScaleVal;
	}

	CPolyLineFX *pNewPoly = GetPolyLineFXBank()->New();

	if (!pNewPoly->Init(&pls) ||
		!pNewPoly->CreateObject(m_pClientDE))
	{
		GetPolyLineFXBank()->Delete(pNewPoly);
		return;
	}
	else
	{
		m_Polies[m_nNumPolies] = pNewPoly;
	}

	m_nNumPolies++;
}
Exemplo n.º 18
0
void CCameraOffsetMgr::Update()
{
	// Testing only...
	ProcessTestingVars();
	// End Testing only...


	// Reset offsets...

	m_vPitchYawRollDelta.Init();
	m_vPosDelta.Init();

    float fTimeDelta = g_pGameClientShell->GetFrameTime();

    int i;
    for (i=0; i < MAX_CAMERA_DELTAS; i++)
	{
		if (m_CameraDeltas[i].GetTotalDelta() > 0.0f)
		{
			m_CameraDeltas[i].Pitch.UpdateVar(fTimeDelta);
			m_vPitchYawRollDelta.x += m_CameraDeltas[i].Pitch.GetValue();

			m_CameraDeltas[i].Yaw.UpdateVar(fTimeDelta);
			m_vPitchYawRollDelta.y += m_CameraDeltas[i].Yaw.GetValue();

			m_CameraDeltas[i].Roll.UpdateVar(fTimeDelta);
			m_vPitchYawRollDelta.z += m_CameraDeltas[i].Roll.GetValue();

			m_CameraDeltas[i].PosX.UpdateVar(fTimeDelta);
			m_vPosDelta.x += m_CameraDeltas[i].PosX.GetValue();

			m_CameraDeltas[i].PosY.UpdateVar(fTimeDelta);
			m_vPosDelta.y += m_CameraDeltas[i].PosY.GetValue();

			m_CameraDeltas[i].PosZ.UpdateVar(fTimeDelta);
			m_vPosDelta.z += m_CameraDeltas[i].PosZ.GetValue();
		}
	}

	for (i=0; i < MAX_STATIC_CAMERA_DELTAS; i++)
	{
		if (m_StaticCameraDeltas[i].GetTotalDelta() > 0.0f)
		{
			m_StaticCameraDeltas[i].Pitch.UpdateVar(fTimeDelta);
			m_vPitchYawRollDelta.x += m_StaticCameraDeltas[i].Pitch.GetValue();

			m_StaticCameraDeltas[i].Yaw.UpdateVar(fTimeDelta);
			m_vPitchYawRollDelta.y += m_StaticCameraDeltas[i].Yaw.GetValue();

			m_StaticCameraDeltas[i].Roll.UpdateVar(fTimeDelta);
			m_vPitchYawRollDelta.z += m_StaticCameraDeltas[i].Roll.GetValue();

			m_StaticCameraDeltas[i].PosX.UpdateVar(fTimeDelta);
			m_vPosDelta.x += m_StaticCameraDeltas[i].PosX.GetValue();

			m_StaticCameraDeltas[i].PosY.UpdateVar(fTimeDelta);
			m_vPosDelta.y += m_StaticCameraDeltas[i].PosY.GetValue();

			m_StaticCameraDeltas[i].PosZ.UpdateVar(fTimeDelta);
			m_vPosDelta.z += m_StaticCameraDeltas[i].PosZ.GetValue();
		}
	}

	ValidateDeltas();


	// Print out our current values...

	if (g_vtCamInfo.GetFloat())
	{
		if (m_vPitchYawRollDelta.x != 0.0f)
			g_pLTClient->CPrint("COM Pitch = %.4f (in Deg = %.2f)", m_vPitchYawRollDelta.x, RAD2DEG(m_vPitchYawRollDelta.x));
		if (m_vPitchYawRollDelta.y != 0.0f)
			g_pLTClient->CPrint("COM Yaw   = %.4f (in Deg = %.2f)", m_vPitchYawRollDelta.y, RAD2DEG(m_vPitchYawRollDelta.y));
		if (m_vPitchYawRollDelta.z != 0.0f)
			g_pLTClient->CPrint("COM Roll  = %.4f (in Deg = %.2f)", m_vPitchYawRollDelta.z, RAD2DEG(m_vPitchYawRollDelta.z));

		if (m_vPosDelta.x != 0.0f)
			g_pLTClient->CPrint("COM Offset X = %.2f", m_vPosDelta.x);
		if (m_vPosDelta.y != 0.0f)
			g_pLTClient->CPrint("COM Offset Y = %.2f", m_vPosDelta.y);
		if (m_vPosDelta.z != 0.0f)
			g_pLTClient->CPrint("COM Offset Z = %.2f", m_vPosDelta.z);
	}
}
Exemplo n.º 19
0
void StartTimingCounterServer()
{
    if (!g_pLTServer || g_ShowTimingTrack.GetFloat() < 1.0f) return;

	s_StartTimer = LTTimeUtils::GetPrecisionTime();
}
Exemplo n.º 20
0
LTBOOL CTracerFX::Update()
{
    if (!m_pClientDE || !m_cs.pTracerFX) return LTFALSE;

    LTFLOAT fTime = m_pClientDE->GetTime();

	if (m_bFirstUpdate)
	{
        m_bFirstUpdate  = LTFALSE;
		m_fStartTime	= fTime;

		PLFXCREATESTRUCT pls;

		m_vTracerPos = m_cs.vStartPos + (m_vDir * g_pGameClientShell->GetFrameTime() * m_fVelocity);

		pls.pTexture				= m_cs.pTracerFX->szTexture[0] ? m_cs.pTracerFX->szTexture : LTNULL;
		pls.vStartPos				= m_cs.vStartPos;
		pls.vEndPos					= m_vTracerPos;
		pls.vInnerColorStart		= m_cs.pTracerFX->vColor;
		pls.vInnerColorEnd			= m_cs.pTracerFX->vColor;
        pls.vOuterColorStart        = m_cs.pTracerFX->vColor;
        pls.vOuterColorEnd          = m_cs.pTracerFX->vColor;
		pls.fAlphaStart				= m_cs.pTracerFX->fInitialAlpha;
		pls.fAlphaEnd				= m_cs.pTracerFX->fFinalAlpha;
		pls.fMinWidth				= 0;
		pls.fMaxWidth				= m_cs.pTracerFX->fWidth;
		pls.fMinDistMult			= 1.0f;
		pls.fMaxDistMult			= 1.0f;
		pls.fLifeTime				= g_cvarTracerLifetime.GetFloat();
		//pls.fLifeTime				= m_fLifetime;
		pls.fAlphaLifeTime			= pls.fLifeTime;
		pls.fPerturb				= 0.0f;
        pls.bAdditive               = LTTRUE;
        pls.bNoZ                    = LTTRUE;
		pls.nWidthStyle				= PLWS_CONSTANT;
		pls.nNumSegments			= (int)g_cvarTracerSegments.GetFloat();
        pls.bAlignUp                = LTTRUE;

		if (!m_Tracer.Init(&pls) || !m_Tracer.CreateObject(m_pClientDE))
		{
            return LTFALSE;
		}
	}
	else if (fTime > m_fStartTime + m_fLifetime)
	{
        return LTFALSE;
	}


	// Draw the tracer...

	m_Tracer.Update();


	// Update the tracer positions...

	if (m_Tracer.HasBeenDrawn())
	{
 		// Use trail technology, instead of moving the tracer...

		PLFXLINESTRUCT ls;

		ls.vStartPos = m_vTracerPos;
		ls.vEndPos	 = m_vTracerPos + (m_vDir * g_pGameClientShell->GetFrameTime() * m_fVelocity);
		
		m_vTracerPos = ls.vEndPos;

		// Get the last vert position...

		PolyLineList* pLines = m_Tracer.GetLines();
		if (pLines->GetLength() > 0)
		{
			PolyLine** pLine = pLines->GetItem(TLIT_LAST);
			if (pLine && *pLine)
			{
				PolyVertStruct** pVert = (*pLine)->list.GetItem(TLIT_LAST);
				if (pVert && *pVert)
				{
					ls.vStartPos = m_Tracer.GetVertPos((*pVert));
				}
			}
		}

		ls.vInnerColorStart		= m_cs.pTracerFX->vColor;
		ls.vInnerColorEnd		= m_cs.pTracerFX->vColor;
		ls.vOuterColorStart		= m_cs.pTracerFX->vColor;
		ls.vOuterColorEnd		= m_cs.pTracerFX->vColor;
		ls.fAlphaStart			= m_cs.pTracerFX->fInitialAlpha;
		ls.fAlphaEnd			= m_cs.pTracerFX->fFinalAlpha;
		ls.fLifeTime			= g_cvarTracerLifetime.GetFloat();
        //ls.fLifeTime            = m_fLifetime - (g_pLTClient->GetTime() - m_fStartTime);
		ls.fLifeTime			= ls.fLifeTime < 0.0f ? 0.0f : ls.fLifeTime;
		ls.fAlphaLifeTime		= ls.fLifeTime;

		m_Tracer.AddLine(ls);
	}

    return LTTRUE;
}
Exemplo n.º 21
0
LTBOOL CLaserTriggerFX::Update()
{
    if (!m_pClientDE || !m_hServerObject || m_bWantRemove) return LTFALSE;

	// Hide/show the beam if necessary...

	if (m_hServerObject)
	{
        uint32 dwUserFlags;
		g_pCommonLT->GetObjectFlags(m_hServerObject, OFT_User, dwUserFlags);

		if (!(dwUserFlags & USRFLG_VISIBLE))
		{
			m_Beam.SetFlags(m_Beam.GetFlags() & ~FLAG_VISIBLE);

			// Update the sprites...

			if (m_cs.bCreateSprite)
			{
				HOBJECT hObj = m_StartSprite.GetObject();
				if (hObj)
				{
					g_pCommonLT->SetObjectFlags(hObj, OFT_Flags, 0, FLAG_VISIBLE);
				}

				hObj = m_EndSprite.GetObject();
				if (hObj)
				{
					g_pCommonLT->SetObjectFlags(hObj, OFT_Flags, 0, FLAG_VISIBLE);
				}
			}

            return LTTRUE;
		}
		else
		{
			m_Beam.SetFlags(m_Beam.GetFlags() | FLAG_VISIBLE);

			// Update the sprites...

			if (m_cs.bCreateSprite)
			{
				HOBJECT hObj = m_StartSprite.GetObject();
				if (hObj)
				{
					g_pCommonLT->SetObjectFlags(hObj, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE);
				}

				hObj = m_EndSprite.GetObject();
				if (hObj)
				{
					g_pCommonLT->SetObjectFlags(hObj, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE);
				}
			}
		}
	}


	// Move the beam to the correct position...

	if (CalcBeamCoords())
	{
        LTBOOL bShowSprites = LTFALSE;
		m_pls.fAlphaStart  = g_vtLaserTriggerAlpha.GetFloat();
        m_pls.bAdditive    = LTFALSE;

		// See if this client can clearly see laser triggers...

		if (g_pPlayerMgr->GetVisionModeMgr()->GetMode() == eVM_SPY)
		{
			m_pls.fAlphaStart = m_cs.fAlpha;
            m_pls.bAdditive   = LTTRUE;
            bShowSprites      = LTTRUE;
		}

		m_pls.fAlphaEnd	= m_pls.fAlphaStart;

		m_Beam.ReInit(&m_pls);
		m_Beam.Update();

		// Update the sprites...

		if (m_cs.bCreateSprite)
		{
			HOBJECT hObj = m_StartSprite.GetObject();
			if (hObj)
			{
				m_StartSprite.Update();

				g_pLTClient->SetObjectPos(hObj, &(m_pls.vStartPos));

				if (bShowSprites)
				{
					g_pCommonLT->SetObjectFlags(hObj, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE);
				}
				else
				{
					g_pCommonLT->SetObjectFlags(hObj, OFT_Flags, 0, FLAG_VISIBLE);
				}
			}

			hObj = m_EndSprite.GetObject();
			if (hObj)
			{
				m_EndSprite.Update();

				g_pLTClient->SetObjectPos(hObj, &(m_pls.vEndPos));

				if (bShowSprites)
				{
					g_pCommonLT->SetObjectFlags(hObj, OFT_Flags, FLAG_VISIBLE, FLAG_VISIBLE);
				}
				else
				{
					g_pCommonLT->SetObjectFlags(hObj, OFT_Flags, 0, FLAG_VISIBLE);
				}
			}
		}
	}

    return LTTRUE;
}
Exemplo n.º 22
0
void StartTimingCounter()
{
    if (!g_pLTClient || g_vtShowTimingTrack.GetFloat() < 1.0f) return;

    g_pLTClient->StartCounter(&s_counter);
}
Exemplo n.º 23
0
void CHeadBobMgr::AdjustCameraPos(LTVector &vPos)
{
	vPos.y += m_fBobHeight * g_vtHeadBobAdjust.GetFloat();
}
Exemplo n.º 24
0
void PlayWeaponSound(WEAPON *pWeapon, LTVector vPos, PlayerSoundId eSoundId,
					 LTBOOL bLocal)
{
	if (!pWeapon) return;

 	if (!s_cvarFirePitchShift.IsInitted())
	{
		s_cvarFirePitchShift.Init(g_pLTClient, "PitchShiftFire", NULL, -1.0f);
	}

	char* pSnd = LTNULL;

	LTFLOAT fRadius = WEAPON_SOUND_RADIUS;

	switch (eSoundId)
	{
		case PSI_FIRE:
		{
			pSnd = pWeapon->szFireSound;
			fRadius = (LTFLOAT) pWeapon->nFireSoundRadius;
		}
		break;

		case PSI_ALT_FIRE:
		{
			pSnd = pWeapon->szAltFireSound;
			fRadius = (LTFLOAT) pWeapon->nFireSoundRadius;
		}
		break;

		case PSI_SILENCED_FIRE:
		{
			pSnd = pWeapon->szSilencedFireSound;
			fRadius = (LTFLOAT) pWeapon->nFireSoundRadius;
		}
		break;

		case PSI_DRY_FIRE:
		{
			pSnd = pWeapon->szDryFireSound;
			fRadius = (LTFLOAT) pWeapon->nFireSoundRadius;
		}
		break;

		case PSI_RELOAD:
		case PSI_RELOAD2:
		case PSI_RELOAD3:
		{
			pSnd = pWeapon->szReloadSounds[eSoundId - PSI_RELOAD];
		}
		break;

		case PSI_SELECT:
		{
			pSnd = pWeapon->szSelectSound;
		}
		break;

		case PSI_DESELECT:
		{
			pSnd = pWeapon->szDeselectSound;
		}
		break;

		case PSI_INVALID:
		default : break;
	}

	if (pSnd && pSnd[0])
	{
		uint32 dwFlags = 0;
		float fPitchShift = 1.0f;
		if (s_cvarFirePitchShift.GetFloat() > 0.0f)
		{
			dwFlags |= PLAYSOUND_CTRL_PITCH;
			fPitchShift = s_cvarFirePitchShift.GetFloat();
		}

 		if (bLocal)
		{
			g_pClientSoundMgr->PlaySoundLocal(pSnd, SOUNDPRIORITY_PLAYER_HIGH,
				dwFlags, SMGR_DEFAULT_VOLUME, fPitchShift);
		}
		else
		{
 			g_pClientSoundMgr->PlaySoundFromPos(vPos, pSnd,
				fRadius, SOUNDPRIORITY_PLAYER_HIGH, dwFlags,
				SMGR_DEFAULT_VOLUME, fPitchShift);
		}
	}
}
Exemplo n.º 25
0
LTBOOL CParticleTrailSegmentFX::CreateObject(ILTClient *pClientDE)
{
    if (!pClientDE || !m_hServerObject) return LTFALSE;

	if (m_nType & PT_SMOKE_LONG)
	{
		m_pTextureName = "SFX\\Smoke\\Spr\\WhiteTrailLong.spr";

        m_basecs.bAdjustParticleScale = LTTRUE;
		m_basecs.fStartParticleScale  = g_cvarSmokeTrailStartScale.GetFloat();
		m_basecs.fEndParticleScale	  = g_cvarSmokeTrailLWEndScale.GetFloat();

        m_basecs.bAdjustParticleAlpha = LTTRUE;
		m_basecs.fStartParticleAlpha  = g_cvarSmokeTrailStartAlpha.GetFloat();
		m_basecs.fEndParticleAlpha	  = g_cvarSmokeTrailEndAlpha.GetFloat();
	}
	else if (m_nType & PT_SMOKE)
	{
		m_pTextureName = "SFX\\Smoke\\Spr\\WhiteTrailShort.spr";

        m_basecs.bAdjustParticleScale = LTTRUE;
		m_basecs.fStartParticleScale  = g_cvarSmokeTrailStartScale.GetFloat();
		m_basecs.fEndParticleScale	  = g_cvarSmokeTrailSWEndScale.GetFloat();

        m_basecs.bAdjustParticleAlpha = LTTRUE;
		m_basecs.fStartParticleAlpha  = g_cvarSmokeTrailStartAlpha.GetFloat();
		m_basecs.fEndParticleAlpha	  = g_cvarSmokeTrailEndAlpha.GetFloat();
	}
	else if (m_nType & PT_SMOKE_BLACK)
	{
		m_pTextureName = "SFX\\Smoke\\Spr\\BlackTrailShort.spr";

        m_basecs.bAdjustParticleScale = LTTRUE;
		m_basecs.fStartParticleScale  = g_cvarSmokeTrailStartScale.GetFloat();
		m_basecs.fEndParticleScale	  = g_cvarSmokeTrailSBEndScale.GetFloat();

        m_basecs.bAdjustParticleAlpha = LTTRUE;
		m_basecs.fStartParticleAlpha  = g_cvarSmokeTrailStartAlpha.GetFloat();
		m_basecs.fEndParticleAlpha	  = g_cvarSmokeTrailEndAlpha.GetFloat();
	}
	else if ((m_nType & PT_GIBSMOKE))
	{
		m_pTextureName = "SFX\\Impact\\Spr\\Smoke.spr";

        m_basecs.bAdjustParticleScale = LTTRUE;
		m_basecs.fStartParticleScale  = g_cvarSmokeTrailStartScale.GetFloat();
		m_basecs.fEndParticleScale	  = g_cvarSmokeTrailSWEndScale.GetFloat();

        m_basecs.bAdjustParticleAlpha = LTTRUE;
		m_basecs.fStartParticleAlpha  = g_cvarSmokeTrailStartAlpha.GetFloat();
		m_basecs.fEndParticleAlpha	  = g_cvarSmokeTrailEndAlpha.GetFloat();
	}
	else if (m_nType & PT_BLOOD)
	{
		if (GetRandom(0, 1) == 0)
		{
			m_pTextureName = "SFX\\Particle\\Blood_1.dtx";
		}
		else
		{
			m_pTextureName = "SFX\\Particle\\Blood_2.dtx";
		}
	}

	// Determine if we are in a liquid...

    LTVector vPos;
	pClientDE->GetObjectPos(m_hServerObject, &vPos);

	HLOCALOBJ objList[1];
    uint32 dwNum = pClientDE->GetPointContainers(&vPos, objList, 1);

	if (dwNum > 0 && objList[0])
	{
        uint32 dwUserFlags;
		pClientDE->GetObjectUserFlags(objList[0], &dwUserFlags);

		if (dwUserFlags & USRFLG_VISIBLE)
		{
            uint16 dwCode;
			if (pClientDE->GetContainerCode(objList[0], &dwCode))
			{
				if (IsLiquid((ContainerCode)dwCode))
				{
					// Don't create blood under water...

					if (m_nType & PT_BLOOD)
					{
                        m_bWantRemove = LTTRUE;
						m_fLifeTime = 0.0f;
						m_fFadeTime = 0.0f;
                        return LTFALSE;
					}

					m_fRadius = 500.0f;
					m_fGravity = 5.0f;
					m_nNumPerPuff *= 3;
                    m_bIgnoreWind = LTTRUE;
					m_pTextureName = DEFAULT_BUBBLE_TEXTURE;
					GetLiquidColorRange((ContainerCode)dwCode, &m_vColor1, &m_vColor2);
				}
			}
		}
	}

	return CBaseParticleSystemFX::CreateObject(pClientDE);
}
LTBOOL CMuzzleFlashFX::ResetFX()
{
	if (!m_pClientDE) return LTFALSE;

    m_bUsingParticles = LTFALSE;
    m_bUsingLight     = LTFALSE;
    m_bUsingScale     = LTFALSE;

	// Create/Reset the fx specified by the weapon...

    if (!m_cs.pWeapon) return LTFALSE;

    CMuzzleFX* pMuzzleFX = LTNULL;
	if (m_cs.bPlayerView)
	{
		pMuzzleFX = m_cs.pWeapon->pPVMuzzleFX;
	}
	else
	{
		pMuzzleFX = m_cs.pWeapon->pHHMuzzleFX;
	}

    if (!pMuzzleFX) return LTFALSE;


	// Create/Update the dynamic light...

	if (pMuzzleFX->pDLightFX)
	{
		if (m_cs.bPlayerView || GetConsoleInt("MuzzleLight", 1))
		{
			m_bUsingLight = (LTBOOL) !!(g_pFXButeMgr->CreateDLightFX(
				pMuzzleFX->pDLightFX, m_cs.vPos, &m_Light));
		}
	}


	// Create/Update the scale fx...

	if (pMuzzleFX->pScaleFX)
	{
        LTVector vU, vR, vF;
        m_pClientDE->GetRotationVectors(&(m_cs.rRot), &vU, &vR, &vF);

        m_bUsingScale = (LTBOOL) !!(g_pFXButeMgr->CreateScaleFX(pMuzzleFX->pScaleFX,
			m_cs.vPos, vF, LTNULL, &(m_cs.rRot), &m_Scale));

		// Make camera-relative if player view...

		if (m_bUsingScale && m_cs.bPlayerView)
		{
			if (m_Scale.GetObject())
			{
				uint32 dwFlags = m_pClientDE->GetObjectFlags(m_Scale.GetObject());
				m_pClientDE->SetObjectFlags(m_Scale.GetObject(), dwFlags | FLAG_REALLYCLOSE);
			}
		}
	}

	// Create/Update the particle muzzle fx...

	if (pMuzzleFX->pPMuzzleFX)
	{
		MFPCREATESTRUCT mfpcs;
		mfpcs.pPMuzzleFX		= pMuzzleFX->pPMuzzleFX;
		mfpcs.bPlayerView		= m_cs.bPlayerView;
		mfpcs.vPos				= m_cs.vPos;
		mfpcs.rRot				= m_cs.rRot;
        mfpcs.hFiredFrom        = m_cs.bPlayerView ? LTNULL : m_cs.hParent;

		if (!m_Particle.GetObject())
		{
			if (m_Particle.Init(&mfpcs))
			{
                m_Particle.CreateObject(m_pClientDE);

				// Make camera-relative if player view...

				if (m_cs.bPlayerView)
				{
					if (m_Particle.GetObject())
					{
						uint32 dwFlags = m_pClientDE->GetObjectFlags(m_Particle.GetObject());

						if (g_vtReallyClose.GetFloat())
						{
							m_pClientDE->SetObjectFlags(m_Particle.GetObject(), dwFlags | FLAG_REALLYCLOSE);
						}
						else
						{
							m_pClientDE->SetObjectFlags(m_Particle.GetObject(), dwFlags & ~FLAG_REALLYCLOSE);
						}
					}
				}
			}
		}
		else
		{
			m_Particle.Reset(mfpcs);
		}

        m_bUsingParticles = LTTRUE;
	}

    return LTTRUE;
}