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

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


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

在下文中一共展示了CClientPlayer::GetCurrentWeaponSlot方法的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: DrawDefault

void CNametags::DrawDefault()
{
    // Grab the resolution width and height
    static float fResWidth = static_cast<float>(g_pCore->GetGraphics()->GetViewportWidth());
    static float fResHeight = static_cast<float>(g_pCore->GetGraphics()->GetViewportHeight());

    // Got any players that are not local?
    if (m_pPlayerManager->Count() <= 1)
        return;

    list<CClientPlayer*> playerTags;

    // Grab the local player
    CClientPlayer* pLocalPlayer = m_pPlayerManager->GetLocalPlayer();
    if (!pLocalPlayer)
        return;

    CClientVehicle* pSniperTargetedVehicle = NULL;
    CClientPlayer*  pSniperTargetedPlayer = NULL;

    // Grab our current weapon slot. Use screen center if melee or none
    eWeaponSlot eSlot = pLocalPlayer->GetCurrentWeaponSlot();
    if (eSlot >= WEAPONSLOT_TYPE_HANDGUN && eSlot <= WEAPONSLOT_TYPE_RIFLE)
    {
        CVector vecOrigin, vecTarget;
        pLocalPlayer->GetShotData(&vecOrigin, &vecTarget);

        // 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;
        flags.bSeeThroughStuff = true;
        flags.bIgnoreSomeObjectsForCamera = false;
        flags.bShootThroughStuff = true;
        g_pGame->GetWorld()->ProcessLineOfSight(&vecOrigin, &vecTarget, &pColPoint, &pEntity, flags);
        if (pColPoint)
            pColPoint->Destroy();

        // Un-ignore the local player
        pLocalPlayer->WorldIgnore(false);

        // Did we find an entity?
        if (pEntity)
        {
            // Grab the CClientEntity belonging to this game_sa entity
            CClientEntity* pClientEntity = reinterpret_cast<CClientEntity*>(pEntity->GetStoredPointer());
            if (pClientEntity)
            {
                // Is it a vehicle? Is it a ped?
                eClientEntityType EntityType = pClientEntity->GetType();
                switch (EntityType)
                {
                    case CCLIENTVEHICLE:
                    {
                        pSniperTargetedVehicle = static_cast<CClientVehicle*>(pClientEntity);
                        break;
                    }
                    case CCLIENTPLAYER:
                    {
                        pSniperTargetedPlayer = static_cast<CClientPlayer*>(pClientEntity);
                        break;
                    }
                    default:
                        break;
                }
            }
        }
    }

    // Grab the local player vehicle
    CClientVehicle* pLocalVehicle = pLocalPlayer->GetOccupiedVehicle();
    CVehicle*       pLocalGameVehicle = NULL;
    if (pLocalVehicle)
        pLocalGameVehicle = pLocalVehicle->GetGameVehicle();

    CMatrix CameraMatrix;
    g_pGame->GetCamera()->GetMatrix(&CameraMatrix);

    // Remove collision from our local vehicle (if we have one)
    if (pLocalVehicle)
        pLocalVehicle->WorldIgnore(true);

    // Draw the nametags we need to
    CVector                                     vecPlayerPosition;
    CClientVehicle*                             pPlayerVehicle = NULL;
    float                                       fDistanceExp;
    bool                                        bCollision;
    CColPoint*                                  pColPoint = NULL;
    CEntity*                                    pGameEntity = NULL;
    CClientEntity*                              pEntity = NULL;
    CClientPlayer*                              pPlayer;
    CClientStreamElement*                       pElement;
//.........这里部分代码省略.........
开发者ID:ccw808,项目名称:mtasa-blue,代码行数:101,代码来源:CNametags.cpp

本文标签属性:

示例:示例英文

代码:代码大全可复制

CClientPlayer:CClientPlayer

GetCurrentWeaponSlot:GetCurrentWeaponSlot

上一篇:分辨率有哪几种(分辨率的概念)
下一篇:水稻常见的病虫害有哪些?(水稻常见水稻常见病虫害有哪些病虫害防治措施及防治措施)

为您推荐