diff --git a/conf/Anticheat.conf.dist b/conf/Anticheat.conf.dist index 21b0761..f609bac 100644 --- a/conf/Anticheat.conf.dist +++ b/conf/Anticheat.conf.dist @@ -160,3 +160,15 @@ Anticheat.ReportsForJail = 70 Anticheat.AnnounceKick = 0 Anticheat.AnnounceBan = 0 Anticheat.AnnounceJail = 0 + +# Anticheat Counter Measures +# +# Anticheat.BG.StartAreaTeleport +# +# Description: Sends player back to start position if player cheats and teleports out of start spot +# before the BG begins. +# Default: 0 - (Disabled) +# 1 - (Enabled) +# + +Anticheat.BG.StartAreaTeleport = 0 diff --git a/src/AnticheatMgr.cpp b/src/AnticheatMgr.cpp index 096ad48..eed7505 100644 --- a/src/AnticheatMgr.cpp +++ b/src/AnticheatMgr.cpp @@ -936,6 +936,30 @@ void AnticheatMgr::BGreport(Player* player) BuildReport(player, TELEPORT_HACK_REPORT); } +Position const* AnticheatMgr::GetTeamStartPosition(TeamId teamId) const +{ + return &_startPosition[teamId]; +} + +void AnticheatMgr::CheckStartPositions(Player* player) +{ + if (!sConfigMgr->GetOption("Anticheat.BG.StartAreaTeleport", true)) + return; + + Position pos = player->GetPosition(); + Position const* startPos = GetTeamStartPosition(player->GetBgTeamId()); + + if (pos.GetExactDistSq(!startPos)) + { + if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) + { + LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: Sending {} back to start location (BG Map: {}) (possible exploit)", player->GetName(), player->GetMapId()); + } + player->TeleportTo(player->GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation()); + } + +} + void AnticheatMgr::BGStartExploit(Player* player, MovementInfo movementInfo) { if (!sConfigMgr->GetOption("Anticheat.DetectBGStartHack", true)) @@ -957,12 +981,14 @@ void AnticheatMgr::BGStartExploit(Player* player, MovementInfo movementInfo) (player->GetTeamId() == TEAM_ALLIANCE && movementInfo.pos.GetPositionY() < -525.0f)) { sAnticheatMgr->BGreport(player); + sAnticheatMgr->CheckStartPositions(player); } if ((player->GetTeamId() == TEAM_HORDE && movementInfo.pos.GetPositionY() > -535.0f) || (player->GetTeamId() == TEAM_HORDE && movementInfo.pos.GetPositionX() > -1283.33f) || (player->GetTeamId() == TEAM_HORDE && movementInfo.pos.GetPositionY() < -716.0f)) { sAnticheatMgr->BGreport(player); + sAnticheatMgr->CheckStartPositions(player); } } } @@ -974,6 +1000,7 @@ void AnticheatMgr::BGStartExploit(Player* player, MovementInfo movementInfo) if (!(movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING_FAR) || m_Players[key].GetLastOpcode() == MSG_MOVE_JUMP) && movementInfo.pos.GetPositionZ() > 380.0f) { sAnticheatMgr->BGreport(player); + sAnticheatMgr->CheckStartPositions(player); } if (Battleground* bg = player->GetBattleground()) { @@ -985,12 +1012,14 @@ void AnticheatMgr::BGStartExploit(Player* player, MovementInfo movementInfo) (player->GetTeamId() == TEAM_ALLIANCE && movementInfo.pos.GetPositionY() < 1450.0f)) { sAnticheatMgr->BGreport(player); + sAnticheatMgr->CheckStartPositions(player); } if ((player->GetTeamId() == TEAM_HORDE && movementInfo.pos.GetPositionX() > 957.0f) || (player->GetTeamId() == TEAM_HORDE && movementInfo.pos.GetPositionY() < 1416.0f) || (player->GetTeamId() == TEAM_HORDE && movementInfo.pos.GetPositionY() > 1466.0f)) { sAnticheatMgr->BGreport(player); + sAnticheatMgr->CheckStartPositions(player); } } } @@ -1008,11 +1037,13 @@ void AnticheatMgr::BGStartExploit(Player* player, MovementInfo movementInfo) (player->GetTeamId() == TEAM_ALLIANCE && movementInfo.pos.GetPositionY() > 1361.0f)) { sAnticheatMgr->BGreport(player); + sAnticheatMgr->CheckStartPositions(player); } if ((player->GetTeamId() == TEAM_HORDE && movementInfo.pos.GetPositionX() > 730.0f) || (player->GetTeamId() == TEAM_HORDE && movementInfo.pos.GetPositionY() > 724.8f)) { sAnticheatMgr->BGreport(player); + sAnticheatMgr->CheckStartPositions(player); } } } @@ -1030,12 +1061,14 @@ void AnticheatMgr::BGStartExploit(Player* player, MovementInfo movementInfo) (player->GetTeamId() == TEAM_ALLIANCE && movementInfo.pos.GetPositionY() < 1584.0f)) { sAnticheatMgr->BGreport(player); + sAnticheatMgr->CheckStartPositions(player); } if ((player->GetTeamId() == TEAM_HORDE && movementInfo.pos.GetPositionX() > 1816.0f) || (player->GetTeamId() == TEAM_HORDE && movementInfo.pos.GetPositionY() > 1554.0f) || (player->GetTeamId() == TEAM_HORDE && movementInfo.pos.GetPositionY() < 1526.0f)) { sAnticheatMgr->BGreport(player); + sAnticheatMgr->CheckStartPositions(player); } } } @@ -1053,12 +1086,14 @@ void AnticheatMgr::BGStartExploit(Player* player, MovementInfo movementInfo) (player->GetTeamId() == TEAM_ALLIANCE && movementInfo.pos.GetPositionY() > -760.0f)) { sAnticheatMgr->BGreport(player); + sAnticheatMgr->CheckStartPositions(player); } if ((player->GetTeamId() == TEAM_HORDE && movementInfo.pos.GetPositionX() < 1147.8f) || (player->GetTeamId() == TEAM_HORDE && movementInfo.pos.GetPositionY() < -855.0f) || (player->GetTeamId() == TEAM_HORDE && movementInfo.pos.GetPositionY() > -676.0f)) { sAnticheatMgr->BGreport(player); + sAnticheatMgr->CheckStartPositions(player); } } } diff --git a/src/AnticheatMgr.h b/src/AnticheatMgr.h index 23b9b8a..9620cc6 100644 --- a/src/AnticheatMgr.h +++ b/src/AnticheatMgr.h @@ -109,6 +109,8 @@ class AnticheatMgr void AnticheatDeleteCommand(ObjectGuid guid); void AnticheatPurgeCommand(ChatHandler* handler); void ResetDailyReportStates(); + void SetMapId(uint32 MapID) { m_MapId = MapID; } + [[nodiscard]] uint32 GetMapId() const { return m_MapId; } private: void SpeedHackDetection(Player* player, MovementInfo movementInfo); @@ -125,6 +127,7 @@ class AnticheatMgr void AntiKnockBackHackDetection(Player* player, MovementInfo movementInfo); void NoFallDamageDetection(Player* player, MovementInfo movementInfo); void BGreport(Player* player); + void CheckStartPositions(Player* player); void BGStartExploit(Player* player, MovementInfo movementInfo); void BuildReport(Player* player,uint16 reportType); bool MustCheckTempReports(uint8 type); @@ -132,6 +135,9 @@ class AnticheatMgr uint32 _alertFrequency = 0; uint32 _assignedspeeddiff = 0; uint32 _updateCheckTimer = 4000; + uint32 m_MapId; + std::array _startPosition; + Position const* GetTeamStartPosition(TeamId teamId) const; AnticheatPlayersDataMap m_Players; ///< Player data };