forked from metin2/server
Used effolkronium/random for PRNG
This commit is contained in:
@@ -328,7 +328,7 @@ void Initialize()
|
||||
|
||||
int DetermineFishByProbIndex(int prob_idx)
|
||||
{
|
||||
int rv = number(1, g_prob_sum[prob_idx]);
|
||||
int rv = Random::get(1, g_prob_sum[prob_idx]);
|
||||
int * p = std::lower_bound(g_prob_accumulate[prob_idx], g_prob_accumulate[prob_idx]+ MAX_FISH, rv);
|
||||
int fish_idx = p - g_prob_accumulate[prob_idx];
|
||||
return fish_idx;
|
||||
@@ -382,7 +382,7 @@ int DetermineFish(LPCHARACTER ch)
|
||||
adjust = (100-fish_pct_value) * fish_info[0].prob[prob_idx] / 100;
|
||||
}
|
||||
|
||||
int rv = number(adjust + 1, g_prob_sum[prob_idx]);
|
||||
int rv = Random::get(adjust + 1, g_prob_sum[prob_idx]);
|
||||
|
||||
int * p = std::lower_bound(g_prob_accumulate[prob_idx], g_prob_accumulate[prob_idx] + MAX_FISH, rv);
|
||||
int fish_idx = p - g_prob_accumulate[prob_idx];
|
||||
@@ -438,7 +438,7 @@ void FishingPractice(LPCHARACTER ch)
|
||||
if (rod && rod->GetType() == ITEM_ROD)
|
||||
{
|
||||
// <20>ִ<EFBFBD> <20><><EFBFBD>õ<EFBFBD><C3B5><EFBFBD> <20>ƴ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ô<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
if ( rod->GetRefinedVnum()>0 && rod->GetSocket(0) < rod->GetValue(2) && number(1,rod->GetValue(1))==1 )
|
||||
if ( rod->GetRefinedVnum()>0 && rod->GetSocket(0) < rod->GetValue(2) && Random::get(1,rod->GetValue(1))==1 )
|
||||
{
|
||||
rod->SetSocket(0, rod->GetSocket(0) + 1);
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>õ<EFBFBD><C3B5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>! (%d/%d)"),rod->GetSocket(0), rod->GetValue(2));
|
||||
@@ -529,7 +529,7 @@ LPEVENT CreateFishingEvent(LPCHARACTER ch)
|
||||
info->step = 0;
|
||||
info->hang_time = 0;
|
||||
|
||||
int time = number(10, 40);
|
||||
int time = Random::get(10, 40);
|
||||
|
||||
TPacketGCFishing p;
|
||||
p.header = HEADER_GC_FISHING;
|
||||
@@ -567,9 +567,9 @@ int Compute(DWORD fish_id, DWORD ms, DWORD* item, int level)
|
||||
|
||||
int time_step = MINMAX(0,((ms + 99) / 200), MAX_FISHING_TIME_COUNT - 1);
|
||||
|
||||
if (number(1, 100) <= aFishingTime[fish_info[fish_id].time_type][time_step])
|
||||
if (Random::get(1, 100) <= aFishingTime[fish_info[fish_id].time_type][time_step])
|
||||
{
|
||||
if (number(1, fish_info[fish_id].difficulty) <= level)
|
||||
if (Random::get(1, fish_info[fish_id].difficulty) <= level)
|
||||
{
|
||||
*item = fish_info[fish_id].vnum;
|
||||
return 0;
|
||||
@@ -582,19 +582,19 @@ int Compute(DWORD fish_id, DWORD ms, DWORD* item, int level)
|
||||
|
||||
int GetFishLength(int fish_id)
|
||||
{
|
||||
if (number(0,99))
|
||||
if (Random::get(0,99))
|
||||
{
|
||||
// 99% : normal size
|
||||
return (int)(fish_info[fish_id].length_range[0] +
|
||||
(fish_info[fish_id].length_range[1] - fish_info[fish_id].length_range[0])
|
||||
* (number(0,2000)+number(0,2000)+number(0,2000)+number(0,2000)+number(0,2000))/10000);
|
||||
* (Random::get(0,2000)+Random::get(0,2000)+Random::get(0,2000)+Random::get(0,2000)+Random::get(0,2000))/10000);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 1% : extra LARGE size
|
||||
return (int)(fish_info[fish_id].length_range[1] +
|
||||
(fish_info[fish_id].length_range[2] - fish_info[fish_id].length_range[1])
|
||||
* 2 * asin(number(0,10000)/10000.) / M_PI);
|
||||
* 2 * asin(Random::get(0,10000)/10000.) / M_PI);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -739,7 +739,7 @@ void Simulation(int level, int count, int prob_idx, LPCHARACTER ch)
|
||||
{
|
||||
int fish_id = DetermineFishByProbIndex(prob_idx);
|
||||
DWORD item = 0;
|
||||
Compute(fish_id, (number(2000, 4000) + number(2000,4000)) / 2, &item, level);
|
||||
Compute(fish_id, (Random::get(2000, 4000) + Random::get(2000,4000)) / 2, &item, level);
|
||||
|
||||
if (item)
|
||||
{
|
||||
@@ -763,7 +763,7 @@ void UseFish(LPCHARACTER ch, LPITEM item)
|
||||
if (idx<=1 || idx >= MAX_FISH)
|
||||
return;
|
||||
|
||||
int r = number(1, 10000);
|
||||
int r = Random::get(1, 10000);
|
||||
|
||||
item->SetCount(item->GetCount()-1);
|
||||
|
||||
@@ -794,7 +794,7 @@ void UseFish(LPCHARACTER ch, LPITEM item)
|
||||
case USED_SHELLFISH: // 1
|
||||
if ( LC_IsCanada() == true )
|
||||
{
|
||||
if ( number(0, 2) != 2 ) return;
|
||||
if ( Random::get(0, 2) != 2 ) return;
|
||||
}
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<EFBFBD><EFBFBD> <20>ӿ<EFBFBD><D3BF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>Խ<EFBFBD><D4BD>ϴ<EFBFBD>."));
|
||||
@@ -869,7 +869,7 @@ int RealRefineRod(LPCHARACTER ch, LPITEM item)
|
||||
|
||||
int iAdv = rod->GetValue(0) / 10;
|
||||
|
||||
if (number(1,100) <= rod->GetValue(3))
|
||||
if (Random::get(1,100) <= rod->GetValue(3))
|
||||
{
|
||||
LogManager::instance().RefineLog(ch->GetPlayerID(), rod->GetName(), rod->GetID(), iAdv, 1, "ROD");
|
||||
|
||||
|
Reference in New Issue
Block a user