Advertisement
osdever

Untitled

Sep 16th, 2023
692
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.30 KB | None | 0 0
  1.     if (auto pChopper = player->QueryInterface<ISimpleChopper>())
  2.                 {
  3.                     auto ClearEdges = []()
  4.                     {
  5.                         using namespace Superheated;
  6.                         using speed::Vector3;
  7.  
  8.                         WCollisionPack** pPacks = *(WCollisionPack***)0x9B38A0;
  9.                         for (int i = 0; i < 0xA8C; i++)
  10.                         {
  11.                             if (!pPacks[i]) continue;
  12.                             for (unsigned int j = 0; j < pPacks[i]->mInstanceNum; j++)
  13.                             {
  14.                                 CARPCollisionInstance& obj = pPacks[i]->mInstanceList[j];
  15.  
  16.                                 Vector3 pos = Vector3(-obj.fInvPosRadius.x, -obj.fInvPosRadius.y, -obj.fInvPosRadius.z);
  17.                                 if (obj.fCollisionArticle->fNumEdges)
  18.                                 {
  19.                                     obj.fCollisionArticle->fIntermediatObjInd = obj.fCollisionArticle->fNumEdges | 0b100000000000000;
  20.                                     obj.fCollisionArticle->fNumEdges = 0;
  21.                                 }
  22.                             }
  23.                         }
  24.                     };
  25.  
  26.                     ClearEdges();
  27.  
  28.                     auto pRigidBody = player->QueryInterface<IRigidBody>();
  29.                     auto deltaTime = ImGui::GetIO().DeltaTime;
  30.  
  31.                     auto pCollisionBody = player->QueryInterface<ICollisionBody>();
  32.  
  33.                     static float mSpeed = 0.f;
  34.  
  35.                     bool wPressed = is_down('W');
  36.                     bool aPressed = is_down('A');
  37.                     bool sPressed = is_down('S');
  38.                     bool dPressed = is_down('D');
  39.  
  40.                     auto lerpVec3 = [](const auto& v1, const auto& v2, auto t)
  41.                     {
  42.                         auto lerp = [](auto a, auto b, auto t)
  43.                         {
  44.                             return ((a)+(t) * ((b)-(a)));
  45.                         };
  46.  
  47.                         return lm::Vec3{
  48.                             lerp(v1.x, v2.x, t),
  49.                             lerp(v1.y, v2.y, t),
  50.                             lerp(v1.z, v2.z, t)
  51.                         };
  52.                     };
  53.  
  54.                     if (wPressed)
  55.                         mSpeed += deltaTime * 5;
  56.                     else
  57.                         mSpeed -= deltaTime;
  58.  
  59.                     if (mSpeed < 0.f)
  60.                         mSpeed = 0.f;
  61.  
  62.                     lm::Vec3 fvec = pCollisionBody->GetForwardVector();
  63.                     lm::Vec3 rvec = pCollisionBody->GetRightVector();
  64.                     lm::Vec3 rotated;
  65.  
  66.                     auto vec = fvec;
  67.  
  68.                     if (aPressed)
  69.                         rotated = lerpVec3(fvec, rvec * -1.f, deltaTime * 5);
  70.                     if (dPressed)
  71.                         rotated = lerpVec3(fvec, rvec, deltaTime * 5);
  72.  
  73.                     if (aPressed || dPressed)
  74.                         vec = rotated;
  75.                     if (wPressed || aPressed || dPressed)
  76.                         pChopper->SetDesiredFacingVector(vec);
  77.                     if (wPressed)
  78.                         vec *= mSpeed;
  79.  
  80.                     if (sPressed)
  81.                         vec *= -1.f;
  82.  
  83.                     if (is_down(VK_UP))
  84.                         vec.y = 10.f;
  85.                     if (is_down(VK_DOWN))
  86.                         vec.y = -7.5f;
  87.  
  88.                     pChopper->SetDesiredVelocity(vec);
  89.                 }
  90.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement