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

Commit

Permalink
Add magnet triggerbot
Browse files Browse the repository at this point in the history
  • Loading branch information
notgoodusename committed Sep 2, 2023
1 parent 4627479 commit 9377ad3
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Osiris/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ static void from_json(const json& j, Config::Ragebot& r)
static void from_json(const json& j, Config::Triggerbot& t)
{
read(j, "Enabled", t.enabled);
read(j, "Magnet", t.magnet);
read(j, "Friendly fire", t.friendlyFire);
read(j, "Scoped only", t.scopedOnly);
read(j, "Ignore flash", t.ignoreFlash);
Expand Down Expand Up @@ -1020,6 +1021,7 @@ static void to_json(json& j, const Config::Ragebot& o, const Config::Ragebot& du
static void to_json(json& j, const Config::Triggerbot& o, const Config::Triggerbot& dummy = {})
{
WRITE("Enabled", enabled);
WRITE("Magnet", magnet);
WRITE("Friendly fire", friendlyFire);
WRITE("Scoped only", scopedOnly);
WRITE("Ignore flash", ignoreFlash);
Expand Down
1 change: 1 addition & 0 deletions Osiris/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class Config {

struct Triggerbot {
bool enabled = false;
bool magnet = false;
bool friendlyFire = false;
bool scopedOnly = true;
bool ignoreFlash = false;
Expand Down
1 change: 1 addition & 0 deletions Osiris/GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ void GUI::renderTriggerbotWindow() noexcept
ImGui::PopID();
ImGui::SameLine();
ImGui::Checkbox("Enabled", &config->triggerbot[currentWeapon].enabled);
ImGui::Checkbox("Magnet", &config->triggerbot[currentWeapon].magnet);
ImGui::Checkbox("Friendly fire", &config->triggerbot[currentWeapon].friendlyFire);
ImGui::Checkbox("Scoped only", &config->triggerbot[currentWeapon].scopedOnly);
ImGui::Checkbox("Ignore flash", &config->triggerbot[currentWeapon].ignoreFlash);
Expand Down
24 changes: 24 additions & 0 deletions Osiris/Hacks/AimbotFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,30 @@ bool AimbotFunction::hitboxIntersection(const matrix3x4 matrix[MAXSTUDIOBONES],
return false;
}

Vector AimbotFunction::getCenterOfHitbox(const matrix3x4 matrix[MAXSTUDIOBONES], StudioBbox* hitbox) noexcept
{
auto VectorTransformWrapper = [](const Vector& in1, const matrix3x4 in2, Vector& out)
{
auto VectorTransform = [](const float* in1, const matrix3x4 in2, float* out)
{
auto dotProducts = [](const float* v1, const float* v2)
{
return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
};
out[0] = dotProducts(in1, in2[0]) + in2[0][3];
out[1] = dotProducts(in1, in2[1]) + in2[1][3];
out[2] = dotProducts(in1, in2[2]) + in2[2][3];
};
VectorTransform(&in1.x, in2, &out.x);
};

Vector min, max;
VectorTransformWrapper(hitbox->bbMin, matrix[hitbox->bone], min);
VectorTransformWrapper(hitbox->bbMax, matrix[hitbox->bone], max);
return (min + max) * 0.5f;
}


std::vector<Vector> AimbotFunction::multiPoint(Entity* entity, const matrix3x4 matrix[MAXSTUDIOBONES], StudioBbox* hitbox, Vector localEyePos, int _hitbox, int _multiPoint)
{
auto VectorTransformWrapper = [](const Vector& in1, const matrix3x4 in2, Vector& out)
Expand Down
2 changes: 2 additions & 0 deletions Osiris/Hacks/AimbotFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace AimbotFunction

bool hitboxIntersection(const matrix3x4 matrix[MAXSTUDIOBONES], int iHitbox, StudioHitboxSet* set, const Vector& start, const Vector& end) noexcept;

Vector getCenterOfHitbox(const matrix3x4 matrix[MAXSTUDIOBONES], StudioBbox* hitbox) noexcept;

std::vector<Vector> multiPoint(Entity* entity, const matrix3x4 matrix[MAXSTUDIOBONES], StudioBbox* hitbox, Vector localEyePos, int _hitbox, int _multiPoint);

bool hitChance(Entity* localPlayer, Entity* entity, StudioHitboxSet*, const matrix3x4 matrix[MAXSTUDIOBONES], Entity* activeWeapon, const Vector& destination, const UserCmd* cmd, const int hitChance) noexcept;
Expand Down
37 changes: 35 additions & 2 deletions Osiris/Hacks/Triggerbot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ void Triggerbot::run(UserCmd* cmd) noexcept
// Head
hitbox[Hitboxes::Head] = (cfg.hitboxes & 1 << 0) == 1 << 0;
// Chest
hitbox[Hitboxes::Neck] = (cfg.hitboxes & 1 << 0) == 1 << 1;
hitbox[Hitboxes::UpperChest] = (cfg.hitboxes & 1 << 1) == 1 << 1;
hitbox[Hitboxes::Thorax] = (cfg.hitboxes & 1 << 1) == 1 << 1;
hitbox[Hitboxes::LowerChest] = (cfg.hitboxes & 1 << 1) == 1 << 1;
Expand Down Expand Up @@ -142,6 +143,10 @@ void Triggerbot::run(UserCmd* cmd) noexcept
if (!hitbox[j])
continue;

StudioBbox* hitbox = set->getHitbox(j);
if (!hitbox)
continue;

if (AimbotFunction::hitboxIntersection(player.matrix.data(), j, set, startPos, endPos))
{
Trace trace;
Expand All @@ -157,11 +162,23 @@ void Triggerbot::run(UserCmd* cmd) noexcept
if (float armorRatio{ weaponData->armorRatio / 2.0f }; activeWeapon->itemDefinitionIndex2() != WeaponId::Taser && HitGroup::isArmored(trace.hitgroup, trace.entity->hasHelmet(), trace.entity->armor(), trace.entity->hasHeavyArmor()))
AimbotFunction::calculateArmorDamage(armorRatio, trace.entity->armor(), trace.entity->hasHeavyArmor(), damage);

const auto destination = AimbotFunction::calculateRelativeAngle(startPos, trace.endpos, cmd->viewangles + aimPunch);

if (damage >= (cfg.killshot ? trace.entity->health() : cfg.minDamage) &&
AimbotFunction::hitChance(localPlayer.get(), entity, set, player.matrix.data(), activeWeapon, AimbotFunction::calculateRelativeAngle(startPos, trace.endpos, cmd->viewangles + aimPunch), cmd, cfg.hitChance))
AimbotFunction::hitChance(localPlayer.get(), entity, set, player.matrix.data(), activeWeapon, destination, cmd, cfg.hitChance))
{
cmd->buttons |= UserCmd::IN_ATTACK;
cmd->tickCount = timeToTicks(player.simulationTime + Backtrack::getLerp());

if (cfg.magnet)
{
const auto centerHitbox = AimbotFunction::getCenterOfHitbox(player.matrix.data(), hitbox);
const auto angle = AimbotFunction::calculateRelativeAngle(startPos, centerHitbox, cmd->viewangles + aimPunch);

cmd->viewangles += angle;
interfaces->engine->setViewAngles(cmd->viewangles);
}

lastTime = 0.0f;
lastContact = now;
}
Expand Down Expand Up @@ -237,6 +254,10 @@ void Triggerbot::run(UserCmd* cmd) noexcept
if (!hitbox[j])
continue;

StudioBbox* hitbox = set->getHitbox(j);
if (!hitbox)
continue;

if (AimbotFunction::hitboxIntersection(record.matrix, j, set, startPos, endPos))
{
Trace trace;
Expand All @@ -252,11 +273,23 @@ void Triggerbot::run(UserCmd* cmd) noexcept
if (float armorRatio{ weaponData->armorRatio / 2.0f }; activeWeapon->itemDefinitionIndex2() != WeaponId::Taser && HitGroup::isArmored(trace.hitgroup, trace.entity->hasHelmet(), trace.entity->armor(), trace.entity->hasHeavyArmor()))
AimbotFunction::calculateArmorDamage(armorRatio, trace.entity->armor(), trace.entity->hasHeavyArmor(), damage);

const auto destination = AimbotFunction::calculateRelativeAngle(startPos, trace.endpos, cmd->viewangles + aimPunch);

if (damage >= (cfg.killshot ? trace.entity->health() : cfg.minDamage) &&
AimbotFunction::hitChance(localPlayer.get(), entity, set, record.matrix, activeWeapon, AimbotFunction::calculateRelativeAngle(startPos, trace.endpos, cmd->viewangles + aimPunch), cmd, cfg.hitChance))
AimbotFunction::hitChance(localPlayer.get(), entity, set, record.matrix, activeWeapon, destination, cmd, cfg.hitChance))
{
cmd->buttons |= UserCmd::IN_ATTACK;
cmd->tickCount = timeToTicks(record.simulationTime + Backtrack::getLerp());

if (cfg.magnet)
{
const auto centerHitbox = AimbotFunction::getCenterOfHitbox(player.matrix.data(), hitbox);
const auto angle = AimbotFunction::calculateRelativeAngle(startPos, centerHitbox, cmd->viewangles + aimPunch);

cmd->viewangles += angle;
interfaces->engine->setViewAngles(cmd->viewangles);
}

lastTime = 0.0f;
lastContact = now;
}
Expand Down

0 comments on commit 9377ad3

Please sign in to comment.