Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some speed hacker problems
Browse files Browse the repository at this point in the history
kissingers committed Aug 25, 2024
1 parent 98fb1d8 commit c347e2d
Showing 4 changed files with 10 additions and 69 deletions.
1 change: 0 additions & 1 deletion src/AnticheatData.cpp
Original file line number Diff line number Diff line change
@@ -38,7 +38,6 @@ AnticheatData::AnticheatData()
average = 0.0f;
creationTime = 0;
hasDailyReport = false;
justUsedMovementSpell = false;
}

AnticheatData::~AnticheatData()
3 changes: 0 additions & 3 deletions src/AnticheatData.h
Original file line number Diff line number Diff line change
@@ -72,8 +72,6 @@ class AnticheatData
void SetDailyReportState(bool b);
bool GetDailyReportState();

[[nodiscard]] bool GetJustUsedMovementSpell() const { return justUsedMovementSpell; }
void SetJustUsedMovementSpell(bool value) { justUsedMovementSpell = value; }
private:
uint32 lastOpcode;
MovementInfo lastMovementInfo;
@@ -86,7 +84,6 @@ class AnticheatData
uint32 tempReports[MAX_REPORT_TYPES];
uint32 tempReportsTimer[MAX_REPORT_TYPES];
bool hasDailyReport;
bool justUsedMovementSpell;
};

#endif
73 changes: 10 additions & 63 deletions src/AnticheatMgr.cpp
Original file line number Diff line number Diff line change
@@ -45,17 +45,10 @@ constexpr auto ALLOWED_ACK_LAG = 2000;

enum Spells : uint32
{
BLINK = 1953,
BLINK_COOLDOWN_REDUCTION = 23025, // Reduces Blink cooldown by 2 seconds.
GLYPH_OF_BLINK = 56365, // Increases Blink distance by 5 yards.
SHADOWSTEP = 36554,
FILTHY_TRICKS_RANK_1 = 58414, // Reduces Shadowstep cooldown by 5 seconds.
FILTHY_TRICKS_RANK_2 = 58415, // Reduces Shadowstep cooldown by 10 seconds.
SHACKLES = 38505,
LFG_SPELL_DUNGEON_DESERTER = 71041,
BG_SPELL_DESERTER = 26013,
SILENCED = 23207,
RESURRECTION_SICKNESS = 15007,
SLOWDOWN = 61458
};

@@ -354,54 +347,14 @@ void AnticheatMgr::BuildAndSendReportToIngameGameMasters(Player* player, ReportT
}
}

uint32 AnticheatMgr::GetTeleportSkillCooldownDurationInMS(Player* player) const
{
switch (player->getClass())
{
case CLASS_ROGUE:
if (player->HasAura(FILTHY_TRICKS_RANK_2))
return 20000u;
else if (player->HasAura(FILTHY_TRICKS_RANK_1))
return 25000u;
return 30000u;
case CLASS_MAGE:
if (player->HasAura(BLINK_COOLDOWN_REDUCTION)) // Bonus from Vanilla/Early TBC pvp gear.
return 13000u;
return 15000u;
default:
return 0u;
}
}

float AnticheatMgr::GetTeleportSkillDistanceInYards(Player* player) const
{
switch (player->getClass())
{
case CLASS_ROGUE: // The rogue's teleport spell is Shadowstep.
return 25.0f; // Synful-Syn: Help needed! At least, 25 yards adjustment is better than nothing!
// The spell can be casted at a maximum of 25 yards from the middle of the ennemy and teleports the player a short distance behind the target which might be over 25 yards, especially when the target is facing the rogue.
// Using Shadowstep on Onyxia at as far as I could moved me by 44 yards. Doing it on a blood elf in duel moved me 29 yards.
case CLASS_MAGE: // The mage's teleport spell is Blink.
if (player->HasAura(GLYPH_OF_BLINK))
return 25.1f; // Includes a 0.1 miscalculation margin.
return 20.1f; // Includes a 0.1 miscalculation margin.
default:
return 0.0f;
}
}

// Get how many yards the player can move in a second.
float AnticheatMgr::GetPlayerCurrentSpeedRate(Player* player) const
{
// we need to know HOW is the player moving
// TO-DO: Should we check the incoming movement flags?
if (player->HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING))
return player->GetSpeed(MOVE_SWIM);
else if (player->IsFlying())
return player->GetSpeed(MOVE_FLIGHT);
else if (player->HasUnitMovementFlag(MOVEMENTFLAG_WALKING))
return player->GetSpeed(MOVE_WALK);
return player->GetSpeed(MOVE_RUN);
return std::max({player->GetSpeed(MOVE_WALK), player->GetSpeed(MOVE_FLIGHT), player->GetSpeed(MOVE_RUN)});
}

void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo)
@@ -414,6 +367,10 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo)
if (m_Players[key].GetLastMapId() != player->GetMapId())
return;

//例外部分光环,111为LUA传送和特定技能后用,8326为死亡释放后自带,56365为闪现,36554为暗影步,51690为杀戮盛宴
if (player->HasAura(111) || player->HasAura(8326) || player->HasAura(56365) || player->HasAura(36554) || player->HasAura(51690))
return;

// We also must check the map because the movementFlag can be modified by the client.
// If we just check the flag, they could always add that flag and always skip the speed hacking detection.

@@ -521,21 +478,6 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo)
BuildReport(player, COUNTER_MEASURES_REPORT, movementInfo);
}

// Adjust distance from Blink/Shadowstep.
if (player->HasAura(BLINK) || player->HasAura(SHADOWSTEP))
{
// Only adjust the travelled distance if the player previously didn't use a movement spell or didn't move at all since they previously used the movement spell.
if (!m_Players[key].GetJustUsedMovementSpell() || timeDiff >= GetTeleportSkillCooldownDurationInMS(player))
{
m_Players[key].SetJustUsedMovementSpell(true);
distance2D = std::max(distance2D - GetTeleportSkillDistanceInYards(player), 0.0f);
}
}
else
{
m_Players[key].SetJustUsedMovementSpell(false);
}

// this is the distance doable by the player in 1 sec, using the time done to move to this point.
float clientSpeedRate = 0.0f;
if (float floatTimeDiff = float(timeDiff))
@@ -587,6 +529,11 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo)
}
BuildReport(player, COUNTER_MEASURES_REPORT, movementInfo);
}
std::string str = "|cFFFFFC00 SPEED HACK Speed " + std::to_string(clientSpeedRate) + ", and current allow Speed " + std::to_string(speedRate) + ", and time " + std::to_string(timeDiff);
DoToAllGMs([&](Player* p)
{
ChatHandler(p->GetSession()).PSendModuleSysMessage(modulestring, LANG_ANTICHEAT_COUNTERMEASURE, str, player->GetName(), player->GetName());
});
BuildReport(player, SPEED_HACK_REPORT, movementInfo);
}
}
2 changes: 0 additions & 2 deletions src/AnticheatMgr.h
Original file line number Diff line number Diff line change
@@ -140,8 +140,6 @@ class AnticheatMgr
[[nodiscard]] uint32 GetMaximumReportInChatThresholdConfigFromReportType(ReportTypes reportType);
void BuildAndSendReportToIngameGameMasters(Player* player, ReportTypes reportType, Optional<MovementInfo> optMovementInfo);

[[nodiscard]] uint32 GetTeleportSkillCooldownDurationInMS(Player* player) const;
[[nodiscard]] float GetTeleportSkillDistanceInYards(Player* player) const;
[[nodiscard]] float GetPlayerCurrentSpeedRate(Player* player) const;
uint32 _updateCheckTimer = 4000;
std::array<Position, PVP_TEAMS_COUNT> _startPosition;

0 comments on commit c347e2d

Please sign in to comment.