Skip to content

Commit

Permalink
feat: add argument to vphys commands to change component
Browse files Browse the repository at this point in the history
  • Loading branch information
NeKzor authored and ThisAMJ committed Mar 11, 2024
1 parent 3215d89 commit c7168d8
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions src/Features/Hud/VphysHud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ CON_COMMAND(sar_vphys_setgravity, "sar_vphys_setgravity <hitbox> <enabled> - set
EnableGravity(hitbox ? m_pShadowCrouch : m_pShadowStand, enabled);
}

CON_COMMAND(sar_vphys_setangle, "sar_vphys_setangle <hitbox> <angle> - sets rotation angle to either standing (0) or crouching (1) havok collision shadow\n") {
CON_COMMAND(sar_vphys_setangle, "sar_vphys_setangle <hitbox> <angle> [component = z] - sets rotation angle to either standing (0) or crouching (1) havok collision shadow\n") {
if (engine->demoplayer->IsPlaying()) {
return;
}
if (!sv_cheats.GetBool()) {
return console->Print("Cannot use sar_vphys_setangle without sv_cheats set to 1.\n");
}

if (args.ArgC() != 3) {
if (args.ArgC() < 3 || args.ArgC() > 4) {
return console->Print(sar_vphys_setangle.ThisPtr()->m_pszHelpString);
}

Expand All @@ -206,27 +206,36 @@ CON_COMMAND(sar_vphys_setangle, "sar_vphys_setangle <hitbox> <angle> - sets rota
_SetPosition SetPosition = Memory::VMT<_SetPosition>(m_pShadowStand, Offsets::SetPosition);
_GetPosition GetPosition = Memory::VMT<_GetPosition>(m_pShadowStand, Offsets::GetPosition);

int hitbox = std::atoi(args[1]);
float angle = std::atof(args[2]);
auto hitbox = std::atoi(args[1]);
auto angle = float(std::atof(args[2]));
auto component = args.ArgC() == 4 ? args[3] : "z";

void *selected = hitbox ? m_pShadowCrouch : m_pShadowStand;

Vector v;
QAngle q;
GetPosition(selected, &v, &q);
q.z = angle;

if (!strcmp(component, "x")) {
q.x = angle;
} else if (!strcmp(component, "y")) {
q.y = angle;
} else {
q.z = angle;
}

SetPosition(selected, v, q, false);
}

CON_COMMAND(sar_vphys_setspin, "sar_vphys_setspin <hitbox> <angvel> - sets rotation speed to either standing (0) or crouching (1) havok collision shadow\n") {
CON_COMMAND(sar_vphys_setspin, "sar_vphys_setspin <hitbox> <angvel> [component = x] - sets rotation speed to either standing (0) or crouching (1) havok collision shadow\n") {
if (engine->demoplayer->IsPlaying()) {
return;
}
if (!sv_cheats.GetBool()) {
return console->Print("Cannot use sar_vphys_setspin without sv_cheats set to 1.\n");
}

if (args.ArgC() != 3) {
if (args.ArgC() < 3 || args.ArgC() > 4) {
return console->Print(sar_vphys_setspin.ThisPtr()->m_pszHelpString);
}

Expand All @@ -239,14 +248,23 @@ CON_COMMAND(sar_vphys_setspin, "sar_vphys_setspin <hitbox> <angvel> - sets rotat
using _SetVelocity = void(__rescall *)(void *thisptr, const Vector *velocity, const Vector *angularVelocity);
_SetVelocity SetVelocity = Memory::VMT<_SetVelocity>(m_pShadowStand, Offsets::SetVelocity);

int hitbox = std::atoi(args[1]);
float angle = std::atof(args[2]);
auto hitbox = std::atoi(args[1]);
auto angvel = float(std::atof(args[2]));
auto component = args.ArgC() == 4 ? args[3] : "x";

void *selected = hitbox ? m_pShadowCrouch : m_pShadowStand;

Vector v;
GetVelocity(selected, NULL, &v);
v.x = angle;

if (!strcmp(component, "y")) {
v.y = angvel;
} else if (!strcmp(component, "z")) {
v.z = angvel;
} else {
v.x = angvel;
}

SetVelocity(selected, NULL, &v);
}

Expand Down

0 comments on commit c7168d8

Please sign in to comment.