Original work done by Grz3s on Cmangos (cherry picked from commit 59a4ea1edce35a29bbe53b80767c7872999854a1)