Вопрос Thirdperson is not working correctly

Начинающий
Статус
Оффлайн
Регистрация
10 Авг 2021
Сообщения
9
Реакции[?]
4
Поинты[?]
0
third person code:
C++:
 void C_Movement::ThirdPerson( ) {
      if ( !movementData->m_pLocal )
         return;

      if ( !g_Vars.misc.third_person )
         return;

      auto local = C_CSPlayer::GetLocalPlayer( );
      if ( !local || local != movementData->m_pLocal )
         return;

      C_WeaponCSBaseGun* Weapon = ( C_WeaponCSBaseGun* ) movementData->m_pLocal->m_hActiveWeapon( ).Get( );
      if (weapon) {
         auto weaponInfo = Weapon->GetCSWeaponData( );
         if (weaponInfo.IsValid( ) ) {
            if ( weaponInfo->m_iWeaponType == WEAPONTYPE_GRENADE && g_Vars.misc.off_third_person_on_grenade ) {
               Source::m_pInput->m_bCameraInThirdPerson = false;
               return;
            }
         }
      }

      static auto require_reset = false;
      static auto percent = 0.f;

      if ( !local->IsDead( ) )
         require_reset = false;

      static Vector vecCameraOffsetBackup = Vector( 0, 0, 0 );
      if ( !Source::m_pInput->m_bCameraInThirdPerson )
         vecCameraOffsetBackup = Source::m_pInput->m_vecCameraOffset;
      else
         Source::m_pInput->m_vecCameraOffset = vecCameraOffsetBackup;

      if ( g_Vars.misc.third_person && g_Vars.misc.third_person_bind.enabled && !local->IsDead( ) ) {
         Source::m_pInput->m_bCameraInThirdPerson = true;

         percent = Math::Clamp( percent + Source::m_pGlobalVars->frametime * 8.f, 0.f, 1.f );
         float ideal_distance = g_Vars.misc.third_person_dist * percent;

         QAngle view_angles;
         Source::m_pEngine->GetViewAngles( view_angles );

         QAngle inverse_angles;
         Source::m_pEngine->GetViewAngles( inverse_angles );
         inverse_angles.z = ideal_distance;

         Vector camForward, camRight, camUp;
         camForward = inverse_angles.ToVectors( &camRight, &camUp );

         CTraceFilterWorldAndPropsOnly filter;
         CGameTrace trace;
         Ray_tray;

         Vector eyePosition = movementData->m_pLocal->GetAbsOrigin( ) + movementData->m_pLocal->m_vecViewOffset( );

         Vector vecCamOffset = eyePosition + ( camForward * -ideal_distance ) + ( camRight * 1.f ) + ( camUp * 1.f );

         ray.Init( eyePosition, vecCamOffset, Vector( -4.0f, -4.0f, -4.0f ), Vector( 4.0f, 4.0f, 4.0f ) );
         Source::m_pEngineTrace->TraceRay( ray, MASK_SOLID & ~CONTENTS_MONSTER, &filter, &trace );

         view_angles.roll = ideal_distance * trace.fraction;

         Source::m_pInput->m_vecCameraOffset = Vector( view_angles.pitch, view_angles.yaw, view_angles.roll );

         movementData->m_pLocal->UpdateVisibilityAllEntities( );
      } else {
         percent = 0.f;
         Source::m_pInput->m_bCameraInThirdPerson = false;
      }

      if ( require_reset ) {
         movementData->m_pLocal->m_iObserverMode( ) = 5;
      }

      if ( movementData->m_pLocal->m_iObserverMode( ) == 4 )
         require_reset = true;
   }
IInput class:
C++:
#pragma once

class IInput
{
public:
    virtual void Init_All( void ) = 0;
    virtual void Shutdown_All( void ) = 0;
    virtual int GetButtonBits( int ) = 0;
    virtual void CreateMove( int sequence_number, float input_sample_frametime, bool active ) = 0;
    virtual void ExtraMouseSample( float frametime, bool active ) = 0;
    virtual bool WriteUsercmdDeltaToBuffer( int nSlot, void* buf, int from, int to, bool isnewcommand ) = 0;
    virtual void EncodeUserCmdToBuffer( void* buf, int slot ) = 0;
    virtual void DecodeUserCmdFromBuffer( void* buf, int slot ) = 0;

    charpad0[0xC]; // 0x00
    bool m_bTrackIRAvailable; // 0x0C
    bool m_bMouseInitialized; // 0x0D
    bool m_bMouseActive; // 0x0E
    charpad1[0x9A]; // 0x0F
    bool m_bCameraInThirdPerson; // 0xA9
    char pad2[ 0x2 ]; // 0xAA
    Vector m_vecCameraOffset; // 0xAC
    charpad3[0x38]; // 0xB8
    CUserCmd* m_pCommands; // 0xF0
    CVerifiedUserCmd* m_pVerifiedCommands; // 0xF4

    inline CUserCmd* GetUserCmd( int sequence_number );
    inline CVerifiedUserCmd* GetVerifiedCmd( int sequence_number );
};

CUserCmd* IInput::GetUserCmd( int sequence_number ) {
    using OriginalFn = CUserCmd* ( __thiscall* )( void*, int, int );
    return Memory::VCall< OriginalFn >( this, 8 )( this, 0, sequence_number );
}

CVerifiedUserCmd* IInput::GetVerifiedCmd( int sequence_number ) {
    auto verifiedCommands = *( CVerifiedUserCmd** )( reinterpret_cast< uint32_t >( this ) + 0xF4 );
    return &verifiedCommands[ sequence_number % MULTIPLAYER_BACKUP ];
}
My Issue is that the thirdperson isn't activating, I would appreciate any help or info thanks!
 
Начинающий
Статус
Оффлайн
Регистрация
16 Май 2021
Сообщения
3
Реакции[?]
0
Поинты[?]
0
Im only use:
C++:
m_pInput->m_vecCameraOffset = Vector(angles.x, angles.y, 255);
before you need hook sv_cheats. And you need set
C++:
m_pInput->m_isCameraInThirdPerson = (isButtonPushed && etc...)
 
Эксперт
Статус
Оффлайн
Регистрация
29 Мар 2021
Сообщения
1,596
Реакции[?]
605
Поинты[?]
46K
im gonna throw up:
QAngle view_angles;
Source::m_pEngine->GetViewAngles( view_angles );
QAngle inverse_angles;
Source::m_pEngine->GetViewAngles( inverse_angles );
inverse_angles.z = ideal_distance;
 
Сверху Снизу