Ejemplo n.º 1
0
CWeapon * CPedSA::GiveWeapon ( eWeaponType weaponType, unsigned int uiAmmo, eWeaponSkill skill )
{
    if ( weaponType != WEAPONTYPE_UNARMED )
    {
        CWeaponInfo* pInfo = pGame->GetWeaponInfo ( weaponType, skill );
        if ( pInfo )
        {
            int iModel = pInfo->GetModel();

            if ( iModel )
            {
                CModelInfo * pWeaponModel = pGame->GetModelInfo ( iModel );
                if ( pWeaponModel )
                {
                    pWeaponModel->Request ( BLOCKING, "CPedSA::GiveWeapon" );
                    pWeaponModel->MakeCustomModel ();
                }
            }
            // If the weapon is satchels, load the detonator too
            if ( weaponType == WEAPONTYPE_REMOTE_SATCHEL_CHARGE )
            {
                /*int iModel = pGame->GetWeaponInfo ( WEAPONTYPE_DETONATOR )->GetModel();
                if ( iModel )
                {
                    CModelInfo * pWeaponModel = pGame->GetModelInfo ( iModel );
                    if ( pWeaponModel )
                    {
                        pWeaponModel->Request ( true, true );
                    }
                }*/
                // Load the weapon and give it properly so getPedWeapon shows the weapon is there.
                GiveWeapon( WEAPONTYPE_DETONATOR, 1, WEAPONSKILL_STD );
            }
        }
    }

    DWORD dwReturn = 0;
    DWORD dwFunc = FUNC_GiveWeapon;
    DWORD dwThis = (DWORD)this->GetInterface();
    _asm
    {
        mov     ecx, dwThis
        push    1
        push    uiAmmo
        push    weaponType
        call    dwFunc
        mov     dwReturn, eax
    }

    CWeapon* pWeapon = GetWeapon ( (eWeaponSlot)dwReturn );

    return pWeapon;
}
Ejemplo n.º 2
0
bool CClientModelRequestManager::RequestBlocking ( unsigned short usModelID )
{
    // Grab the model info
    CModelInfo* pInfo = g_pGame->GetModelInfo ( usModelID );
    if ( pInfo )
    {
        pInfo->Request ( TRUE, TRUE );
        pInfo->MakeCustomModel ();
        return true;
    }

    // Bad model ID probably.
    return false;
}
bool CClientModelRequestManager::RequestBlocking ( unsigned short usModelID, const char* szTag )
{
    // Grab the model info
    CModelInfo* pInfo = g_pGame->GetModelInfo ( usModelID );
    if ( pInfo )
    {
        pInfo->Request ( BLOCKING, szTag );
        if ( pInfo->IsLoaded () )
        {
            pInfo->MakeCustomModel ();
            return true;
        }
        OutputDebugLine ( SString ( "[Models] RequestBlocking failed for id %d", usModelID ) );
    }

    // Bad model ID probably.
    return false;
}
Ejemplo n.º 4
0
bool CClientModelRequestManager::Request ( unsigned short usModelID, CClientEntity* pRequester )
{
    assert ( pRequester );
    SClientModelRequest* pEntry;

    // Grab the model info for that model
    CModelInfo* pInfo = g_pGame->GetModelInfo ( usModelID );
    if ( pInfo )
    {
        // Has it already requested something?
        list < SClientModelRequest* > ::iterator iter;
        if ( GetRequestEntry ( pRequester, iter ) )
        {
            // Get the entry
            pEntry = *iter;

            // The same model?
            if ( pInfo == pEntry->pModel )
            {
                // He has to wait more for it
                return false;
            }
            else
            {
                // Remove the reference to the old model
                pEntry->pModel->RemoveRef ();

                // Is it loaded?
                if ( pInfo->IsLoaded () )
                {
                    // Delete it, remove the it from the list and return true.
                    delete pEntry;
                    m_Requests.erase ( iter );

                    pInfo->MakeCustomModel ();
                    return true;
                }
                else
                {
                    // If not loaded. Replace the model we're going to load.
                    // Also remember that we requested it now.
                    pEntry->pModel = pInfo;
                    pEntry->dwTimeRequested = timeGetTime ();

                    // Start loading the new model.
                    pInfo->AddRef ( false );

                    // He has to wait for it.
                    return false;
                }
            }
        }
        else
        {
            // Already loaded? Don't bother adding to the list.
            if ( pInfo->IsLoaded () )
            {
                pInfo->MakeCustomModel ();

                return true;
            }

            // Boost loading priority if the object is close to the local player
            bool bHighPriority = false;
            if ( pRequester->GetDistanceBetweenBoundingSpheres ( g_pClientGame->GetLocalPlayer () ) < 20 )
                bHighPriority = true;

            // Request it
            pInfo->AddRef ( false, bHighPriority );

            // Add him to the list over models we're waiting for.
            pEntry = new SClientModelRequest;
            pEntry->pModel = pInfo;
            pEntry->pEntity = pRequester;
            pEntry->dwTimeRequested = timeGetTime ();
            m_Requests.push_back ( pEntry );

            // Return false. Caller needs to wait.
            return false;
        }
    }

    // Error, model is bad. Caller should not do this.
    return false;
}
bool CClientModelRequestManager::Request ( unsigned short usModelID, CClientEntity* pRequester )
{
    assert ( pRequester );
    SClientModelRequest* pEntry;

    // Grab the model info for that model
    CModelInfo* pInfo = g_pGame->GetModelInfo ( usModelID );
    if ( pInfo )
    {
        // Has it already requested something?
        list < SClientModelRequest* > ::iterator iter;
        if ( GetRequestEntry ( pRequester, iter ) )
        {
            // Get the entry
            pEntry = *iter;

            // The same model?
            if ( pInfo == pEntry->pModel )
            {
                // He has to wait more for it
                return false;
            }
            else
            {
                // Remove the reference to the old model
                pEntry->pModel->RemoveRef ();

                // Is it loaded?
                if ( pInfo->IsLoaded () )
                {
                    // Delete it, remove the it from the list and return true.
                    delete pEntry;
                    m_Requests.erase ( iter );

                    pInfo->MakeCustomModel ();
                    return true;
                }
                else
                {
                    // If not loaded. Replace the model we're going to load.
                    // Also remember that we requested it now.
                    pEntry->pModel = pInfo;
                    pEntry->requestTimer.Reset ();

                    // Start loading the new model.
                    pInfo->ModelAddRef ( NON_BLOCKING, "CClientModelRequestManager::Request" );

                    // He has to wait for it.
                    return false;
                }
            }
        }
        else
        {
            // Already loaded? Don't bother adding to the list.
            if ( pInfo->IsLoaded () )
            {
                pInfo->MakeCustomModel ();

                return true;
            }

            // Request it
            pInfo->ModelAddRef ( NON_BLOCKING, "CClientModelRequestManager::Request #2" );

            // Add him to the list over models we're waiting for.
            pEntry = new SClientModelRequest;
            pEntry->pModel = pInfo;
            pEntry->pEntity = pRequester;
            pEntry->requestTimer.SetMaxIncrement ( 500 );
            pEntry->requestTimer.Reset ();
            m_Requests.push_back ( pEntry );

            // Return false. Caller needs to wait.
            return false;
        }
    }

    // Error, model is bad. Caller should not do this.
    return false;
}