Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void aimbot::extrapolate(C_BaseEntity* player, Vector& origin, Vector& velocity, int& flags, bool on_ground)
- {
- static const auto sv_gravity = g_pCvar->FindVar("sv_gravity");
- static const auto sv_jump_impulse = g_pCvar->FindVar("sv_jump_impulse");
- if (!(flags & FL_ONGROUND))
- velocity.z -= TICKS_TO_TIME(sv_gravity->GetFloat());
- else if (player->GetFlags() & FL_ONGROUND && !on_ground)
- velocity.z = sv_jump_impulse->GetFloat();
- const auto src = origin;
- auto end = src + velocity * g_pGlobalVars->intervalPerTick;
- Ray_t r;
- r.Init(src, end, player->GetMins(), player->GetMaxs());
- trace_t t{};
- CTraceFilter filter;
- filter.pSkip1 = player;
- g_pTrace->TraceRay(r, mask_playersolid, &filter, &t);
- if (t.flFraction != 1.f)
- {
- for (auto i = 0; i < 2; i++)
- {
- velocity -= t.plane.normal * velocity.Dot(t.plane.normal);
- const auto dot = velocity.Dot(t.plane.normal);
- if (dot < 0.f)
- velocity -= Vector(dot * t.plane.normal.x,
- dot * t.plane.normal.y, dot * t.plane.normal.z);
- end = t.end + velocity * TICKS_TO_TIME(1.f - t.flFraction);
- r.Init(t.end, end, player->GetMins(), player->GetMaxs());
- g_pTrace->TraceRay(r, mask_playersolid, &filter, &t);
- if (t.flFraction == 1.f)
- break;
- }
- }
- origin = end = t.end;
- end.z -= 2.f;
- r.Init(origin, end, player->GetMins(), player->GetMaxs());
- g_pTrace->TraceRay(r, mask_playersolid, &filter, &t);
- flags &= ~FL_ONGROUND;
- if (t.DidHit() && t.plane.normal.z > .7f)
- flags |= FL_ONGROUND;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement