IMKYZABITCHES

BG_WeaponFireRecoil [MW2][XBOX][TU8]

May 14th, 2015
878
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.32 KB | None | 0 0
  1. // ALL Reversed by Bitwise
  2. // EDIT: Valid seed address: 0x82539084
  3. // EDIT2: Address in Memory: 0x820E31F8
  4. float random(int iSeed)
  5. {
  6.     int ran = (*(int*)iSeed * 0x343FD) + 0x279EC3;
  7.     *(int*)iSeed = ran;
  8.     return float(ran >> 0x11) * 0.000031;
  9. }
  10.  
  11. #define fViewKickPitchLerp(iSeed, ads, weapDef) (random(iSeed) * ads ? (*(float*)(weapDef + 0x4A8) - *(float*)(weapDef + 0x4AC)) : (*(float*)(weapDef + 0x4EC) - *(float*)(weapDef + 0x4F0))) + ads ? *(float*)(weapDef + 0x4A8) : *(float*)(weapDef + 0x4EC)
  12. #define fViewKickYawLerp(iSeed, ads, weapDef) (random(iSeed) * ads ? (*(float*)(weapDef + 0x4B0) - *(float*)(weapDef + 0x4B4)) : (*(float*)(weapDef + 0x4F4) - *(float*)(weapDef + 0x4F8))) + ads ? *(float*)(weapDef + 0x4F4) : *(float*)(weapDef + 0x4B0)
  13. #define fGunKickPitchLerp(iSeed, ads, weapDef) (random(iSeed) * ads ? (*(float*)(weapDef + 0x488) - *(float*)(weapDef + 0x48C)) : (*(float*)(weapDef + 0x4CC) - *(float*)(weapDef + 0x4D0)) + ads ? *(float*)(weapDef + 0x488) : *(float*)(weapDef + 0x4CC)
  14. #define fGunKickYawLerp(iSeed, ads, weapDef) (random(iSeed) * ads ? (*(float*)(weapDef + 0x490) - *(float*)(weapDef + 0x494)) : (*(float*)(weapDef + 0x4D4) - *(float*)(weapDef + 0x4D8)) + ads ? *(float*)(weapDef + 0x490) : *(float*)(weapDef + 0x4D4)
  15.  
  16. void BG_WeaponFireRecoil(playerState_s *ps, float*vGunSpeed, float*kickAVel, int iSeed, bool weapState)
  17. {
  18.     int weapDef = 0x8255A320 + (ps->weapCommon.weapFlags & 0x2 ? ps->weapCommon.offHandIndex * 4 : ps->weapCommon.weapon * 4);
  19.     bool ads = ps->weapCommon.fWeaponPosFrac == 1.0;
  20.     float fKickReducedKickPercent = ps->weapState[weapState].weaponRestrictKickTime <= 0 ? 1.0 : ps->weapCommon.fWeaponPosFrac != 1.0 ? *(float*)(weapDef + 0x4C8) : *(float*)(weapDef + 0x484), // if player is not fully ADS, use hip kick, else use ADS
  21.         fRecoilScale = fKickReducedKickPercent * 0.0099999998;
  22.     if(ps->weapCommon.weapFlags & 0x400){fRecoilScale *= (float)ps->recoilScale * 0.0099999998;}
  23.     kickAVel[0] = -((fViewKickPitchLerp(iSeed, ads, weapDef) * fRecoilScale) * ps->weapCommon.weapFlags & 0x200 ? 5.0 : 0.0);
  24.     kickAVel[1] = fViewKickYawLerp(iSeed, ads, weapDef) * fRecoilScale;
  25.     kickAVel[2] = kickAVel[1] * -0.5;
  26.     vGunSpeed[0] += ((fGunKickPitchLerp(iSeed, ads, weapDef) * fRecoilScale) * ps->weapCommon.weapFlags & 0x200 ? 5.0 : 0.0);
  27.     vGunSpeed[1] += fGunKickYawLerp(iSeed, ads, weapDef) * fRecoilScale;
  28. }
Add Comment
Please, Sign In to add comment