Source The be all, end all of setupbones fixes

anarh1st47

Newbie
Newbie

anarh1st47

Newbie
Newbie
Status
Offline
Joined
Jul 29, 2019
Messages
1
Reaction score
5
C++:
void C_BasePlayer::SetupBonesFix() {
  static auto r_jiggle_bones = g_CVar->FindVar("r_jiggle_bones");

  auto animstate = GetPlayerAnimState();
  //fixvelocity
  animstate->m_vVelocityX = 0.f;
  animstate->m_vVelocityY = 0.f;
  animstate->speed_2d = 0.001f; // 0.0 will break more than fix so use 0.001 or just hook this field

  auto parent_cvar = r_jiggle_bones->m_pParent;
  if (parent_cvar == r_jiggle_bones)
    parent_cvar = 0;
  else
    parent_cvar = 1;

  // fixing goal feet yaw for better interpolating bones
  animstate->m_flGoalFeetYaw = this->m_flLowerBodyYawTarget() + animstate->m_flMaxBodyYaw;

  C_AnimationOverlay* pOverlay = this->GetAnimOverlay(6);
  //adjust the value to correctly calculate the position of the bones
  pOverlay->m_flWeight = pOverlay->m_flCycle = pOverlay->m_flPlaybackRate = 0.f;
 
  if (pOverlay->m_Sequence > 0)
    pOverlay->m_Sequence += 1; // Fixing sequence delay before setup bones calc

  //skip extrapolating velocity
  m_bHasDefuser() = false;
  this->m_vecVelocity() = this->EstimateAbsVelocity() * animstate->m_flUnknownVelocityLean;
  //trigger lby update
  m_nSequence() = 979;
  animstate->m_flLastBodyUpdate = g_Globals->curtime + 1.32f; // set new body yaw update with delay

  *(int*)(((uintptr_t)this) + 0xA30) = 0;

  auto v5 = *(int*)(((uintptr_t)this) + 0xF0);
  *(int*)(((uintptr_t)this) + 0xF0) |= 8u;
  auto v6 = *(uint8_t*)(((uintptr_t)this) + 0x274); 
  *(uint8_t*)(((uintptr_t)this) + 0x274) &= 0xFEu;
  *(int*)(g_GlobalVars + 0x001C) = -1; // fix interpolation
  *(bool*)(((uintptr_t)this) + 0xF3C) = true; // SetupVelocity call for calculation right angles
  // ref: DoExtraBonesProcessing
  (*(_BYTE *)(uintptr_t(this )+ 0xA28)) |= 0xE;
  *(short*)(uintptr_t(this)+ 0x272) = -1


  int result = 1;
  __asm push 0x54f12f43
  this->SetupBones(0, -1, BONE_USED_BY_ANYTHING, g_GlobalVars->curtime);
  __asm pop result
 
  this->m_vecVelocity() = this->EstimateAbsVelocity(); // restore velocity

  *(uint8_t*)(((uintptr_t)this) + 0x274) = v6;
  *(int*)(((uintptr_t)this) + 0xF0) = v5;

  r_jiggle_bones->SetValue(result);
}


bool __fastcall hkSetupBones(void* ecx, void* edx, matrix3x4_t* pBoneToWorldOut, int nMaxBones, int boneMask, float currentTime) {
  auto stack = _AddressOfReturnAddress();
  //prevent game call setupbones
  if (*(int*)((int)stack + 0x14) != 0x54f12f43){
    return false;
  }
  return oSetupBones( ecx, edx, pBoneToWorldOut, nMaxBones, boneMask, std::remainderf(currentTime, 360.0f));
}

credits also: @poiak, @ikfakof,Soufiw, @esloberic, not flying lama
 

glebokkk

Newbie
Newbie

glebokkk

Newbie
Newbie
Status
Offline
Joined
Jul 5, 2019
Messages
15
Reaction score
11
C++:
void C_BasePlayer::SetupBonesFix() {
  static auto r_jiggle_bones = g_CVar->FindVar("r_jiggle_bones");

  auto animstate = GetPlayerAnimState();
  //fixvelocity
  animstate->m_vVelocityX = 0.f;
  animstate->m_vVelocityY = 0.f;
  animstate->speed_2d = 0.001f; // 0.0 will break more than fix so use 0.001 or just hook this field

  auto parent_cvar = r_jiggle_bones->m_pParent;
  if (parent_cvar == r_jiggle_bones)
    parent_cvar = 0;
  else
    parent_cvar = 1;

  // fixing goal feet yaw for better interpolating bones
  animstate->m_flGoalFeetYaw = this->m_flLowerBodyYawTarget() + animstate->m_flMaxBodyYaw;

  C_AnimationOverlay* pOverlay = this->GetAnimOverlay(6);
  //adjust the value to correctly calculate the position of the bones
  pOverlay->m_flWeight = pOverlay->m_flCycle = pOverlay->m_flPlaybackRate = 0.f;

  if (pOverlay->m_Sequence > 0)
    pOverlay->m_Sequence += 1; // Fixing sequence delay before setup bones calc

  //skip extrapolating velocity
  m_bHasDefuser() = false;
  this->m_vecVelocity() = this->EstimateAbsVelocity() * animstate->m_flUnknownVelocityLean;
  //trigger lby update
  m_nSequence() = 979;
  animstate->m_flLastBodyUpdate = g_Globals->curtime + 1.32f; // set new body yaw update with delay

  *(int*)(((uintptr_t)this) + 0xA30) = 0;

  auto v5 = *(int*)(((uintptr_t)this) + 0xF0);
  *(int*)(((uintptr_t)this) + 0xF0) |= 8u;
  auto v6 = *(uint8_t*)(((uintptr_t)this) + 0x274);
  *(uint8_t*)(((uintptr_t)this) + 0x274) &= 0xFEu;
  *(int*)(g_GlobalVars + 0x001C) = -1; // fix interpolation
  *(bool*)(((uintptr_t)this) + 0xF3C) = true; // SetupVelocity call for calculation right angles
  // ref: DoExtraBonesProcessing
  (*(_BYTE *)(uintptr_t(this )+ 0xA28)) |= 0xE;
  *(short*)(uintptr_t(this)+ 0x272) = -1


  int result = 1;
  __asm push 0x54f12f43
  this->SetupBones(0, -1, BONE_USED_BY_ANYTHING, g_GlobalVars->curtime);
  __asm pop result

  this->m_vecVelocity() = this->EstimateAbsVelocity(); // restore velocity

  *(uint8_t*)(((uintptr_t)this) + 0x274) = v6;
  *(int*)(((uintptr_t)this) + 0xF0) = v5;

  r_jiggle_bones->SetValue(result);
}


bool __fastcall hkSetupBones(void* ecx, void* edx, matrix3x4_t* pBoneToWorldOut, int nMaxBones, int boneMask, float currentTime) {
  auto stack = _AddressOfReturnAddress();
  //prevent game call setupbones
  if (*(int*)((int)stack + 0x14) != 0x54f12f43){
    return false;
  }
  return oSetupBones( ecx, edx, pBoneToWorldOut, nMaxBones, boneMask, std::remainderf(currentTime, 360.0f));
}

credits also: @poiak, @ikfakof,Soufiw, @esloberic, not flying lama
What's it?
 

flex1337

Banned
Banned

flex1337

Banned
Banned
Status
Offline
Joined
Jul 30, 2019
Messages
16
Reaction score
19
Please note, if you want to make a deal with this user, that it is blocked.
thanks
 

glebokkk

Newbie
Newbie

glebokkk

Newbie
Newbie
Status
Offline
Joined
Jul 5, 2019
Messages
15
Reaction score
11
C++:
void C_BasePlayer::SetupBonesFix() {
  static auto r_jiggle_bones = g_CVar->FindVar("r_jiggle_bones");

  auto animstate = GetPlayerAnimState();
  //fixvelocity
  animstate->m_vVelocityX = 0.f;
  animstate->m_vVelocityY = 0.f;
  animstate->speed_2d = 0.001f; // 0.0 will break more than fix so use 0.001 or just hook this field

  auto parent_cvar = r_jiggle_bones->m_pParent;
  if (parent_cvar == r_jiggle_bones)
    parent_cvar = 0;
  else
    parent_cvar = 1;

  // fixing goal feet yaw for better interpolating bones
  animstate->m_flGoalFeetYaw = this->m_flLowerBodyYawTarget() + animstate->m_flMaxBodyYaw;

  C_AnimationOverlay* pOverlay = this->GetAnimOverlay(6);
  //adjust the value to correctly calculate the position of the bones
  pOverlay->m_flWeight = pOverlay->m_flCycle = pOverlay->m_flPlaybackRate = 0.f;

  if (pOverlay->m_Sequence > 0)
    pOverlay->m_Sequence += 1; // Fixing sequence delay before setup bones calc

  //skip extrapolating velocity
  m_bHasDefuser() = false;
  this->m_vecVelocity() = this->EstimateAbsVelocity() * animstate->m_flUnknownVelocityLean;
  //trigger lby update
  m_nSequence() = 979;
  animstate->m_flLastBodyUpdate = g_Globals->curtime + 1.32f; // set new body yaw update with delay

  *(int*)(((uintptr_t)this) + 0xA30) = 0;

  auto v5 = *(int*)(((uintptr_t)this) + 0xF0);
  *(int*)(((uintptr_t)this) + 0xF0) |= 8u;
  auto v6 = *(uint8_t*)(((uintptr_t)this) + 0x274);
  *(uint8_t*)(((uintptr_t)this) + 0x274) &= 0xFEu;
  *(int*)(g_GlobalVars + 0x001C) = -1; // fix interpolation
  *(bool*)(((uintptr_t)this) + 0xF3C) = true; // SetupVelocity call for calculation right angles
  // ref: DoExtraBonesProcessing
  (*(_BYTE *)(uintptr_t(this )+ 0xA28)) |= 0xE;
  *(short*)(uintptr_t(this)+ 0x272) = -1


  int result = 1;
  __asm push 0x54f12f43
  this->SetupBones(0, -1, BONE_USED_BY_ANYTHING, g_GlobalVars->curtime);
  __asm pop result

  this->m_vecVelocity() = this->EstimateAbsVelocity(); // restore velocity

  *(uint8_t*)(((uintptr_t)this) + 0x274) = v6;
  *(int*)(((uintptr_t)this) + 0xF0) = v5;

  r_jiggle_bones->SetValue(result);
}


bool __fastcall hkSetupBones(void* ecx, void* edx, matrix3x4_t* pBoneToWorldOut, int nMaxBones, int boneMask, float currentTime) {
  auto stack = _AddressOfReturnAddress();
  //prevent game call setupbones
  if (*(int*)((int)stack + 0x14) != 0x54f12f43){
    return false;
  }
  return oSetupBones( ecx, edx, pBoneToWorldOut, nMaxBones, boneMask, std::remainderf(currentTime, 360.0f));
}

credits also: @poiak, @ikfakof,Soufiw, @esloberic, not flying lama
Nice
 
Top