From 5068c8dca5d0ab7ea158f1cb92bb810bd5d9fe36 Mon Sep 17 00:00:00 2001 From: notgoodusename <57305491+notgoodusename@users.noreply.github.com> Date: Sun, 26 Feb 2023 18:07:35 -0300 Subject: [PATCH] Update ragebot to work with backtrack and improve tickbase exploits on ragebob --- Osiris/Hacks/Backtrack.cpp | 8 ++-- Osiris/Hacks/Chams.cpp | 2 +- Osiris/Hacks/Ragebot.cpp | 98 +++++++++++++++++++++----------------- 3 files changed, 59 insertions(+), 49 deletions(-) diff --git a/Osiris/Hacks/Backtrack.cpp b/Osiris/Hacks/Backtrack.cpp index 294d72ff..78603c0d 100644 --- a/Osiris/Hacks/Backtrack.cpp +++ b/Osiris/Hacks/Backtrack.cpp @@ -71,7 +71,7 @@ void Backtrack::run(UserCmd* cmd) noexcept if (player.backtrackRecords.empty() || (!config->backtrack.ignoreSmoke && memory->lineGoesThroughSmoke(localPlayer->getEyePosition(), entity->getAbsOrigin(), 1))) continue; - for (int j = static_cast(player.backtrackRecords.size() - 1); j >= 0; j--) + for (int j = static_cast(player.backtrackRecords.size() - 1U); j >= 0; j--) { if (Backtrack::valid(player.backtrackRecords.at(j).simulationTime)) { @@ -151,9 +151,9 @@ bool Backtrack::valid(float simtime) noexcept if (simtime < deadTime) return false; - const auto extraTickbaseDelta = (Tickbase::getTargetTickShift() >= timeToTicks(0.2f) && Tickbase::canShift(Tickbase::getTargetTickShift())) ? ticksToTime(Tickbase::getTargetTickShift()) : 0.0f; - const auto delta = std::clamp(network->getLatency(0) + network->getLatency(1) + getLerp(), 0.f, cvars.maxUnlag->getFloat()) - (memory->globalVars->serverTime() - simtime) + extraTickbaseDelta; - return std::abs(delta) <= 0.2f + extraTickbaseDelta; + const auto extraTickbaseDelta = Tickbase::canShift(Tickbase::getTargetTickShift()) ? ticksToTime(Tickbase::getTargetTickShift()) : 0.0f; + const auto delta = std::clamp(network->getLatency(0) + network->getLatency(1) + getLerp(), 0.f, cvars.maxUnlag->getFloat()) - (memory->globalVars->serverTime() - extraTickbaseDelta - simtime); + return std::abs(delta) <= 0.2f; } void Backtrack::init() noexcept diff --git a/Osiris/Hacks/Chams.cpp b/Osiris/Hacks/Chams.cpp index e34b6aa7..13ea66d4 100644 --- a/Osiris/Hacks/Chams.cpp +++ b/Osiris/Hacks/Chams.cpp @@ -197,7 +197,7 @@ void Chams::renderPlayer(Entity* player) noexcept { int lastTick = -1; - for (int i = static_cast(records->size() - 1); i >= 0; i--) + for (int i = static_cast(records->size() - 1U); i >= 0; i--) { if (Backtrack::valid(records->at(i).simulationTime) && records->at(i).origin != player->origin()) { diff --git a/Osiris/Hacks/Ragebot.cpp b/Osiris/Hacks/Ragebot.cpp index 1ad62e93..7d1bbfa1 100644 --- a/Osiris/Hacks/Ragebot.cpp +++ b/Osiris/Hacks/Ragebot.cpp @@ -26,7 +26,7 @@ void Ragebot::updateInput() noexcept config->minDamageOverrideKey.handleToggle(); } -void runRagebot(UserCmd* cmd, Entity* entity, Animations::Players::Record record, Ragebot::Enemies target, std::array hitbox, Entity* activeWeapon, int weaponIndex, Vector localPlayerEyePosition, Vector aimPunch, int multiPoint, int minDamage, float& damageDiff, Vector& bestAngle, Vector& bestTarget, int& bestIndex, float& bestSimulationTime) noexcept +void runRagebot(UserCmd* cmd, Entity* entity, matrix3x4* matrix, Ragebot::Enemies target, std::array hitbox, Entity* activeWeapon, int weaponIndex, Vector localPlayerEyePosition, Vector aimPunch, int multiPoint, int minDamage, float& damageDiff, Vector& bestAngle, Vector& bestTarget) noexcept { const auto& cfg = config->ragebot; @@ -53,7 +53,7 @@ void runRagebot(UserCmd* cmd, Entity* entity, Animations::Players::Record record if (!hitbox) continue; - for (auto& bonePosition : AimbotFunction::multiPoint(entity, record.matrix, hitbox, localPlayerEyePosition, i, multiPoint)) + for (auto& bonePosition : AimbotFunction::multiPoint(entity, matrix, hitbox, localPlayerEyePosition, i, multiPoint)) { const auto angle{ AimbotFunction::calculateRelativeAngle(localPlayerEyePosition, bonePosition, cmd->viewangles + aimPunch) }; const auto fov{ angle.length2D() }; @@ -100,20 +100,16 @@ void runRagebot(UserCmd* cmd, Entity* entity, Animations::Players::Record record bestAngle = angle; damageDiff = std::fabsf((float)target.health - damage); bestTarget = bonePosition; - bestSimulationTime = record.simulationTime; - bestIndex = target.id; } } } if (bestTarget.notNull()) { - if (!AimbotFunction::hitChance(localPlayer.get(), entity, set, record.matrix, activeWeapon, bestAngle, cmd, cfg[weaponIndex].hitChance)) + if (!AimbotFunction::hitChance(localPlayer.get(), entity, set, matrix, activeWeapon, bestAngle, cmd, cfg[weaponIndex].hitChance)) { bestTarget = Vector{ }; bestAngle = Vector{ }; - bestIndex = -1; - bestSimulationTime = 0; damageDiff = FLT_MAX; } } @@ -238,64 +234,78 @@ void Ragebot::run(UserCmd* cmd) noexcept const auto player = Animations::getPlayer(target.id); const int minDamage = std::clamp(std::clamp(config->minDamageOverrideKey.isActive() ? cfg[weaponIndex].minDamageOverride : cfg[weaponIndex].minDamage, 0, target.health), 0, activeWeapon->getWeaponData()->damage); - const auto backupBoneCache = entity->getBoneCache().memory; - const auto backupMins = entity->getCollideable()->obbMins(); - const auto backupMaxs = entity->getCollideable()->obbMaxs(); - const auto backupOrigin = entity->getAbsOrigin(); - const auto backupAbsAngle = entity->getAbsAngle(); + const auto& backupBoneCache = entity->getBoneCache().memory; + const auto& backupMins = entity->getCollideable()->obbMins(); + const auto& backupMaxs = entity->getCollideable()->obbMaxs(); + const auto& backupOrigin = entity->getAbsOrigin(); + const auto& backupAbsAngle = entity->getAbsAngle(); for (int cycle = 0; cycle < 2; cycle++) { - Animations::Players::Record record; - if (cycle == 0) - { - if (!Backtrack::valid(player.simulationTime)) - continue; - record.absAngle = player.absAngle; - std::copy(player.matrix.begin(), player.matrix.end(), record.matrix); - record.maxs = player.maxs; - record.mins = player.mins; - record.origin = player.origin; - record.simulationTime = player.simulationTime; - } - else - { - if (cfg[weaponIndex].disableBacktrackIfLowFPS && static_cast(1 / frameRate) <= 1 / memory->globalVars->intervalPerTick) - continue; - - if (!config->backtrack.enabled) - continue; + float currentSimulationTime = -1.0f; + if (config->backtrack.enabled) + { const auto records = Animations::getBacktrackRecords(entity->index()); if (!records || records->empty()) continue; - int lastTick = -1; - - for (int i = static_cast(records->size() - 1); i >= 0; i--) + int bestTick = -1; + if (cycle == 0) + { + for (size_t i = 0; i < records->size(); i++) + { + if (Backtrack::valid(records->at(i).simulationTime)) + { + bestTick = static_cast(i); + break; + } + } + } + else { - if (Backtrack::valid(records->at(i).simulationTime)) + for (int i = static_cast(records->size() - 1U); i >= 0; i--) { - lastTick = i; - break; + if (Backtrack::valid(records->at(i).simulationTime)) + { + bestTick = i; + break; + } } } - if (lastTick <= -1) + if (bestTick <= -1) continue; - record = records->at(lastTick); + memcpy(entity->getBoneCache().memory, records->at(bestTick).matrix, std::clamp(entity->getBoneCache().size, 0, MAXSTUDIOBONES) * sizeof(matrix3x4)); + memory->setAbsOrigin(entity, records->at(bestTick).origin); + memory->setAbsAngle(entity, Vector{ 0.f, records->at(bestTick).absAngle.y, 0.f }); + memory->setCollisionBounds(entity->getCollideable(), records->at(bestTick).mins, records->at(bestTick).maxs); + + currentSimulationTime = records->at(bestTick).simulationTime; } + else + { + //We skip backtrack + if (cycle == 1) + continue; + + memcpy(entity->getBoneCache().memory, player.matrix.data(), std::clamp(entity->getBoneCache().size, 0, MAXSTUDIOBONES) * sizeof(matrix3x4)); + memory->setAbsOrigin(entity, player.origin); + memory->setAbsAngle(entity, Vector{ 0.f, player.absAngle.y, 0.f }); + memory->setCollisionBounds(entity->getCollideable(), player.mins, player.maxs); - memcpy(entity->getBoneCache().memory, record.matrix, std::clamp(entity->getBoneCache().size, 0, MAXSTUDIOBONES) * sizeof(matrix3x4)); - memory->setAbsOrigin(entity, record.origin); - memory->setAbsAngle(entity, Vector{ 0.f, record.absAngle.y, 0.f }); - entity->getCollideable()->setCollisionBounds(record.mins, record.maxs); + currentSimulationTime = player.simulationTime; + } - runRagebot(cmd, entity, record, target, hitbox, activeWeapon, weaponIndex, localPlayerEyePosition, aimPunch, multiPoint, minDamage, damageDiff, bestAngle, bestTarget, bestIndex, bestSimulationTime); + runRagebot(cmd, entity, entity->getBoneCache().memory, target, hitbox, activeWeapon, weaponIndex, localPlayerEyePosition, aimPunch, multiPoint, minDamage, damageDiff, bestAngle, bestTarget); resetMatrix(entity, backupBoneCache, backupOrigin, backupAbsAngle, backupMins, backupMaxs); if (bestTarget.notNull()) + { + bestSimulationTime = currentSimulationTime; + bestIndex = target.id; break; + } } if (bestTarget.notNull()) break;