diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_chess_event.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_chess_event.cpp index b7a481ace..564c6a75d 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_chess_event.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_chess_event.cpp @@ -395,88 +395,85 @@ struct npc_echo_of_medivh : public ScriptedAI for (uint8 col = 0; col < MAX_COL; ++col) { BoardCell const& cell = _boards[row][col]; - if (cell.pieceGUID == piece->GetGUID()) + if (cell.pieceGUID != piece->GetGUID()) + continue; + + std::vector orientations; + switch (orientation) { - std::vector orientations; - switch (orientation) + case ORI_SE: + orientations = { ORI_NE, ORI_E, ORI_S, ORI_SW }; + break; + case ORI_S: + orientations = { ORI_E, ORI_SE, ORI_SW, ORI_W }; + break; + case ORI_SW: + orientations = { ORI_SE, ORI_S, ORI_W, ORI_NW }; + break; + case ORI_W: + orientations = { ORI_NE, ORI_SW, ORI_NW, ORI_N }; + break; + case ORI_NW: + orientations = { ORI_SW, ORI_W, ORI_N, ORI_NE }; + break; + case ORI_N: + orientations = { ORI_W, ORI_NW, ORI_NE, ORI_E }; + break; + case ORI_NE: + orientations = { ORI_NW, ORI_N, ORI_E, ORI_SE }; + break; + case ORI_E: + orientations = { ORI_N, ORI_NE, ORI_SE, ORI_S }; + break; + default: + break; + } + + for (KarazhanChessOrientationType orient : orientations) + { + uint8 newRow = row; + uint8 newCol = col; + switch (orient) { case ORI_SE: - orientations = { ORI_NE, ORI_E, ORI_S, ORI_SW }; + newRow -= 1; break; case ORI_S: - orientations = { ORI_E, ORI_SE, ORI_SW, ORI_W }; + newRow -= 1; + newCol -= 1; break; case ORI_SW: - orientations = { ORI_SE, ORI_S, ORI_W, ORI_NW }; + newCol -= 1; break; case ORI_W: - orientations = { ORI_NE, ORI_SW, ORI_NW, ORI_N }; + newRow += 1; + newCol -= 1; break; case ORI_NW: - orientations = { ORI_SW, ORI_W, ORI_N, ORI_NE }; + newRow += 1; break; case ORI_N: - orientations = { ORI_W, ORI_NW, ORI_NE, ORI_E }; + newRow += 1; + newCol += 1; break; case ORI_NE: - orientations = { ORI_NW, ORI_N, ORI_E, ORI_SE }; + newCol += 1; break; case ORI_E: - orientations = { ORI_N, ORI_NE, ORI_SE, ORI_S }; + newRow -= 1; + newCol += 1; break; default: break; } - for (KarazhanChessOrientationType orient : orientations) - { - uint8 newRow = row; - uint8 newCol = col; - switch (orient) - { - case ORI_SE: - newRow -= 1; - break; - case ORI_S: - newRow -= 1; - newCol -= 1; - break; - case ORI_SW: - newCol -= 1; - break; - case ORI_W: - newRow += 1; - newCol -= 1; - break; - case ORI_NW: - newRow += 1; - break; - case ORI_N: - newRow += 1; - newCol += 1; - break; - case ORI_NE: - newCol += 1; - break; - case ORI_E: - newRow -= 1; - newCol += 1; - break; - default: - break; - } - + if (newRow < MAX_ROW && newCol < MAX_COL && newRow >= 0 && newCol >= 0) if (Creature* targetPiece = ObjectAccessor::GetCreature(*me, _boards[newRow][newCol].pieceGUID)) - { if (!IsFriendly(piece, targetPiece)) - { return targetPiece; - } - } - } - - return nullptr; } + + return nullptr; } }