Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
Update ragebot to work with backtrack and improve tickbase exploits o…
Browse files Browse the repository at this point in the history
…n ragebob
  • Loading branch information
notgoodusename committed Feb 26, 2023
1 parent 2a4942e commit 5068c8d
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 49 deletions.
8 changes: 4 additions & 4 deletions Osiris/Hacks/Backtrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(player.backtrackRecords.size() - 1); j >= 0; j--)
for (int j = static_cast<int>(player.backtrackRecords.size() - 1U); j >= 0; j--)
{
if (Backtrack::valid(player.backtrackRecords.at(j).simulationTime))
{
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Osiris/Hacks/Chams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void Chams::renderPlayer(Entity* player) noexcept
{
int lastTick = -1;

for (int i = static_cast<int>(records->size() - 1); i >= 0; i--)
for (int i = static_cast<int>(records->size() - 1U); i >= 0; i--)
{
if (Backtrack::valid(records->at(i).simulationTime) && records->at(i).origin != player->origin())
{
Expand Down
98 changes: 54 additions & 44 deletions Osiris/Hacks/Ragebot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool, Hitboxes::Max> 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<bool, Hitboxes::Max> 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;

Expand All @@ -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() };
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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<int>(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<int>(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<int>(i);
break;
}
}
}
else
{
if (Backtrack::valid(records->at(i).simulationTime))
for (int i = static_cast<int>(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;
Expand Down

0 comments on commit 5068c8d

Please sign in to comment.