Premium flatik 190 Posted December 20, 2020 Premium Share Posted December 20, 2020 Hi all! This is recommended for those who are testing or running on windows. The reason for the error is that they have a 100% chance of dropp. C++11. Based on the video, you can watch: number_ex old version: https://metin2.download/video/404cFTu02qN7zGDbO2RA8za82mHM6xzq/.mp4 number_ex fixed: https://metin2.download/video/8084RGh8gld28tLTsoYfx1ITK5W1fWxC/.mp4 FIX: #include <random> int number_ex(int from, int to, const char* file, int line) { if (from > to) { int tmp = from; sys_err("number(): first argument is bigger than second argument %d -> %d, %s %d", from, to, file, line); from = to; to = tmp; } int returnValue = 0; std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution<> distrib(from, to); if ((to - from + 1) != 0) returnValue = distrib(gen); else sys_err("number(): devided by 0"); return returnValue; } 2 3 10 c++latest, latest libs... Link to comment Share on other sites More sharing options...
DrTurk 133 Posted December 21, 2020 Share Posted December 21, 2020 (edited) good job Edited August 26, 2022 by Metin2 Dev Core X - External 2 Internal 3 Link to comment Share on other sites More sharing options...
Etzhel 115 Posted December 21, 2020 Share Posted December 21, 2020 (edited) int number_ex(int from, int to, const char *file, int line) { // We only need (and want) to initialize the mersenne twister generator once static std::random_device rd; static std::mt19937 mt(rd()); static std::uniform_int_distribution<int> dist; // not too expensive to create, though if (from > to) { int tmp = from; sys_err("number(): first argument is bigger than second argument %d -> %d, %s %d", from, to, file, line); from = to; to = tmp; } // Set the range we'd like our distribution to be on, and generate the number return dist(mt, std::uniform_int_distribution<int>::param_type(from, to)); } Edited December 21, 2020 by Etzhel 1 1 Link to comment Share on other sites More sharing options...
Active Member Exygo 1091 Posted May 7, 2022 Active Member Share Posted May 7, 2022 For people who might want to use this nowadays, I tested the drops and the upgrade succes percentage and is not so good, very bad drops and a lot of failed upgrades with this uniform random, but even if you use the ymir's function you might have situations where upgrade succeeds in a row or failing in a row 1 https://www.youtube.com/channel/UCQ8mAeda9TWq6SsTzB53emw/videos Link to comment Share on other sites More sharing options...
Developer Mitachi 1455 Posted May 13, 2022 Developer Share Posted May 13, 2022 (edited) I checked and apparently I misunderstood., but I'm intrigued by the discussion. Edited May 13, 2022 by Mitachi 1 Link to comment Share on other sites More sharing options...
Recommended Posts