1
0
Fork 0

Used effolkronium/random for PRNG

This commit is contained in:
Exynox 2022-11-27 14:36:04 +02:00
parent d188b4d53f
commit 3a74dac29e
55 changed files with 434 additions and 518 deletions

View File

@ -25,4 +25,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads)
find_package(Libevent CONFIG REQUIRED) find_package(Libevent CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE libevent::core libevent::extra libevent::pthreads) target_link_libraries(${PROJECT_NAME} PRIVATE libevent::core libevent::extra libevent::pthreads)
# effolkronium/random
find_package(effolkronium_random CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE effolkronium_random)
target_link_libraries(${PROJECT_NAME} PRIVATE libpoly libsql libthecore) target_link_libraries(${PROJECT_NAME} PRIVATE libpoly libsql libthecore)

View File

@ -777,7 +777,7 @@ void CClientManager::RESULT_SAFEBOX_LOAD(CPeer * pkPeer, SQLMsg * msg)
do do
{ {
dwSkillIdx = number(0, m_vec_skillTable.size()-1); dwSkillIdx = Random::get<int>(0, m_vec_skillTable.size() - 1);
dwSkillVnum = m_vec_skillTable[dwSkillIdx].dwVnum; dwSkillVnum = m_vec_skillTable[dwSkillIdx].dwVnum;

View File

@ -54,7 +54,7 @@ namespace
{ {
FSendPeerWar(BYTE bType, BYTE bWar, DWORD GID1, DWORD GID2) FSendPeerWar(BYTE bType, BYTE bWar, DWORD GID1, DWORD GID2)
{ {
if (number(0, 1)) if (Random::get<bool>())
std::swap(GID1, GID2); std::swap(GID1, GID2);
memset(&p, 0, sizeof(TPacketGuildWar)); memset(&p, 0, sizeof(TPacketGuildWar));

View File

@ -42,10 +42,13 @@ if (LZO_FOUND)
target_link_libraries (${PROJECT_NAME} ${LZO_LIBRARIES}) target_link_libraries (${PROJECT_NAME} ${LZO_LIBRARIES})
endif (LZO_FOUND) endif (LZO_FOUND)
# Pthreads # Pthreads
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package (Threads REQUIRED) find_package (Threads REQUIRED)
target_link_libraries (${PROJECT_NAME} Threads::Threads) target_link_libraries (${PROJECT_NAME} Threads::Threads)
# effolkronium/random
find_package(effolkronium_random CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} effolkronium_random)
target_link_libraries(${PROJECT_NAME} libgame libpoly libsql libthecore liblua) target_link_libraries(${PROJECT_NAME} libgame libpoly libsql libthecore liblua)

View File

@ -312,7 +312,7 @@ void CBattleArena::SpawnRandomStone()
if ( idx < 0 || idx >= 3 ) return; if ( idx < 0 || idx >= 3 ) return;
CHARACTER_MANAGER::instance().SpawnMobRange( CHARACTER_MANAGER::instance().SpawnMobRange(
vnum[number(0, 6)], vnum[Random::get(0, 6)],
m_nMapIndex, m_nMapIndex,
region_info[idx][0], region_info[idx][1], region_info[idx][2], region_info[idx][3], region_info[idx][0], region_info[idx][1], region_info[idx][2], region_info[idx][3],
false, true); false, true);

View File

@ -37,7 +37,7 @@ time_t UseBlueDragonSkill(LPCHARACTER pChar, unsigned int idx)
pSecMap->for_each( f ); pSecMap->for_each( f );
nextUsingTime = number(BlueDragon_GetSkillFactor(3, "Skill0", "period", "min"), BlueDragon_GetSkillFactor(3, "Skill0", "period", "max")); nextUsingTime = Random::get(BlueDragon_GetSkillFactor(3, "Skill0", "period", "min"), BlueDragon_GetSkillFactor(3, "Skill0", "period", "max"));
} }
break; break;
@ -49,7 +49,7 @@ time_t UseBlueDragonSkill(LPCHARACTER pChar, unsigned int idx)
pSecMap->for_each( f ); pSecMap->for_each( f );
nextUsingTime = number(BlueDragon_GetSkillFactor(3, "Skill1", "period", "min"), BlueDragon_GetSkillFactor(3, "Skill1", "period", "max")); nextUsingTime = Random::get(BlueDragon_GetSkillFactor(3, "Skill1", "period", "min"), BlueDragon_GetSkillFactor(3, "Skill1", "period", "max"));
} }
break; break;
@ -61,7 +61,7 @@ time_t UseBlueDragonSkill(LPCHARACTER pChar, unsigned int idx)
pSecMap->for_each( f ); pSecMap->for_each( f );
nextUsingTime = number(BlueDragon_GetSkillFactor(3, "Skill2", "period", "min"), BlueDragon_GetSkillFactor(3, "Skill2", "period", "max")); nextUsingTime = Random::get(BlueDragon_GetSkillFactor(3, "Skill2", "period", "min"), BlueDragon_GetSkillFactor(3, "Skill2", "period", "max"));
if (NULL != f.pFarthestChar) if (NULL != f.pFarthestChar)
{ {

View File

@ -10,9 +10,9 @@ struct FSkillBreath
{ {
pAttacker = p; pAttacker = p;
Set1 = static_cast<EJobs>(number(0,3)); Set1 = static_cast<EJobs>(Random::get(0,3));
Set2 = static_cast<EJobs>(number(0,3)); Set2 = static_cast<EJobs>(Random::get(0,3));
gender = static_cast<ESex>(number(0,2)); gender = static_cast<ESex>(Random::get(0,2));
} }
void operator()(LPENTITY ent) void operator()(LPENTITY ent)
@ -53,7 +53,7 @@ struct FSkillBreath
} }
int firstDamagePercent = number(BlueDragon_GetSkillFactor(4, "Skill0", "damage", ptr, "min"), BlueDragon_GetSkillFactor(4, "Skill0", "damage", ptr, "max")); int firstDamagePercent = Random::get(BlueDragon_GetSkillFactor(4, "Skill0", "damage", ptr, "min"), BlueDragon_GetSkillFactor(4, "Skill0", "damage", ptr, "max"));
pct += firstDamagePercent; pct += firstDamagePercent;
if (firstDamagePercent > 0) if (firstDamagePercent > 0)
@ -75,7 +75,7 @@ struct FSkillBreath
case JOB_MAX_NUM: return; case JOB_MAX_NUM: return;
} }
int secondDamagePercent = number(BlueDragon_GetSkillFactor(4, "Skill0", "damage", ptr, "min"), BlueDragon_GetSkillFactor(4, "Skill0", "damage", ptr, "max")); int secondDamagePercent = Random::get(BlueDragon_GetSkillFactor(4, "Skill0", "damage", ptr, "min"), BlueDragon_GetSkillFactor(4, "Skill0", "damage", ptr, "max"));
pct += secondDamagePercent; pct += secondDamagePercent;
if (secondDamagePercent > 0) if (secondDamagePercent > 0)
@ -93,7 +93,7 @@ struct FSkillBreath
default: return; default: return;
} }
int thirdDamagePercent = number(BlueDragon_GetSkillFactor(4, "Skill0", "gender", ptr, "min"), BlueDragon_GetSkillFactor(4, "Skill0", "gender", ptr, "max")); int thirdDamagePercent = Random::get(BlueDragon_GetSkillFactor(4, "Skill0", "gender", ptr, "min"), BlueDragon_GetSkillFactor(4, "Skill0", "gender", ptr, "max"));
pct += thirdDamagePercent; pct += thirdDamagePercent;
if (thirdDamagePercent > 0) if (thirdDamagePercent > 0)
@ -117,7 +117,7 @@ struct FSkillBreath
pct += addPct; pct += addPct;
int dam = number(BlueDragon_GetSkillFactor(3, "Skill0", "default_damage", "min"), BlueDragon_GetSkillFactor(3, "Skill0", "default_damage", "max")); int dam = Random::get(BlueDragon_GetSkillFactor(3, "Skill0", "default_damage", "min"), BlueDragon_GetSkillFactor(3, "Skill0", "default_damage", "max"));
dam += (dam * addPct) / 100; dam += (dam * addPct) / 100;
dam += (ch->GetMaxHP() * pct) / 100; dam += (ch->GetMaxHP() * pct) / 100;
@ -161,7 +161,7 @@ struct FSkillWeakBreath
int addPct = BlueDragon_GetRangeFactor("hp_damage", pAttacker->GetHPPct()); int addPct = BlueDragon_GetRangeFactor("hp_damage", pAttacker->GetHPPct());
int dam = number( BlueDragon_GetSkillFactor(3, "Skill1", "default_damage", "min"), BlueDragon_GetSkillFactor(3, "Skill1", "default_damage", "max") ); int dam = Random::get( BlueDragon_GetSkillFactor(3, "Skill1", "default_damage", "min"), BlueDragon_GetSkillFactor(3, "Skill1", "default_damage", "max") );
dam += (dam * addPct) / 100; dam += (dam * addPct) / 100;
ch->Damage( pAttacker, dam, DAMAGE_TYPE_ICE ); ch->Damage( pAttacker, dam, DAMAGE_TYPE_ICE );
@ -189,9 +189,9 @@ struct FSkillEarthQuake
MaxDistance = 0; MaxDistance = 0;
pFarthestChar = NULL; pFarthestChar = NULL;
Set1 = static_cast<EJobs>(number(0,3)); Set1 = static_cast<EJobs>(Random::get(0,3));
Set2 = static_cast<EJobs>(number(0,3)); Set2 = static_cast<EJobs>(Random::get(0,3));
gender = static_cast<ESex>(number(0,2)); gender = static_cast<ESex>(Random::get(0,2));
} }
void operator()(LPENTITY ent) void operator()(LPENTITY ent)
@ -213,7 +213,7 @@ struct FSkillEarthQuake
return; return;
} }
int sec = number(BlueDragon_GetSkillFactor(4, "Skill2", "stun_time", "default", "min"), BlueDragon_GetSkillFactor(4, "Skill2", "stun_time", "default", "max")); int sec = Random::get(BlueDragon_GetSkillFactor(4, "Skill2", "stun_time", "default", "min"), BlueDragon_GetSkillFactor(4, "Skill2", "stun_time", "default", "max"));
if (ch->GetJob() == Set1) if (ch->GetJob() == Set1)
{ {
@ -230,7 +230,7 @@ struct FSkillEarthQuake
case JOB_MAX_NUM: return; case JOB_MAX_NUM: return;
} }
sec += number(BlueDragon_GetSkillFactor(4, "Skill2", "stun_time", ptr, "min"), BlueDragon_GetSkillFactor(4, "Skill2", "stun_time", ptr, "max")); sec += Random::get(BlueDragon_GetSkillFactor(4, "Skill2", "stun_time", ptr, "min"), BlueDragon_GetSkillFactor(4, "Skill2", "stun_time", ptr, "max"));
} }
if (ch->GetJob() == Set2) if (ch->GetJob() == Set2)
@ -248,7 +248,7 @@ struct FSkillEarthQuake
case JOB_MAX_NUM: return; case JOB_MAX_NUM: return;
} }
sec += number(BlueDragon_GetSkillFactor(4, "Skill2", "stun_time", ptr, "min"), BlueDragon_GetSkillFactor(4, "Skill2", "stun_time", ptr, "max")); sec += Random::get(BlueDragon_GetSkillFactor(4, "Skill2", "stun_time", ptr, "min"), BlueDragon_GetSkillFactor(4, "Skill2", "stun_time", ptr, "max"));
} }
if (GET_SEX(ch) == gender) if (GET_SEX(ch) == gender)
@ -262,12 +262,12 @@ struct FSkillEarthQuake
default: return; default: return;
} }
sec += number(BlueDragon_GetSkillFactor(4, "Skill2", "gender", ptr, "min"), BlueDragon_GetSkillFactor(4, "Skill2", "gender", ptr, "max")); sec += Random::get(BlueDragon_GetSkillFactor(4, "Skill2", "gender", ptr, "min"), BlueDragon_GetSkillFactor(4, "Skill2", "gender", ptr, "max"));
} }
int addPct = BlueDragon_GetRangeFactor("hp_damage", pAttacker->GetHPPct()); int addPct = BlueDragon_GetRangeFactor("hp_damage", pAttacker->GetHPPct());
int dam = number( BlueDragon_GetSkillFactor(3, "Skill2", "default_damage", "min"), BlueDragon_GetSkillFactor(3, "Skill2", "default_damage", "max") ); int dam = Random::get( BlueDragon_GetSkillFactor(3, "Skill2", "default_damage", "min"), BlueDragon_GetSkillFactor(3, "Skill2", "default_damage", "max") );
dam += (dam * addPct) / 100; dam += (dam * addPct) / 100;
ch->Damage( pAttacker, dam, DAMAGE_TYPE_ICE); ch->Damage( pAttacker, dam, DAMAGE_TYPE_ICE);
@ -311,12 +311,12 @@ struct FSkillEarthQuake
ty = ch->GetY() + vec.y * nFlyDistance * -1; ty = ch->GetY() + vec.y * nFlyDistance * -1;
break; break;
case 3: case 3:
tx = ch->GetX() + vec.x * number(1,100); tx = ch->GetX() + vec.x * Random::get(1,100);
ty = ch->GetY() + vec.y * number(1,100); ty = ch->GetY() + vec.y * Random::get(1,100);
break; break;
case 4: case 4:
tx = ch->GetX() + vec.x * number(1,10); tx = ch->GetX() + vec.x * Random::get(1,10);
ty = ch->GetY() + vec.y * number(1,10); ty = ch->GetY() + vec.y * Random::get(1,10);
break; break;
} }
} }

View File

@ -20,7 +20,7 @@ int Gamble(std::vector<float>& vec_probs)
{ {
range += vec_probs[i]; range += vec_probs[i];
} }
float fProb = fnumber(0.f, range); float fProb = Random::get<float>(0.f, range);
float sum = 0.f; float sum = 0.f;
for (int idx = 0; idx < vec_probs.size(); idx++) for (int idx = 0; idx < vec_probs.size(); idx++)
{ {
@ -47,7 +47,7 @@ bool MakeDistinctRandomNumberSet(std::list <float> prob_lst, OUT std::vector<int
{ {
range += *it; range += *it;
} }
float r = fnumber (0.f, range); float r = Random::get<float>(0.f, range);
float sum = 0.f; float sum = 0.f;
int idx = 0; int idx = 0;
for (std::list <float>::iterator it = prob_lst.begin(); it != prob_lst.end(); it++) for (std::list <float>::iterator it = prob_lst.begin(); it != prob_lst.end(); it++)
@ -263,7 +263,7 @@ bool DSManager::PutAttributes(LPITEM pDS)
pDS->SetForceAttribute(i, bType, sValue); pDS->SetForceAttribute(i, bType, sValue);
} }
BYTE additional_attr_num = MIN(number (add_min, add_max), 3); BYTE additional_attr_num = MIN(Random::get(add_min, add_max), 3);
std::vector <int> random_set; std::vector <int> random_set;
if (additional_attr_num > 0) if (additional_attr_num > 0)
@ -450,7 +450,7 @@ bool DSManager::PullOut(LPCHARACTER ch, TItemPos DestCell, LPITEM& pItem, LPITEM
iBonus = pExtractor->GetValue(ITEM_VALUE_DRAGON_SOUL_POLL_OUT_BONUS_IDX); iBonus = pExtractor->GetValue(ITEM_VALUE_DRAGON_SOUL_POLL_OUT_BONUS_IDX);
pExtractor->SetCount(pExtractor->GetCount() - 1); pExtractor->SetCount(pExtractor->GetCount() - 1);
} }
fDice = fnumber(0.f, 100.f); fDice = Random::get<float>(0.f, 100.f);
bSuccess = fDice <= (fProb * (100 + iBonus) / 100.f); bSuccess = fDice <= (fProb * (100 + iBonus) / 100.f);
} }
@ -948,7 +948,7 @@ bool DSManager::DoRefineStrength(LPCHARACTER ch, TItemPos (&aItemPoses)[DRAGON_S
LPITEM pResult = NULL; LPITEM pResult = NULL;
BYTE bSubHeader; BYTE bSubHeader;
if (fnumber(0.f, 100.f) <= fProb) if (Random::get<float>(0.f, 100.f) <= fProb)
{ {
pResult = ITEM_MANAGER::instance().CreateItem(MakeDragonSoulVnum(bType, bGrade, bStep, bStrength + 1)); pResult = ITEM_MANAGER::instance().CreateItem(MakeDragonSoulVnum(bType, bGrade, bStep, bStrength + 1));
if (NULL == pResult) if (NULL == pResult)

View File

@ -217,7 +217,7 @@ EVENTFUNC(oxevent_timer)
if (LC_IsJapan()) if (LC_IsJapan())
{ {
SendNoticeMap("間違えた方々を外に移動させます。", OXEVENT_MAP_INDEX, true); SendNoticeMap("??????X??O??????????B", OXEVENT_MAP_INDEX, true);
} }
else else
{ {
@ -245,7 +245,7 @@ bool COXEventManager::Quiz(unsigned char level, int timelimit)
if (timelimit < 0) timelimit = 30; if (timelimit < 0) timelimit = 30;
int idx = number(0, m_vec_quiz[level].size()-1); int idx = Random::get<int>(0, m_vec_quiz[level].size() - 1);
SendNoticeMap(LC_TEXT("문제 입니다."), OXEVENT_MAP_INDEX, true); SendNoticeMap(LC_TEXT("문제 입니다."), OXEVENT_MAP_INDEX, true);
SendNoticeMap(m_vec_quiz[level][idx].Quiz, OXEVENT_MAP_INDEX, true); SendNoticeMap(m_vec_quiz[level][idx].Quiz, OXEVENT_MAP_INDEX, true);
@ -313,10 +313,10 @@ bool COXEventManager::CheckAnswer(bool answer)
else else
{ {
pkChar->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("정답입니다!")); pkChar->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("정답입니다!"));
// pkChar->CreateFly(number(FLY_FIREWORK1, FLY_FIREWORK6), pkChar); // pkChar->CreateFly(Random::get(FLY_FIREWORK1, FLY_FIREWORK6), pkChar);
char chatbuf[256]; char chatbuf[256];
int len = snprintf(chatbuf, sizeof(chatbuf), int len = snprintf(chatbuf, sizeof(chatbuf),
"%s %u %u", number(0, 1) == 1 ? "cheer1" : "cheer2", (DWORD)pkChar->GetVID(), 0); "%s %u %u", Random::get(0, 1) == 1 ? "cheer1" : "cheer2", (DWORD)pkChar->GetVID(), 0);
// 리턴값이 sizeof(chatbuf) 이상일 경우 truncate되었다는 뜻.. // 리턴값이 sizeof(chatbuf) 이상일 경우 truncate되었다는 뜻..
if (len < 0 || len >= (int) sizeof(chatbuf)) if (len < 0 || len >= (int) sizeof(chatbuf))
@ -370,7 +370,7 @@ void COXEventManager::WarpToAudience()
if (pkChar != NULL) if (pkChar != NULL)
{ {
switch ( number(0, 3)) switch ( Random::get(0, 3))
{ {
case 0 : pkChar->Show(OXEVENT_MAP_INDEX, 896300, 28900); break; case 0 : pkChar->Show(OXEVENT_MAP_INDEX, 896300, 28900); break;
case 1 : pkChar->Show(OXEVENT_MAP_INDEX, 890900, 28100); break; case 1 : pkChar->Show(OXEVENT_MAP_INDEX, 890900, 28100); break;

View File

@ -141,13 +141,13 @@ DWORD CPetActor::Summon(const char* petName, LPITEM pSummonItem, bool bSpawnFar)
if (true == bSpawnFar) if (true == bSpawnFar)
{ {
x += (number(0, 1) * 2 - 1) * number(2000, 2500); x += (Random::get(0, 1) * 2 - 1) * Random::get(2000, 2500);
y += (number(0, 1) * 2 - 1) * number(2000, 2500); y += (Random::get(0, 1) * 2 - 1) * Random::get(2000, 2500);
} }
else else
{ {
x += number(-100, 100); x += Random::get(-100, 100);
y += number(-100, 100); y += Random::get(-100, 100);
} }
if (0 != m_pkChar) if (0 != m_pkChar)
@ -192,12 +192,12 @@ DWORD CPetActor::Summon(const char* petName, LPITEM pSummonItem, bool bSpawnFar)
bool CPetActor::_UpdatAloneActionAI(float fMinDist, float fMaxDist) bool CPetActor::_UpdatAloneActionAI(float fMinDist, float fMaxDist)
{ {
float fDist = number(fMinDist, fMaxDist); float fDist = Random::get(fMinDist, fMaxDist);
float r = (float)number (0, 359); float r = Random::get<float>(0, 359);
float dest_x = GetOwner()->GetX() + fDist * cos(r); float dest_x = GetOwner()->GetX() + fDist * cos(r);
float dest_y = GetOwner()->GetY() + fDist * sin(r); float dest_y = GetOwner()->GetY() + fDist * sin(r);
//m_pkChar->SetRotation(number(0, 359)); // 방향은 랜덤으로 설정 //m_pkChar->SetRotation(Random::get(0, 359)); // 방향은 랜덤으로 설정
//GetDeltaByDegree(m_pkChar->GetRotation(), fDist, &fx, &fy); //GetDeltaByDegree(m_pkChar->GetRotation(), fDist, &fx, &fy);
@ -291,7 +291,7 @@ bool CPetActor::_UpdateFollowAI()
// Follow 중이지만 주인과 일정 거리 이내로 가까워졌다면 멈춤 // Follow 중이지만 주인과 일정 거리 이내로 가까워졌다면 멈춤
else else
m_pkChar->SendMovePacket(FUNC_WAIT, 0, 0, 0, 0); m_pkChar->SendMovePacket(FUNC_WAIT, 0, 0, 0, 0);
//else if (currentTime - m_dwLastActionTime > number(5000, 12000)) //else if (currentTime - m_dwLastActionTime > Random::get(5000, 12000))
//{ //{
// this->_UpdatAloneActionAI(START_FOLLOW_DISTANCE / 2, START_FOLLOW_DISTANCE); // this->_UpdatAloneActionAI(START_FOLLOW_DISTANCE / 2, START_FOLLOW_DISTANCE);
//} //}

View File

@ -179,7 +179,7 @@ void battle_end(LPCHARACTER ch)
int CalcBattleDamage(int iDam, int iAttackerLev, int iVictimLev) int CalcBattleDamage(int iDam, int iAttackerLev, int iVictimLev)
{ {
if (iDam < 3) if (iDam < 3)
iDam = number(1, 5); iDam = Random::get(1, 5);
//return CALCULATE_DAMAGE_LVDELTA(iAttackerLev, iVictimLev, iDam); //return CALCULATE_DAMAGE_LVDELTA(iAttackerLev, iVictimLev, iDam);
return iDam; return iDam;
@ -439,7 +439,7 @@ int CalcMeleeDamage(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, bool bIgnoreDe
iDamMax = pkAttacker->GetMobDamageMax(); iDamMax = pkAttacker->GetMobDamageMax();
} }
iDam = number(iDamMin, iDamMax) * 2; iDam = Random::get(iDamMin, iDamMax) * 2;
// TESTSERVER_SHOW_ATTACKINFO // TESTSERVER_SHOW_ATTACKINFO
DEBUG_iDamCur = iDam; DEBUG_iDamCur = iDam;
@ -568,7 +568,7 @@ int CalcArrowDamage(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, LPITEM pkBow,
int iDam = 0; int iDam = 0;
float fAR = CalcAttackRating(pkAttacker, pkVictim, false); float fAR = CalcAttackRating(pkAttacker, pkVictim, false);
iDam = number(pkBow->GetValue(3), pkBow->GetValue(4)) * 2 + pkArrow->GetValue(3); iDam = Random::get(pkBow->GetValue(3), pkBow->GetValue(4)) * 2 + pkArrow->GetValue(3);
int iAtk; int iAtk;
// level must be ignored when multiply by fAR, so subtract it before calculation. // level must be ignored when multiply by fAR, so subtract it before calculation.
@ -617,7 +617,7 @@ void NormalAttackAffect(LPCHARACTER pkAttacker, LPCHARACTER pkVictim)
// 독 공격은 특이하므로 특수 처리 // 독 공격은 특이하므로 특수 처리
if (pkAttacker->GetPoint(POINT_POISON_PCT) && !pkVictim->IsAffectFlag(AFF_POISON)) if (pkAttacker->GetPoint(POINT_POISON_PCT) && !pkVictim->IsAffectFlag(AFF_POISON))
{ {
if (number(1, 100) <= pkAttacker->GetPoint(POINT_POISON_PCT)) if (Random::get(1, 100) <= pkAttacker->GetPoint(POINT_POISON_PCT))
pkVictim->AttackedByPoison(pkAttacker); pkVictim->AttackedByPoison(pkAttacker);
} }

View File

@ -44,7 +44,7 @@ inline void AttackAffect(LPCHARACTER pkAttacker,
{ {
if (pkAttacker->GetPoint(att_point) && !pkVictim->IsAffectFlag(affect_flag)) if (pkAttacker->GetPoint(att_point) && !pkVictim->IsAffectFlag(affect_flag))
{ {
if (number(1, 100) <= pkAttacker->GetPoint(att_point) && !pkVictim->IsImmune(immune_flag)) if (Random::get(1, 100) <= pkAttacker->GetPoint(att_point) && !pkVictim->IsImmune(immune_flag))
{ {
pkVictim->AddAffect(affect_idx, affect_point, affect_amount, affect_flag, time, 0, true); pkVictim->AddAffect(affect_idx, affect_point, affect_amount, affect_flag, time, 0, true);
@ -72,7 +72,7 @@ inline void SkillAttackAffect(LPCHARACTER pkVictim,
{ {
if (success_pct && !pkVictim->IsAffectFlag(affect_flag)) if (success_pct && !pkVictim->IsAffectFlag(affect_flag))
{ {
if (number(1, 1000) <= success_pct && !pkVictim->IsImmune(immune_flag)) if (Random::get(1, 1000) <= success_pct && !pkVictim->IsImmune(immune_flag))
{ {
pkVictim->AddAffect(affect_idx, affect_point, affect_amount, affect_flag, time, 0, true); pkVictim->AddAffect(affect_idx, affect_point, affect_amount, affect_flag, time, 0, true);

View File

@ -155,7 +155,7 @@ bool Blend_Item_load(char *file)
static int FN_random_index() static int FN_random_index()
{ {
int percent = number(1,100); int percent = Random::get(1,100);
if (percent<=10) // level 1 :10% if (percent<=10) // level 1 :10%
return 0; return 0;
@ -179,7 +179,7 @@ static int FN_random_index()
static int FN_ECS_random_index() static int FN_ECS_random_index()
{ {
int percent = number(1,100); int percent = Random::get(1,100);
if (percent<=5) // level 1 : 5% if (percent<=5) // level 1 : 5%
return 0; return 0;

View File

@ -296,7 +296,7 @@ static DWORD FN_random_stone()
8027 8027
}; };
int index = number(0, 6); int index = Random::get(0, 6);
return vnum[index]; return vnum[index];
} }
@ -746,7 +746,7 @@ static DWORD FN_random_tower()
11510 11510
}; };
int index = number(0, 4); int index = Random::get(0, 4);
return vnum[index]; return vnum[index];
} }

View File

@ -1951,7 +1951,7 @@ void CHARACTER::SetProto(const CMob * pkMob)
info->ch = this; info->ch = this;
m_pkMiningEvent = event_create(kill_ore_load_event, info, PASSES_PER_SEC(number(7 * 60, 15 * 60))); m_pkMiningEvent = event_create(kill_ore_load_event, info, PASSES_PER_SEC(Random::get(7 * 60, 15 * 60)));
} }
// END_OF_MINING // END_OF_MINING
} }
@ -3155,8 +3155,8 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast
case 4: case 4:
{ {
int iHP = number(JobInitialPoints[GetJob()].hp_per_lv_begin, JobInitialPoints[GetJob()].hp_per_lv_end); int iHP = Random::get(JobInitialPoints[GetJob()].hp_per_lv_begin, JobInitialPoints[GetJob()].hp_per_lv_end);
int iSP = number(JobInitialPoints[GetJob()].sp_per_lv_begin, JobInitialPoints[GetJob()].sp_per_lv_end); int iSP = Random::get(JobInitialPoints[GetJob()].sp_per_lv_begin, JobInitialPoints[GetJob()].sp_per_lv_end);
m_points.iRandomHP += iHP; m_points.iRandomHP += iHP;
m_points.iRandomSP += iSP; m_points.iRandomSP += iSP;
@ -3951,7 +3951,7 @@ void CHARACTER::mining(LPCHARACTER chLoad)
return; return;
} }
int count = number(5, 15); // µ¿ÀÛ È½¼ö, ÇÑ µ¿ÀÛ´ç 2ÃÊ int count = Random::get(5, 15); // µ¿ÀÛ È½¼ö, ÇÑ µ¿ÀÛ´ç 2ÃÊ
// 䱤 µ¿ÀÛÀ» º¸¿©ÁÜ // 䱤 µ¿ÀÛÀ» º¸¿©ÁÜ
TPacketGCDigMotion p; TPacketGCDigMotion p;
@ -5465,9 +5465,9 @@ bool CHARACTER::Follow(LPCHARACTER pkChr, float fMinDistance)
while (--retry) while (--retry)
{ {
if (fDist < 500.0f) if (fDist < 500.0f)
GetDeltaByDegree((rot + number(-90, 90) + number(-90, 90)) % 360, fMinDistance, &fx, &fy); GetDeltaByDegree((rot + Random::get(-90, 90) + Random::get(-90, 90)) % 360, fMinDistance, &fx, &fy);
else else
GetDeltaByDegree(number(0, 359), fMinDistance, &fx, &fy); GetDeltaByDegree(Random::get(0, 359), fMinDistance, &fx, &fy);
dx = x + (int) fx; dx = x + (int) fx;
dy = y + (int) fy; dy = y + (int) fy;
@ -5878,8 +5878,8 @@ void CHARACTER::ResetPoint(int iLv)
SetRealPoint(POINT_IQ, JobInitialPoints[bJob].iq); SetRealPoint(POINT_IQ, JobInitialPoints[bJob].iq);
SetPoint(POINT_IQ, GetRealPoint(POINT_IQ)); SetPoint(POINT_IQ, GetRealPoint(POINT_IQ));
SetRandomHP((iLv - 1) * number(JobInitialPoints[GetJob()].hp_per_lv_begin, JobInitialPoints[GetJob()].hp_per_lv_end)); SetRandomHP((iLv - 1) * Random::get(JobInitialPoints[GetJob()].hp_per_lv_begin, JobInitialPoints[GetJob()].hp_per_lv_end));
SetRandomSP((iLv - 1) * number(JobInitialPoints[GetJob()].sp_per_lv_begin, JobInitialPoints[GetJob()].sp_per_lv_end)); SetRandomSP((iLv - 1) * Random::get(JobInitialPoints[GetJob()].sp_per_lv_begin, JobInitialPoints[GetJob()].sp_per_lv_end));
//PointChange(POINT_STAT, ((MINMAX(1, iLv, 99) - 1) * 3) + GetPoint(POINT_LEVEL_STEP) - GetPoint(POINT_STAT)); //PointChange(POINT_STAT, ((MINMAX(1, iLv, 99) - 1) * 3) + GetPoint(POINT_LEVEL_STEP) - GetPoint(POINT_STAT));
PointChange(POINT_STAT, ((MINMAX(1, iLv, 90) - 1) * 3) + GetPoint(POINT_LEVEL_STEP) - GetPoint(POINT_STAT)); PointChange(POINT_STAT, ((MINMAX(1, iLv, 90) - 1) * 3) + GetPoint(POINT_LEVEL_STEP) - GetPoint(POINT_STAT));
@ -5917,14 +5917,14 @@ void CHARACTER::GiveRandomSkillBook()
{ {
BYTE bJob = 0; BYTE bJob = 0;
if (!number(0, 1)) if (!Random::get<bool>())
bJob = GetJob() + 1; bJob = GetJob() + 1;
DWORD dwSkillVnum = 0; DWORD dwSkillVnum = 0;
do do
{ {
dwSkillVnum = number(1, 111); dwSkillVnum = Random::get(1, 111);
const CSkillProto* pkSk = CSkillManager::instance().Get(dwSkillVnum); const CSkillProto* pkSk = CSkillManager::instance().Get(dwSkillVnum);
if (NULL == pkSk) if (NULL == pkSk)
@ -6014,12 +6014,12 @@ void CHARACTER::MonsterChat(BYTE bMonsterChatType)
if (IsMonster()) if (IsMonster())
{ {
if (number(0, 60)) if (Random::get(0, 60))
return; return;
snprintf(sbuf, sizeof(sbuf), snprintf(sbuf, sizeof(sbuf),
"(locale.monster_chat[%i] and locale.monster_chat[%i][%d] or '')", "(locale.monster_chat[%i] and locale.monster_chat[%i][%d] or '')",
GetRaceNum(), GetRaceNum(), bMonsterChatType*3 + number(1, 3)); GetRaceNum(), GetRaceNum(), bMonsterChatType*3 + Random::get(1, 3));
} }
else else
{ {
@ -6028,12 +6028,12 @@ void CHARACTER::MonsterChat(BYTE bMonsterChatType)
if (IsGuardNPC()) if (IsGuardNPC())
{ {
if (number(0, 6)) if (Random::get(0, 6))
return; return;
} }
else else
{ {
if (number(0, 30)) if (Random::get(0, 30))
return; return;
} }
@ -6219,8 +6219,8 @@ void CHARACTER::DetermineDropMetinStone()
const SStoneDropInfo & info = aStoneDrop[idx]; const SStoneDropInfo & info = aStoneDrop[idx];
m_bDropMetinStonePct = info.iDropPct; m_bDropMetinStonePct = info.iDropPct;
{ {
m_dwDropMetinStone = c_adwMetin[number(0, METIN_STONE_NUM - 1)]; m_dwDropMetinStone = c_adwMetin[Random::get(0, METIN_STONE_NUM - 1)];
int iGradePct = number(1, 100); int iGradePct = Random::get(1, 100);
for (int iStoneLevel = 0; iStoneLevel < STONE_LEVEL_MAX_NUM; iStoneLevel ++) for (int iStoneLevel = 0; iStoneLevel < STONE_LEVEL_MAX_NUM; iStoneLevel ++)
{ {
int iLevelGradePortion = info.iLevelPct[iStoneLevel]; int iLevelGradePortion = info.iLevelPct[iStoneLevel];
@ -6327,7 +6327,7 @@ namespace {
if (3 != sscanf(pkWarp->GetName(), " %s %d %d ", szTmp, &m_lTargetX, &m_lTargetY)) if (3 != sscanf(pkWarp->GetName(), " %s %d %d ", szTmp, &m_lTargetX, &m_lTargetY))
{ {
if (number(1, 100) < 5) if (Random::get(1, 100) < 5)
sys_err("Warp NPC name wrong : vnum(%d) name(%s)", pkWarp->GetRaceNum(), pkWarp->GetName()); sys_err("Warp NPC name wrong : vnum(%d) name(%s)", pkWarp->GetRaceNum(), pkWarp->GetName());
m_bInvalid = true; m_bInvalid = true;
@ -6889,7 +6889,7 @@ void CHARACTER::SetGodSpeed(bool mode)
bool CHARACTER::IsDeathBlow() const bool CHARACTER::IsDeathBlow() const
{ {
if (number(1, 100) <= m_pkMobData->m_table.bDeathBlowPoint) if (Random::get(1, 100) <= m_pkMobData->m_table.bDeathBlowPoint)
{ {
return true; return true;
} }
@ -6916,7 +6916,7 @@ struct FFindReviver
if (ch->IsReviver() == true && pChar != ch && ch->IsDead() != true) if (ch->IsReviver() == true && pChar != ch && ch->IsDead() != true)
{ {
if (number(1, 100) <= ch->GetMobTable().bRevivePoint) if (Random::get(1, 100) <= ch->GetMobTable().bRevivePoint)
{ {
HasReviver = true; HasReviver = true;
pChar = ch; pChar = ch;
@ -7127,7 +7127,7 @@ void CHARACTER::IncreaseComboHackCount(int k)
if (m_iComboHackCount >= 10) if (m_iComboHackCount >= 10)
{ {
if (GetDesc()) if (GetDesc())
if (GetDesc()->DelayedDisconnect(number(2, 7))) if (GetDesc()->DelayedDisconnect(Random::get(2, 7)))
{ {
sys_log(0, "COMBO_HACK_DISCONNECT: %s count: %d", GetName(), m_iComboHackCount); sys_log(0, "COMBO_HACK_DISCONNECT: %s count: %d", GetName(), m_iComboHackCount);
LogManager::instance().HackLog("Combo", this); LogManager::instance().HackLog("Combo", this);

View File

@ -108,7 +108,7 @@ void CHARACTER::DistributeSP(LPCHARACTER pkKiller, int iMethod)
if (iMethod == 1) if (iMethod == 1)
{ {
int num = number(0, 3); int num = Random::get(0, 3);
if (!num) if (!num)
{ {
@ -294,7 +294,7 @@ void CHARACTER::DeathPenalty(BYTE bTown)
return; return;
} }
if (number(0, 2)) if (Random::get(0, 2))
{ {
sys_log(0, "NO_DEATH_PENALTY_LUCK(%s)", GetName()); sys_log(0, "NO_DEATH_PENALTY_LUCK(%s)", GetName());
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("용신의 가호로 경험치가 떨어지지 않았습니다.")); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("용신의 가호로 경험치가 떨어지지 않았습니다."));
@ -579,19 +579,19 @@ void CHARACTER::RewardGold(LPCHARACTER pkAttacker)
iPercent = ((iGoldPercent * PERCENT_LVDELTA(pkAttacker->GetLevel(), GetLevel())) / 100); iPercent = ((iGoldPercent * PERCENT_LVDELTA(pkAttacker->GetLevel(), GetLevel())) / 100);
//int iPercent = CALCULATE_VALUE_LVDELTA(pkAttacker->GetLevel(), GetLevel(), iGoldPercent); //int iPercent = CALCULATE_VALUE_LVDELTA(pkAttacker->GetLevel(), GetLevel(), iGoldPercent);
if (number(1, 100) > iPercent) if (Random::get(1, 100) > iPercent)
return; return;
int iGoldMultipler = GetGoldMultipler(); int iGoldMultipler = GetGoldMultipler();
if (1 == number(1, 50000)) // 1/50000 확률로 돈이 10배 if (1 == Random::get(1, 50000)) // 1/50000 확률로 돈이 10배
iGoldMultipler *= 10; iGoldMultipler *= 10;
else if (1 == number(1, 10000)) // 1/10000 확률로 돈이 5배 else if (1 == Random::get(1, 10000)) // 1/10000 확률로 돈이 5배
iGoldMultipler *= 5; iGoldMultipler *= 5;
// 개인 적용 // 개인 적용
if (pkAttacker->GetPoint(POINT_GOLD_DOUBLE_BONUS)) if (pkAttacker->GetPoint(POINT_GOLD_DOUBLE_BONUS))
if (number(1, 100) <= pkAttacker->GetPoint(POINT_GOLD_DOUBLE_BONUS)) if (Random::get(1, 100) <= pkAttacker->GetPoint(POINT_GOLD_DOUBLE_BONUS))
iGoldMultipler *= 2; iGoldMultipler *= 2;
// //
@ -611,14 +611,14 @@ void CHARACTER::RewardGold(LPCHARACTER pkAttacker)
// MOB_RANK가 BOSS보다 높으면 무조건 돈폭탄 // MOB_RANK가 BOSS보다 높으면 무조건 돈폭탄
if (GetMobRank() >= MOB_RANK_BOSS && !IsStone() && GetMobTable().dwGoldMax != 0) if (GetMobRank() >= MOB_RANK_BOSS && !IsStone() && GetMobTable().dwGoldMax != 0)
{ {
if (1 == number(1, iGold10DropPct)) if (1 == Random::get(1, iGold10DropPct))
iGoldMultipler *= 10; // 1% 확률로 돈 10배 iGoldMultipler *= 10; // 1% 확률로 돈 10배
int iSplitCount = number(25, 35); int iSplitCount = Random::get(25, 35);
for (int i = 0; i < iSplitCount; ++i) for (int i = 0; i < iSplitCount; ++i)
{ {
int iGold = number(GetMobTable().dwGoldMin, GetMobTable().dwGoldMax) / iSplitCount; int iGold = Random::get(GetMobTable().dwGoldMin, GetMobTable().dwGoldMax) / iSplitCount;
if (test_server) if (test_server)
sys_log(0, "iGold %d", iGold); sys_log(0, "iGold %d", iGold);
iGold = iGold * CHARACTER_MANAGER::instance().GetMobGoldAmountRate(pkAttacker) / 100; iGold = iGold * CHARACTER_MANAGER::instance().GetMobGoldAmountRate(pkAttacker) / 100;
@ -638,8 +638,8 @@ void CHARACTER::RewardGold(LPCHARACTER pkAttacker)
// NOTE: 돈 폭탄은 제 3의 손 처리를 하지 않음 // NOTE: 돈 폭탄은 제 3의 손 처리를 하지 않음
if ((item = ITEM_MANAGER::instance().CreateItem(1, iGold))) if ((item = ITEM_MANAGER::instance().CreateItem(1, iGold)))
{ {
pos.x = GetX() + ((number(-14, 14) + number(-14, 14)) * 23); pos.x = GetX() + ((Random::get(-14, 14) + Random::get(-14, 14)) * 23);
pos.y = GetY() + ((number(-14, 14) + number(-14, 14)) * 23); pos.y = GetY() + ((Random::get(-14, 14) + Random::get(-14, 14)) * 23);
item->AddToGround(GetMapIndex(), pos); item->AddToGround(GetMapIndex(), pos);
item->StartDestroyEvent(); item->StartDestroyEvent();
@ -649,14 +649,14 @@ void CHARACTER::RewardGold(LPCHARACTER pkAttacker)
} }
} }
// 1% 확률로 돈을 10개 떨어 뜨린다. (10배 드롭임) // 1% 확률로 돈을 10개 떨어 뜨린다. (10배 드롭임)
else if (1 == number(1, iGold10DropPct)) else if (1 == Random::get(1, iGold10DropPct))
{ {
// //
// 돈 폭탄식 드롭 // 돈 폭탄식 드롭
// //
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
{ {
int iGold = number(GetMobTable().dwGoldMin, GetMobTable().dwGoldMax); int iGold = Random::get(GetMobTable().dwGoldMin, GetMobTable().dwGoldMax);
iGold = iGold * CHARACTER_MANAGER::instance().GetMobGoldAmountRate(pkAttacker) / 100; iGold = iGold * CHARACTER_MANAGER::instance().GetMobGoldAmountRate(pkAttacker) / 100;
iGold *= iGoldMultipler; iGold *= iGoldMultipler;
@ -668,8 +668,8 @@ void CHARACTER::RewardGold(LPCHARACTER pkAttacker)
// NOTE: 돈 폭탄은 제 3의 손 처리를 하지 않음 // NOTE: 돈 폭탄은 제 3의 손 처리를 하지 않음
if ((item = ITEM_MANAGER::instance().CreateItem(1, iGold))) if ((item = ITEM_MANAGER::instance().CreateItem(1, iGold)))
{ {
pos.x = GetX() + (number(-7, 7) * 20); pos.x = GetX() + (Random::get(-7, 7) * 20);
pos.y = GetY() + (number(-7, 7) * 20); pos.y = GetY() + (Random::get(-7, 7) * 20);
item->AddToGround(GetMapIndex(), pos); item->AddToGround(GetMapIndex(), pos);
item->StartDestroyEvent(); item->StartDestroyEvent();
@ -683,17 +683,17 @@ void CHARACTER::RewardGold(LPCHARACTER pkAttacker)
// //
// 일반적인 방식의 돈 드롭 // 일반적인 방식의 돈 드롭
// //
int iGold = number(GetMobTable().dwGoldMin, GetMobTable().dwGoldMax); int iGold = Random::get(GetMobTable().dwGoldMin, GetMobTable().dwGoldMax);
iGold = iGold * CHARACTER_MANAGER::instance().GetMobGoldAmountRate(pkAttacker) / 100; iGold = iGold * CHARACTER_MANAGER::instance().GetMobGoldAmountRate(pkAttacker) / 100;
iGold *= iGoldMultipler; iGold *= iGoldMultipler;
int iSplitCount; int iSplitCount;
if (iGold >= 3 && !LC_IsYMIR()) if (iGold >= 3 && !LC_IsYMIR())
iSplitCount = number(1, 3); iSplitCount = Random::get(1, 3);
else if (GetMobRank() >= MOB_RANK_BOSS) else if (GetMobRank() >= MOB_RANK_BOSS)
{ {
iSplitCount = number(3, 10); iSplitCount = Random::get(3, 10);
if ((iGold / iSplitCount) == 0) if ((iGold / iSplitCount) == 0)
iSplitCount = 1; iSplitCount = 1;
@ -713,8 +713,8 @@ void CHARACTER::RewardGold(LPCHARACTER pkAttacker)
} }
else if ((item = ITEM_MANAGER::instance().CreateItem(1, iGold / iSplitCount))) else if ((item = ITEM_MANAGER::instance().CreateItem(1, iGold / iSplitCount)))
{ {
pos.x = GetX() + (number(-7, 7) * 20); pos.x = GetX() + (Random::get(-7, 7) * 20);
pos.y = GetY() + (number(-7, 7) * 20); pos.y = GetY() + (Random::get(-7, 7) * 20);
item->AddToGround(GetMapIndex(), pos); item->AddToGround(GetMapIndex(), pos);
item->StartDestroyEvent(); item->StartDestroyEvent();
@ -736,10 +736,10 @@ void CHARACTER::Reward(bool bItemDrop)
return; return;
LPITEM item; LPITEM item;
int iGold = number(GetMobTable().dwGoldMin, GetMobTable().dwGoldMax); int iGold = Random::get(GetMobTable().dwGoldMin, GetMobTable().dwGoldMax);
iGold = iGold * CHARACTER_MANAGER::instance().GetMobGoldAmountRate(NULL) / 100; iGold = iGold * CHARACTER_MANAGER::instance().GetMobGoldAmountRate(NULL) / 100;
iGold *= GetGoldMultipler(); iGold *= GetGoldMultipler();
int iSplitCount = number(25, 35); int iSplitCount = Random::get(25, 35);
sys_log(0, "WAEGU Dead gold %d split %d", iGold, iSplitCount); sys_log(0, "WAEGU Dead gold %d split %d", iGold, iSplitCount);
@ -749,8 +749,8 @@ void CHARACTER::Reward(bool bItemDrop)
{ {
if (i != 0) if (i != 0)
{ {
pos.x = number(-7, 7) * 20; pos.x = Random::get(-7, 7) * 20;
pos.y = number(-7, 7) * 20; pos.y = Random::get(-7, 7) * 20;
pos.x += GetX(); pos.x += GetX();
pos.y += GetY(); pos.y += GetY();
@ -787,7 +787,7 @@ void CHARACTER::Reward(bool bItemDrop)
quest::CQuestManager::instance().Kill(pkAttacker->GetPlayerID(), GetRaceNum()); quest::CQuestManager::instance().Kill(pkAttacker->GetPlayerID(), GetRaceNum());
CHARACTER_MANAGER::instance().KillLog(GetRaceNum()); CHARACTER_MANAGER::instance().KillLog(GetRaceNum());
if (!number(0, 9)) if (!Random::get(0, 9))
{ {
if (pkAttacker->GetPoint(POINT_KILL_HP_RECOVERY)) if (pkAttacker->GetPoint(POINT_KILL_HP_RECOVERY))
{ {
@ -847,8 +847,8 @@ void CHARACTER::Reward(bool bItemDrop)
item->StartDestroyEvent(); item->StartDestroyEvent();
pos.x = number(-7, 7) * 20; pos.x = Random::get(-7, 7) * 20;
pos.y = number(-7, 7) * 20; pos.y = Random::get(-7, 7) * 20;
pos.x += GetX(); pos.x += GetX();
pos.y += GetY(); pos.y += GetY();
@ -903,8 +903,8 @@ void CHARACTER::Reward(bool bItemDrop)
//item->SetOwnership(pkAttacker); //item->SetOwnership(pkAttacker);
item->StartDestroyEvent(); item->StartDestroyEvent();
pos.x = number(-7, 7) * 20; pos.x = Random::get(-7, 7) * 20;
pos.y = number(-7, 7) * 20; pos.y = Random::get(-7, 7) * 20;
pos.x += GetX(); pos.x += GetX();
pos.y += GetY(); pos.y += GetY();
@ -945,8 +945,8 @@ void CHARACTER::Reward(bool bItemDrop)
item->StartDestroyEvent(); item->StartDestroyEvent();
pos.x = number(-7, 7) * 20; pos.x = Random::get(-7, 7) * 20;
pos.y = number(-7, 7) * 20; pos.y = Random::get(-7, 7) * 20;
pos.x += GetX(); pos.x += GetX();
pos.y += GetY(); pos.y += GetY();
@ -1031,8 +1031,8 @@ void CHARACTER::ItemDropPenalty(LPCHARACTER pkKiller)
TItemDropPenalty & r = table[iAlignIndex]; TItemDropPenalty & r = table[iAlignIndex];
sys_log(0, "%s align %d inven_pct %d equip_pct %d", GetName(), iAlignIndex, r.iInventoryPct, r.iEquipmentPct); sys_log(0, "%s align %d inven_pct %d equip_pct %d", GetName(), iAlignIndex, r.iInventoryPct, r.iEquipmentPct);
bool bDropInventory = r.iInventoryPct >= number(1, 1000); bool bDropInventory = r.iInventoryPct >= Random::get(1, 1000);
bool bDropEquipment = r.iEquipmentPct >= number(1, 100); bool bDropEquipment = r.iEquipmentPct >= Random::get(1, 100);
bool bDropAntiDropUniqueItem = false; bool bDropAntiDropUniqueItem = false;
if ((bDropInventory || bDropEquipment) && IsEquipUniqueItem(UNIQUE_ITEM_SKIP_ITEM_DROP_PENALTY)) if ((bDropInventory || bDropEquipment) && IsEquipUniqueItem(UNIQUE_ITEM_SKIP_ITEM_DROP_PENALTY))
@ -1057,7 +1057,7 @@ void CHARACTER::ItemDropPenalty(LPCHARACTER pkKiller)
int iQty = MIN(vec_bSlots.size(), r.iInventoryQty); int iQty = MIN(vec_bSlots.size(), r.iInventoryQty);
if (iQty) if (iQty)
iQty = number(1, iQty); iQty = Random::get(1, iQty);
for (i = 0; i < iQty; ++i) for (i = 0; i < iQty; ++i)
{ {
@ -1090,10 +1090,10 @@ void CHARACTER::ItemDropPenalty(LPCHARACTER pkKiller)
if (isDropAllEquipments) if (isDropAllEquipments)
iQty = vec_bSlots.size(); iQty = vec_bSlots.size();
else else
iQty = MIN(vec_bSlots.size(), number(1, r.iEquipmentQty)); iQty = MIN(vec_bSlots.size(), Random::get(1, r.iEquipmentQty));
if (iQty) if (iQty)
iQty = number(1, iQty); iQty = Random::get(1, iQty);
for (i = 0; i < iQty; ++i) for (i = 0; i < iQty; ++i)
{ {
@ -1147,8 +1147,8 @@ void CHARACTER::ItemDropPenalty(LPCHARACTER pkKiller)
sys_log(0, "DROP_ITEM_PK: %s %d %d from %s", item->GetName(), pos.x, pos.y, GetName()); sys_log(0, "DROP_ITEM_PK: %s %d %d from %s", item->GetName(), pos.x, pos.y, GetName());
LogManager::instance().ItemLog(this, item, "DEAD_DROP", (window == INVENTORY) ? "INVENTORY" : ((window == EQUIPMENT) ? "EQUIPMENT" : "")); LogManager::instance().ItemLog(this, item, "DEAD_DROP", (window == INVENTORY) ? "INVENTORY" : ((window == EQUIPMENT) ? "EQUIPMENT" : ""));
pos.x = GetX() + number(-7, 7) * 20; pos.x = GetX() + Random::get(-7, 7) * 20;
pos.y = GetY() + number(-7, 7) * 20; pos.y = GetY() + Random::get(-7, 7) * 20;
} }
} }
} }
@ -1338,7 +1338,7 @@ void CHARACTER::Dead(LPCHARACTER pkKiller, bool bImmediateDead)
iNoPenaltyProb = 20; iNoPenaltyProb = 20;
} }
if (number(1, 100) < iNoPenaltyProb) if (Random::get(1, 100) < iNoPenaltyProb)
pkKiller->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("용신의 보호로 아이템이 떨어지지 않았습니다.")); pkKiller->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("용신의 보호로 아이템이 떨어지지 않았습니다."));
else else
{ {
@ -1639,7 +1639,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
if (bDropMoney) if (bDropMoney)
{ {
DWORD dwGold = 1000; DWORD dwGold = 1000;
int iSplitCount = number(10, 13); int iSplitCount = Random::get(10, 13);
sys_log(0, "WAEGU DropGoldOnHit %d times", GetMaxSP()); sys_log(0, "WAEGU DropGoldOnHit %d times", GetMaxSP());
@ -1652,8 +1652,8 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
{ {
if (i != 0) if (i != 0)
{ {
pos.x = (number(-14, 14) + number(-14, 14)) * 20; pos.x = (Random::get(-14, 14) + Random::get(-14, 14)) * 20;
pos.y = (number(-14, 14) + number(-14, 14)) * 20; pos.y = (Random::get(-14, 14) + Random::get(-14, 14)) * 20;
pos.x += GetX(); pos.x += GetX();
pos.y += GetY(); pos.y += GetY();
@ -1673,7 +1673,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
{ {
int pct = GetSkillPower(SKILL_TERROR) / 400; int pct = GetSkillPower(SKILL_TERROR) / 400;
if (number(1, 100) <= pct) if (Random::get(1, 100) <= pct)
return false; return false;
} }
} }
@ -1726,7 +1726,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
//크리티컬 저항 값 적용. //크리티컬 저항 값 적용.
iCriticalPct -= GetPoint(POINT_RESIST_CRITICAL); iCriticalPct -= GetPoint(POINT_RESIST_CRITICAL);
if (number(1, 100) <= iCriticalPct) if (Random::get(1, 100) <= iCriticalPct)
{ {
IsCritical = true; IsCritical = true;
dam *= 2; dam *= 2;
@ -1773,7 +1773,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
//관통타격 저항 값 적용. //관통타격 저항 값 적용.
iPenetratePct -= GetPoint(POINT_RESIST_PENETRATE); iPenetratePct -= GetPoint(POINT_RESIST_PENETRATE);
if (number(1, 100) <= iPenetratePct) if (Random::get(1, 100) <= iPenetratePct)
{ {
IsPenetrate = true; IsPenetrate = true;
@ -1798,7 +1798,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
if (type == DAMAGE_TYPE_NORMAL) if (type == DAMAGE_TYPE_NORMAL)
{ {
// 근접 평타일 경우 막을 수 있음 // 근접 평타일 경우 막을 수 있음
if (GetPoint(POINT_BLOCK) && number(1, 100) <= GetPoint(POINT_BLOCK)) if (GetPoint(POINT_BLOCK) && Random::get(1, 100) <= GetPoint(POINT_BLOCK))
{ {
if (test_server) if (test_server)
{ {
@ -1813,7 +1813,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
else if (type == DAMAGE_TYPE_NORMAL_RANGE) else if (type == DAMAGE_TYPE_NORMAL_RANGE)
{ {
// 원거리 평타의 경우 피할 수 있음 // 원거리 평타의 경우 피할 수 있음
if (GetPoint(POINT_DODGE) && number(1, 100) <= GetPoint(POINT_DODGE)) if (GetPoint(POINT_DODGE) && Random::get(1, 100) <= GetPoint(POINT_DODGE))
{ {
if (test_server) if (test_server)
{ {
@ -1867,7 +1867,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
//크리티컬 저항 값 적용. //크리티컬 저항 값 적용.
iCriticalPct -= GetPoint(POINT_RESIST_CRITICAL); iCriticalPct -= GetPoint(POINT_RESIST_CRITICAL);
if (number(1, 100) <= iCriticalPct) if (Random::get(1, 100) <= iCriticalPct)
{ {
IsCritical = true; IsCritical = true;
dam *= 2; dam *= 2;
@ -1899,7 +1899,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
//관통타격 저항 값 적용. //관통타격 저항 값 적용.
iPenetratePct -= GetPoint(POINT_RESIST_PENETRATE); iPenetratePct -= GetPoint(POINT_RESIST_PENETRATE);
if (number(1, 100) <= iPenetratePct) if (Random::get(1, 100) <= iPenetratePct)
{ {
IsPenetrate = true; IsPenetrate = true;
@ -1914,7 +1914,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
{ {
int pct = 1; int pct = 1;
if (number(1, 10) <= pct) if (Random::get(1, 10) <= pct)
{ {
int iHP = MIN(dam, MAX(0, iCurHP)) * pAttacker->GetPoint(POINT_STEAL_HP) / 100; int iHP = MIN(dam, MAX(0, iCurHP)) * pAttacker->GetPoint(POINT_STEAL_HP) / 100;
@ -1932,7 +1932,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
{ {
int pct = 1; int pct = 1;
if (number(1, 10) <= pct) if (Random::get(1, 10) <= pct)
{ {
int iCur; int iCur;
@ -1957,16 +1957,16 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
// 돈 스틸 // 돈 스틸
if (pAttacker->GetPoint(POINT_STEAL_GOLD)) if (pAttacker->GetPoint(POINT_STEAL_GOLD))
{ {
if (number(1, 100) <= pAttacker->GetPoint(POINT_STEAL_GOLD)) if (Random::get(1, 100) <= pAttacker->GetPoint(POINT_STEAL_GOLD))
{ {
int iAmount = number(1, GetLevel()); int iAmount = Random::get(1, GetLevel());
pAttacker->PointChange(POINT_GOLD, iAmount); pAttacker->PointChange(POINT_GOLD, iAmount);
DBManager::instance().SendMoneyLog(MONEY_LOG_MISC, 1, iAmount); DBManager::instance().SendMoneyLog(MONEY_LOG_MISC, 1, iAmount);
} }
} }
// 칠 때마다 HP회복 // 칠 때마다 HP회복
if (pAttacker->GetPoint(POINT_HIT_HP_RECOVERY) && number(0, 4) > 0) // 80% 확률 if (pAttacker->GetPoint(POINT_HIT_HP_RECOVERY) && Random::get(0, 4) > 0) // 80% 확률
{ {
int i = MIN(dam, iCurHP) * pAttacker->GetPoint(POINT_HIT_HP_RECOVERY) / 100; int i = MIN(dam, iCurHP) * pAttacker->GetPoint(POINT_HIT_HP_RECOVERY) / 100;
@ -1978,7 +1978,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
} }
// 칠 때마다 SP회복 // 칠 때마다 SP회복
if (pAttacker->GetPoint(POINT_HIT_SP_RECOVERY) && number(0, 4) > 0) // 80% 확률 if (pAttacker->GetPoint(POINT_HIT_SP_RECOVERY) && Random::get(0, 4) > 0) // 80% 확률
{ {
int i = MIN(dam, iCurHP) * pAttacker->GetPoint(POINT_HIT_SP_RECOVERY) / 100; int i = MIN(dam, iCurHP) * pAttacker->GetPoint(POINT_HIT_SP_RECOVERY) / 100;
@ -1992,7 +1992,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
// 상대방의 마나를 없앤다. // 상대방의 마나를 없앤다.
if (pAttacker->GetPoint(POINT_MANA_BURN_PCT)) if (pAttacker->GetPoint(POINT_MANA_BURN_PCT))
{ {
if (number(1, 100) <= pAttacker->GetPoint(POINT_MANA_BURN_PCT)) if (Random::get(1, 100) <= pAttacker->GetPoint(POINT_MANA_BURN_PCT))
PointChange(POINT_SP, -50); PointChange(POINT_SP, -50);
} }
} }
@ -2211,7 +2211,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
{ {
if (pAttacker->IsDeathBlow()) if (pAttacker->IsDeathBlow())
{ {
if (number(1, 4) == GetJob()) if (Random::get(1, 4) == GetJob())
{ {
IsDeathBlow = true; IsDeathBlow = true;
dam = dam * 4; dam = dam * 4;
@ -2357,7 +2357,7 @@ static void GiveExp(LPCHARACTER from, LPCHARACTER to, int iExp)
// 아이템 경험치 두배 속성 // 아이템 경험치 두배 속성
if (to->GetPoint(POINT_EXP_DOUBLE_BONUS)) if (to->GetPoint(POINT_EXP_DOUBLE_BONUS))
if (number(1, 100) <= to->GetPoint(POINT_EXP_DOUBLE_BONUS)) if (Random::get(1, 100) <= to->GetPoint(POINT_EXP_DOUBLE_BONUS))
iExp += iExp * 30 / 100; // 1.3배 (30%) iExp += iExp * 30 / 100; // 1.3배 (30%)
// 경험의 반지 (2시간짜리) // 경험의 반지 (2시간짜리)
@ -3406,7 +3406,7 @@ struct FuncAggregateMonster
if (ch->GetVictim()) if (ch->GetVictim())
return; return;
if (number(1, 100) <= 50) // 임시로 50% 확률로 적을 끌어온다 if (Random::get(1, 100) <= 50) // 임시로 50% 확률로 적을 끌어온다
if (DISTANCE_APPROX(ch->GetX() - m_ch->GetX(), ch->GetY() - m_ch->GetY()) < 5000) if (DISTANCE_APPROX(ch->GetX() - m_ch->GetX(), ch->GetY() - m_ch->GetY()) < 5000)
if (ch->CanBeginFight()) if (ch->CanBeginFight())
ch->BeginFight(m_ch); ch->BeginFight(m_ch);

View File

@ -161,13 +161,13 @@ void CHARACTER::HorseSummon(bool bSummon, bool bFromFar, DWORD dwVnum, const cha
if (bFromFar) if (bFromFar)
{ {
x += (number(0, 1) * 2 - 1) * number(2000, 2500); x += (Random::get(0, 1) * 2 - 1) * Random::get(2000, 2500);
y += (number(0, 1) * 2 - 1) * number(2000, 2500); y += (Random::get(0, 1) * 2 - 1) * Random::get(2000, 2500);
} }
else else
{ {
x += number(-100, 100); x += Random::get(-100, 100);
y += number(-100, 100); y += Random::get(-100, 100);
} }
m_chHorse = CHARACTER_MANAGER::instance().SpawnMob( m_chHorse = CHARACTER_MANAGER::instance().SpawnMob(

View File

@ -909,7 +909,7 @@ bool CHARACTER::DoRefine(LPITEM item, bool bMoneyOnly)
RemoveSpecifyItem(prt->materials[i].vnum, prt->materials[i].count); RemoveSpecifyItem(prt->materials[i].vnum, prt->materials[i].count);
} }
int prob = number(1, 100); int prob = Random::get(1, 100);
if (IsRefineThroughGuild() || bMoneyOnly) if (IsRefineThroughGuild() || bMoneyOnly)
prob -= 10; prob -= 10;
@ -1110,7 +1110,7 @@ bool CHARACTER::DoRefineWithScroll(LPITEM item)
for (int i = 0; i < prt->material_count; ++i) for (int i = 0; i < prt->material_count; ++i)
RemoveSpecifyItem(prt->materials[i].vnum, prt->materials[i].count); RemoveSpecifyItem(prt->materials[i].vnum, prt->materials[i].count);
int prob = number(1, 100); int prob = Random::get(1, 100);
int success_prob = prt->prob; int success_prob = prt->prob;
bool bDestroyWhenFail = false; bool bDestroyWhenFail = false;
@ -1777,7 +1777,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
return false; return false;
} }
LPCHARACTER campfire = CHARACTER_MANAGER::instance().SpawnMob(fishing::CAMPFIRE_MOB, GetMapIndex(), (int)(GetX()+fx), (int)(GetY()+fy), 0, false, number(0, 359)); LPCHARACTER campfire = CHARACTER_MANAGER::instance().SpawnMob(fishing::CAMPFIRE_MOB, GetMapIndex(), (int)(GetX()+fx), (int)(GetY()+fy), 0, false, Random::get(0, 359));
char_event_info* info = AllocEventInfo<char_event_info>(); char_event_info* info = AllocEventInfo<char_event_info>();
@ -2148,7 +2148,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
{ {
ITEM_MANAGER::instance().RemoveItem(item); ITEM_MANAGER::instance().RemoveItem(item);
int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX); int iReadDelay = Random::get<int>(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
if (distribution_test_server) if (distribution_test_server)
iReadDelay /= 3; iReadDelay /= 3;
@ -2634,7 +2634,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
else else
bi = b1; bi = b1;
int pct = number(1, 1000); int pct = Random::get(1, 1000);
int i; int i;
for (i=0;i<MAX_BAG_INFO;i++) for (i=0;i<MAX_BAG_INFO;i++)
@ -2780,7 +2780,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
else else
info = info_10; info = info_10;
int prob = number(1, 100); int prob = Random::get(1, 100);
for (int i = 0; i < EVENT_STONE_MAX_INFO; ++i) for (int i = 0; i < EVENT_STONE_MAX_INFO; ++i)
{ {
@ -2952,7 +2952,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
else else
{ {
// 독다루기가 없으면 50% 즉사 50% 공격력 +2 // 독다루기가 없으면 50% 즉사 50% 공격력 +2
if (number(0, 1)) if (Random::get(0, 1))
{ {
if (GetHP() > 100) if (GetHP() > 100)
PointChange(POINT_HP, -(GetHP() - 1)); PointChange(POINT_HP, -(GetHP() - 1));
@ -2973,7 +2973,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
{ {
item->SetCount(item->GetCount() - 1); item->SetCount(item->GetCount() - 1);
int r = number(1, 100); int r = Random::get(1, 100);
if (r <= 50) if (r <= 50)
{ {
@ -3018,7 +3018,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
break; break;
case 71013: // 축제용폭죽 case 71013: // 축제용폭죽
CreateFly(number(FLY_FIREWORK1, FLY_FIREWORK6), this); CreateFly(Random::get<int>(FLY_FIREWORK1, FLY_FIREWORK6), this);
item->SetCount(item->GetCount() - 1); item->SetCount(item->GetCount() - 1);
break; break;
@ -3084,7 +3084,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
{ {
ITEM_MANAGER::instance().RemoveItem(item); ITEM_MANAGER::instance().RemoveItem(item);
int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX); int iReadDelay = Random::get<int>(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
if (distribution_test_server) iReadDelay /= 3; if (distribution_test_server) iReadDelay /= 3;
SetSkillNextReadTime(SKILL_LEADERSHIP, get_global_time() + iReadDelay); SetSkillNextReadTime(SKILL_LEADERSHIP, get_global_time() + iReadDelay);
@ -3126,7 +3126,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
{ {
ITEM_MANAGER::instance().RemoveItem(item); ITEM_MANAGER::instance().RemoveItem(item);
int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX); int iReadDelay = Random::get<int>(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
if (distribution_test_server) iReadDelay /= 3; if (distribution_test_server) iReadDelay /= 3;
SetSkillNextReadTime(SKILL_COMBO, get_global_time() + iReadDelay); SetSkillNextReadTime(SKILL_COMBO, get_global_time() + iReadDelay);
@ -3155,7 +3155,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
{ {
ITEM_MANAGER::instance().RemoveItem(item); ITEM_MANAGER::instance().RemoveItem(item);
int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX); int iReadDelay = Random::get<int>(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
if (distribution_test_server) iReadDelay /= 3; if (distribution_test_server) iReadDelay /= 3;
SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay); SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
@ -3184,7 +3184,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
{ {
ITEM_MANAGER::instance().RemoveItem(item); ITEM_MANAGER::instance().RemoveItem(item);
int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX); int iReadDelay = Random::get<int>(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
if (distribution_test_server) iReadDelay /= 3; if (distribution_test_server) iReadDelay /= 3;
SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay); SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
@ -3257,7 +3257,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
{ {
ITEM_MANAGER::instance().RemoveItem(item); ITEM_MANAGER::instance().RemoveItem(item);
int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX); int iReadDelay = Random::get<int>(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
if (distribution_test_server) iReadDelay /= 3; if (distribution_test_server) iReadDelay /= 3;
SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay); SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
@ -3288,7 +3288,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
{ {
ITEM_MANAGER::instance().RemoveItem(item); ITEM_MANAGER::instance().RemoveItem(item);
int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX); int iReadDelay = Random::get<int>(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
if (distribution_test_server) iReadDelay /= 3; if (distribution_test_server) iReadDelay /= 3;
SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay); SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
@ -3330,7 +3330,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
{ {
ITEM_MANAGER::instance().RemoveItem(item); ITEM_MANAGER::instance().RemoveItem(item);
int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX); int iReadDelay = Random::get<int>(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
if (distribution_test_server) iReadDelay /= 3; if (distribution_test_server) iReadDelay /= 3;
SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay); SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
@ -3379,13 +3379,13 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
return false; return false;
} }
if (number(1, 100) <= iPct) if (Random::get(1, 100) <= iPct)
{ {
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("승마 수련서를 읽어 승마 스킬 포인트를 얻었습니다.")); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("승마 수련서를 읽어 승마 스킬 포인트를 얻었습니다."));
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("얻은 포인트로는 승마 스킬의 레벨을 올릴 수 있습니다.")); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("얻은 포인트로는 승마 스킬의 레벨을 올릴 수 있습니다."));
PointChange(POINT_HORSE_SKILL, 1); PointChange(POINT_HORSE_SKILL, 1);
int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX); int iReadDelay = Random::get<int>(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
if (distribution_test_server) iReadDelay /= 3; if (distribution_test_server) iReadDelay /= 3;
if (!test_server) if (!test_server)
@ -4678,7 +4678,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
char buf[21]; char buf[21];
snprintf(buf, sizeof(buf), "%u", item2->GetID()); snprintf(buf, sizeof(buf), "%u", item2->GetID());
if (number(1, 100) <= aiItemAttributeAddPercent[item2->GetAttributeCount()]) if (Random::get(1, 100) <= aiItemAttributeAddPercent[item2->GetAttributeCount()])
{ {
item2->AddAttribute(); item2->AddAttribute();
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성 추가에 성공하였습니다.")); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성 추가에 성공하였습니다."));
@ -4723,7 +4723,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
char buf[21]; char buf[21];
snprintf(buf, sizeof(buf), "%u", item2->GetID()); snprintf(buf, sizeof(buf), "%u", item2->GetID());
if (number(1, 100) <= aiItemAttributeAddPercent[item2->GetAttributeCount()]) if (Random::get(1, 100) <= aiItemAttributeAddPercent[item2->GetAttributeCount()])
{ {
item2->AddAttribute(); item2->AddAttribute();
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성 추가에 성공하였습니다.")); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("속성 추가에 성공하였습니다."));
@ -4771,7 +4771,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
{ {
if (item2->GetAccessorySocketMaxGrade() < ITEM_ACCESSORY_SOCKET_MAX_NUM) if (item2->GetAccessorySocketMaxGrade() < ITEM_ACCESSORY_SOCKET_MAX_NUM)
{ {
if (number(1, 100) <= 50) if (Random::get(1, 100) <= 50)
{ {
item2->SetAccessorySocketMaxGrade(item2->GetAccessorySocketMaxGrade() + 1); item2->SetAccessorySocketMaxGrade(item2->GetAccessorySocketMaxGrade() + 1);
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("소켓이 성공적으로 추가되었습니다.")); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("소켓이 성공적으로 추가되었습니다."));
@ -4806,7 +4806,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
if (item2->GetAccessorySocketGrade() < item2->GetAccessorySocketMaxGrade()) if (item2->GetAccessorySocketGrade() < item2->GetAccessorySocketMaxGrade())
{ {
if (number(1, 100) <= aiAccessorySocketPutPct[item2->GetAccessorySocketGrade()]) if (Random::get(1, 100) <= aiAccessorySocketPutPct[item2->GetAccessorySocketGrade()])
{ {
item2->SetAccessorySocketGrade(item2->GetAccessorySocketGrade() + 1); item2->SetAccessorySocketGrade(item2->GetAccessorySocketGrade() + 1);
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("장착에 성공하였습니다.")); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("장착에 성공하였습니다."));
@ -4908,7 +4908,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
break; break;
case USE_CREATE_STONE: case USE_CREATE_STONE:
AutoGiveItem(number(28000, 28013)); AutoGiveItem(Random::get(28000, 28013));
item->SetCount(item->GetCount() - 1); item->SetCount(item->GetCount() - 1);
break; break;
@ -4971,7 +4971,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
pBottle->SetCount(pBottle->GetCount() - 1); pBottle->SetCount(pBottle->GetCount() - 1);
if (number(1, 100) > item->GetValue(5)) if (Random::get(1, 100) > item->GetValue(5))
{ {
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("물약 제조에 실패했습니다.")); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("물약 제조에 실패했습니다."));
return false; return false;
@ -5044,7 +5044,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
if (item2->GetSocket(i) >= 1 && item2->GetSocket(i) <= 2 && item2->GetSocket(i) >= item->GetValue(2)) if (item2->GetSocket(i) >= 1 && item2->GetSocket(i) <= 2 && item2->GetSocket(i) >= item->GetValue(2))
{ {
// 석 확률 // 석 확률
if (number(1, 100) <= 30) if (Random::get(1, 100) <= 30)
{ {
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("메틴석 부착에 성공하였습니다.")); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("메틴석 부착에 성공하였습니다."));
item2->SetSocket(i, item->GetVnum()); item2->SetSocket(i, item->GetVnum());
@ -7017,8 +7017,8 @@ bool CHARACTER::GiveItemFromSpecialItemGroup(DWORD dwGroupNum, std::vector<DWORD
case CSpecialItemGroup::MOB: case CSpecialItemGroup::MOB:
{ {
sys_log(0, "CSpecialItemGroup::MOB %d", dwCount); sys_log(0, "CSpecialItemGroup::MOB %d", dwCount);
int x = GetX() + number(-500, 500); int x = GetX() + Random::get(-500, 500);
int y = GetY() + number(-500, 500); int y = GetY() + Random::get(-500, 500);
LPCHARACTER ch = CHARACTER_MANAGER::instance().SpawnMob(dwCount, GetMapIndex(), x, y, 0, true, -1); LPCHARACTER ch = CHARACTER_MANAGER::instance().SpawnMob(dwCount, GetMapIndex(), x, y, 0, true, -1);
if (ch) if (ch)
@ -7052,10 +7052,10 @@ bool CHARACTER::GiveItemFromSpecialItemGroup(DWORD dwGroupNum, std::vector<DWORD
case CSpecialItemGroup::MOB_GROUP: case CSpecialItemGroup::MOB_GROUP:
{ {
int sx = GetX() - number(300, 500); int sx = GetX() - Random::get(300, 500);
int sy = GetY() - number(300, 500); int sy = GetY() - Random::get(300, 500);
int ex = GetX() + number(300, 500); int ex = GetX() + Random::get(300, 500);
int ey = GetY() + number(300, 500); int ey = GetY() + Random::get(300, 500);
CHARACTER_MANAGER::instance().SpawnGroup(dwCount, GetMapIndex(), sx, sy, ex, ey, NULL, true); CHARACTER_MANAGER::instance().SpawnGroup(dwCount, GetMapIndex(), sx, sy, ex, ey, NULL, true);
bSuccess = true; bSuccess = true;

View File

@ -280,8 +280,8 @@ LPCHARACTER CHARACTER_MANAGER::SpawnMobRandomPosition(DWORD dwVnum, int lMapInde
int x, y; int x, y;
for (i=0; i<2000; i++) for (i=0; i<2000; i++)
{ {
x = number(1, (pkSectreeMap->m_setting.iWidth / 100) - 1) * 100 + pkSectreeMap->m_setting.iBaseX; x = Random::get(1, (pkSectreeMap->m_setting.iWidth / 100) - 1) * 100 + pkSectreeMap->m_setting.iBaseX;
y = number(1, (pkSectreeMap->m_setting.iHeight / 100) - 1) * 100 + pkSectreeMap->m_setting.iBaseY; y = Random::get(1, (pkSectreeMap->m_setting.iHeight / 100) - 1) * 100 + pkSectreeMap->m_setting.iBaseY;
//LPSECTREE tree = SECTREE_MANAGER::instance().Get(lMapIndex, x, y); //LPSECTREE tree = SECTREE_MANAGER::instance().Get(lMapIndex, x, y);
LPSECTREE tree = pkSectreeMap->Find(x, y); LPSECTREE tree = pkSectreeMap->Find(x, y);
@ -328,7 +328,7 @@ LPCHARACTER CHARACTER_MANAGER::SpawnMobRandomPosition(DWORD dwVnum, int lMapInde
if (ch->GetEmpire() == 0) if (ch->GetEmpire() == 0)
ch->SetEmpire(SECTREE_MANAGER::instance().GetEmpireFromMapIndex(lMapIndex)); ch->SetEmpire(SECTREE_MANAGER::instance().GetEmpireFromMapIndex(lMapIndex));
ch->SetRotation(number(0, 360)); ch->SetRotation(Random::get(0, 360));
if (!ch->Show(lMapIndex, x, y, 0, false)) if (!ch->Show(lMapIndex, x, y, 0, false))
{ {
@ -420,7 +420,7 @@ LPCHARACTER CHARACTER_MANAGER::SpawnMob(DWORD dwVnum, int lMapIndex, int x, int
} }
if (iRot == -1) if (iRot == -1)
iRot = number(0, 360); iRot = Random::get(0, 360);
ch->SetProto(pkMob); ch->SetProto(pkMob);
@ -455,8 +455,8 @@ LPCHARACTER CHARACTER_MANAGER::SpawnMobRange(DWORD dwVnum, int lMapIndex, int sx
while (i--) while (i--)
{ {
int x = number(sx, ex); int x = Random::get(sx, ex);
int y = number(sy, ey); int y = Random::get(sy, ey);
/* /*
if (bIsException) if (bIsException)
if (is_regen_exception(x, y)) if (is_regen_exception(x, y))
@ -518,10 +518,10 @@ bool CHARACTER_MANAGER::SpawnMoveGroup(DWORD dwVnum, int lMapIndex, int sx, int
continue; continue;
} }
sx = tch->GetX() - number(300, 500); sx = tch->GetX() - Random::get(300, 500);
sy = tch->GetY() - number(300, 500); sy = tch->GetY() - Random::get(300, 500);
ex = tch->GetX() + number(300, 500); ex = tch->GetX() + Random::get(300, 500);
ey = tch->GetY() + number(300, 500); ey = tch->GetY() + Random::get(300, 500);
if (m_pkChrSelectedStone) if (m_pkChrSelectedStone)
tch->SetStone(m_pkChrSelectedStone); tch->SetStone(m_pkChrSelectedStone);
@ -607,10 +607,10 @@ LPCHARACTER CHARACTER_MANAGER::SpawnGroup(DWORD dwVnum, int lMapIndex, int sx, i
tch->SetDungeon(pDungeon); tch->SetDungeon(pDungeon);
sx = tch->GetX() - number(300, 500); sx = tch->GetX() - Random::get(300, 500);
sy = tch->GetY() - number(300, 500); sy = tch->GetY() - Random::get(300, 500);
ex = tch->GetX() + number(300, 500); ex = tch->GetX() + Random::get(300, 500);
ey = tch->GetY() + number(300, 500); ey = tch->GetY() + Random::get(300, 500);
if (m_pkChrSelectedStone) if (m_pkChrSelectedStone)
tch->SetStone(m_pkChrSelectedStone); tch->SetStone(m_pkChrSelectedStone);
@ -915,7 +915,7 @@ LPCHARACTER CHARACTER_MANAGER::FindSpecifyPC(unsigned int uiJobFlag, int lMapInd
continue; continue;
} }
if (!chFind || number(1, ++n) == 1) if (!chFind || Random::get(1, ++n) == 1)
chFind = ch; chFind = ch;
} }

View File

@ -194,7 +194,7 @@ void CHARACTER::AttackedByPoison(LPCHARACTER pkAttacker)
if (delta > 8) if (delta > 8)
delta = 8; delta = 8;
if (number(1, 100) > poison_level_adjust[delta]) if (Random::get(1, 100) > poison_level_adjust[delta])
return; return;
} }
@ -254,7 +254,7 @@ bool CHARACTER::IsImmune(DWORD dwImmuneFlag)
if (IS_SET(m_pointsInstant.dwImmuneFlag, dwImmuneFlag)) if (IS_SET(m_pointsInstant.dwImmuneFlag, dwImmuneFlag))
{ {
int immune_pct = 90; int immune_pct = 90;
int percent = number(1, 100); int percent = Random::get(1, 100);
if (percent <= immune_pct) // 90% Immune if (percent <= immune_pct) // 90% Immune
{ {

View File

@ -364,10 +364,10 @@ bool CHARACTER::LearnGrandMasterSkill(DWORD dwSkillVnum)
RemoveAffect(AFFECT_SKILL_BOOK_BONUS); RemoveAffect(AFFECT_SKILL_BOOK_BONUS);
} }
int n = number(1, iBookCount); int n = Random::get(1, iBookCount);
sys_log(0, "Number(%d)", n); sys_log(0, "Number(%d)", n);
DWORD nextTime = get_global_time() + number(28800, 43200); DWORD nextTime = get_global_time() + Random::get(28800, 43200);
sys_log(0, "GrandMaster SkillBookCount min %d cur %d max %d (next_time=%d)", iMinReadCount, iTotalReadCount, iMaxReadCount, nextTime); sys_log(0, "GrandMaster SkillBookCount min %d cur %d max %d (next_time=%d)", iMinReadCount, iTotalReadCount, iMaxReadCount, nextTime);
@ -485,7 +485,7 @@ bool CHARACTER::LearnSkillByBook(DWORD dwSkillVnum, BYTE bProb)
sys_log(0, "LearnSkillByBook Pct %u prob %d", dwSkillVnum, bProb); sys_log(0, "LearnSkillByBook Pct %u prob %d", dwSkillVnum, bProb);
if (number(1, 100) <= bProb) if (Random::get(1, 100) <= bProb)
{ {
if (test_server) if (test_server)
sys_log(0, "LearnSkillByBook %u SUCC", dwSkillVnum); sys_log(0, "LearnSkillByBook %u SUCC", dwSkillVnum);
@ -528,7 +528,7 @@ bool CHARACTER::LearnSkillByBook(DWORD dwSkillVnum, BYTE bProb)
RemoveAffect(AFFECT_SKILL_BOOK_BONUS); RemoveAffect(AFFECT_SKILL_BOOK_BONUS);
} }
if (number(1, 100) > percent) if (Random::get(1, 100) > percent)
{ {
// 책읽기에 성공 // 책읽기에 성공
if (read_count >= need_bookcount) if (read_count >= need_bookcount)
@ -544,7 +544,7 @@ bool CHARACTER::LearnSkillByBook(DWORD dwSkillVnum, BYTE bProb)
{ {
pPC->SetFlag(flag, read_count + 1); pPC->SetFlag(flag, read_count + 1);
switch (number(1, 3)) switch (Random::get(1, 3))
{ {
case 1: case 1:
ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("어느정도 이 기술에 대해 이해가 되었지만 조금 부족한듯 한데..")); ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("어느정도 이 기술에 대해 이해가 되었지만 조금 부족한듯 한데.."));
@ -597,7 +597,7 @@ bool CHARACTER::LearnSkillByBook(DWORD dwSkillVnum, BYTE bProb)
RemoveAffect(AFFECT_SKILL_BOOK_BONUS); RemoveAffect(AFFECT_SKILL_BOOK_BONUS);
} }
if (number(1, iBookCount) == 2) if (Random::get(1, iBookCount) == 2)
SkillLevelUp(dwSkillVnum, SKILL_UP_BY_BOOK); SkillLevelUp(dwSkillVnum, SKILL_UP_BY_BOOK);
} }
// END_OF_INTERNATIONAL_VERSION // END_OF_INTERNATIONAL_VERSION
@ -818,7 +818,7 @@ void CHARACTER::SkillLevelUp(DWORD dwVnum, BYTE bMethod)
} }
else else
{ {
if (number(1, 21 - MIN(20, GetSkillLevel(pkSk->dwVnum))) == 1) if (Random::get(1, 21 - MIN(20, GetSkillLevel(pkSk->dwVnum))) == 1)
SetSkillLevel(pkSk->dwVnum, 20); SetSkillLevel(pkSk->dwVnum, 20);
} }
} }
@ -827,7 +827,7 @@ void CHARACTER::SkillLevelUp(DWORD dwVnum, BYTE bMethod)
case SKILL_MASTER: case SKILL_MASTER:
if (GetSkillLevel(pkSk->dwVnum) >= 30) if (GetSkillLevel(pkSk->dwVnum) >= 30)
{ {
if (number(1, 31 - MIN(30, GetSkillLevel(pkSk->dwVnum))) == 1) if (Random::get(1, 31 - MIN(30, GetSkillLevel(pkSk->dwVnum))) == 1)
SetSkillLevel(pkSk->dwVnum, 30); SetSkillLevel(pkSk->dwVnum, 30);
} }
break; break;
@ -948,7 +948,7 @@ struct FFindNearVictim
{ {
++m_count; ++m_count;
if ((m_count == 1) || number(1, m_count) == 1) if ((m_count == 1) || Random::get(1, m_count) == 1)
m_pkChrNextTarget = pkChr; m_pkChrNextTarget = pkChr;
} }
} }
@ -1000,7 +1000,7 @@ EVENTFUNC(ChainLightningEvent)
if (pkChrVictim->GetParty()) // 파티 먼저 if (pkChrVictim->GetParty()) // 파티 먼저
{ {
pkTarget = pkChrVictim->GetParty()->GetNextOwnership(NULL, pkChrVictim->GetX(), pkChrVictim->GetY()); pkTarget = pkChrVictim->GetParty()->GetNextOwnership(NULL, pkChrVictim->GetX(), pkChrVictim->GetY());
if (pkTarget == pkChrVictim || !number(0, 2) || pkChr->GetChainLightingExcept().find(pkTarget) != pkChr->GetChainLightingExcept().end()) if (pkTarget == pkChrVictim || !Random::get(0, 2) || pkChr->GetChainLightingExcept().find(pkTarget) != pkChr->GetChainLightingExcept().end())
pkTarget = NULL; pkTarget = NULL;
} }
@ -1037,10 +1037,10 @@ void SetPolyVarForAttack(LPCHARACTER ch, CSkillProto * pkSk, LPITEM pkWeapon)
{ {
if (pkWeapon && pkWeapon->GetType() == ITEM_WEAPON) if (pkWeapon && pkWeapon->GetType() == ITEM_WEAPON)
{ {
int iWep = number(pkWeapon->GetValue(3), pkWeapon->GetValue(4)); int iWep = Random::get(pkWeapon->GetValue(3), pkWeapon->GetValue(4));
iWep += pkWeapon->GetValue(5); iWep += pkWeapon->GetValue(5);
int iMtk = number(pkWeapon->GetValue(1), pkWeapon->GetValue(2)); int iMtk = Random::get(pkWeapon->GetValue(1), pkWeapon->GetValue(2));
iMtk += pkWeapon->GetValue(5); iMtk += pkWeapon->GetValue(5);
pkSk->SetPointVar("wep", iWep); pkSk->SetPointVar("wep", iWep);
@ -1056,7 +1056,7 @@ void SetPolyVarForAttack(LPCHARACTER ch, CSkillProto * pkSk, LPITEM pkWeapon)
} }
else else
{ {
int iWep = number(ch->GetMobDamageMin(), ch->GetMobDamageMax()); int iWep = Random::get(ch->GetMobDamageMin(), ch->GetMobDamageMax());
pkSk->SetPointVar("wep", iWep); pkSk->SetPointVar("wep", iWep);
pkSk->SetPointVar("mwep", iWep); pkSk->SetPointVar("mwep", iWep);
pkSk->SetPointVar("mtk", iWep); pkSk->SetPointVar("mtk", iWep);
@ -1129,7 +1129,7 @@ struct FuncSplashDamage
{ {
int iPenetratePct = (int) m_pkSk->kPointPoly2.Eval(); int iPenetratePct = (int) m_pkSk->kPointPoly2.Eval();
if (number(1, 100) <= iPenetratePct) if (Random::get(1, 100) <= iPenetratePct)
bIgnoreDefense = true; bIgnoreDefense = true;
} }
@ -1139,7 +1139,7 @@ struct FuncSplashDamage
{ {
int iPct = (int) m_pkSk->kPointPoly2.Eval(); int iPct = (int) m_pkSk->kPointPoly2.Eval();
if (number(1, 100) <= iPct) if (Random::get(1, 100) <= iPct)
bIgnoreTargetRating = true; bIgnoreTargetRating = true;
} }
@ -1405,7 +1405,7 @@ struct FuncSplashDamage
int iDur2 = (int) m_pkSk->kDurationPoly2.Eval(); int iDur2 = (int) m_pkSk->kDurationPoly2.Eval();
iDur2 += m_pkChr->GetPoint(POINT_PARTY_BUFFER_BONUS); iDur2 += m_pkChr->GetPoint(POINT_PARTY_BUFFER_BONUS);
if (number(1, 100) <= iAmount2) if (Random::get(1, 100) <= iAmount2)
{ {
pkChrVictim->RemoveGoodAffect(); pkChrVictim->RemoveGoodAffect();
pkChrVictim->AddAffect(m_pkSk->dwVnum, POINT_NONE, 0, AFF_PABEOP, iDur2, 0, true); pkChrVictim->AddAffect(m_pkSk->dwVnum, POINT_NONE, 0, AFF_PABEOP, iDur2, 0, true);
@ -1440,14 +1440,14 @@ struct FuncSplashDamage
iDur += bonus / 2; iDur += bonus / 2;
} }
if (number(1, 100) <= iDur) if (Random::get(1, 100) <= iDur)
{ {
pkChrVictim->AttackedByFire(m_pkChr, iPct, 5); pkChrVictim->AttackedByFire(m_pkChr, iPct, 5);
} }
} }
else if (IS_SET(m_pkSk->dwFlag, SKILL_FLAG_POISON)) else if (IS_SET(m_pkSk->dwFlag, SKILL_FLAG_POISON))
{ {
if (number(1, 100) <= iPct) if (Random::get(1, 100) <= iPct)
pkChrVictim->AttackedByPoison(m_pkChr); pkChrVictim->AttackedByPoison(m_pkChr);
} }
} }
@ -1634,7 +1634,7 @@ EVENTFUNC(skill_gwihwan_event)
int percent = 20 * sklv - 1; int percent = 20 * sklv - 1;
if (number(1, 100) <= percent) if (Random::get(1, 100) <= percent)
{ {
PIXEL_POSITION pos; PIXEL_POSITION pos;
@ -1773,7 +1773,7 @@ int CHARACTER::ComputeSkillAtPosition(DWORD dwVnum, const PIXEL_POSITION& posTar
if (IS_SET(pkSk->dwFlag, SKILL_FLAG_REMOVE_BAD_AFFECT)) if (IS_SET(pkSk->dwFlag, SKILL_FLAG_REMOVE_BAD_AFFECT))
{ {
if (number(1, 100) <= iAmount2) if (Random::get(1, 100) <= iAmount2)
{ {
RemoveBadAffect(); RemoveBadAffect();
} }
@ -2122,7 +2122,7 @@ int CHARACTER::ComputeSkill(DWORD dwVnum, LPCHARACTER pkVictim, BYTE bSkillLevel
// REMOVE_BAD_AFFECT_BUG_FIX // REMOVE_BAD_AFFECT_BUG_FIX
if (IS_SET(pkSk->dwFlag, SKILL_FLAG_REMOVE_BAD_AFFECT)) if (IS_SET(pkSk->dwFlag, SKILL_FLAG_REMOVE_BAD_AFFECT))
{ {
if (number(1, 100) <= iAmount2) if (Random::get(1, 100) <= iAmount2)
{ {
pkVictim->RemoveBadAffect(); pkVictim->RemoveBadAffect();
} }
@ -2866,7 +2866,7 @@ bool CHARACTER::CanUseMobSkill(unsigned int idx) const
if (m_adwMobSkillCooltime[idx] > get_dword_time()) if (m_adwMobSkillCooltime[idx] > get_dword_time())
return false; return false;
if (number(0, 1)) if (Random::get(0, 1))
return false; return false;
return true; return true;

View File

@ -285,10 +285,10 @@ void CHARACTER::CowardEscape()
for (int iDistIdx = 2; iDistIdx >= 0; --iDistIdx) for (int iDistIdx = 2; iDistIdx >= 0; --iDistIdx)
for (int iTryCount = 0; iTryCount < 8; ++iTryCount) for (int iTryCount = 0; iTryCount < 8; ++iTryCount)
{ {
SetRotation(number(0, 359)); // 방향은 랜덤으로 설정 SetRotation(Random::get(0, 359)); // 방향은 랜덤으로 설정
float fx, fy; float fx, fy;
float fDist = number(iDist[iDistIdx], iDist[iDistIdx+1]); float fDist = Random::get(iDist[iDistIdx], iDist[iDistIdx+1]);
GetDeltaByDegree(GetRotation(), fDist, &fx, &fy); GetDeltaByDegree(GetRotation(), fDist, &fx, &fy);
@ -390,7 +390,7 @@ void CHARACTER::__StateIdle_Stone()
m_dwStateDuration = PASSES_PER_SEC(1); m_dwStateDuration = PASSES_PER_SEC(1);
int iPercent = (GetHP() * 100) / GetMaxHP(); int iPercent = (GetHP() * 100) / GetMaxHP();
DWORD dwVnum = number(MIN(GetMobTable().sAttackSpeed, GetMobTable().sMovingSpeed ), MAX(GetMobTable().sAttackSpeed, GetMobTable().sMovingSpeed)); DWORD dwVnum = Random::get(MIN(GetMobTable().sAttackSpeed, GetMobTable().sMovingSpeed ), MAX(GetMobTable().sAttackSpeed, GetMobTable().sMovingSpeed));
if (iPercent <= 10 && GetMaxSP() < 10) if (iPercent <= 10 && GetMaxSP() < 10)
{ {
@ -549,7 +549,7 @@ void CHARACTER::__StateIdle_NPC()
const int WARP_MAP_INDEX_NUM = 7; const int WARP_MAP_INDEX_NUM = 7;
static const int c_lWarpMapIndexs[WARP_MAP_INDEX_NUM] = { 61, 62, 63, 64, 3, 23, 43 }; static const int c_lWarpMapIndexs[WARP_MAP_INDEX_NUM] = { 61, 62, 63, 64, 3, 23, 43 };
int lNextMapIndex; int lNextMapIndex;
lNextMapIndex = c_lWarpMapIndexs[number(1, WARP_MAP_INDEX_NUM) - 1]; lNextMapIndex = c_lWarpMapIndexs[Random::get(1, WARP_MAP_INDEX_NUM) - 1];
if (map_allow_find(lNextMapIndex)) if (map_allow_find(lNextMapIndex))
{ {
@ -587,17 +587,17 @@ void CHARACTER::__StateIdle_NPC()
{ {
if (DISTANCE_APPROX(GetX() - pkChrProtege->GetX(), GetY() - pkChrProtege->GetY()) > 500) if (DISTANCE_APPROX(GetX() - pkChrProtege->GetX(), GetY() - pkChrProtege->GetY()) > 500)
{ {
if (Follow(pkChrProtege, number(100, 300))) if (Follow(pkChrProtege, Random::get(100, 300)))
return; return;
} }
} }
if (!number(0, 6)) if (!Random::get(0, 6))
{ {
SetRotation(number(0, 359)); // 방향은 랜덤으로 설정 SetRotation(Random::get(0, 359)); // 방향은 랜덤으로 설정
float fx, fy; float fx, fy;
float fDist = number(200, 400); float fDist = Random::get(200, 400);
GetDeltaByDegree(GetRotation(), fDist, &fx, &fy); GetDeltaByDegree(GetRotation(), fDist, &fx, &fy);
@ -677,9 +677,9 @@ void CHARACTER::__StateIdle_Monster()
} }
if (IsAggressive() && !victim) if (IsAggressive() && !victim)
m_dwStateDuration = PASSES_PER_SEC(number(1, 3)); m_dwStateDuration = PASSES_PER_SEC(Random::get(1, 3));
else else
m_dwStateDuration = PASSES_PER_SEC(number(3, 5)); m_dwStateDuration = PASSES_PER_SEC(Random::get(3, 5));
LPCHARACTER pkChrProtege = GetProtege(); LPCHARACTER pkChrProtege = GetProtege();
@ -688,7 +688,7 @@ void CHARACTER::__StateIdle_Monster()
{ {
if (DISTANCE_APPROX(GetX() - pkChrProtege->GetX(), GetY() - pkChrProtege->GetY()) > 1000) if (DISTANCE_APPROX(GetX() - pkChrProtege->GetX(), GetY() - pkChrProtege->GetY()) > 1000)
{ {
if (Follow(pkChrProtege, number(150, 400))) if (Follow(pkChrProtege, Random::get(150, 400)))
{ {
MonsterLog("[IDLE] 리더로부터 너무 멀리 떨어졌다! 복귀한다."); MonsterLog("[IDLE] 리더로부터 너무 멀리 떨어졌다! 복귀한다.");
return; return;
@ -701,12 +701,12 @@ void CHARACTER::__StateIdle_Monster()
// //
if (!no_wander && !IS_SET(m_pointsInstant.dwAIFlag, AIFLAG_NOMOVE)) if (!no_wander && !IS_SET(m_pointsInstant.dwAIFlag, AIFLAG_NOMOVE))
{ {
if (!number(0, 6)) if (!Random::get(0, 6))
{ {
SetRotation(number(0, 359)); // 방향은 랜덤으로 설정 SetRotation(Random::get(0, 359)); // 방향은 랜덤으로 설정
float fx, fy; float fx, fy;
float fDist = number(300, 700); float fDist = Random::get(300, 700);
GetDeltaByDegree(GetRotation(), fDist, &fx, &fy); GetDeltaByDegree(GetRotation(), fDist, &fx, &fy);
@ -719,7 +719,7 @@ void CHARACTER::__StateIdle_Monster()
// 그래픽 팀에서 몬스터가 걷는 모습도 보고싶다고 해서 임시로 특정확률로 걷거나 뛰게 함. (게임의 전반적인 느낌이 틀려지기 때문에 일단 테스트 모드에서만 작동) // 그래픽 팀에서 몬스터가 걷는 모습도 보고싶다고 해서 임시로 특정확률로 걷거나 뛰게 함. (게임의 전반적인 느낌이 틀려지기 때문에 일단 테스트 모드에서만 작동)
if (g_test_server) if (g_test_server)
{ {
if (number(0, 100) < 60) if (Random::get(0, 100) < 60)
SetNowWalking(false); SetNowWalking(false);
else else
SetNowWalking(true); SetNowWalking(true);
@ -848,7 +848,7 @@ void CHARACTER::StateMove()
LPCHARACTER victim = GetVictim(); LPCHARACTER victim = GetVictim();
// 거대 거북 // 거대 거북
if (GetRaceNum() == 2191 && number(1, 20) == 1 && get_dword_time() - m_pkMobInst->m_dwLastWarpTime > 1000) if (GetRaceNum() == 2191 && Random::get(1, 20) == 1 && get_dword_time() - m_pkMobInst->m_dwLastWarpTime > 1000)
{ {
// 워프 테스트 // 워프 테스트
float fx, fy; float fx, fy;
@ -865,7 +865,7 @@ void CHARACTER::StateMove()
} }
// TODO 방향전환을 해서 덜 바보가 되자! // TODO 방향전환을 해서 덜 바보가 되자!
if (number(0, 3) == 0) if (Random::get(0, 3) == 0)
{ {
if (__CHARACTER_GotoNearTarget(this, victim)) if (__CHARACTER_GotoNearTarget(this, victim))
return; return;
@ -900,7 +900,7 @@ void CHARACTER::StateMove()
LPCHARACTER rider = GetRider(); LPCHARACTER rider = GetRider();
m_dwStateDuration = PASSES_PER_SEC(number(1, 3)); m_dwStateDuration = PASSES_PER_SEC(Random::get(1, 3));
} }
} }
} }
@ -932,7 +932,7 @@ void CHARACTER::StateBattle()
SetVictim(NULL); SetVictim(NULL);
if (number(1, 50) != 1) if (Random::get(1, 50) != 1)
{ {
GotoState(m_stateIdle); GotoState(m_stateIdle);
m_dwStateDuration = 1; m_dwStateDuration = 1;
@ -964,9 +964,9 @@ void CHARACTER::StateBattle()
case BATTLE_TYPE_TANKER: case BATTLE_TYPE_TANKER:
{ {
float fx, fy; float fx, fy;
float fDist = number(400, 1500); float fDist = Random::get(400, 1500);
GetDeltaByDegree(number(0, 359), fDist, &fx, &fy); GetDeltaByDegree(Random::get(0, 359), fDist, &fx, &fy);
if (SECTREE_MANAGER::instance().IsMovablePosition(victim->GetMapIndex(), if (SECTREE_MANAGER::instance().IsMovablePosition(victim->GetMapIndex(),
victim->GetX() + (int) fx, victim->GetX() + (int) fx,
@ -1010,7 +1010,7 @@ void CHARACTER::StateBattle()
} }
LPPARTY pParty = GetParty(); LPPARTY pParty = GetParty();
bool bPct = !number(0, 3); bool bPct = !Random::get(0, 3);
if (bPct && pParty->CountMemberByVnum(GetSummonVnum()) < SUMMON_MONSTER_COUNT) if (bPct && pParty->CountMemberByVnum(GetSummonVnum()) < SUMMON_MONSTER_COUNT)
{ {
@ -1043,7 +1043,7 @@ void CHARACTER::StateBattle()
// 보호할 것(돌, 파티장) 주변으로 간다. // 보호할 것(돌, 파티장) 주변으로 간다.
if (pkChrProtege) if (pkChrProtege)
if (DISTANCE_APPROX(GetX() - pkChrProtege->GetX(), GetY() - pkChrProtege->GetY()) > 1000) if (DISTANCE_APPROX(GetX() - pkChrProtege->GetX(), GetY() - pkChrProtege->GetY()) > 1000)
Follow(pkChrProtege, number(150, 400)); Follow(pkChrProtege, Random::get(150, 400));
return; return;
} }
@ -1200,19 +1200,19 @@ void CHARACTER::StateHorse()
if (fDist > START_RUN_DISTANCE) if (fDist > START_RUN_DISTANCE)
SetNowWalking(!bRun); // NOTE: 함수 이름보고 멈추는건줄 알았는데 SetNowWalking(false) 하면 뛰는거임.. -_-; SetNowWalking(!bRun); // NOTE: 함수 이름보고 멈추는건줄 알았는데 SetNowWalking(false) 하면 뛰는거임.. -_-;
Follow(victim, number(MIN_APPROACH, MAX_APPROACH)); Follow(victim, Random::get(MIN_APPROACH, MAX_APPROACH));
m_dwStateDuration = STATE_DURATION; m_dwStateDuration = STATE_DURATION;
} }
else if (bDoMoveAlone && (get_dword_time() > m_dwLastAttackTime)) else if (bDoMoveAlone && (get_dword_time() > m_dwLastAttackTime))
{ {
// wondering-.- // wondering-.-
m_dwLastAttackTime = get_dword_time() + number(5000, 12000); m_dwLastAttackTime = get_dword_time() + Random::get(5000, 12000);
SetRotation(number(0, 359)); // 방향은 랜덤으로 설정 SetRotation(Random::get(0, 359)); // 방향은 랜덤으로 설정
float fx, fy; float fx, fy;
float fDist = number(200, 400); float fDist = Random::get(200, 400);
GetDeltaByDegree(GetRotation(), fDist, &fx, &fy); GetDeltaByDegree(GetRotation(), fDist, &fx, &fy);

View File

@ -1906,10 +1906,10 @@ ACMD(do_monarch_mob)
tch = CHARACTER_MANAGER::instance().SpawnMobRange(vnum, tch = CHARACTER_MANAGER::instance().SpawnMobRange(vnum,
ch->GetMapIndex(), ch->GetMapIndex(),
ch->GetX() - number(200, 750), ch->GetX() - Random::get(200, 750),
ch->GetY() - number(200, 750), ch->GetY() - Random::get(200, 750),
ch->GetX() + number(200, 750), ch->GetX() + Random::get(200, 750),
ch->GetY() + number(200, 750), ch->GetY() + Random::get(200, 750),
true, true,
pkMob->m_table.bType == CHAR_TYPE_STONE, pkMob->m_table.bType == CHAR_TYPE_STONE,
true); true);
@ -2377,7 +2377,7 @@ ACMD(do_dice)
end = MAX(start, end); end = MAX(start, end);
start = MIN(start, end); start = MIN(start, end);
int n = number(start, end); int n = Random::get(start, end);
if (ch->GetParty()) if (ch->GetParty())
ch->GetParty()->ChatPacketToAllMember(CHAT_TYPE_INFO, LC_TEXT("%s님이 주사위를 굴려 %d가 나왔습니다. (%d-%d)"), ch->GetName(), n, start, end); ch->GetParty()->ChatPacketToAllMember(CHAT_TYPE_INFO, LC_TEXT("%s님이 주사위를 굴려 %d가 나왔습니다. (%d-%d)"), ch->GetName(), n, start, end);

View File

@ -661,10 +661,10 @@ ACMD(do_mob_coward)
{ {
tch = CHARACTER_MANAGER::instance().SpawnMobRange(vnum, tch = CHARACTER_MANAGER::instance().SpawnMobRange(vnum,
ch->GetMapIndex(), ch->GetMapIndex(),
ch->GetX() - number(200, 750), ch->GetX() - Random::get(200, 750),
ch->GetY() - number(200, 750), ch->GetY() - Random::get(200, 750),
ch->GetX() + number(200, 750), ch->GetX() + Random::get(200, 750),
ch->GetY() + number(200, 750), ch->GetY() + Random::get(200, 750),
true, true,
pkMob->m_table.bType == CHAR_TYPE_STONE); pkMob->m_table.bType == CHAR_TYPE_STONE);
if (tch) if (tch)
@ -743,10 +743,10 @@ ACMD(do_mob_aggresive)
{ {
tch = CHARACTER_MANAGER::instance().SpawnMobRange(vnum, tch = CHARACTER_MANAGER::instance().SpawnMobRange(vnum,
ch->GetMapIndex(), ch->GetMapIndex(),
ch->GetX() - number(200, 750), ch->GetX() - Random::get(200, 750),
ch->GetY() - number(200, 750), ch->GetY() - Random::get(200, 750),
ch->GetX() + number(200, 750), ch->GetX() + Random::get(200, 750),
ch->GetY() + number(200, 750), ch->GetY() + Random::get(200, 750),
true, true,
pkMob->m_table.bType == CHAR_TYPE_STONE); pkMob->m_table.bType == CHAR_TYPE_STONE);
if (tch) if (tch)
@ -806,10 +806,10 @@ ACMD(do_mob)
{ {
CHARACTER_MANAGER::instance().SpawnMobRange(vnum, CHARACTER_MANAGER::instance().SpawnMobRange(vnum,
ch->GetMapIndex(), ch->GetMapIndex(),
ch->GetX() - number(200, 750), ch->GetX() - Random::get(200, 750),
ch->GetY() - number(200, 750), ch->GetY() - Random::get(200, 750),
ch->GetX() + number(200, 750), ch->GetX() + Random::get(200, 750),
ch->GetY() + number(200, 750), ch->GetY() + Random::get(200, 750),
true, true,
pkMob->m_table.bType == CHAR_TYPE_STONE); pkMob->m_table.bType == CHAR_TYPE_STONE);
} }
@ -1820,11 +1820,11 @@ ACMD(do_b1)
for (int i = 0; i < 30; ++i) for (int i = 0; i < 30; ++i)
{ {
int rot = number(0, 359); int rot = Random::get(0, 359);
float fx, fy; float fx, fy;
GetDeltaByDegree(rot, 800, &fx, &fy); GetDeltaByDegree(rot, 800, &fx, &fy);
LPCHARACTER tch = CHARACTER_MANAGER::instance().SpawnMobRange(number(701, 706), LPCHARACTER tch = CHARACTER_MANAGER::instance().SpawnMobRange(Random::get(701, 706),
ch->GetMapIndex(), ch->GetMapIndex(),
304222 + (int)fx, 304222 + (int)fx,
742858 + (int)fy, 742858 + (int)fy,
@ -1837,7 +1837,7 @@ ACMD(do_b1)
for (int i = 0; i < 5; ++i) for (int i = 0; i < 5; ++i)
{ {
int rot = number(0, 359); int rot = Random::get(0, 359);
float fx, fy; float fx, fy;
GetDeltaByDegree(rot, 800, &fx, &fy); GetDeltaByDegree(rot, 800, &fx, &fy);
@ -1889,11 +1889,11 @@ ACMD(do_b4)
for (int i = 0; i < 30; ++i) for (int i = 0; i < 30; ++i)
{ {
int rot = number(0, 359); int rot = Random::get(0, 359);
float fx, fy; float fx, fy;
GetDeltaByDegree(rot, 1200, &fx, &fy); GetDeltaByDegree(rot, 1200, &fx, &fy);
LPCHARACTER tch = CHARACTER_MANAGER::instance().SpawnMobRange(number(701, 706), LPCHARACTER tch = CHARACTER_MANAGER::instance().SpawnMobRange(Random::get(701, 706),
ch->GetMapIndex(), ch->GetMapIndex(),
307900 + (int)fx, 307900 + (int)fx,
744500 + (int)fy, 744500 + (int)fy,
@ -1906,7 +1906,7 @@ ACMD(do_b4)
for (int i = 0; i < 5; ++i) for (int i = 0; i < 5; ++i)
{ {
int rot = number(0, 359); int rot = Random::get(0, 359);
float fx, fy; float fx, fy;
GetDeltaByDegree(rot, 1200, &fx, &fy); GetDeltaByDegree(rot, 1200, &fx, &fy);
@ -3712,8 +3712,8 @@ ACMD(do_siege)
int empire = strtol(arg1, NULL, 10); int empire = strtol(arg1, NULL, 10);
int tower_count = strtol(arg2, NULL, 10); int tower_count = strtol(arg2, NULL, 10);
if (empire == 0) empire = number(1, 3); if (empire == 0) empire = Random::get(1, 3);
if (tower_count < 5 || tower_count > 10) tower_count = number(5, 10); if (tower_count < 5 || tower_count > 10) tower_count = Random::get(5, 10);
TPacketGGSiege packet; TPacketGGSiege packet;
packet.bHeader = HEADER_GG_SIEGE; packet.bHeader = HEADER_GG_SIEGE;
@ -3842,7 +3842,7 @@ ACMD(do_weeklyevent)
} }
else else
{ {
CBattleArena::instance().Start(rand()%3 + 1); CBattleArena::instance().Start(Random::get(1, 3));
} }
ch->ChatPacket(CHAT_TYPE_INFO, "Weekly Event Start"); ch->ChatPacket(CHAT_TYPE_INFO, "Weekly Event Start");
} }

View File

@ -243,8 +243,8 @@ CUBE_VALUE* CUBE_DATA::reward_value ()
DWORD reward_index = 0; DWORD reward_index = 0;
end_index = this->reward.size(); end_index = this->reward.size();
reward_index = number(0, end_index); reward_index = Random::get(0, end_index);
reward_index = number(0, end_index-1); reward_index = Random::get(0, end_index-1);
return &this->reward[reward_index]; return &this->reward[reward_index];
} }
@ -556,7 +556,7 @@ bool Cube_make (LPCHARACTER ch)
if (0 < cube_proto->gold) if (0 < cube_proto->gold)
ch->PointChange(POINT_GOLD, -(cube_proto->gold), false); ch->PointChange(POINT_GOLD, -(cube_proto->gold), false);
percent_number = number(1,100); percent_number = Random::get(1,100);
if ( percent_number<=cube_proto->percent) if ( percent_number<=cube_proto->percent)
{ {
// ¼º°ø // ¼º°ø

View File

@ -129,7 +129,7 @@ DWORD DESC_MANAGER::CreateHandshake()
RETRY: RETRY:
do do
{ {
DWORD val = thecore_random() % (1024 * 1024); DWORD val = Random::get(0, 1024 * 1024 - 1);
*(DWORD *) (crc_buf ) = val; *(DWORD *) (crc_buf ) = val;
*((DWORD *) crc_buf + 1) = get_global_time(); *((DWORD *) crc_buf + 1) = get_global_time();
@ -411,7 +411,7 @@ void DESC_MANAGER::GetUserCount(int & iTotal, int ** paiEmpireUserCount, int & i
DWORD DESC_MANAGER::MakeRandomKey(DWORD dwHandle) DWORD DESC_MANAGER::MakeRandomKey(DWORD dwHandle)
{ {
DWORD random_key = thecore_random(); DWORD random_key = Random::get<int>();
m_map_handle_random_key.insert(std::make_pair(dwHandle, random_key)); m_map_handle_random_key.insert(std::make_pair(dwHandle, random_key));
return random_key; return random_key;
} }
@ -444,7 +444,7 @@ DWORD DESC_MANAGER::CreateLoginKey(LPDESC d)
do do
{ {
dwKey = number(1, INT_MAX); dwKey = Random::get(1, INT_MAX);
if (m_map_pkLoginKey.find(dwKey) != m_map_pkLoginKey.end()) if (m_map_pkLoginKey.find(dwKey) != m_map_pkLoginKey.end())
continue; continue;

View File

@ -517,7 +517,7 @@ void CDungeon::SpawnMoveUnique(const char* key, DWORD vnum, const char* pos_from
TAreaInfo & ai_to = it_to->second; TAreaInfo & ai_to = it_to->second;
int dir = ai.dir; int dir = ai.dir;
if (dir==-1) if (dir==-1)
dir = number(0,359); dir = Random::get(0,359);
LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(m_lMapIndex); LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(m_lMapIndex);
if (pkSectreeMap == NULL) { if (pkSectreeMap == NULL) {
@ -526,10 +526,10 @@ void CDungeon::SpawnMoveUnique(const char* key, DWORD vnum, const char* pos_from
} }
for (int i=0;i<100;i++) for (int i=0;i<100;i++)
{ {
int dx = number(ai.sx, ai.ex); int dx = Random::get(ai.sx, ai.ex);
int dy = number(ai.sy, ai.ey); int dy = Random::get(ai.sy, ai.ey);
int tx = number(ai_to.sx, ai_to.ex); int tx = Random::get(ai_to.sx, ai_to.ex);
int ty = number(ai_to.sy, ai_to.ey); int ty = Random::get(ai_to.sy, ai_to.ey);
LPCHARACTER ch = CHARACTER_MANAGER::instance().SpawnMob(vnum, m_lMapIndex, pkSectreeMap->m_setting.iBaseX+dx, pkSectreeMap->m_setting.iBaseY+dy, 0, false, dir); LPCHARACTER ch = CHARACTER_MANAGER::instance().SpawnMob(vnum, m_lMapIndex, pkSectreeMap->m_setting.iBaseX+dx, pkSectreeMap->m_setting.iBaseY+dy, 0, false, dir);
@ -562,7 +562,7 @@ void CDungeon::SpawnUnique(const char* key, DWORD vnum, const char* pos)
TAreaInfo & ai = it->second; TAreaInfo & ai = it->second;
int dir = ai.dir; int dir = ai.dir;
if (dir==-1) if (dir==-1)
dir = number(0,359); dir = Random::get(0,359);
LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(m_lMapIndex); LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(m_lMapIndex);
if (pkSectreeMap == NULL) { if (pkSectreeMap == NULL) {
@ -571,8 +571,8 @@ void CDungeon::SpawnUnique(const char* key, DWORD vnum, const char* pos)
} }
for (int i=0;i<100;i++) for (int i=0;i<100;i++)
{ {
int dx = number(ai.sx, ai.ex); int dx = Random::get(ai.sx, ai.ex);
int dy = number(ai.sy, ai.ey); int dy = Random::get(ai.sy, ai.ey);
LPCHARACTER ch = CHARACTER_MANAGER::instance().SpawnMob(vnum, m_lMapIndex, pkSectreeMap->m_setting.iBaseX+dx, pkSectreeMap->m_setting.iBaseY+dy, 0, false, dir); LPCHARACTER ch = CHARACTER_MANAGER::instance().SpawnMob(vnum, m_lMapIndex, pkSectreeMap->m_setting.iBaseX+dx, pkSectreeMap->m_setting.iBaseY+dy, 0, false, dir);
@ -707,7 +707,7 @@ void CDungeon::Spawn(DWORD vnum, const char* pos)
TAreaInfo & ai = it->second; TAreaInfo & ai = it->second;
int dir = ai.dir; int dir = ai.dir;
if (dir==-1) if (dir==-1)
dir = number(0,359); dir = Random::get(0,359);
LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(m_lMapIndex); LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(m_lMapIndex);
if (pkSectreeMap == NULL) if (pkSectreeMap == NULL)
@ -715,8 +715,8 @@ void CDungeon::Spawn(DWORD vnum, const char* pos)
sys_err("cannot find map by index %d", m_lMapIndex); sys_err("cannot find map by index %d", m_lMapIndex);
return; return;
} }
int dx = number(ai.sx, ai.ex); int dx = Random::get(ai.sx, ai.ex);
int dy = number(ai.sy, ai.ey); int dy = Random::get(ai.sy, ai.ey);
LPCHARACTER ch = CHARACTER_MANAGER::instance().SpawnMob(vnum, m_lMapIndex, pkSectreeMap->m_setting.iBaseX+dx, pkSectreeMap->m_setting.iBaseY+dy, 0, false, dir); LPCHARACTER ch = CHARACTER_MANAGER::instance().SpawnMob(vnum, m_lMapIndex, pkSectreeMap->m_setting.iBaseX+dx, pkSectreeMap->m_setting.iBaseY+dy, 0, false, dir);
if (ch) if (ch)
@ -900,7 +900,7 @@ void CDungeon::SpawnMoveGroup(DWORD vnum, const char* pos_from, const char* pos_
int dir = ai.dir; int dir = ai.dir;
if (dir == -1) if (dir == -1)
dir = number(0,359); dir = Random::get(0,359);
LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(m_lMapIndex); LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(m_lMapIndex);
if (pkSectreeMap == NULL) { if (pkSectreeMap == NULL) {
@ -910,8 +910,8 @@ void CDungeon::SpawnMoveGroup(DWORD vnum, const char* pos_from, const char* pos_
while (count--) while (count--)
{ {
int tx = number(ai_to.sx, ai_to.ex)+pkSectreeMap->m_setting.iBaseX; int tx = Random::get(ai_to.sx, ai_to.ex)+pkSectreeMap->m_setting.iBaseX;
int ty = number(ai_to.sy, ai_to.ey)+pkSectreeMap->m_setting.iBaseY; int ty = Random::get(ai_to.sy, ai_to.ey)+pkSectreeMap->m_setting.iBaseY;
CHARACTER_MANAGER::instance().SpawnMoveGroup(vnum, m_lMapIndex, pkSectreeMap->m_setting.iBaseX+ai.sx, pkSectreeMap->m_setting.iBaseY+ai.sy, pkSectreeMap->m_setting.iBaseX+ai.ex, pkSectreeMap->m_setting.iBaseY+ai.ey, tx, ty, NULL, true); CHARACTER_MANAGER::instance().SpawnMoveGroup(vnum, m_lMapIndex, pkSectreeMap->m_setting.iBaseX+ai.sx, pkSectreeMap->m_setting.iBaseY+ai.sy, pkSectreeMap->m_setting.iBaseX+ai.ex, pkSectreeMap->m_setting.iBaseY+ai.ey, tx, ty, NULL, true);
} }
} }

View File

@ -50,14 +50,14 @@ void ConvertEmpireText(DWORD dwEmpireID, char* szText, size_t len, int iPct)
for (BYTE* pbText = reinterpret_cast<BYTE*>(szText) ; len > 0 && *pbText != '\0' ; --len, ++pbText) for (BYTE* pbText = reinterpret_cast<BYTE*>(szText) ; len > 0 && *pbText != '\0' ; --len, ++pbText)
{ {
if (number(1,100) > iPct) if (Random::get(1,100) > iPct)
{ {
if (*pbText & 0x80) if (*pbText & 0x80)
{ {
if (g_iUseLocale) if (g_iUseLocale)
{ {
static char s_cChinaTable[][3] = {"¡ò","££","£¤","¡ù","¡ð" }; static char s_cChinaTable[][3] = {"¡ò","££","£¤","¡ù","¡ð" };
int n = number(0, 4); int n = Random::get(0, 4);
pbText[0] = s_cChinaTable[n][0]; pbText[0] = s_cChinaTable[n][0];
pbText[1] = s_cChinaTable[n][1]; pbText[1] = s_cChinaTable[n][1];
} }

View File

@ -328,7 +328,7 @@ void Initialize()
int DetermineFishByProbIndex(int prob_idx) 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 * 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]; int fish_idx = p - g_prob_accumulate[prob_idx];
return fish_idx; return fish_idx;
@ -382,7 +382,7 @@ int DetermineFish(LPCHARACTER ch)
adjust = (100-fish_pct_value) * fish_info[0].prob[prob_idx] / 100; 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 * 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]; int fish_idx = p - g_prob_accumulate[prob_idx];
@ -438,7 +438,7 @@ void FishingPractice(LPCHARACTER ch)
if (rod && rod->GetType() == ITEM_ROD) if (rod && rod->GetType() == ITEM_ROD)
{ {
// 최대 수련도가 아닌 경우 낚시대 수련 // 최대 수련도가 아닌 경우 낚시대 수련
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); rod->SetSocket(0, rod->GetSocket(0) + 1);
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("낚시대의 수련도가 증가하였습니다! (%d/%d)"),rod->GetSocket(0), rod->GetValue(2)); ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("낚시대의 수련도가 증가하였습니다! (%d/%d)"),rod->GetSocket(0), rod->GetValue(2));
@ -529,7 +529,7 @@ LPEVENT CreateFishingEvent(LPCHARACTER ch)
info->step = 0; info->step = 0;
info->hang_time = 0; info->hang_time = 0;
int time = number(10, 40); int time = Random::get(10, 40);
TPacketGCFishing p; TPacketGCFishing p;
p.header = HEADER_GC_FISHING; 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); 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; *item = fish_info[fish_id].vnum;
return 0; return 0;
@ -582,19 +582,19 @@ int Compute(DWORD fish_id, DWORD ms, DWORD* item, int level)
int GetFishLength(int fish_id) int GetFishLength(int fish_id)
{ {
if (number(0,99)) if (Random::get(0,99))
{ {
// 99% : normal size // 99% : normal size
return (int)(fish_info[fish_id].length_range[0] + return (int)(fish_info[fish_id].length_range[0] +
(fish_info[fish_id].length_range[1] - 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 else
{ {
// 1% : extra LARGE size // 1% : extra LARGE size
return (int)(fish_info[fish_id].length_range[1] + return (int)(fish_info[fish_id].length_range[1] +
(fish_info[fish_id].length_range[2] - 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); int fish_id = DetermineFishByProbIndex(prob_idx);
DWORD item = 0; 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) if (item)
{ {
@ -763,7 +763,7 @@ void UseFish(LPCHARACTER ch, LPITEM item)
if (idx<=1 || idx >= MAX_FISH) if (idx<=1 || idx >= MAX_FISH)
return; return;
int r = number(1, 10000); int r = Random::get(1, 10000);
item->SetCount(item->GetCount()-1); item->SetCount(item->GetCount()-1);
@ -794,7 +794,7 @@ void UseFish(LPCHARACTER ch, LPITEM item)
case USED_SHELLFISH: // 1 case USED_SHELLFISH: // 1
if ( LC_IsCanada() == true ) if ( LC_IsCanada() == true )
{ {
if ( number(0, 2) != 2 ) return; if ( Random::get(0, 2) != 2 ) return;
} }
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("배 속에서 조개가 나왔습니다.")); ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("배 속에서 조개가 나왔습니다."));
@ -869,7 +869,7 @@ int RealRefineRod(LPCHARACTER ch, LPITEM item)
int iAdv = rod->GetValue(0) / 10; 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"); LogManager::instance().RefineLog(ch->GetPlayerID(), rod->GetName(), rod->GetID(), iAdv, 1, "ROD");

View File

@ -163,7 +163,7 @@ void CInputDB::LoginSuccess(DWORD dwHandle, const char *data)
{ {
TPacketGCEmpire pe; TPacketGCEmpire pe;
pe.bHeader = HEADER_GC_EMPIRE; pe.bHeader = HEADER_GC_EMPIRE;
pe.bEmpire = number(1, 3); pe.bEmpire = Random::get(1, 3);
d->Packet(&pe, sizeof(pe)); d->Packet(&pe, sizeof(pe));
} }
else else
@ -2533,7 +2533,7 @@ void CInputDB::AddMonarchMoney(LPDESC d, const char * data )
if (ch) if (ch)
{ {
if (number(1, 100) > 95) if (Random::get(1, 100) > 95)
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("현재 %s 국고에는 %u 의 돈이 있습니다"), EMPIRE_NAME(Empire), CMonarch::instance().GetMoney(Empire)); ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("현재 %s 국고에는 %u 의 돈이 있습니다"), EMPIRE_NAME(Empire), CMonarch::instance().GetMoney(Empire));
} }
} }

View File

@ -295,8 +295,8 @@ bool NewPlayerTable(TPlayerTable * table,
table->sp = JobInitialPoints[job].max_sp + table->iq * JobInitialPoints[job].sp_per_iq; table->sp = JobInitialPoints[job].max_sp + table->iq * JobInitialPoints[job].sp_per_iq;
table->stamina = JobInitialPoints[job].max_stamina; table->stamina = JobInitialPoints[job].max_stamina;
table->x = CREATE_START_X(bEmpire) + number(-300, 300); table->x = CREATE_START_X(bEmpire) + Random::get(-300, 300);
table->y = CREATE_START_Y(bEmpire) + number(-300, 300); table->y = CREATE_START_Y(bEmpire) + Random::get(-300, 300);
table->z = 0; table->z = 0;
table->dir = 0; table->dir = 0;
table->playtime = 0; table->playtime = 0;
@ -310,8 +310,8 @@ bool NewPlayerTable(TPlayerTable * table,
for (int i = 1; i < 35; ++i) for (int i = 1; i < 35; ++i)
{ {
int iHP = number(JobInitialPoints[job].hp_per_lv_begin, JobInitialPoints[job].hp_per_lv_end); int iHP = Random::get(JobInitialPoints[job].hp_per_lv_begin, JobInitialPoints[job].hp_per_lv_end);
int iSP = number(JobInitialPoints[job].sp_per_lv_begin, JobInitialPoints[job].sp_per_lv_end); int iSP = Random::get(JobInitialPoints[job].sp_per_lv_begin, JobInitialPoints[job].sp_per_lv_end);
table->sRandomHP += iHP; table->sRandomHP += iHP;
table->sRandomSP += iSP; table->sRandomSP += iSP;
table->stat_point += 3; table->stat_point += 3;
@ -411,8 +411,8 @@ bool NewPlayerTable2(TPlayerTable * table, const char * name, BYTE race, BYTE sh
table->sp = JobInitialPoints[job].max_sp + table->iq * JobInitialPoints[job].sp_per_iq; table->sp = JobInitialPoints[job].max_sp + table->iq * JobInitialPoints[job].sp_per_iq;
table->stamina = JobInitialPoints[job].max_stamina; table->stamina = JobInitialPoints[job].max_stamina;
table->x = CREATE_START_X(bEmpire) + number(-300, 300); table->x = CREATE_START_X(bEmpire) + Random::get(-300, 300);
table->y = CREATE_START_Y(bEmpire) + number(-300, 300); table->y = CREATE_START_Y(bEmpire) + Random::get(-300, 300);
table->z = 0; table->z = 0;
table->dir = 0; table->dir = 0;
table->playtime = 0; table->playtime = 0;

View File

@ -1463,7 +1463,7 @@ bool CheckComboHack(LPCHARACTER ch, BYTE bArg, DWORD dwTime, bool CheckSpeedHack
else else
{ {
// 말이 안되는 콤보가 왔다 해커일 가능성? // 말이 안되는 콤보가 왔다 해커일 가능성?
//if (ch->GetDesc()->DelayedDisconnect(number(2, 9))) //if (ch->GetDesc()->DelayedDisconnect(Random::get(2, 9)))
//{ //{
// LogManager::instance().HackLog("Hacker", ch); // LogManager::instance().HackLog("Hacker", ch);
// sys_log(0, "HACKER: %s arg %u", ch->GetName(), bArg); // sys_log(0, "HACKER: %s arg %u", ch->GetName(), bArg);
@ -1488,7 +1488,7 @@ bool CheckComboHack(LPCHARACTER ch, BYTE bArg, DWORD dwTime, bool CheckSpeedHack
else else
{ {
// 말이 안되는 콤보가 왔다 해커일 가능성? // 말이 안되는 콤보가 왔다 해커일 가능성?
if (ch->GetDesc()->DelayedDisconnect(number(2, 9))) if (ch->GetDesc()->DelayedDisconnect(Random::get(2, 9)))
{ {
LogManager::instance().HackLog("Hacker", ch); LogManager::instance().HackLog("Hacker", ch);
sys_log(0, "HACKER: %s arg %u", ch->GetName(), bArg); sys_log(0, "HACKER: %s arg %u", ch->GetName(), bArg);
@ -1627,12 +1627,12 @@ void CInputMain::Move(LPCHARACTER ch, const char * data)
if (test_server) if (test_server)
{ {
ch->GetDesc()->DelayedDisconnect(number(2, 8)); ch->GetDesc()->DelayedDisconnect(Random::get(2, 8));
ch->ChatPacket(CHAT_TYPE_INFO, szBuf); ch->ChatPacket(CHAT_TYPE_INFO, szBuf);
} }
else else
{ {
ch->GetDesc()->DelayedDisconnect(number(150, 500)); ch->GetDesc()->DelayedDisconnect(Random::get(150, 500));
} }
} }
@ -1663,13 +1663,13 @@ void CInputMain::Move(LPCHARACTER ch, const char * data)
/* /*
if (pinfo->dwTime == 10653691) // 디버거 발견 if (pinfo->dwTime == 10653691) // 디버거 발견
{ {
if (ch->GetDesc()->DelayedDisconnect(number(15, 30))) if (ch->GetDesc()->DelayedDisconnect(Random::get(15, 30)))
LogManager::instance().HackLog("Debugger", ch); LogManager::instance().HackLog("Debugger", ch);
} }
else if (pinfo->dwTime == 10653971) // Softice 발견 else if (pinfo->dwTime == 10653971) // Softice 발견
{ {
if (ch->GetDesc()->DelayedDisconnect(number(15, 30))) if (ch->GetDesc()->DelayedDisconnect(Random::get(15, 30)))
LogManager::instance().HackLog("Softice", ch); LogManager::instance().HackLog("Softice", ch);
} }
*/ */

View File

@ -1213,10 +1213,10 @@ void CItem::AlterToMagicItem()
// 100% 확률로 좋은 속성 하나 // 100% 확률로 좋은 속성 하나
PutAttribute(aiItemMagicAttributePercentHigh); PutAttribute(aiItemMagicAttributePercentHigh);
if (number(1, 100) <= iSecondPct) if (Random::get(1, 100) <= iSecondPct)
PutAttribute(aiItemMagicAttributePercentLow); PutAttribute(aiItemMagicAttributePercentLow);
if (number(1, 100) <= iThirdPct) if (Random::get(1, 100) <= iThirdPct)
PutAttribute(aiItemMagicAttributePercentLow); PutAttribute(aiItemMagicAttributePercentLow);
} }

View File

@ -22,12 +22,12 @@ void CItemAddonManager::ApplyAddonTo(int iAddonType, LPITEM pItem)
// TODO 일단 하드코딩으로 평타 스킬 수치 변경만 경우만 적용받게한다. // TODO 일단 하드코딩으로 평타 스킬 수치 변경만 경우만 적용받게한다.
int iSkillBonus = MINMAX(-30, (int) (gauss_random(0, 5) + 0.5f), 30); int iSkillBonus = MINMAX(-30, (int) (Random::get<std::normal_distribution<>>(0, 5) + 0.5f), 30);
int iNormalHitBonus = 0; int iNormalHitBonus = 0;
if (abs(iSkillBonus) <= 20) if (abs(iSkillBonus) <= 20)
iNormalHitBonus = -2 * iSkillBonus + abs(number(-8, 8) + number(-8, 8)) + number(1, 4); iNormalHitBonus = -2 * iSkillBonus + abs(Random::get(-8, 8) + Random::get(-8, 8)) + Random::get(1, 4);
else else
iNormalHitBonus = -2 * iSkillBonus + number(1, 5); iNormalHitBonus = -2 * iSkillBonus + Random::get(1, 5);
pItem->RemoveAttributeType(APPLY_SKILL_DAMAGE_BONUS); pItem->RemoveAttributeType(APPLY_SKILL_DAMAGE_BONUS);
pItem->RemoveAttributeType(APPLY_NORMAL_HIT_DAMAGE_BONUS); pItem->RemoveAttributeType(APPLY_NORMAL_HIT_DAMAGE_BONUS);

View File

@ -138,7 +138,7 @@ void CItem::PutAttributeWithLevel(BYTE bLevel)
} }
// 구축된 배열로 확률 계산을 통해 붙일 속성 선정 // 구축된 배열로 확률 계산을 통해 붙일 속성 선정
unsigned int prob = number(1, total); unsigned int prob = Random::get(1, total);
int attr_idx = APPLY_NONE; int attr_idx = APPLY_NONE;
for (DWORD i = 0; i < avail.size(); ++i) for (DWORD i = 0; i < avail.size(); ++i)
@ -171,7 +171,7 @@ void CItem::PutAttributeWithLevel(BYTE bLevel)
void CItem::PutAttribute(const int * aiAttrPercentTable) void CItem::PutAttribute(const int * aiAttrPercentTable)
{ {
int iAttrLevelPercent = number(1, 100); int iAttrLevelPercent = Random::get(1, 100);
int i; int i;
for (i = 0; i < ITEM_ATTRIBUTE_MAX_LEVEL; ++i) for (i = 0; i < ITEM_ATTRIBUTE_MAX_LEVEL; ++i)
@ -397,7 +397,7 @@ bool CItem::AddRareAttribute()
} }
} }
const TItemAttrTable& r = g_map_itemRare[avail[number(0, avail.size() - 1)]]; const TItemAttrTable& r = g_map_itemRare[avail[Random::get<int>(0, avail.size() - 1)]];
int nAttrLevel = 5; int nAttrLevel = 5;
if (nAttrLevel > r.bMaxLevelBySet[nAttrSet]) if (nAttrLevel > r.bMaxLevelBySet[nAttrSet])

View File

@ -164,7 +164,7 @@ LPITEM ITEM_MANAGER::CreateItem(DWORD vnum, DWORD count, DWORD id, bool bTryMagi
do do
{ {
dwSkillVnum = number(1, 111); dwSkillVnum = Random::get(1, 111);
CSkillProto * pkSk = CSkillManager::instance().Get(dwSkillVnum); CSkillProto * pkSk = CSkillManager::instance().Get(dwSkillVnum);
@ -349,7 +349,7 @@ LPITEM ITEM_MANAGER::CreateItem(DWORD vnum, DWORD count, DWORD id, bool bTryMagi
if (iRarePct == -1) if (iRarePct == -1)
iRarePct = table->bAlterToMagicItemPct; iRarePct = table->bAlterToMagicItemPct;
if (number(1, 100) <= iRarePct) if (Random::get(1, 100) <= iRarePct)
item->AlterToMagicItem(); item->AlterToMagicItem();
} }
@ -363,7 +363,7 @@ LPITEM ITEM_MANAGER::CreateItem(DWORD vnum, DWORD count, DWORD id, bool bTryMagi
do do
{ {
dwSkillVnum = number(1, 111); dwSkillVnum = Random::get(1, 111);
if (NULL != CSkillManager::instance().Get(dwSkillVnum)) if (NULL != CSkillManager::instance().Get(dwSkillVnum))
break; break;
@ -377,7 +377,7 @@ LPITEM ITEM_MANAGER::CreateItem(DWORD vnum, DWORD count, DWORD id, bool bTryMagi
do do
{ {
dwSkillVnum = number(112, 119); dwSkillVnum = Random::get(112, 119);
if (NULL != CSkillManager::instance().Get(dwSkillVnum)) if (NULL != CSkillManager::instance().Get(dwSkillVnum))
break; break;
@ -720,7 +720,7 @@ DWORD lotto()
do do
{ {
for (int i = 0; i < 6; ++i) for (int i = 0; i < 6; ++i)
szBuf[i] = 48 + number(1, 9); szBuf[i] = 48 + Random::get(1, 9);
szBuf[6] = '\0'; szBuf[6] = '\0';
@ -805,9 +805,9 @@ bool ITEM_MANAGER::GetDropPct(LPCHARACTER pkChr, LPCHARACTER pkKiller, OUT int&
BYTE bRank = pkChr->GetMobRank(); BYTE bRank = pkChr->GetMobRank();
if (1 == number(1, 50000)) if (1 == Random::get(1, 50000))
iDeltaPercent += 1000; iDeltaPercent += 1000;
else if (1 == number(1, 10000)) else if (1 == Random::get(1, 10000))
iDeltaPercent += 500; iDeltaPercent += 500;
sys_log(3, "CreateDropItem for level: %d rank: %u pct: %d", iLevel, bRank, iDeltaPercent); sys_log(3, "CreateDropItem for level: %d rank: %u pct: %d", iLevel, bRank, iDeltaPercent);
@ -864,7 +864,7 @@ bool ITEM_MANAGER::CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::
int iPercent = (c_rInfo.m_iPercent * iDeltaPercent) / 100; int iPercent = (c_rInfo.m_iPercent * iDeltaPercent) / 100;
sys_log(3, "CreateDropItem %d ~ %d %d(%d)", c_rInfo.m_iLevelStart, c_rInfo.m_iLevelEnd, c_rInfo.m_dwVnum, iPercent, c_rInfo.m_iPercent); sys_log(3, "CreateDropItem %d ~ %d %d(%d)", c_rInfo.m_iLevelStart, c_rInfo.m_iLevelEnd, c_rInfo.m_dwVnum, iPercent, c_rInfo.m_iPercent);
if (iPercent >= number(1, iRandRange)) if (iPercent >= Random::get(1, iRandRange))
{ {
TItemTable * table = GetTable(c_rInfo.m_dwVnum); TItemTable * table = GetTable(c_rInfo.m_dwVnum);
@ -903,7 +903,7 @@ bool ITEM_MANAGER::CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::
{ {
int iPercent = (v[i].dwPct * iDeltaPercent) / 100; int iPercent = (v[i].dwPct * iDeltaPercent) / 100;
if (iPercent >= number(1, iRandRange)) if (iPercent >= Random::get(1, iRandRange))
{ {
item = CreateItem(v[i].dwVnum, v[i].iCount, 0, true); item = CreateItem(v[i].dwVnum, v[i].iCount, 0, true);
@ -938,7 +938,7 @@ bool ITEM_MANAGER::CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::
if (pGroup && !pGroup->IsEmpty()) if (pGroup && !pGroup->IsEmpty())
{ {
int iPercent = 40000 * iDeltaPercent / pGroup->GetKillPerDrop(); int iPercent = 40000 * iDeltaPercent / pGroup->GetKillPerDrop();
if (iPercent >= number(1, iRandRange)) if (iPercent >= Random::get(1, iRandRange))
{ {
const CMobItemGroup::SMobItemGroupInfo& info = pGroup->GetOne(); const CMobItemGroup::SMobItemGroupInfo& info = pGroup->GetOne();
item = CreateItem(info.dwItemVnum, info.iCount, 0, true, info.iRarePct); item = CreateItem(info.dwItemVnum, info.iCount, 0, true, info.iRarePct);
@ -963,7 +963,7 @@ bool ITEM_MANAGER::CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::
for ( DWORD i=0; i < v.size(); i++ ) for ( DWORD i=0; i < v.size(); i++ )
{ {
if ( v[i].dwPct >= (DWORD)number(1, 1000000/*iRandRange*/) ) if ( v[i].dwPct >= Random::get(1, 1000000) )
{ {
DWORD dwVnum = v[i].dwVNum; DWORD dwVnum = v[i].dwVNum;
item = CreateItem(dwVnum, v[i].iCount, 0, true); item = CreateItem(dwVnum, v[i].iCount, 0, true);
@ -990,7 +990,7 @@ bool ITEM_MANAGER::CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::
{ {
int iPercent = (v[i].dwPct * iDeltaPercent) / 100; int iPercent = (v[i].dwPct * iDeltaPercent) / 100;
if (iPercent >= number(1, iRandRange)) if (iPercent >= Random::get(1, iRandRange))
{ {
DWORD dwVnum = v[i].dwVnum; DWORD dwVnum = v[i].dwVnum;
item = CreateItem(dwVnum, v[i].iCount, 0, true); item = CreateItem(dwVnum, v[i].iCount, 0, true);
@ -1010,7 +1010,7 @@ bool ITEM_MANAGER::CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::
{ {
int iPercent = (it->second * iDeltaPercent) / 100; int iPercent = (it->second * iDeltaPercent) / 100;
if (iPercent >= number(1, iRandRange)) if (iPercent >= Random::get(1, iRandRange))
{ {
item = CreateItem(pkChr->GetMobDropItemVnum(), 1, 0, true); item = CreateItem(pkChr->GetMobDropItemVnum(), 1, 0, true);
if (item) vec_item.push_back(item); if (item) vec_item.push_back(item);
@ -1024,7 +1024,7 @@ bool ITEM_MANAGER::CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::
{ {
int iPercent = (pkChr->GetDropMetinStonePct() * iDeltaPercent) * 400; int iPercent = (pkChr->GetDropMetinStonePct() * iDeltaPercent) * 400;
if (iPercent >= number(1, iRandRange)) if (iPercent >= Random::get(1, iRandRange))
{ {
item = CreateItem(pkChr->GetDropMetinStoneVnum(), 1, 0, true); item = CreateItem(pkChr->GetDropMetinStoneVnum(), 1, 0, true);
if (item) vec_item.push_back(item); if (item) vec_item.push_back(item);
@ -1033,7 +1033,7 @@ bool ITEM_MANAGER::CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::
} }
if (pkKiller->IsHorseRiding() && if (pkKiller->IsHorseRiding() &&
GetDropPerKillPct(1000, 1000000, iDeltaPercent, "horse_skill_book_drop") >= number(1, iRandRange)) GetDropPerKillPct(1000, 1000000, iDeltaPercent, "horse_skill_book_drop") >= Random::get(1, iRandRange))
{ {
sys_log(0, "EVENT HORSE_SKILL_BOOK_DROP"); sys_log(0, "EVENT HORSE_SKILL_BOOK_DROP");
@ -1042,7 +1042,7 @@ bool ITEM_MANAGER::CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::
} }
if (GetDropPerKillPct(100, 1000, iDeltaPercent, "lotto_drop") >= number(1, iRandRange)) if (GetDropPerKillPct(100, 1000, iDeltaPercent, "lotto_drop") >= Random::get(1, iRandRange))
{ {
DWORD * pdw = M2_NEW DWORD[3]; DWORD * pdw = M2_NEW DWORD[3];
@ -1075,7 +1075,7 @@ bool ITEM_MANAGER::CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::
if (73 == pkKiller->GetMapIndex()) if (73 == pkKiller->GetMapIndex())
{ {
int per = 25; // 0.25% int per = 25; // 0.25%
if (number(1, 10000) <= per) if (Random::get(1, 10000) <= per)
{ {
LPITEM item = 0; LPITEM item = 0;
if ((item = CreateItem(71122, 1, 0, true))) if ((item = CreateItem(71122, 1, 0, true)))
@ -1104,7 +1104,7 @@ bool ITEM_MANAGER::CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::
break; break;
int per = 5; // 0.05% int per = 5; // 0.05%
if (number(1, 10000) <= per) if (Random::get(1, 10000) <= per)
{ {
LPITEM item = 0; LPITEM item = 0;
item = CreateItem(vnum, 1, 0, true); item = CreateItem(vnum, 1, 0, true);
@ -1190,7 +1190,7 @@ static void __DropEvent_CharStone_DropItem(CHARACTER & killer, CHARACTER & victi
if (LC_IsCanada() == true) if (LC_IsCanada() == true)
MaxRange = 20000; MaxRange = 20000;
if (number(1, MaxRange) <= dropPercent) if (Random::get(1, MaxRange) <= dropPercent)
{ {
int log_level = (test_server || killer.GetGMLevel() >= GM_LOW_WIZARD) ? 0 : 1; int log_level = (test_server || killer.GetGMLevel() >= GM_LOW_WIZARD) ? 0 : 1;
int victim_level = victim.GetLevel(); int victim_level = victim.GetLevel();
@ -1205,7 +1205,7 @@ static void __DropEvent_CharStone_DropItem(CHARACTER & killer, CHARACTER & victi
} }
static const int Stones[] = { 30210, 30211, 30212, 30213, 30214, 30215, 30216, 30217, 30218, 30219, 30258, 30259, 30260, 30261, 30262, 30263 }; static const int Stones[] = { 30210, 30211, 30212, 30213, 30214, 30215, 30216, 30217, 30218, 30219, 30258, 30259, 30260, 30261, 30262, 30263 };
int item_vnum = Stones[number(0, _countof(Stones))]; int item_vnum = Stones[Random::get<int>(0, _countof(Stones))];
LPITEM p_item = NULL; LPITEM p_item = NULL;
@ -1307,23 +1307,23 @@ static LPITEM __DropEvent_RefineBox_GetDropItem(CHARACTER & killer, CHARACTER &
if (killer_level <= gs_dropEvent_refineBox.low) if (killer_level <= gs_dropEvent_refineBox.low)
{ {
if (number (1, gs_dropEvent_refineBox.percent_low) == 1) if (Random::get(1, gs_dropEvent_refineBox.percent_low) == 1)
{ {
return itemMgr.CreateItem(lowerBox [number (1,lowerBox_range) - 1], 1, 0, true); return itemMgr.CreateItem(lowerBox[Random::get(1, lowerBox_range) - 1], 1, 0, true);
} }
} }
else if (killer_level <= gs_dropEvent_refineBox.mid) else if (killer_level <= gs_dropEvent_refineBox.mid)
{ {
if (number (1, gs_dropEvent_refineBox.percent_mid) == 1) if (Random::get(1, gs_dropEvent_refineBox.percent_mid) == 1)
{ {
return itemMgr.CreateItem(midderBox [number (1,midderBox_range) - 1], 1, 0, true); return itemMgr.CreateItem(midderBox[Random::get(1, midderBox_range) - 1], 1, 0, true);
} }
} }
else else
{ {
if (number (1, gs_dropEvent_refineBox.percent_high) == 1) if (Random::get(1, gs_dropEvent_refineBox.percent_high) == 1)
{ {
return itemMgr.CreateItem(higherBox [number (1,higherBox_range) - 1], 1, 0, true); return itemMgr.CreateItem(higherBox[Random::get(1, higherBox_range) - 1], 1, 0, true);
} }
} }
return NULL; return NULL;
@ -1406,7 +1406,7 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
DWORD SOCK_ITEM_VNUM = 0; DWORD SOCK_ITEM_VNUM = 0;
if (LC_IsKorea() || LC_IsYMIR()) if (LC_IsKorea() || LC_IsYMIR())
{ {
SOCK_ITEM_VNUM = (number(1,100)<=50) ? 50010 : 71111; SOCK_ITEM_VNUM = (Random::get(1,100)<=50) ? 50010 : 71111;
} }
else else
{ {
@ -1433,7 +1433,7 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
} }
sys_log(0, "SOCK DROP %d %d", iPercent, iRandRange); sys_log(0, "SOCK DROP %d %d", iPercent, iRandRange);
if (iPercent >= number(1, iRandRange)) if (iPercent >= Random::get(1, iRandRange))
{ {
if ((item = CreateItem(SOCK_ITEM_VNUM, 1, 0, true))) if ((item = CreateItem(SOCK_ITEM_VNUM, 1, 0, true)))
vec_item.push_back(item); vec_item.push_back(item);
@ -1460,7 +1460,7 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
{ {
int iPercent = 40000 * iDeltaPercent / iDropPerKill[pkChr->GetMobRank()]; int iPercent = 40000 * iDeltaPercent / iDropPerKill[pkChr->GetMobRank()];
if (iPercent >= number(1, iRandRange)) if (iPercent >= Random::get(1, iRandRange))
{ {
if ((item = CreateItem(ITEM_VNUM, 1, 0, true))) if ((item = CreateItem(ITEM_VNUM, 1, 0, true)))
vec_item.push_back(item); vec_item.push_back(item);
@ -1478,7 +1478,7 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
{ {
const DWORD ITEM_VNUM = 30178; const DWORD ITEM_VNUM = 30178;
if (number(1,100) <= pct) if (Random::get(1,100) <= pct)
{ {
if ((item = CreateItem(ITEM_VNUM, 1, 0, true))) if ((item = CreateItem(ITEM_VNUM, 1, 0, true)))
vec_item.push_back(item); vec_item.push_back(item);
@ -1488,7 +1488,7 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
} }
//육각보합 //육각보합
if (GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "2006_drop") >= number(1, iRandRange)) if (GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "2006_drop") >= Random::get(1, iRandRange))
{ {
sys_log(0, "육각보합 DROP EVENT "); sys_log(0, "육각보합 DROP EVENT ");
@ -1500,7 +1500,7 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
} }
//육각보합+ //육각보합+
if (GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "2007_drop") >= number(1, iRandRange)) if (GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "2007_drop") >= Random::get(1, iRandRange))
{ {
sys_log(0, "육각보합 DROP EVENT "); sys_log(0, "육각보합 DROP EVENT ");
@ -1511,7 +1511,7 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
} }
// 새해 폭죽 이벤트 // 새해 폭죽 이벤트
if (GetDropPerKillPct(/* minimum */ 100, /* default */ 1000, iDeltaPercent, "newyear_fire") >= number(1, iRandRange)) if (GetDropPerKillPct(/* minimum */ 100, /* default */ 1000, iDeltaPercent, "newyear_fire") >= Random::get(1, iRandRange))
{ {
// 중국은 폭죽, 한국 팽이 // 중국은 폭죽, 한국 팽이
const DWORD ITEM_VNUM_FIRE = g_iUseLocale ? 50107 : 50108; const DWORD ITEM_VNUM_FIRE = g_iUseLocale ? 50107 : 50108;
@ -1521,31 +1521,31 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
} }
// 새해 대보름 원소 이벤트 // 새해 대보름 원소 이벤트
if (GetDropPerKillPct(100, 500, iDeltaPercent, "newyear_moon") >= number(1, iRandRange)) if (GetDropPerKillPct(100, 500, iDeltaPercent, "newyear_moon") >= Random::get(1, iRandRange))
{ {
sys_log(0, "EVENT NEWYEAR_MOON DROP"); sys_log(0, "EVENT NEWYEAR_MOON DROP");
const static DWORD wonso_items[6] = { 50016, 50017, 50018, 50019, 50019, 50019, }; const static DWORD wonso_items[6] = { 50016, 50017, 50018, 50019, 50019, 50019, };
DWORD dwVnum = wonso_items[number(0,5)]; DWORD dwVnum = wonso_items[Random::get(0, 5)];
if ((item = CreateItem(dwVnum, 1, 0, true))) if ((item = CreateItem(dwVnum, 1, 0, true)))
vec_item.push_back(item); vec_item.push_back(item);
} }
// 발렌타인 데이 이벤트. OGE의 요구에 따라 event 최소값을 1로 변경.(다른 이벤트는 일단 그대로 둠.) // 발렌타인 데이 이벤트. OGE의 요구에 따라 event 최소값을 1로 변경.(다른 이벤트는 일단 그대로 둠.)
if (GetDropPerKillPct(1, g_iUseLocale ? 2000 : 800, iDeltaPercent, "valentine_drop") >= number(1, iRandRange)) if (GetDropPerKillPct(1, g_iUseLocale ? 2000 : 800, iDeltaPercent, "valentine_drop") >= Random::get(1, iRandRange))
{ {
sys_log(0, "EVENT VALENTINE_DROP"); sys_log(0, "EVENT VALENTINE_DROP");
const static DWORD valentine_items[2] = { 50024, 50025 }; const static DWORD valentine_items[2] = { 50024, 50025 };
DWORD dwVnum = valentine_items[number(0, 1)]; DWORD dwVnum = valentine_items[Random::get(0, 1)];
if ((item = CreateItem(dwVnum, 1, 0, true))) if ((item = CreateItem(dwVnum, 1, 0, true)))
vec_item.push_back(item); vec_item.push_back(item);
} }
// 아이스크림 이벤트 // 아이스크림 이벤트
if (GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "icecream_drop") >= number(1, iRandRange)) if (GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "icecream_drop") >= Random::get(1, iRandRange))
{ {
const static DWORD icecream = 50123; const static DWORD icecream = 50123;
@ -1555,26 +1555,26 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
// new 크리스마스 이벤트 // new 크리스마스 이벤트
// 53002 : 아기 순록 소환권 // 53002 : 아기 순록 소환권
if ((pkKiller->CountSpecifyItem(53002) > 0) && (GetDropPerKillPct(50, 100, iDeltaPercent, "new_xmas_event") >= number(1, iRandRange))) if ((pkKiller->CountSpecifyItem(53002) > 0) && (GetDropPerKillPct(50, 100, iDeltaPercent, "new_xmas_event") >= Random::get(1, iRandRange)))
{ {
const static DWORD xmas_sock = 50010; const static DWORD xmas_sock = 50010;
pkKiller->AutoGiveItem (xmas_sock, 1); pkKiller->AutoGiveItem (xmas_sock, 1);
} }
if ((pkKiller->CountSpecifyItem(53007) > 0) && (GetDropPerKillPct(50, 100, iDeltaPercent, "new_xmas_event") >= number(1, iRandRange))) if ((pkKiller->CountSpecifyItem(53007) > 0) && (GetDropPerKillPct(50, 100, iDeltaPercent, "new_xmas_event") >= Random::get(1, iRandRange)))
{ {
const static DWORD xmas_sock = 50010; const static DWORD xmas_sock = 50010;
pkKiller->AutoGiveItem (xmas_sock, 1); pkKiller->AutoGiveItem (xmas_sock, 1);
} }
//if (pkChr->GetLevel() >= 30 && (GetDropPerKillPct(50, 100, iDeltaPercent, "ds_drop") >= number(1, iRandRange))) //if (pkChr->GetLevel() >= 30 && (GetDropPerKillPct(50, 100, iDeltaPercent, "ds_drop") >= Random::get(1, iRandRange)))
//{ //{
// const static DWORD dragon_soul_gemstone = 30270; // const static DWORD dragon_soul_gemstone = 30270;
// if ((item = CreateItem(dragon_soul_gemstone, 1, 0, true))) // if ((item = CreateItem(dragon_soul_gemstone, 1, 0, true)))
// vec_item.push_back(item); // vec_item.push_back(item);
//} //}
if ( GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "halloween_drop") >= number(1, iRandRange) ) if ( GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "halloween_drop") >= Random::get(1, iRandRange) )
{ {
const static DWORD halloween_item = 30321; const static DWORD halloween_item = 30321;
@ -1582,7 +1582,7 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
vec_item.push_back(item); vec_item.push_back(item);
} }
if ( GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "ramadan_drop") >= number(1, iRandRange) ) if ( GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "ramadan_drop") >= Random::get(1, iRandRange) )
{ {
const static DWORD ramadan_item = 30315; const static DWORD ramadan_item = 30315;
@ -1590,16 +1590,16 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
vec_item.push_back(item); vec_item.push_back(item);
} }
if ( GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "easter_drop") >= number(1, iRandRange) ) if ( GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "easter_drop") >= Random::get(1, iRandRange) )
{ {
const static DWORD easter_item_base = 50160; const static DWORD easter_item_base = 50160;
if ( (item=CreateItem(easter_item_base+number(0,19), 1, 0, true)) ) if ( (item=CreateItem(easter_item_base + Random::get(0, 19), 1, 0, true)) )
vec_item.push_back(item); vec_item.push_back(item);
} }
// 월드컵 이벤트 // 월드컵 이벤트
if ( GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "football_drop") >= number(1, iRandRange) ) if ( GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "football_drop") >= Random::get(1, iRandRange) )
{ {
const static DWORD football_item = 50096; const static DWORD football_item = 50096;
@ -1608,11 +1608,11 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
} }
// 화이트 데이 이벤트 // 화이트 데이 이벤트
if (GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "whiteday_drop") >= number(1, iRandRange)) if (GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "whiteday_drop") >= Random::get(1, iRandRange))
{ {
sys_log(0, "EVENT WHITEDAY_DROP"); sys_log(0, "EVENT WHITEDAY_DROP");
const static DWORD whiteday_items[2] = { ITEM_WHITEDAY_ROSE, ITEM_WHITEDAY_CANDY }; const static DWORD whiteday_items[2] = { ITEM_WHITEDAY_ROSE, ITEM_WHITEDAY_CANDY };
DWORD dwVnum = whiteday_items[number(0,1)]; DWORD dwVnum = whiteday_items[Random::get(0, 1)];
if ((item = CreateItem(dwVnum, 1, 0, true))) if ((item = CreateItem(dwVnum, 1, 0, true)))
vec_item.push_back(item); vec_item.push_back(item);
@ -1621,7 +1621,7 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
// 어린이날 수수께끼 상자 이벤트 // 어린이날 수수께끼 상자 이벤트
if (pkKiller->GetLevel()>=50) if (pkKiller->GetLevel()>=50)
{ {
if (GetDropPerKillPct(100, 1000, iDeltaPercent, "kids_day_drop_high") >= number(1, iRandRange)) if (GetDropPerKillPct(100, 1000, iDeltaPercent, "kids_day_drop_high") >= Random::get(1, iRandRange))
{ {
DWORD ITEM_QUIZ_BOX = 50034; DWORD ITEM_QUIZ_BOX = 50034;
@ -1631,7 +1631,7 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
} }
else else
{ {
if (GetDropPerKillPct(100, 1000, iDeltaPercent, "kids_day_drop") >= number(1, iRandRange)) if (GetDropPerKillPct(100, 1000, iDeltaPercent, "kids_day_drop") >= Random::get(1, iRandRange))
{ {
DWORD ITEM_QUIZ_BOX = 50034; DWORD ITEM_QUIZ_BOX = 50034;
@ -1641,10 +1641,10 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
} }
// 올림픽 드롭 이벤트 // 올림픽 드롭 이벤트
if (pkChr->GetLevel() >= 30 && GetDropPerKillPct(50, 100, iDeltaPercent, "medal_part_drop") >= number(1, iRandRange)) if (pkChr->GetLevel() >= 30 && GetDropPerKillPct(50, 100, iDeltaPercent, "medal_part_drop") >= Random::get(1, iRandRange))
{ {
const static DWORD drop_items[] = { 30265, 30266, 30267, 30268, 30269 }; const static DWORD drop_items[] = { 30265, 30266, 30267, 30268, 30269 };
int i = number (0, 4); int i = Random::get(0, 4);
item = CreateItem(drop_items[i]); item = CreateItem(drop_items[i]);
if (item != NULL) if (item != NULL)
vec_item.push_back(item); vec_item.push_back(item);
@ -1652,7 +1652,7 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
// ADD_GRANDMASTER_SKILL // ADD_GRANDMASTER_SKILL
// 혼석 아이템 드롭 // 혼석 아이템 드롭
if (pkChr->GetLevel() >= 40 && pkChr->GetMobRank() >= MOB_RANK_BOSS && GetDropPerKillPct(/* minimum */ 1, /* default */ 1000, iDeltaPercent, "three_skill_item") / GetThreeSkillLevelAdjust(pkChr->GetLevel()) >= number(1, iRandRange)) if (pkChr->GetLevel() >= 40 && pkChr->GetMobRank() >= MOB_RANK_BOSS && GetDropPerKillPct(/* minimum */ 1, /* default */ 1000, iDeltaPercent, "three_skill_item") / GetThreeSkillLevelAdjust(pkChr->GetLevel()) >= Random::get(1, iRandRange))
{ {
const DWORD ITEM_VNUM = 50513; const DWORD ITEM_VNUM = 50513;
@ -1664,7 +1664,7 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
// //
// 종자 아이템 drop // 종자 아이템 drop
// //
if (GetDropPerKillPct(100, 1000, iDeltaPercent, "dragon_boat_festival_drop") >= number(1, iRandRange)) if (GetDropPerKillPct(100, 1000, iDeltaPercent, "dragon_boat_festival_drop") >= Random::get(1, iRandRange))
{ {
const DWORD ITEM_SEED = 50085; const DWORD ITEM_SEED = 50085;
@ -1687,7 +1687,7 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
}; };
if (iDropMultiply[pkChr->GetMobRank()] && if (iDropMultiply[pkChr->GetMobRank()] &&
GetDropPerKillPct(1000, 1500, iDeltaPercent, "mars_drop") >= number(1, iRandRange) * iDropMultiply[pkChr->GetMobRank()]) GetDropPerKillPct(1000, 1500, iDeltaPercent, "mars_drop") >= Random::get(1, iRandRange) * iDropMultiply[pkChr->GetMobRank()])
{ {
if ((item = CreateItem(ITEM_HANIRON, 1, 0, true))) if ((item = CreateItem(ITEM_HANIRON, 1, 0, true)))
vec_item.push_back(item); vec_item.push_back(item);

View File

@ -89,14 +89,14 @@ class CSpecialItemGroup
if (m_bType == PCT) if (m_bType == PCT)
{ {
int count = 0; int count = 0;
if (number(1,100) <= m_vecProbs[0]) if (Random::get(1,100) <= m_vecProbs[0])
{ {
idx_vec.push_back(0); idx_vec.push_back(0);
count++; count++;
} }
for (uint i = 1; i < m_vecProbs.size(); i++) for (uint i = 1; i < m_vecProbs.size(); i++)
{ {
if (number(1,100) <= m_vecProbs[i] - m_vecProbs[i-1]) if (Random::get(1,100) <= m_vecProbs[i] - m_vecProbs[i-1])
{ {
idx_vec.push_back(i); idx_vec.push_back(i);
count++; count++;
@ -113,7 +113,7 @@ class CSpecialItemGroup
int GetOneIndex() const int GetOneIndex() const
{ {
int n = number(1, m_vecProbs.back()); int n = Random::get(1, m_vecProbs.back());
itertype(m_vecProbs) it = lower_bound(m_vecProbs.begin(), m_vecProbs.end(), n); itertype(m_vecProbs) it = lower_bound(m_vecProbs.begin(), m_vecProbs.end(), n);
return std::distance(m_vecProbs.begin(), it); return std::distance(m_vecProbs.begin(), it);
} }
@ -211,7 +211,7 @@ class CMobItemGroup
int GetOneIndex() const int GetOneIndex() const
{ {
int n = number(1, m_vecProbs.back()); int n = Random::get(1, m_vecProbs.back());
itertype(m_vecProbs) it = lower_bound(m_vecProbs.begin(), m_vecProbs.end(), n); itertype(m_vecProbs) it = lower_bound(m_vecProbs.begin(), m_vecProbs.end(), n);
return std::distance(m_vecProbs.begin(), it); return std::distance(m_vecProbs.begin(), it);
} }

View File

@ -8,7 +8,6 @@
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#define thecore_random random
#define sys_err printf #define sys_err printf
#define sys_log printf #define sys_log printf
@ -78,8 +77,8 @@ void MatrixCardRndCoordinate(unsigned int & rows, unsigned int & cols)
{ {
for (register unsigned int i = 0; i < (ASLENGTH >> 1); i++) for (register unsigned int i = 0; i < (ASLENGTH >> 1); i++)
{ {
rows |= ((thecore_random() % MAX_ROWS) & 0x000000FF) << ((4 - i - 1) * 8); rows |= ((Random::get(0, MAX_ROWS - 1)) & 0x000000FF) << ((4 - i - 1) * 8);
cols |= ((thecore_random() % MAX_COLS) & 0x000000FF) << ((4 - i - 1) * 8); cols |= ((Random::get(0, MAX_COLS - 1)) & 0x000000FF) << ((4 - i - 1) * 8);
} }
} }

View File

@ -103,12 +103,12 @@ namespace mining
int GetFractionCount() int GetFractionCount()
{ {
int r = number(1, 100); int r = Random::get(1, 100);
for (int i = 0; i < MAX_FRACTION_COUNT; ++i) for (int i = 0; i < MAX_FRACTION_COUNT; ++i)
{ {
if (r <= fraction_info[i][0]) if (r <= fraction_info[i][0])
return number(fraction_info[i][1], fraction_info[i][2]); return Random::get(fraction_info[i][1], fraction_info[i][2]);
else else
r -= fraction_info[i][0]; r -= fraction_info[i][0];
} }
@ -137,8 +137,8 @@ namespace mining
} }
PIXEL_POSITION pos; PIXEL_POSITION pos;
pos.x = ch->GetX() + number(-200, 200); pos.x = ch->GetX() + Random::get(-200, 200);
pos.y = ch->GetY() + number(-200, 200); pos.y = ch->GetY() + Random::get(-200, 200);
item->AddToGround(ch->GetMapIndex(), pos); item->AddToGround(ch->GetMapIndex(), pos);
item->StartDestroyEvent(); item->StartDestroyEvent();
@ -213,12 +213,12 @@ namespace mining
bool Pick_IsPracticeSuccess(CItem& pick) bool Pick_IsPracticeSuccess(CItem& pick)
{ {
return (number(1,pick.GetValue(1))==1); return (Random::get(1,pick.GetValue(1))==1);
} }
bool Pick_IsRefineSuccess(CItem& pick) bool Pick_IsRefineSuccess(CItem& pick)
{ {
return (number(1,100) <= pick.GetValue(3)); return (Random::get(1,100) <= pick.GetValue(3));
} }
int RealRefinePick(LPCHARACTER ch, LPITEM item) int RealRefinePick(LPCHARACTER ch, LPITEM item)
@ -368,7 +368,7 @@ namespace mining
int iPct = GetOrePct(ch); int iPct = GetOrePct(ch);
if (number(1, 100) <= iPct) if (Random::get(1, 100) <= iPct)
{ {
OreDrop(ch, load->GetRaceNum()); OreDrop(ch, load->GetRaceNum());
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("䱤¿¡ ¼º°øÇÏ¿´½À´Ï´Ù.")); ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("䱤¿¡ ¼º°øÇÏ¿´½À´Ï´Ù."));
@ -426,7 +426,7 @@ namespace mining
if (metinstone_item) if (metinstone_item)
ITEM_MANAGER::instance().RemoveItem(metinstone_item, "REMOVE (MELT)"); ITEM_MANAGER::instance().RemoveItem(metinstone_item, "REMOVE (MELT)");
if (number(1, 100) <= pct) if (Random::get(1, 100) <= pct)
{ {
ch->AutoGiveItem(dwRefinedVnum, 1); ch->AutoGiveItem(dwRefinedVnum, 1);
return true; return true;

View File

@ -74,7 +74,7 @@ class CMobGroupGroup
return 0; return 0;
// ADD_MOB_GROUP_GROUP_PROB // ADD_MOB_GROUP_GROUP_PROB
int n = number(1, m_vec_iProbs.back()); int n = Random::get(1, m_vec_iProbs.back());
itertype(m_vec_iProbs) it = lower_bound(m_vec_iProbs.begin(), m_vec_iProbs.end(), n); itertype(m_vec_iProbs) it = lower_bound(m_vec_iProbs.begin(), m_vec_iProbs.end(), n);
return m_vec_dwMemberVnum[std::distance(m_vec_iProbs.begin(), it)]; return m_vec_dwMemberVnum[std::distance(m_vec_iProbs.begin(), it)];

View File

@ -883,8 +883,8 @@ void CParty::SendMessage(LPCHARACTER ch, BYTE bMsg, DWORD dwArg1, DWORD dwArg2)
if ((pkChr = rMember.pCharacter) && ch != pkChr) if ((pkChr = rMember.pCharacter) && ch != pkChr)
{ {
DWORD x = dwArg1 + number(-500, 500); DWORD x = dwArg1 + Random::get(-500, 500);
DWORD y = dwArg2 + number(-500, 500); DWORD y = dwArg2 + Random::get(-500, 500);
pkChr->SetVictim(NULL); pkChr->SetVictim(NULL);
pkChr->SetRotationToXY(x, y); pkChr->SetRotationToXY(x, y);
@ -1157,7 +1157,7 @@ void CParty::SummonToLeader(DWORD pid)
l->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<파티> 파티원을 현재 위치로 소환할 수 없습니다.")); l->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<파티> 파티원을 현재 위치로 소환할 수 없습니다."));
else else
{ {
int i = number(0, n - 1); int i = Random::get(0, n - 1);
ch->Show(l->GetMapIndex(), x[i], y[i]); ch->Show(l->GetMapIndex(), x[i], y[i]);
ch->Stop(); ch->Stop();
} }

View File

@ -74,7 +74,7 @@ bool CPolymorphUtils::PolymorphCharacter(LPCHARACTER pChar, LPITEM pItem, const
} }
else else
{ {
if (number(1, 100) > iPolyPercent) if (Random::get(1, 100) > iPolyPercent)
{ {
pChar->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("둔갑에 실패 하였습니다")); pChar->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("둔갑에 실패 하였습니다"));
return false; return false;

View File

@ -298,8 +298,8 @@ namespace quest
{ {
for (int loop = 0; loop < 8; ++loop) for (int loop = 0; loop < 8; ++loop)
{ {
float angle = number(0, 999) * M_PI * 2 / 1000; float angle = Random::get(0, 999) * M_PI * 2 / 1000;
float r = number(0, 999) * radius / 1000; float r = Random::get(0, 999) * radius / 1000;
int x = local_x + pMap->m_setting.iBaseX + (int)(r * cos(angle)); int x = local_x + pMap->m_setting.iBaseX + (int)(r * cos(angle));
int y = local_y + pMap->m_setting.iBaseY + (int)(r * sin(angle)); int y = local_y + pMap->m_setting.iBaseY + (int)(r * sin(angle));
@ -370,8 +370,8 @@ namespace quest
{ {
for (int loop = 0; loop < 8; ++loop) for (int loop = 0; loop < 8; ++loop)
{ {
float angle = number(0, 999) * M_PI * 2 / 1000; float angle = Random::get(0, 999) * M_PI * 2 / 1000;
float r = number(0, 999)*radius/1000; float r = Random::get(0, 999)*radius/1000;
int x = local_x + pMap->m_setting.iBaseX + (int)(r * cos(angle)); int x = local_x + pMap->m_setting.iBaseX + (int)(r * cos(angle));
int y = local_y + pMap->m_setting.iBaseY + (int)(r * sin(angle)); int y = local_y + pMap->m_setting.iBaseY + (int)(r * sin(angle));

View File

@ -834,8 +834,8 @@ namespace quest
} }
else else
{ {
float angle = number(0, 999) * M_PI * 2 / 1000; float angle = Random::get(0, 999) * M_PI * 2 / 1000;
float r = number(0, 999) * radius / 1000; float r = Random::get(0, 999) * radius / 1000;
int nx = x + (int)(r * cos(angle)); int nx = x + (int)(r * cos(angle));
int ny = y + (int)(r * sin(angle)); int ny = y + (int)(r * sin(angle));

View File

@ -153,7 +153,7 @@ namespace quest
LPCHARACTER ch = (LPCHARACTER) ent; LPCHARACTER ch = (LPCHARACTER) ent;
if (ch->IsPC()) if (ch->IsPC())
{ {
ch->WarpSet( m_x+(number(0,5)*100), m_y+(number(0,5)*100), m_iMapIndexTo); ch->WarpSet( m_x+(Random::get(0,5)*100), m_y+(Random::get(0,5)*100), m_iMapIndexTo);
} }
} }
} }

View File

@ -113,8 +113,8 @@ namespace quest
} }
PIXEL_POSITION pos; PIXEL_POSITION pos;
pos.x = x + number(-200, 200); pos.x = x + Random::get(-200, 200);
pos.y = y + number(-200, 200); pos.y = y + Random::get(-200, 200);
item->AddToGround(ch->GetMapIndex(), pos); item->AddToGround(ch->GetMapIndex(), pos);
item->StartDestroyEvent(); item->StartDestroyEvent();
@ -161,8 +161,8 @@ namespace quest
item->SetOwnership( ch ); item->SetOwnership( ch );
PIXEL_POSITION pos; PIXEL_POSITION pos;
pos.x = ch->GetX() + number(-200, 200); pos.x = ch->GetX() + Random::get(-200, 200);
pos.y = ch->GetY() + number(-200, 200); pos.y = ch->GetY() + Random::get(-200, 200);
item->AddToGround(ch->GetMapIndex(), pos); item->AddToGround(ch->GetMapIndex(), pos);
item->StartDestroyEvent(); item->StartDestroyEvent();

View File

@ -47,7 +47,7 @@ namespace quest
if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2)) if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2))
lua_pushnumber(L, 0); lua_pushnumber(L, 0);
else else
lua_pushnumber(L, number((int)lua_tonumber(L, 1), (int)lua_tonumber(L, 2))); lua_pushnumber(L, Random::get((int)lua_tonumber(L, 1), (int)lua_tonumber(L, 2)));
return 1; return 1;
} }
@ -1147,10 +1147,10 @@ namespace quest
{ {
const LPCHARACTER pSpawnMonster = CHARACTER_MANAGER::instance().SpawnMobRange( dwVnum, const LPCHARACTER pSpawnMonster = CHARACTER_MANAGER::instance().SpawnMobRange( dwVnum,
pChar->GetMapIndex(), pChar->GetMapIndex(),
pChar->GetX() - number(200, 750), pChar->GetX() - Random::get(200, 750),
pChar->GetY() - number(200, 750), pChar->GetY() - Random::get(200, 750),
pChar->GetX() + number(200, 750), pChar->GetX() + Random::get(200, 750),
pChar->GetY() + number(200, 750), pChar->GetY() + Random::get(200, 750),
true, true,
pMonster->m_table.bType == CHAR_TYPE_STONE, pMonster->m_table.bType == CHAR_TYPE_STONE,
isAggresive ); isAggresive );
@ -1269,7 +1269,7 @@ namespace quest
{ {
++warpCount; ++warpCount;
pChar->WarpSet( number(to_x1, to_x2), number(to_y1, to_y2) ); pChar->WarpSet( Random::get(to_x1, to_x2), Random::get(to_y1, to_y2) );
} }
} }
} }

View File

@ -870,8 +870,8 @@ namespace quest
//레벨 //레벨
ch->PointChange(POINT_LEVEL, newLevel - ch->GetLevel()); ch->PointChange(POINT_LEVEL, newLevel - ch->GetLevel());
//HP, SP //HP, SP
ch->SetRandomHP((newLevel - 1) * number(JobInitialPoints[ch->GetJob()].hp_per_lv_begin, JobInitialPoints[ch->GetJob()].hp_per_lv_end)); ch->SetRandomHP((newLevel - 1) * Random::get(JobInitialPoints[ch->GetJob()].hp_per_lv_begin, JobInitialPoints[ch->GetJob()].hp_per_lv_end));
ch->SetRandomSP((newLevel - 1) * number(JobInitialPoints[ch->GetJob()].sp_per_lv_begin, JobInitialPoints[ch->GetJob()].sp_per_lv_end)); ch->SetRandomSP((newLevel - 1) * Random::get(JobInitialPoints[ch->GetJob()].sp_per_lv_begin, JobInitialPoints[ch->GetJob()].sp_per_lv_end));
// 회복 // 회복
@ -1530,7 +1530,7 @@ namespace quest
return 1; return 1;
} }
if (pct == 100 || number(1, 100) <= pct) if (pct == 100 || Random::get(1, 100) <= pct)
{ {
// 개량 성공 // 개량 성공
lua_pushboolean(L, 1); lua_pushboolean(L, 1);
@ -2183,12 +2183,12 @@ teleport_area:
if ( point == POINT_HT ) if ( point == POINT_HT )
{ {
BYTE job = ch->GetJob(); BYTE job = ch->GetJob();
ch->SetRandomHP((ch->GetLevel()-1) * number(JobInitialPoints[job].hp_per_lv_begin, JobInitialPoints[job].hp_per_lv_end)); ch->SetRandomHP((ch->GetLevel()-1) * Random::get(JobInitialPoints[job].hp_per_lv_begin, JobInitialPoints[job].hp_per_lv_end));
} }
else if ( point == POINT_IQ ) else if ( point == POINT_IQ )
{ {
BYTE job = ch->GetJob(); BYTE job = ch->GetJob();
ch->SetRandomSP((ch->GetLevel()-1) * number(JobInitialPoints[job].sp_per_lv_begin, JobInitialPoints[job].sp_per_lv_end)); ch->SetRandomSP((ch->GetLevel()-1) * Random::get(JobInitialPoints[job].sp_per_lv_begin, JobInitialPoints[job].sp_per_lv_end));
} }
ch->ComputePoints(); ch->ComputePoints();

View File

@ -285,7 +285,7 @@ static void regen_spawn_dungeon(LPREGEN regen, LPDUNGEON pDungeon, bool bOnce)
regen->sy, regen->sy,
regen->z_section, regen->z_section,
false, false,
regen->direction == 0 ? number(0, 7) * 45 : (regen->direction - 1) * 45); regen->direction == 0 ? Random::get(0, 7) * 45 : (regen->direction - 1) * 45);
if (ch) if (ch)
{ {
@ -351,7 +351,7 @@ static void regen_spawn(LPREGEN regen, bool bOnce)
regen->sy, regen->sy,
regen->z_section, regen->z_section,
false, false,
regen->direction == 0 ? number(0, 7) * 45 : (regen->direction - 1) * 45); regen->direction == 0 ? Random::get(0, 7) * 45 : (regen->direction - 1) * 45);
if (ch) if (ch)
++regen->count; ++regen->count;
@ -493,7 +493,7 @@ bool regen_do(const char* filename, int lMapIndex, int base_x, int base_y, LPDUN
info->regen = regen; info->regen = regen;
info->dungeon_id = pDungeon->GetId(); info->dungeon_id = pDungeon->GetId();
regen->event = event_create(dungeon_regen_event, info, PASSES_PER_SEC(number(0, 16)) + PASSES_PER_SEC(regen->time)); regen->event = event_create(dungeon_regen_event, info, PASSES_PER_SEC(Random::get(0, 16)) + PASSES_PER_SEC(regen->time));
pDungeon->AddRegen(regen); pDungeon->AddRegen(regen);
// regen_id should be determined at this point, // regen_id should be determined at this point,
@ -694,7 +694,7 @@ bool regen_load(const char* filename, int lMapIndex, int base_x, int base_y)
info->regen = regen; info->regen = regen;
regen->event = event_create(regen_event, info, PASSES_PER_SEC(number(0, 16)) + PASSES_PER_SEC(regen->time)); regen->event = event_create(regen_event, info, PASSES_PER_SEC(Random::get(0, 16)) + PASSES_PER_SEC(regen->time));
} }
//END_NO_REGEN //END_NO_REGEN
} }

View File

@ -926,8 +926,8 @@ bool SECTREE_MANAGER::GetRandomLocation(int lMapIndex, PIXEL_POSITION & r_pos, D
while (i++ < 100) while (i++ < 100)
{ {
x = number(rRegion.sx + 50, rRegion.ex - 50); x = Random::get(rRegion.sx + 50, rRegion.ex - 50);
y = number(rRegion.sy + 50, rRegion.ey - 50); y = Random::get(rRegion.sy + 50, rRegion.ey - 50);
if (iMaxDistance != 0) if (iMaxDistance != 0)
{ {

View File

@ -236,8 +236,8 @@ bool CThreeWayWar::IsSungZiMapIndex(int iMapIndex) const
void CThreeWayWar::RandomEventMapSet() void CThreeWayWar::RandomEventMapSet()
{ {
const size_t pass_idx = number( 0, PassInfoMap_.size()-1 ); const size_t pass_idx = Random::get<int>(0, PassInfoMap_.size() - 1);
const size_t sung_idx = number( 0, SungZiInfoMap_.size()-1 ); const size_t sung_idx = Random::get<int>(0, SungZiInfoMap_.size() - 1);
quest::CQuestManager::instance().RequestSetEventFlag( "threeway_war_sungzi_idx", sung_idx ); quest::CQuestManager::instance().RequestSetEventFlag( "threeway_war_sungzi_idx", sung_idx );
quest::CQuestManager::instance().RequestSetEventFlag( "threeway_war_pass_idx", pass_idx ); quest::CQuestManager::instance().RequestSetEventFlag( "threeway_war_pass_idx", pass_idx );
@ -541,8 +541,8 @@ void CThreeWayWar::onDead(LPCHARACTER pChar, LPCHARACTER pkKiller)
int x = pChar->GetX(); int x = pChar->GetX();
int y = pChar->GetY(); int y = pChar->GetY();
x = (thecore_random() & 1) ? x - number(200, 1000) : x + number(200, 1000); x = (Random::get<bool>()) ? x - Random::get(200, 1000) : x + Random::get(200, 1000);
y = (thecore_random() & 1) ? y - number(200, 1000) : y + number(200, 1000); y = (Random::get<bool>()) ? y - Random::get(200, 1000) : y + Random::get(200, 1000);
if (x < 0) if (x < 0)
x = pChar->GetX(); x = pChar->GetX();

View File

@ -17,23 +17,6 @@ void set_global_time(time_t t)
sys_log(0, "GLOBAL_TIME: %s time_gap %d", time_str_buf, global_time_gap); sys_log(0, "GLOBAL_TIME: %s time_gap %d", time_str_buf, global_time_gap);
} }
int dice(int number, int size)
{
int sum = 0, val;
if (size <= 0 || number <= 0)
return (0);
while (number)
{
val = ((thecore_random() % size) + 1);
sum += val;
--number;
}
return (sum);
}
size_t str_lower(const char * src, char * dest, size_t dest_size) size_t str_lower(const char * src, char * dest, size_t dest_size)
{ {
size_t len = 0; size_t len = 0;
@ -146,37 +129,6 @@ int CalculateDuration(int iSpd, int iDur)
return iDur * i / 100; return iDur * i / 100;
} }
double uniform_random(double a, double b)
{
return thecore_random() / (RAND_MAX + 1.f) * (b - a) + a;
}
float gauss_random(float avg, float sigma)
{
static bool haveNextGaussian = false;
static float nextGaussian = 0.0f;
if (haveNextGaussian)
{
haveNextGaussian = false;
return nextGaussian * sigma + avg;
}
else
{
double v1, v2, s;
do {
//v1 = 2 * nextDouble() - 1; // between -1.0 and 1.0
//v2 = 2 * nextDouble() - 1; // between -1.0 and 1.0
v1 = uniform_random(-1.f, 1.f);
v2 = uniform_random(-1.f, 1.f);
s = v1 * v1 + v2 * v2;
} while (s >= 1.f || fabs(s) < FLT_EPSILON);
double multiplier = sqrtf(-2 * logf(s)/s);
nextGaussian = v2 * multiplier;
haveNextGaussian = true;
return v1 * multiplier * sigma + avg;
}
}
int parse_time_str(const char* str) int parse_time_str(const char* str)
{ {

View File

@ -50,7 +50,6 @@ inline WORD MAKEWORD(BYTE a, BYTE b)
extern void set_global_time(time_t t); extern void set_global_time(time_t t);
extern time_t get_global_time(); extern time_t get_global_time();
extern int dice(int number, int size);
extern size_t str_lower(const char * src, char * dest, size_t dest_size); extern size_t str_lower(const char * src, char * dest, size_t dest_size);
extern void skip_spaces(char **string); extern void skip_spaces(char **string);
@ -61,8 +60,6 @@ extern const char * first_cmd(const char *argument, char *first_arg, size_t firs
extern int CalculateDuration(int iSpd, int iDur); extern int CalculateDuration(int iSpd, int iDur);
extern float gauss_random(float avg = 0, float sigma = 1);
extern int parse_time_str(const char* str); extern int parse_time_str(const char* str);
extern bool WildCaseCmp(const char *w, const char *s); extern bool WildCaseCmp(const char *w, const char *s);

View File

@ -1,6 +1,9 @@
#ifndef __INC_LIBTHECORE_UTILS_H__ #ifndef __INC_LIBTHECORE_UTILS_H__
#define __INC_LIBTHECORE_UTILS_H__ #define __INC_LIBTHECORE_UTILS_H__
// Random number generator
#include "effolkronium/random.hpp"
using Random = effolkronium::random_static;
#define SAFE_FREE(p) { if (p) { free( (void *) p); (p) = NULL; } } #define SAFE_FREE(p) { if (p) { free( (void *) p); (p) = NULL; } }
#define SAFE_DELETE(p) { if (p) { delete (p); (p) = NULL; } } #define SAFE_DELETE(p) { if (p) { delete (p); (p) = NULL; } }
@ -45,13 +48,7 @@
extern int MIN(int a, int b); // 둘중에 작은 값을 리턴 extern int MIN(int a, int b); // 둘중에 작은 값을 리턴
extern int MINMAX(int min, int value, int max); // 최소 최대 값을 함께 비교해서 리턴 extern int MINMAX(int min, int value, int max); // 최소 최대 값을 함께 비교해서 리턴
extern int number_ex(int from, int to, const char *file, int line); // from으로 부터 to까지의 랜덤 값 리턴
#define number(from, to) number_ex(from, to, __FILE__, __LINE__)
float fnumber(float from, float to);
extern void thecore_sleep(struct timeval * timeout); // timeout만큼 프로세스 쉬기 extern void thecore_sleep(struct timeval * timeout); // timeout만큼 프로세스 쉬기
extern DWORD thecore_random(); // 랜덤 함수
extern float get_float_time(); extern float get_float_time();
extern DWORD get_dword_time(); extern DWORD get_dword_time();

View File

@ -345,42 +345,6 @@ int MINMAX(int min, int value, int max)
return (max < tv) ? max : tv; return (max < tv) ? max : tv;
} }
DWORD thecore_random()
{
#ifdef __WIN32__
return rand();
#else
return random();
#endif
}
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;
if ((to - from + 1) != 0)
returnValue = ((thecore_random() % (to - from + 1)) + from);
else
sys_err("number(): devided by 0");
return returnValue;
}
float fnumber(float from, float to)
{
return (((float)thecore_random() / (float)RAND_MAX) * (to - from)) + from;
}
#ifndef __WIN32__ #ifndef __WIN32__
void thecore_sleep(struct timeval* timeout) void thecore_sleep(struct timeval* timeout)
{ {