Exemplo n.º 1
0
LTBOOL CPickupItemFX::Init(SFXCREATESTRUCT* psfxCreateStruct)
{
    if (!CSpecialFX::Init(psfxCreateStruct)) return LTFALSE;

	PICKUPITEMCREATESTRUCT* pPICS = (PICKUPITEMCREATESTRUCT*)psfxCreateStruct;

	m_bRotate = pPICS->bRotate;
	m_bBounce = pPICS->bBounce;
	m_nTeamId = pPICS->m_nTeamId;

	// Shutdown any currently playing FX...

	if( m_linkClientFX.IsValid() )
	{
		g_pClientFXMgr->ShutdownClientFX( &m_linkClientFX );
	}


	if( pPICS->sClientFX.length() )
	{
		CLIENTFX_CREATESTRUCT fxInit( pPICS->sClientFX.c_str(), FXFLAG_LOOP, m_hServerObject );
		g_pClientFXMgr->CreateClientFX( &m_linkClientFX, fxInit, true );
	}
	
    return LTTRUE;
}
Exemplo n.º 2
0
LTBOOL CPickupItemFX::OnServerMessage( ILTMessage_Read *pMsg )
{
	if( !CSpecialFX::OnServerMessage( pMsg ))
		return LTFALSE;
	
	uint8 nMsgId = pMsg->Readuint8();

	switch( nMsgId )
	{
		case PUFX_CLIENTFX:
		{
			char szClientFX[256] = {0};

			pMsg->ReadString( szClientFX, ARRAY_LEN( szClientFX ));

			// Shutdown any currently playing FX...

			if( m_linkClientFX.IsValid() )
			{
				g_pClientFXMgr->ShutdownClientFX( &m_linkClientFX );
			}


			if( szClientFX[0] )
			{
				CLIENTFX_CREATESTRUCT fxInit( szClientFX, FXFLAG_LOOP, m_hServerObject );
				g_pClientFXMgr->CreateClientFX( &m_linkClientFX, fxInit, true );
			}
		}
		break;

		case PUFX_TEAMID:
		{
			m_nTeamId = pMsg->Readuint8( );
		}
		break;

		default:
		break;
		
	}

	return LTTRUE;
}
Exemplo n.º 3
0
WeaponState CClientWeaponDisc::Update( bool bFire,
                                       FireType eFireType /*=FT_NORMAL_FIRE*/ )
{
/// DEBUG CODE
    if ( g_bDisplayClientWeaponTarget )
    {
        // find the point we're aiming at
        LTVector vTargetPoint;
        CalculatePointGuidedTarget( &vTargetPoint );
        static CLIENTFX_LINK s_pTargetPoint;
        if ( s_pTargetPoint.m_pInstance )
        {
            // back it off just a little
            LTVector vBackOff;
            CalculateControlDirection( &vBackOff );
            vBackOff *= -5.0f;
            vTargetPoint += vBackOff;
            s_pTargetPoint.m_pInstance->SetPos( vTargetPoint, vTargetPoint );
        }
        else
        {
            // create the target point
            CLIENTFX_CREATESTRUCT fxInit( "DISC_target", FXFLAG_LOOP , vTargetPoint );

            g_pClientFXMgr->CreateClientFX( &s_pTargetPoint, fxInit, LTTRUE );
            if ( s_pTargetPoint.m_pInstance )
            {
                s_pTargetPoint.m_pInstance->m_bPlayerView = LTFALSE;
            }
        }
    }
/// DEBUG CODE

    //
    // See if we are disabled...If so don't allow any weapon stuff...
    if ( m_bDisabled )
    {
        return W_IDLE;
    }

    if ( m_bDiscNeedsUpdates )
    {
        CAutoMessage cMsg;
        LTRESULT ltResult;

        cMsg.Writeuint8( MID_PROJECTILE );

        // write the projectile message subtype
        cMsg.Writeuint8( MPROJ_UPDATE_CONTROL_LINE );

        // pass a control vector, which is a vector pointing
        // straight out in front of the player
        LTVector vControlDirection;
        CalculateControlDirection( &vControlDirection );

        // get the control position (in this case, the camera position)
        // get the camera
        HOBJECT hCamera = g_pPlayerMgr->GetCamera();
        ASSERT( 0 != hCamera );
        LTVector vControlPosition;
        ltResult = g_pLTClient->GetObjectPos( hCamera, &vControlPosition );
        ASSERT( LT_OK == ltResult );

        // write the control vector
        cMsg.WriteLTVector( vControlDirection );

        // write the control position
        cMsg.WriteLTVector( vControlPosition );

        // send the message
        ltResult = g_pLTClient->SendToServer(
                       cMsg.Read(),
                       MESSAGE_GUARANTEED
                   );
        ASSERT( LT_OK == ltResult );
    }

    return CClientWeapon::Update( bFire, eFireType );
}
Exemplo n.º 4
0
bool CClientWeaponDisc::HandleMessageProjectile( uint8 messageID,
        ILTMessage_Read *pMsg )
{
    // get the projectile message subtype
    uint8 nProjectileMessageType = pMsg->Readuint8( );

    switch ( nProjectileMessageType )
    {
    case MPROJ_RETURNING:
    {
        //
        // disc is returning
        //

        // stop sending updates to the disc
        m_bDiscNeedsUpdates = false;

        // we handled message, return true
        return true;
    }
    break;

    case MPROJ_RETURNING_DISTANCE_THRESHOLD:
    {
        // don't handle this currently
    }
    break;

    case MPROJ_RETURNED:
    {
        //
        // we now have the disc!
        //

        // get the extra information to be sure

        // get the weapon id
        uint8 nWeaponId = pMsg->Readuint8();

        // get the ammo id
        uint8 nAmmoId = pMsg->Readuint8();

        // get the number of ammos (not needed, cleaning out the message)
        uint8 nAmmoAmount = pMsg->Readuint8();

        // Since the weapon cannot switch until we get
        // the disc back, make sure the returned type
        // is the same weapon and ammo type
        ASSERT( m_nWeaponId == nWeaponId );
        ASSERT( m_nAmmoId == nAmmoId );

        // disc is no longer flying
        m_bIsDiscActive = false;

        // stop sending updates to the disc
        m_bDiscNeedsUpdates = false;

        // reset the active timer
        m_fTimeDiscActive = -1.0f;

        // give the disc back
        IncrementAmmo();

        // we handled message, return true
        return true;
    }
    break;

    case MPROJ_BLOCKED:
    {
        // play a clientfx based on the defense type

        // get the type of defense
        uint8 nDefendType = pMsg->Readuint8( );

        // get the damage percentage
        float fDefendPercentage = pMsg->Readfloat( );

        DISCCLASSDATA const *pDiscData = dynamic_cast< DISCCLASSDATA const * >( m_pAmmo->pProjectileFX->pClassData );

        // no arm defense using the disc
        ASSERT( MPROJ_START_ARM_BLOCK != nDefendType );

        CLIENTFX_LINK clientFXLink;
        uint32 dwFXFlags = FXFLAG_SMOOTHSHUTDOWN | FXFLAG_REALLYCLOSE;
        if ( MPROJ_START_SWAT_BLOCK == nDefendType )
        {
            if ( pDiscData->fSwatCriticalDefendThreshold <= fDefendPercentage )
            {
                // create the critical defense effect
                CLIENTFX_CREATESTRUCT fxInit( pDiscData->szSwatCriticalDefendPVFXName, dwFXFlags, m_hObject );

                // create the client fx
                g_pClientFXMgr->CreateClientFX( &clientFXLink, fxInit, LTTRUE );
                if ( clientFXLink.m_pInstance )
                {
                    // setup the flags
                    clientFXLink.m_pInstance->m_bPlayerView = LTFALSE;
                }
            }
            else
            {
                // create the normal defense effect
                CLIENTFX_CREATESTRUCT fxInit( pDiscData->szSwatDefendPVFXName, dwFXFlags, m_hObject );

                // create the client fx
                g_pClientFXMgr->CreateClientFX( &clientFXLink, fxInit, LTTRUE );
                if ( clientFXLink.m_pInstance )
                {
                    // setup the flags
                    clientFXLink.m_pInstance->m_bPlayerView = LTTRUE;
                }
            }
        }
        else
        {
            // create the hold defense effect
            CLIENTFX_CREATESTRUCT fxInit( pDiscData->szHoldDefendPVFXName, dwFXFlags, m_hObject );

            // set this flag and during the next animation update the hold impact
            // animation will play
            m_bPlayImpactHoldAnimation = true;

            // create the client fx
            g_pClientFXMgr->CreateClientFX( &clientFXLink, fxInit, LTTRUE );
            if ( clientFXLink.m_pInstance )
            {
                // setup the flags
                clientFXLink.m_pInstance->m_bPlayerView = LTTRUE;
            }
        }
    }
    break;

    default:
    {
        // The projectile message type is malformed...
        // perhaps the message was created improperly,
        // or perhaps the client weapon is not
        // designed to handle these messages.
        ASSERT( 0 );
    }
    break;
    };  // switch( nProjectileMessageType )

    return false;
}