当前位置: 首页>>代码示例>>C++>>正文


C++ CClientPlayer::GetCurrentWeaponType方法代码示例

本文整理汇总了C++中CClientPlayer::GetCurrentWeaponType方法的典型用法代码示例。如果您正苦于以下问题:C++ CClientPlayer::GetCurrentWeaponType方法的具体用法?C++ CClientPlayer::GetCurrentWeaponType怎么用?C++ CClientPlayer::GetCurrentWeaponType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CClientPlayer的用法示例。


在下文中一共展示了CClientPlayer::GetCurrentWeaponType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawFromAim

void CNametags::DrawFromAim()
{
    unsigned long ulCurrentTime = CClientTime::GetTime();

    // Got any players that are not local?
    if (m_pPlayerManager->Count() > 1)
    {
        // Grab the local player
        CClientPlayer* pLocalPlayer = m_pPlayerManager->GetLocalPlayer();
        if (pLocalPlayer)
        {
            // Grab the current time and the camera
            unsigned long ulCurrentTime = CClientTime::GetTime();
            CCamera*      pCamera = g_pGame->GetCamera();

            // Grab our controller state
            CControllerState State;
            g_pGame->GetPad()->GetCurrentControllerState(&State);

            // Grab our current weapon slot. Use screen center if melee or none
            CVector     vecStart;
            CVector     vecTarget;
            eWeaponSlot eSlot = pLocalPlayer->GetCurrentWeaponSlot();
            if (eSlot == WEAPONSLOT_TYPE_UNARMED || eSlot == WEAPONSLOT_TYPE_MELEE || eSlot == WEAPONSLOT_TYPE_RIFLE || eSlot == WEAPONSLOT_TYPE_THROWN ||
                eSlot == WEAPONSLOT_TYPE_SPECIAL || eSlot == WEAPONSLOT_TYPE_GIFT || eSlot == WEAPONSLOT_TYPE_PARACHUTE || eSlot == WEAPONSLOT_TYPE_DETONATOR)
            {
                // Grab the active cam
                CCamera* pCamera = g_pGame->GetCamera();
                CCam*    pActive = pCamera->GetCam(pCamera->GetActiveCam());

                // Grab the camera matrix
                CMatrix matCamera;
                pCamera->GetMatrix(&matCamera);
                vecStart = matCamera.vPos;

                // Range
                float        fRange;
                eWeaponType  eWeapon = pLocalPlayer->GetCurrentWeaponType();
                float        fSkill = pLocalPlayer->GetStat(g_pGame->GetStats()->GetSkillStatIndex(eWeapon));
                CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager()->GetWeaponStatsFromSkillLevel(eWeapon, fSkill);
                if (pWeaponStat)
                {
                    fRange = pWeaponStat->GetTargetRange();
                }
                else
                {
                    fRange = MELEE_VISIBLE_RANGE;
                }

                // Find the target position
                CVector vecFront = *pActive->GetFront();
                vecFront.Normalize();
                vecTarget = *pActive->GetSource() + vecFront * fRange;
            }
            else
            {
                // Grab the weapon and keysync state. If it exists and he holds Target down
                CWeapon* pPlayerWeapon = pLocalPlayer->GetWeapon();
                if (pPlayerWeapon && State.RightShoulder1)
                {
                    // Grab the gun muzzle position
                    eWeaponType  eWeapon = pLocalPlayer->GetCurrentWeaponType();
                    float        fSkill = pLocalPlayer->GetStat(g_pGame->GetStats()->GetSkillStatIndex(eWeapon));
                    CWeaponStat* pWeaponStat = g_pGame->GetWeaponStatManager()->GetWeaponStatsFromSkillLevel(eWeapon, fSkill);

                    CVector vecGunMuzzle = *pWeaponStat->GetFireOffset();
                    pLocalPlayer->GetTransformedBonePosition(BONE_RIGHTWRIST, vecGunMuzzle);

                    // Grab the target point
                    pCamera->Find3rdPersonCamTargetVector(AIM_VISIBLE_RANGE, &vecGunMuzzle, &vecStart, &vecTarget);
                }
                else
                {
                    // Grab the active cam
                    CCam* pActive = pCamera->GetCam(pCamera->GetActiveCam());

                    // Grab the camera matrix
                    CMatrix matCamera;
                    pCamera->GetMatrix(&matCamera);
                    vecStart = matCamera.vPos;

                    // Find the target position
                    CVector vecFront = *pActive->GetFront();
                    vecFront.Normalize();
                    vecTarget = *pActive->GetSource() + vecFront * MELEE_VISIBLE_RANGE;
                }
            }

            // Ignore the local player for this
            pLocalPlayer->WorldIgnore(true);

            // Do the raycast
            CColPoint*        pColPoint = NULL;
            CEntity*          pEntity = NULL;
            SLineOfSightFlags flags;
            flags.bCheckBuildings = true;
            flags.bCheckVehicles = true;
            flags.bCheckPeds = true;
            flags.bCheckObjects = true;
            flags.bCheckDummies = true;
//.........这里部分代码省略.........
开发者ID:ccw808,项目名称:mtasa-blue,代码行数:101,代码来源:CNametags.cpp

示例2: Draw

void CNetworkStats::Draw ( void )
{
    // Time to update?
    if ( CClientTime::GetTime () >= m_ulLastUpdateTime + 1000 )
    {
        Update();
    }

    NetStatistics stats;
    g_pNet->GetNetworkStatistics ( &stats );

    // Draw the background
    float fResWidth = static_cast < float > ( g_pCore->GetGraphics ()->GetViewportWidth () );
    float fResHeight = static_cast < float > ( g_pCore->GetGraphics ()->GetViewportHeight () );

    // Grab the bytes sent/recv and datarate in the proper unit
    SString strBytesSent = GetDataUnit ( stats.bytesSent );
    SString strBytesRecv = GetDataUnit ( stats.bytesReceived );
    SString strRecvRate  = GetDataUnit ( Round ( m_fByteReceiveRate ) );
    SString strSendRate  = GetDataUnit ( Round ( m_fByteSendRate ) );

    CClientPlayer* pLocalPlayer = g_pClientGame->GetLocalPlayer ();
    bool bBulletSync = pLocalPlayer && g_pClientGame->GetWeaponTypeUsesBulletSync ( pLocalPlayer->GetCurrentWeaponType () );
    const SVehExtrapolateSettings& vehExtrapolateSettings = g_pClientGame->GetVehExtrapolateSettings ();

    SString strBuffer;

    // Select a string to print
    bool bHoldingCtrl = ( GetAsyncKeyState ( VK_CONTROL ) & 0x8000 ) != 0;
    if ( !bHoldingCtrl )
    {
        strBuffer = SString (
                "Ping: %u ms\n"
                "Messages in send buffer: %u\n"
                "Messages in resend buffer: %u\n"
                "Packets recv: %u\n"
                "Packets sent: %u\n"
                "Overall packet loss: %.2f%%\n"
                "Current packet loss: %.2f%%\n"
                "Bytes recv: %s\n"
                "Bytes sent: %s\n"
                "Datarate in/out: %s/s / %s/s\n"
                "Packet rate in/out: %u / %u\n"
                "BPS limit by CC: %llu\n"
                "BPS limit by OB: %llu\n"
                "Current wep bullet sync: %s\n"
                "Veh. Extrapolate amount: %d%%\n"
                "Veh. Extrapolate max: %dms\n"
                "Alternate pulse order: %s\n"
                "Client: %s\n"
                "Server: %s\n",
                g_pNet->GetPing (),
                stats.messagesInSendBuffer,
                stats.messagesInResendBuffer,
                stats.packetsReceived,
                stats.packetsSent,              
                stats.packetlossTotal,
                stats.packetlossLastSecond,
                strBytesRecv.c_str (),
                strBytesSent.c_str (),
                strRecvRate.c_str (),
                strSendRate.c_str (),
                (unsigned int)floor(m_fPacketReceiveRate + 0.5f),
                (unsigned int)floor(m_fPacketSendRate + 0.5f),                   
                stats.isLimitedByCongestionControl ? 1ULL : 0ULL,
                stats.isLimitedByOutgoingBandwidthLimit ? 1ULL : 0ULL,
                bBulletSync ? "On" : "Off",
                vehExtrapolateSettings.iScalePercent,
                vehExtrapolateSettings.iMaxMs,
                g_pClientGame->IsUsingAlternatePulseOrder() ? "Yes" : "No",
                *CStaticFunctionDefinitions::GetVersionSortable(),
                *g_pClientGame->GetServerVersionSortable ()
                );
    }
    else
    {
        NetRawStatistics& r = stats.raw;
        strBuffer += SString ( "messageSendBuffer %d,%d,%d,%d\n", r.messageSendBuffer[0], r.messageSendBuffer[1], r.messageSendBuffer[2], r.messageSendBuffer[3] );
        strBuffer += SString ( "messagesSent %d,%d,%d,%d\n", r.messagesSent[0], r.messagesSent[1], r.messagesSent[2], r.messagesSent[3] );
        strBuffer += SString ( "messageDataBitsSent %lld,%lld,%lld,%lld\n", r.messageDataBitsSent[0], r.messageDataBitsSent[1], r.messageDataBitsSent[2], r.messageDataBitsSent[3] );
        strBuffer += SString ( "messageTotalBitsSent %lld,%lld,%lld,%lld\n", r.messageTotalBitsSent[0], r.messageTotalBitsSent[1], r.messageTotalBitsSent[2], r.messageTotalBitsSent[3] );
        strBuffer += SString ( "packetsContainingOnlyAcknowlegements %d\n", r.packetsContainingOnlyAcknowlegements );
        strBuffer += SString ( "acknowlegementsSent %d\n", r.acknowlegementsSent );
        strBuffer += SString ( "acknowlegementsPending %d\n", r.acknowlegementsPending );
        strBuffer += SString ( "acknowlegementBitsSent %lld\n", r.acknowlegementBitsSent );
        strBuffer += SString ( "packetsContainingOnlyAcksAndResends %d\n", r.packetsContainingOnlyAcknowlegementsAndResends );
        strBuffer += SString ( "messageResends %d\n", r.messageResends );
        strBuffer += SString ( "messageDataBitsResent %lld\n", r.messageDataBitsResent );
        strBuffer += SString ( "messagesTotalBitsResent %lld\n", r.messagesTotalBitsResent );
        strBuffer += SString ( "messagesOnResendQueue %d\n", r.messagesOnResendQueue );
        strBuffer += SString ( "numberOfUnsplitMessages %d\n", r.numberOfUnsplitMessages );
        strBuffer += SString ( "numberOfSplitMessages %d\n", r.numberOfSplitMessages );
        strBuffer += SString ( "totalSplits %d\n", r.totalSplits );
        strBuffer += SString ( "packetsSent %d\n", r.packetsSent );
        strBuffer += SString ( "encryptionBitsSent %lld\n", r.encryptionBitsSent );
        strBuffer += SString ( "totalBitsSent %lld\n", r.totalBitsSent );
        strBuffer += SString ( "sequencedMessagesOutOfOrder %d\n", r.sequencedMessagesOutOfOrder );
        strBuffer += SString ( "sequencedMessagesInOrder %d\n", r.sequencedMessagesInOrder );
        strBuffer += SString ( "orderedMessagesOutOfOrder %d\n", r.orderedMessagesOutOfOrder );
        strBuffer += SString ( "orderedMessagesInOrder %d\n", r.orderedMessagesInOrder );
//.........这里部分代码省略.........
开发者ID:AdiBoy,项目名称:mtasa-blue,代码行数:101,代码来源:CNetworkStats.cpp


注:本文中的CClientPlayer::GetCurrentWeaponType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。