Skip to content

Add rounded pitch and yaw check to killaura.ts #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: rewrite
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion penrose/modules/killaura.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function getDynamicThreshold(intervals: number[]): number {
function onEntityHit(event: EntityHitEntityAfterEvent) {
const attacker = event.damagingEntity;
const target = event.hitEntity;
const attackerRots = attacker.getRotation();

// Only proceed if the attacker and target are players
if (!(attacker instanceof Player) || !(target instanceof Player)) return;
Expand Down Expand Up @@ -86,7 +87,7 @@ function onEntityHit(event: EntityHitEntityAfterEvent) {
const isFacingTarget = checkIfFacingEntity(attacker, target);

// Flag player for suspicious killaura behavior
if (!isFacingTarget || distance > MAX_ATTACK_DISTANCE || recentAttacks.length >= MAX_ATTACKS_PER_SECOND || isSuspiciousAttackPattern(attackTimes)) {
if (!isFacingTarget || distance > MAX_ATTACK_DISTANCE || recentAttacks.length >= MAX_ATTACKS_PER_SECOND || isSuspiciousAttackPattern(attackTimes) || isFlatRotation(attackerRots.x, attackerRots.y) {
const healthComponentVictim = target.getComponent("health");

// Get or initialize the victim's health
Expand Down Expand Up @@ -147,6 +148,19 @@ function isSuspiciousAttackPattern(attackTimes: number[]): boolean {
return isConsistent; // Return true if all interval differences are within the threshold range
}

// isFlatRotation returns if the players pitch and/or yaw is flat (rounded), this is a common issue in a lot of hive clients, which are the only ones updated currently.
function isFlatRotation(pitch: number, yaw: number) {

// Get the difference between the rounded rotations and the actual rotation, if its 0 its rounded so return true.
// If the pitch or yaw is 0, it can mean that the player has teleported causing their rotation to be 0, 0
const isFlatPitch = Math.abs(Math.round(pitch) - pitch) === 0 && pitch !== 0;
const isFlatYaw = Math.abs(Math.round(yaw) - yaw) === 0 && yaw !== 0;
// The logic above can be improved to account for some clients (private versions of solstice do this) which add a small float value to their pitch or yaw if it's flat.
// This can be detected but WILL need a buffer to stop false flags as it can be achieved legit, if the advanced logic is added, I would also recommending confirming that the player is moving with some decent speed.

return isFlatPitch || isFlatYaw;
}

/**
* Subscribes to the entity hit event for killaura detection.
*/
Expand Down