Example #1
0
void CPedWeapons::SetAmmoInClip(DWORD dwAmmoInClip)
{
	CWeapon * pCurrentWeapon = GetCurrentWeapon();

	if(m_pPedWeapons && pCurrentWeapon)
	{
		WORD wClipSize = pCurrentWeapon->GetClipSize();

		if(dwAmmoInClip > wClipSize)
			dwAmmoInClip = wClipSize;

		DWORD dwCurrentAmmoInClip = pCurrentWeapon->GetAmmoInClip();
		pCurrentWeapon->SetAmmoInClip(dwAmmoInClip);

		DWORD dwCurrentAmmo = pCurrentWeapon->GetAmmoTotal();
		DWORD dwDifference = (dwAmmoInClip - dwCurrentAmmoInClip);

		if(dwDifference >= 25000)
			pCurrentWeapon->SetAmmoTotal(25000);

		DWORD dwNewAmmo = (dwCurrentAmmo + dwDifference);

		if(dwNewAmmo <= 25000)
			pCurrentWeapon->SetAmmoTotal(dwNewAmmo);
		else
			pCurrentWeapon->SetAmmoTotal(25000);
	}
}
Example #2
0
DWORD CPedWeapons::GetAmmoInClip()
{
	CWeapon * pCurrentWeapon = GetCurrentWeapon();

	if(m_pPedWeapons && pCurrentWeapon)
		return pCurrentWeapon->GetAmmoInClip();

	return 0;
}
Example #3
0
void CWeaponRPCs::TakeWeapon ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    // Read out weapon id and ammo amount
    SWeaponTypeSync weaponType;

    if ( bitStream.Read ( &weaponType )  )
    {
        unsigned char ucWeaponID = weaponType.data.ucWeaponType;

        CClientPed * pPed = m_pPedManager->Get ( pSource->GetID (), true );
        if ( pPed )
        {
            // Is the weapon id valid? (may not be neccessary, just being safe)
            if ( CClientPickupManager::IsValidWeaponID ( ucWeaponID ) )
            {
                // Have we ammo in packet? If so, we need to take the ammo, not weapon
                SWeaponAmmoSync ammo ( ucWeaponID, true, false );
                if ( bitStream.Read ( &ammo ) )
                {
                    unsigned short usAmmo = ammo.data.usTotalAmmo;

                    // Do we have the weapon?
                    CWeapon* pPlayerWeapon = pPed->GetWeapon ( (eWeaponType) ucWeaponID );
                    if ( pPlayerWeapon == NULL ) return;

                    unsigned char ucAmmoInClip = static_cast < unsigned char > ( pPlayerWeapon->GetAmmoInClip () );
                    pPlayerWeapon->SetAmmoInClip ( 0 );

                    unsigned long ulWeaponAmmo = pPlayerWeapon->GetAmmoTotal ();
                    if ( usAmmo > ulWeaponAmmo )
                        ulWeaponAmmo = 0;
                    else
                        ulWeaponAmmo -= usAmmo;

                    // Update the ammo
                    pPlayerWeapon->SetAmmoTotal ( ulWeaponAmmo );

                    if ( pPlayerWeapon->GetAmmoTotal () > ucAmmoInClip )
                        pPlayerWeapon->SetAmmoInClip ( ucAmmoInClip );
                    else if ( pPlayerWeapon->GetAmmoTotal () <= ucAmmoInClip )
                        pPlayerWeapon->SetAmmoInClip ( pPlayerWeapon->GetAmmoTotal () );
                }
                else
                {
                    // Don't change remote players weapons (affects sync)
                    if ( pPed->IsLocalPlayer () )
                    {
                        // Remove the weapon
                        pPed->RemoveWeapon ( static_cast < eWeaponType > ( ucWeaponID ) );
                    }
                }
            }
        }
    }
}
Example #4
0
void CWeaponRPCs::TakeWeaponAmmo ( NetBitStreamInterface& bitStream )
{
    ElementID ID;
    SWeaponTypeSync weaponType;
    if ( bitStream.ReadCompressed ( ID ) &&
         bitStream.Read ( &weaponType ) )
    {
        unsigned char ucWeaponID = weaponType.data.ucWeaponType;
        SWeaponAmmoSync ammo ( ucWeaponID, true, false );
        if ( bitStream.Read ( &ammo ) )
        {
            unsigned short usAmmo = ammo.data.usTotalAmmo;

            CClientPed * pPed = m_pPedManager->Get ( ID, true );
            if ( pPed )
            {
                // Valid weapon id?
                if ( !CClientPickupManager::IsValidWeaponID ( ucWeaponID ) ) return;

                // Do we have it?
                CWeapon* pPlayerWeapon = pPed->GetWeapon ( (eWeaponType) ucWeaponID );
                if ( pPlayerWeapon == NULL ) return;

                unsigned char ucAmmoInClip = static_cast < unsigned char > ( pPlayerWeapon->GetAmmoInClip () );
                pPlayerWeapon->SetAmmoInClip ( 0 );

                unsigned long ulWeaponAmmo = pPlayerWeapon->GetAmmoTotal ();
                if ( ulWeaponAmmo - usAmmo < 0 )
                    ulWeaponAmmo = 0;
                else
                    ulWeaponAmmo -= usAmmo;

                // Remove the weapon ammo
                pPlayerWeapon->SetAmmoTotal ( ulWeaponAmmo );

                if ( pPlayerWeapon->GetAmmoTotal () > ucAmmoInClip )
                    pPlayerWeapon->SetAmmoInClip ( ucAmmoInClip );
                else if ( pPlayerWeapon->GetAmmoTotal () <= ucAmmoInClip )
                    pPlayerWeapon->SetAmmoInClip ( pPlayerWeapon->GetAmmoTotal () );
            }
        }
    }
}
Example #5
0
LTBOOL CAIHelicopterStrategyShoot::Update()
{
	if ( !CAIHelicopterStrategy::Update() )
	{
        return LTFALSE;
	}

	if ( !m_hTarget )
	{
        return LTFALSE;
	}

	for ( int iWeapon = 0 ; iWeapon < GetAI()->GetNumWeapons() ; iWeapon++ )
	{
		CWeapon* pWeapon = GetAI()->GetWeapon(iWeapon);

		if ( m_aBursts[iWeapon].m_bFired && m_aBursts[iWeapon].m_bActive )
		{
			UpdateFiring(pWeapon, &m_aBursts[iWeapon]);

			m_aBursts[iWeapon].m_bFired = LTFALSE;
		}
		else
		{
			UpdateAiming(pWeapon, &m_aBursts[iWeapon]);
		}

		if ( 0 == pWeapon->GetAmmoInClip() )
		{
            pWeapon->ReloadClip(LTFALSE);
		}

		if ( 0 == pWeapon->GetParent()->GetAmmoCount(pWeapon->GetAmmoId()) )
		{
			pWeapon->GetParent()->AddAmmo(pWeapon->GetAmmoId(), 999999);
		}
	}

    return LTTRUE;
}
Example #6
0
void CWeaponRPCs::SetWeaponAmmo ( CClientEntity* pSource, NetBitStreamInterface& bitStream )
{
    SWeaponTypeSync weaponType;
    if ( bitStream.Read ( &weaponType ) )
    {
        unsigned char ucWeaponID = weaponType.data.ucWeaponType;
        SWeaponAmmoSync ammo ( ucWeaponID, true, true );

        if ( bitStream.Read ( &ammo ) )
        {
            unsigned short usAmmo = ammo.data.usTotalAmmo;
            unsigned short usAmmoInClip = ammo.data.usAmmoInClip;

            CClientPed * pPed = m_pPedManager->Get ( pSource->GetID (), true );
            if ( pPed )
            {
                // Valid weapon id?
                if ( !CClientPickupManager::IsValidWeaponID ( ucWeaponID ) ) return;

                // Do we have it?
                CWeapon* pPlayerWeapon = pPed->GetWeapon ( (eWeaponType) ucWeaponID );
                if ( pPlayerWeapon == NULL ) return;

                unsigned char ucAmmoInClip = static_cast < unsigned char > ( pPlayerWeapon->GetAmmoInClip () );
                pPlayerWeapon->SetAmmoInClip ( usAmmoInClip );
                pPlayerWeapon->SetAmmoTotal ( usAmmo );

                if ( !usAmmoInClip )
                {
                    if ( usAmmo > ucAmmoInClip )
                        pPlayerWeapon->SetAmmoInClip ( ucAmmoInClip );
                    else if ( usAmmo <= ucAmmoInClip )
                        pPlayerWeapon->SetAmmoInClip ( usAmmo );
                }
            }
        }
    }
}
Example #7
0
void DumpPlayer ( CClientPlayer* pPlayer, CFile *file )
{
    unsigned int uiIndex = 0;

    // Player
    file->Printf( "%s\n", "*** START OF PLAYER ***" );

    // Write the data
    file->Printf( "Nick: %s\n", pPlayer->GetNick () );
    
    CVector vecTemp;
    pPlayer->GetPosition ( vecTemp );
    file->Printf( "Position: %f %f %f\n", vecTemp.fX, vecTemp.fY, vecTemp.fZ );

    file->Printf( "Nametag text: %s\n", pPlayer->GetNametagText () );

    unsigned char ucR, ucG, ucB;
    pPlayer->GetNametagColor ( ucR, ucG, ucB );
    file->Printf( "Nametag color: %u %u %u\n", ucR, ucG, ucB );

    file->Printf( "Nametag show: %u\n", pPlayer->IsNametagShowing () );

    file->Printf( "Local player: %u\n", pPlayer->IsLocalPlayer () );
    file->Printf( "Dead: %u\n", pPlayer->IsDead () );

    file->Printf( "Exp aim: %u\n", pPlayer->IsExtrapolatingAim () );
    file->Printf( "Latency: %u\n", pPlayer->GetLatency () );

    file->Printf( "Last psync time: %u\n", pPlayer->GetLastPuresyncTime () );
    file->Printf( "Has con trouble: %u\n\n", pPlayer->HasConnectionTrouble () );

    CClientTeam* pTeam = pPlayer->GetTeam ();
    if ( pTeam )
        file->Printf( "Team: %s\n", pTeam->GetTeamName () );

    // Get the matrix
    RwMatrix matPlayer;
    pPlayer->GetMatrix ( matPlayer );

    file->Printf( "Matrix: vecRoll: %f %f %f\n", matPlayer.vRight.fX, matPlayer.vRight.fY, matPlayer.vRight.fZ );
    file->Printf( "        vecDir:  %f %f %f\n", matPlayer.vFront.fX, matPlayer.vFront.fY, matPlayer.vFront.fZ );
    file->Printf( "        vecWas:  %f %f %f\n", matPlayer.vUp.fX, matPlayer.vUp.fY, matPlayer.vUp.fZ );
    file->Printf( "        vecPos:  %f %f %f\n\n", matPlayer.vPos.fX, matPlayer.vPos.fY, matPlayer.vPos.fZ );

    file->Printf( "Euler rot: %f\n", pPlayer->GetCurrentRotation () );
    file->Printf( "Cam rot: %f\n", pPlayer->GetCameraRotation () );

    pPlayer->GetMoveSpeed ( vecTemp );
    file->Printf( "Move speed: %f %f %f\n", vecTemp.fX, vecTemp.fY, vecTemp.fZ );

    pPlayer->GetTurnSpeed ( vecTemp );
    file->Printf( "Turn speed: %f %f %f\n", vecTemp.fX, vecTemp.fY, vecTemp.fZ );

    CControllerState State;
    pPlayer->GetControllerState ( State );

    signed short* pController = reinterpret_cast < signed short* > ( &State );
    file->Printf( "CContr state: \n" );
    for ( uiIndex = 0; uiIndex < 36; uiIndex++ )
    {
        file->Printf( "State [%u] = %i\n", uiIndex, pController [uiIndex] );
    }

    pPlayer->GetLastControllerState ( State );

    pController = reinterpret_cast < signed short* > ( &State );
    file->Printf( "LContr state: \n" );
    for ( uiIndex = 0; uiIndex < 36; uiIndex++ )
    {
        file->Printf( "State [%u] = %i\n", uiIndex, pController [uiIndex] );
    }

    file->Printf( "\nVeh IO state: %i\n", pPlayer->GetVehicleInOutState () );
    file->Printf( "Visible: %u\n", pPlayer->IsVisible () );
    file->Printf( "Health: %f\n", pPlayer->GetHealth () );
    file->Printf( "Armor: %f\n", pPlayer->GetArmor () );
    file->Printf( "On screen: %u\n", pPlayer->IsOnScreen () );
    file->Printf( "Frozen: %u\n", pPlayer->IsFrozen () );
    file->Printf( "Respawn state: %i\n", pPlayer->GetRespawnState () );

    file->Printf( "Cur weapon slot: %i\n", static_cast < int > ( pPlayer->GetCurrentWeaponSlot () ) );
    file->Printf( "Cur weapon type: %i\n", static_cast < int > ( pPlayer->GetCurrentWeaponType () ) );

    CWeapon* pWeapon = pPlayer->GetWeapon ();
    if ( pWeapon )
    {
        file->Printf( "Cur weapon state: %i\n", static_cast < int > ( pWeapon->GetState () ) );
        file->Printf( "Cur weapon ammo clip: %u\n", pWeapon->GetAmmoInClip () );
        file->Printf( "Cur weapon ammo total: %u\n", pWeapon->GetAmmoTotal () );
    }

    CTaskManager* pTaskMgr = pPlayer->GetTaskManager ();
    if ( pTaskMgr )
    {
        // Primary task
        CTask* pTask = pTaskMgr->GetTask ( TASK_PRIORITY_PRIMARY );
        if ( pTask )
        {
            file->Printf( "Primary task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Primary task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Primary task: none\n" );

        // Physical response task
        pTask = pTaskMgr->GetTask ( TASK_PRIORITY_PHYSICAL_RESPONSE );
        if ( pTask )
        {
            file->Printf( "Physical response task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Physical response task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Physical response task: none\n" );

        // Event response task temp
        pTask = pTaskMgr->GetTask ( TASK_PRIORITY_EVENT_RESPONSE_TEMP );
        if ( pTask )
        {
            file->Printf( "Event rsp tmp task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Event rsp tmp task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Event rsp tmp task: none\n" );

        // Event response task nontemp
        pTask = pTaskMgr->GetTask ( TASK_PRIORITY_EVENT_RESPONSE_NONTEMP );
        if ( pTask )
        {
            file->Printf( "Event rsp nontmp task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Event rsp nontmp task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Event rsp nontmp task: none\n" );

        // Event response task nontemp
        pTask = pTaskMgr->GetTask ( TASK_PRIORITY_DEFAULT );
        if ( pTask )
        {
            file->Printf( "Default task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Default task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Default task: none\n" );

        // Secondary attack
        pTask = pTaskMgr->GetTaskSecondary ( TASK_SECONDARY_ATTACK );
        if ( pTask )
        {
            file->Printf( "Secondary attack task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Secondary attack task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Secondary attack task task: none\n" );

        // Secondary duck
        pTask = pTaskMgr->GetTaskSecondary ( TASK_SECONDARY_DUCK );
        if ( pTask )
        {
            file->Printf( "Secondary duck task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Secondary duck task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Secondary duck task task: none\n" );

        // Secondary say
        pTask = pTaskMgr->GetTaskSecondary ( TASK_SECONDARY_SAY );
        if ( pTask )
        {
            file->Printf( "Secondary say task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Secondary say task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Secondary say task task: none\n" );

        // Secondary facial complex
        pTask = pTaskMgr->GetTaskSecondary ( TASK_SECONDARY_FACIAL_COMPLEX );
        if ( pTask )
        {
            file->Printf( "Secondary facial task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Secondary facial task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Secondary facial task task: none\n" );

        // Secondary partial anim
        pTask = pTaskMgr->GetTaskSecondary ( TASK_SECONDARY_PARTIAL_ANIM );
        if ( pTask )
        {
            file->Printf( "Secondary partial anim task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Secondary partial anim task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Secondary partial anim task task: none\n" );

        // Secondary IK
        pTask = pTaskMgr->GetTaskSecondary ( TASK_SECONDARY_IK );
        if ( pTask )
        {
            file->Printf( "Secondary IK task name: %s\n", pTask->GetTaskName () );
            file->Printf( "Secondary IK task type: %i\n", pTask->GetTaskType () );
        }
        else
            file->Printf( "Secondary IK task task: none\n" );
    }

    float fX, fY;
    pPlayer->GetAim ( fX, fY );
    file->Printf( "Aim: %f %f\n", fX, fY );

    vecTemp = pPlayer->GetAimSource ();
    file->Printf( "Aim source: %f %f %f\n", vecTemp.fX, vecTemp.fY, vecTemp.fZ );

    vecTemp = pPlayer->GetAimTarget ();
    file->Printf( "Aim target: %f %f %f\n", vecTemp.fX, vecTemp.fY, vecTemp.fZ );

    file->Printf( "Veh aim anim: %u\n", pPlayer->GetVehicleAimAnim () );
    file->Printf( "Ducked: %u\n", pPlayer->IsDucked () );
    file->Printf( "Wearing googles: %u\n", pPlayer->IsWearingGoggles () );
    file->Printf( "Has jetpack: %u\n", pPlayer->HasJetPack () );
    file->Printf( "In water: %u\n", pPlayer->IsInWater () );
    file->Printf( "On ground: %u\n", pPlayer->IsOnGround () );
    file->Printf( "Is climbing: %u\n", pPlayer->IsClimbing () );
    file->Printf( "Interiour: %u\n", pPlayer->GetInterior () );
    file->Printf( "Fight style: %u\n", static_cast < int > ( pPlayer->GetFightingStyle () ) );
    file->Printf( "Satchel count: %u\n", pPlayer->CountProjectiles ( WEAPONTYPE_REMOTE_SATCHEL_CHARGE ) );

    CRemoteDataStorage* pRemote = pPlayer->GetRemoteData ();
    if ( pRemote )
    {
        vecTemp = pRemote->GetAkimboTarget ();
        file->Printf( "Akimbo target: %f %f %f\n", vecTemp.fX, vecTemp.fY, vecTemp.fZ );
        file->Printf( "Akimbo aim up: %u\n", pRemote->GetAkimboTargetUp () );
    }
    else
        file->Printf( "Remote: no\n" );

    file->Printf( "Using gun: %u\n", pPlayer->IsUsingGun () );
    file->Printf( "Entering veh: %u\n", pPlayer->IsEnteringVehicle () );
    file->Printf( "Getting jacked: %u\n", pPlayer->IsGettingJacked () );
    file->Printf( "Alpha: %u\n", pPlayer->GetAlpha () );
    

    file->Printf( "Stats:\n" );

    for ( uiIndex = 0; uiIndex < NUM_PLAYER_STATS; uiIndex++ )
    {
        file->Printf( "Stat [%u] = %f\n", uiIndex, pPlayer->GetStat ( uiIndex ) );
    }

    file->Printf( "Streamed in: %u\n", pPlayer->IsStreamedIn () );


    file->Printf( "Model: %u\n", pPlayer->GetModel () );

    // Write model data
    CModelInfo* pInfo = g_pGame->GetModelInfo ( pPlayer->GetModel () );
    file->Printf( "Model ref count: %i\n", pInfo->GetRefCount () );
    file->Printf( "Model loaded: %u\n", pInfo->IsLoaded () );
    file->Printf( "Model valid: %u\n", pInfo->IsValid () );

    // End of player
    file->Printf( "%s", "\n*** END OF PLAYER ***\n\n\n\n" );
}