Jump to content

Recommended Posts

spacer.png

 

 

How is it possible that you drop +4 stones if the percentage is 0? I just changed the percentages and removed some rows (some metin stones) from the table 

 

 

Edited by Metin2 Dev International
Core X - External 2 Internal
Link to comment
https://metin2.dev/topic/30702-strone-drop-from-source-costantscpp/
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Bot

Hello,

If you check the algorithm in char.cpp (DetermineDropMetinStone()) you will see that in some cases that is totaly posible. (for example pick randomly number 90 and folow the algorithm with the percentages from your table line 1 (40, 13, 5, 2, 0).

If you look closely the last value from the table is not even used because the loop goes from 0 to 3 only (the 0 in your table). 

To fix this I consider the best way is to use discrete_distribution from stl:
 

#include <random>

void CHARACTER::DetermineDropMetinStone()
{
	const int METIN_STONE_NUM = 14;
	static DWORD c_adwMetin[METIN_STONE_NUM] = 
	{
		28030,
		28031,
		28032,
		28033,
		28034,
		28035,
		28036,
		28037,
		28038,
		28039,
		28040,
		28041,
		28042,
		28043,
	};
	
	DWORD stone_num = GetRaceNum();
	int idx = std::lower_bound(aStoneDrop, aStoneDrop+STONE_INFO_MAX_NUM, stone_num) - aStoneDrop;
	if (idx >= STONE_INFO_MAX_NUM || aStoneDrop[idx].dwMobVnum != stone_num)
	{
		m_dwDropMetinStone = 0;
	}
	else
	{
		const SStoneDropInfo & info = aStoneDrop[idx];
		m_bDropMetinStonePct = info.iDropPct;

		std::random_device rd;
		std::mt19937 gen(rd());
		std::discrete_distribution<> d(info.iLevelPct, info.iLevelPct + STONE_LEVEL_MAX_NUM + 1);
		int randomIndex = d(gen); // This will be a random number in range (0, 4)
		m_dwDropMetinStone = c_adwMetin[number(0, METIN_STONE_NUM - 1)] + (randomIndex * 100);
	}
}

 

Edited by Abel(Tiger)

english_banner.gif

30 minutes ago, Abel(Tiger) said:

Hello,

If you check the algorithm in char.cpp (DetermineDropMetinStone()) you will see that in some cases that is totaly posible. (for example pick randomly number 90 and folow the algorithm with the percentages from your table line 1 (40, 13, 5, 2, 0).

If you look closely the last value from the table is not even used because the loop goes from 0 to 3 only (the 0 in your table). 

To fix this I consider the best way is to use discrete_distribution from stl:
 

#include <random>

void CHARACTER::DetermineDropMetinStone()
{
	const int METIN_STONE_NUM = 14;
	static DWORD c_adwMetin[METIN_STONE_NUM] = 
	{
		28030,
		28031,
		28032,
		28033,
		28034,
		28035,
		28036,
		28037,
		28038,
		28039,
		28040,
		28041,
		28042,
		28043,
	};
	
	DWORD stone_num = GetRaceNum();
	int idx = std::lower_bound(aStoneDrop, aStoneDrop+STONE_INFO_MAX_NUM, stone_num) - aStoneDrop;
	if (idx >= STONE_INFO_MAX_NUM || aStoneDrop[idx].dwMobVnum != stone_num)
	{
		m_dwDropMetinStone = 0;
	}
	else
	{
		const SStoneDropInfo & info = aStoneDrop[idx];
		m_bDropMetinStonePct = info.iDropPct;

		std::random_device rd;
		std::mt19937 gen(rd());
		std::discrete_distribution<> d(info.iLevelPct, info.iLevelPct + STONE_LEVEL_MAX_NUM + 1);
		int randomIndex = d(gen); // This will be a random number in range (0, 4)
		m_dwDropMetinStone = c_adwMetin[number(0, METIN_STONE_NUM - 1)] + (randomIndex * 100);
	}
}

 

Thanks i have another little problem but im not sure that is from source , i want to remove automatic riding when teleporting but i don't know what whatch/modify

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.