예제 #1
0
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 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;
}