Skip to content

Commit

Permalink
Fix speedBoost cheat
Browse files Browse the repository at this point in the history
  • Loading branch information
scp222thj committed Jun 22, 2024
1 parent 7b25876 commit 7897bed
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
19 changes: 19 additions & 0 deletions src/Cheats/MalumCheats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,23 @@ public static void noClipCheat()

}catch{}
}

public static void speedBoostCheat()
{
const float defaultSpeed = 2.5f;
const float defaultGhostSpeed = 3f;
const float speedMultiplier = 2.0f;

try
{
float newSpeed = CheatToggles.speedBoost ? defaultSpeed * speedMultiplier : defaultSpeed;

float newGhostSpeed = CheatToggles.speedBoost ? defaultGhostSpeed * speedMultiplier : defaultGhostSpeed;

PlayerControl.LocalPlayer.MyPhysics.Speed = newSpeed;
PlayerControl.LocalPlayer.MyPhysics.GhostSpeed = newGhostSpeed;
}
catch{}
}

}
26 changes: 2 additions & 24 deletions src/Patches/PlayerPhysicsPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static void Postfix(PlayerPhysics __instance)
MalumESP.seeGhostsCheat(__instance);

MalumCheats.noClipCheat();
MalumCheats.speedBoostCheat();
MalumCheats.murderAllCheat();
MalumCheats.teleportCursorCheat();
MalumCheats.completeMyTasksCheat();
Expand All @@ -36,27 +37,4 @@ public static void Postfix(PlayerPhysics __instance)
}
}
}
}

[HarmonyPatch(typeof(PlayerPhysics), nameof(PlayerPhysics.SetNormalizedVelocity))]
public static class PlayerPhysics_SetNormalizedVelocity
{
// Prefix patch of PlayerPhysics.SetNormalizedVelocity to double the player's speed when the speedBoost cheat is enabled
public static bool Prefix(PlayerPhysics __instance, Vector2 direction)
{
if (CheatToggles.speedBoost){

// Cheat multiplier
float cheatSpeed = 2f;

// Actual speed of player (no hacks)
float actualSpeed = PlayerControl.LocalPlayer.MyPhysics.Speed * PlayerControl.LocalPlayer.MyPhysics.SpeedMod;

PlayerControl.LocalPlayer.MyPhysics.body.velocity = direction * actualSpeed * cheatSpeed;

return false;
}

return true;
}
}
}

0 comments on commit 7897bed

Please sign in to comment.