void CMuRummyMng::CardShuffle(CMuRummyCardInfo* pCCardInfo) { CMuRummyCardInfo CardInfoTmp; for (int nCnt = 0; nCnt < MURUMMY_MAX_CARD; nCnt++) { DWORD iIndex = nCnt + GetLargeRand() % (MURUMMY_MAX_CARD - nCnt); if (iIndex > MURUMMY_MAX_CARD - 1) { return; } CardInfoTmp.SetColor(pCCardInfo[nCnt].GetColor()); CardInfoTmp.SetNumber(pCCardInfo[nCnt].GetNumber()); CardInfoTmp.SetState(pCCardInfo[nCnt].GetState()); CardInfoTmp.SetSlotNum(pCCardInfo[nCnt].GetSlotNum()); pCCardInfo[nCnt].SetColor(pCCardInfo[iIndex].GetColor()); pCCardInfo[nCnt].SetNumber(pCCardInfo[iIndex].GetNumber()); pCCardInfo[nCnt].SetState(pCCardInfo[iIndex].GetState()); pCCardInfo[nCnt].SetSlotNum(pCCardInfo[iIndex].GetSlotNum()); pCCardInfo[iIndex].SetColor(CardInfoTmp.GetColor()); pCCardInfo[iIndex].SetNumber(CardInfoTmp.GetNumber()); pCCardInfo[iIndex].SetState(CardInfoTmp.GetState()); pCCardInfo[iIndex].SetSlotNum(CardInfoTmp.GetSlotNum()); } }
int TRandomPoolMgr::GetRandomValue(enum eRandomPoolSelectType eSelectType) { int iReturnValue = 0; int iPoolSize = this->m_listPool.size(); if ( iPoolSize == 0 ) return iReturnValue; if ( this->m_iSumWeight <= 0 ) eSelectType = eRANDOMPOOL_BY_RANDOM; if ( eSelectType == eRANDOMPOOL_BY_RANDOM ) { int iPos = GetLargeRand()% (DWORD)iPoolSize; int iCount = 0; for ( std::map<int, int>::iterator iter = this->m_listPool.begin() ; iter != this->m_listPool.end() ; ++iter) { if ( iPos == iCount ) { iReturnValue = iter->first; break; } } } else if ( eSelectType == eRANDOMPOOL_BY_WEIGHT ) { int iRandom = GetLargeRand() % (DWORD)this->m_iSumWeight; int iCurRate = 0; for (std::map<int, int>::iterator iter = this->m_listPool.begin() ; iter != this->m_listPool.end() ; ++iter) { int iRate = iter->second; iCurRate += iRate; if ( iCurRate >= iRandom ) { iReturnValue = iter->first; break; } } } return iReturnValue; }
//005b5d70 -> 100% (Identical) int CSetItemOption::LuckyItemGenSetOption(int itemnum, int * piAddSetOptRate) { if( itemnum < 0 || itemnum > MAX_ITEMS - 1 ) { LogAdd("GenSetType Check error: (itemnum:%d)", itemnum); return false; } // ---- if( !this->m_SetItemTypeInfo[itemnum].IsLoad ) { return false; } // ---- int SetOption; // ---- if( this->m_SetItemTypeInfo[itemnum].OptionIndex[0] && this->m_SetItemTypeInfo[itemnum].OptionIndex[1] ) { SetOption = rand() % 2 + 1; } else if( this->m_SetItemTypeInfo[itemnum].OptionIndex[0] ) { SetOption = 1; } else { SetOption = 2; } // ---- DWORD dwRand = GetLargeRand() % 1000000; // ---- if( dwRand <= piAddSetOptRate[0] ) { SetOption |= 4; //return SetOption; } else if( dwRand <= piAddSetOptRate[0] + piAddSetOptRate[1] ) { SetOption |= 8; //return SetOption; } // ---- return SetOption; }
BYTE CGambleSystem::SortExcOption() //0049D020 (Identical) { BYTE btExOption = 0; int iItemIndex = 0; int count = 0; while(true) { if (this->m_iGeneralExcRate[iItemIndex] >= GetLargeRand() % 1000000) { btExOption |= 1 << iItemIndex; count++; } iItemIndex++; if(count == 0) { if(iItemIndex >= GAMBLE_MAX_SECRET_ITEM_TYPE) { iItemIndex = 0; } } else if(count == 1) { if(iItemIndex >= GAMBLE_MAX_SECRET_ITEM_TYPE) { break; } } else if(count >= 2) { break; } } return btExOption; }
BYTE CGambleSystem::SortExcNumberPerKind(int n) //0049CF30 (Identical) { BYTE btExOption = 0; int iFullOptRate = 0; int iItemIndex = 0; while(true) { if (this->m_iExcRatePerItemKind[iItemIndex] >= GetLargeRand() % 1000000) { btExOption |= 1 << iItemIndex; } else { iFullOptRate++; } if(iFullOptRate >= 6-n) { while(true) { iItemIndex++; if(iItemIndex >= GAMBLE_MAX_SECRET_ITEM_TYPE) { break; } btExOption |= 1 << iItemIndex; } break; } iItemIndex++; } return btExOption; }
BYTE CGambleSystem::TryGamble(int aIndex, BYTE MapNumber, int cX, int cY, BYTE btRareItemNum) //0049C6D0 (Identical) { if (this->bLoad == FALSE) { return 0; } float Dur = 0; int ItemType = 0; int Level = 0; int MapPosX = 0; int MapPosY = 0; int Op1 = 0; int Op2 = 0; int Op3 = 0; DWORD n = 0; //loc10 int loc_11 = 0; int NewOp = 0; LPOBJ lpObj = &gObj[aIndex]; //loc_13 if(this->GetBagItemCount() > 0) { if (this->m_dwSpecialItemRate[btRareItemNum] >= GetLargeRand() % 1000000) { Level = 0; Dur = 0; Op1 = 1; Op2 = 0; DWORD dwOptionRate = GetLargeRand() % 1000000; if ( dwOptionRate <= this->m_iBagItemOptionRate[0]) { Op3 = 1; } else if ( dwOptionRate <= this->m_iBagItemOptionRate[0] + this->m_iBagItemOptionRate[1]) { Op3 = 2; } else if ( dwOptionRate <= this->m_iBagItemOptionRate[0] + this->m_iBagItemOptionRate[1] + this->m_iBagItemOptionRate[2]) { Op3 = 3; } else if ( dwOptionRate <= this->m_iBagItemOptionRate[0] + this->m_iBagItemOptionRate[1] + this->m_iBagItemOptionRate[2] + this->m_iBagItemOptionRate[3]) { Op3 = 4; } DWORD dwNewOptionRate = GetLargeRand() % 1000000; if ( dwNewOptionRate <= this->m_iBagItemExcRate[0]) { NewOp = this->SortExcNumberPerKind(1); } else if ( dwNewOptionRate <= this->m_iBagItemExcRate[0] + this->m_iBagItemExcRate[1]) { NewOp = this->SortExcNumberPerKind(2); } else if ( dwNewOptionRate <= this->m_iBagItemExcRate[0] + this->m_iBagItemExcRate[1] + this->m_iBagItemExcRate[2]) { NewOp = this->SortExcNumberPerKind(3); } else if ( dwNewOptionRate <= this->m_iBagItemExcRate[0] + this->m_iBagItemExcRate[1] + this->m_iBagItemExcRate[2] + this->m_iBagItemExcRate[3]) { NewOp = this->SortExcNumberPerKind(4); } switch ( btRareItemNum ) //5 Types of Special Item { case 0: ItemType = ItemGetNumberMake(3, 11); break; case 1: ItemType = ItemGetNumberMake(5, 33); break; case 2: ItemType = ItemGetNumberMake(4, 24); break; case 3: ItemType = ItemGetNumberMake(2, 18); break; case 4: ItemType = ItemGetNumberMake(5, 34); break; } } else //else for common items like a bag { int iBagNumberCount = 0; int iRandA = 0; int iRandB = 0; int iBagNumber = 0; switch( btRareItemNum ) { case 0: iBagNumber = 0; break; case 1: iBagNumber = 5; break; case 2: iBagNumber = 10; break; case 3: iBagNumber = 15; break; case 4: iBagNumber = 20; break; } DWORD dwSortItemRand = GetLargeRand() % 1000000; int iSortItemRate = 0; for ( int i = iBagNumber; i < iBagNumber + GAMBLE_MAX_NORMAL_ITEM; i++) { iSortItemRate += this->m_GamblingInfo[i].m_iSortItemRate; if(dwSortItemRand <= iSortItemRate) { iBagNumber = i; break; } } while(true) //Max 25 { iRandB += this->m_iDropRatePerItemCount[iBagNumberCount]; if (iBagNumber <= iBagNumberCount) { break; } iRandA += this->m_iDropRatePerItemCount[iBagNumberCount]; iBagNumberCount++; } while(true) //temp fix { if( iRandB > iRandA ) { break; } // --- iRandB++; } n = (GetLargeRand() % (iRandB - iRandA)) + iRandA; Dur = 0; MapPosX = 0; MapPosY = 0; Level = this->GetLevel(n); ItemType = ItemGetNumberMake(this->BagObject[n].m_type,this->BagObject[n].m_index); if (ItemType == -1) { return 0; } if( this->BagObject[n].m_isskill != 0) { if (this->m_GamblingInfo[iBagNumber].m_iSkillRate >= GetLargeRand()%1000000) { Op1 = 1; } } if(this->BagObject[n].m_isluck != 0) { if (this->m_GamblingInfo[iBagNumber].m_iLuckRate >= GetLargeRand()%1000000) { Op2 = 1; } } if(this->BagObject[n].m_isoption != 0) { if (this->m_GamblingInfo[iBagNumber].m_iOptionRate >= GetLargeRand()%1000000) { int iOpt3Rand = GetLargeRand() % 1000000; if ( iOpt3Rand <= this->m_iBagItemOptionRate[0]) { Op3 = 1; } else if ( iOpt3Rand <= this->m_iBagItemOptionRate[0] + this->m_iBagItemOptionRate[1]) { Op3 = 2; } else if ( iOpt3Rand <= this->m_iBagItemOptionRate[0] + this->m_iBagItemOptionRate[1] + this->m_iBagItemOptionRate[2]) { Op3 = 3; } else if ( iOpt3Rand <= this->m_iBagItemOptionRate[0] + this->m_iBagItemOptionRate[1] + this->m_iBagItemOptionRate[2] + this->m_iBagItemOptionRate[3]) { Op3 = 4; } } } if(this->BagObject[n].m_isexitem != 0) { if (this->m_GamblingInfo[iBagNumber].m_iExcRate >= GetLargeRand()%1000000) { NewOp = this->SortExcOption(); Op2 = 0; Op1 = 1; Level = 0; } } } ItemSerialCreateSend(lpObj->m_Index,MapNumber,MapPosX,MapPosY,ItemType,Level,Dur,Op1,Op2,Op3,lpObj->m_Index,NewOp,0); LogAddTD("[ GAMBLING ][ TryGambling ] %s(%s) Try Item : [%s]%d Level:%d op1:%d op2:%d op3:%d ExOp:%d",lpObj->AccountID,lpObj->Name,ItemAttribute[ItemType].Name,ItemType,Level,Op1,Op2, Op3,NewOp); } return 1; }
int CCashLotterySystem::GetItem(CItem *lpItem) { int iItemCategory = 0; int iMaxItemCountInCategory = 0; int iItemSelectNumber = 0; CItem ReturnItem; int iItemNumber = 0; int iItemType = 0; int iItemIndex = 0; int iItemLevel = 0; int iItemLevelMin = 0; int iItemLevelMax = 0; int iSkillOption = 0; int iLuckOption = 0; int iAddOption = 0; int iExOption = 0; int iSkillOptionRate = 0; int iLuckOptionRate = 0; int iAddOptionRate = 0; int iExOptionRate = 0; BYTE btSkillOption = 0; BYTE btLuckOption = 0; BYTE btAddOption = 0; BYTE btExOption = 0; BYTE btExOptionKey = 0; BYTE btExOptionValue1 = 0; BYTE btExOptionValue2 = 0; int iTemp = 0; int iRandomKey = 0; BYTE ExOption[MAX_EXOPTION_SIZE]; if ( lpItem == NULL ) return -1; iItemCategory = this->CategoryRandomPool.GetRandomValue(eRANDOMPOOL_BY_WEIGHT); if ( iItemCategory < 0 || iItemCategory > MAX_LOTTERY_ITEM_CATEGORY ) return -1; iMaxItemCountInCategory = this->LotteryItemListCount[iItemCategory]; if ( iMaxItemCountInCategory <= 0 || iMaxItemCountInCategory > MAX_LOTTERY_ITEM_COUNT ) return -1; iItemSelectNumber = rand() % iMaxItemCountInCategory; if ( iItemSelectNumber < 0 || iItemSelectNumber > MAX_LOTTERY_ITEM_COUNT ) return -1; iItemType = this->LotteryItemList[iItemCategory][iItemSelectNumber].btItemType; iItemIndex = this->LotteryItemList[iItemCategory][iItemSelectNumber].wItemIndex; iItemLevelMin = this->LotteryItemList[iItemCategory][iItemSelectNumber].btItemLevelMin; iItemLevelMax = this->LotteryItemList[iItemCategory][iItemSelectNumber].btItemLevelMax; iSkillOption = this->LotteryItemList[iItemCategory][iItemSelectNumber].btSkillOption; iLuckOption = this->LotteryItemList[iItemCategory][iItemSelectNumber].btLuckOption; iAddOption = this->LotteryItemList[iItemCategory][iItemSelectNumber].btAddOption; iExOption = this->LotteryItemList[iItemCategory][iItemSelectNumber].btExOption; if ( iItemType == -1 || iItemIndex == -1 || iItemLevelMin == -1 || iItemLevelMax == -1 || iItemLevelMin == -1 || iItemLevelMax == -1 || iSkillOption == -1 || iLuckOption == -1 || iAddOption == -1 || iExOption == -1 ) return -1; iSkillOptionRate = this->LotteryItemOptionRate[iItemCategory].iSkillOptionRate; iLuckOptionRate = this->LotteryItemOptionRate[iItemCategory].iLuckOptionRate; iAddOptionRate = this->LotteryItemOptionRate[iItemCategory].iAddOptionRate; iExOptionRate = this->LotteryItemOptionRate[iItemCategory].iExOptionRate; iRandomKey = rand() % (iItemLevelMax - iItemLevelMin + 1); iItemLevel = iItemLevelMin + iRandomKey; if ( iItemLevel > iItemLevelMax || iItemLevel < iItemLevelMin ) iItemLevel = iItemLevelMin; if ( iSkillOption == 1 ) { iRandomKey = GetLargeRand() % 1000000; if ( iRandomKey < iSkillOptionRate ) btSkillOption = 1; } if ( iLuckOption == 1 ) { iRandomKey = GetLargeRand() % 1000000; if ( iRandomKey < iLuckOptionRate ) btLuckOption = 1; } if ( iAddOption == 1 ) { iRandomKey = GetLargeRand() % 1000000; if ( iRandomKey < iAddOptionRate ) { btAddOption = this->AddOptionRandomPool.GetRandomValue(eRANDOMPOOL_BY_WEIGHT); iTemp = btAddOption; } } if ( iExOption == 1 ) { iRandomKey = GetLargeRand() % 1000000; if ( iRandomKey < iExOptionRate ) { btExOptionValue1 = this->ExOptionRandomPool.GetRandomValue(eRANDOMPOOL_BY_WEIGHT); btExOptionKey = 1 << (int)(btExOptionValue1); btExOption |= btExOptionKey; iItemLevel = 0; if ( (rand() % 4) == 0 ) { btExOptionValue2 = this->ExOptionRandomPool.GetRandomValue(eRANDOMPOOL_BY_WEIGHT); if ( btExOptionValue1 != btExOptionValue2 ) { btExOptionKey = 1 << (int)(btExOptionValue2); btExOption |= btExOptionKey; } } } } else if ( iExOption == 2 ) { btExOptionValue1 = this->ExOptionRandomPool.GetRandomValue(eRANDOMPOOL_BY_WEIGHT); btExOptionKey = 1 << (int)(btExOptionValue1); btExOption |= btExOptionKey; iItemLevel = 0; if ( (rand() % 4) == 0 ) { btExOptionValue2 = this->ExOptionRandomPool.GetRandomValue(eRANDOMPOOL_BY_WEIGHT); if ( btExOptionValue1 != btExOptionValue2 ) { btExOptionKey = 1 << (int)(btExOptionValue2); btExOption |= btExOptionKey; } } } if ( btAddOption != iTemp ) btAddOption = 0; iItemNumber = ItemGetNumberMake(iItemType, iItemIndex); lpItem->Convert(iItemNumber, btSkillOption, btLuckOption, btAddOption, btExOption, 0, 0, 0, -1, CURRENT_DB_VERSION); lpItem->m_Level = iItemLevel; if ( !lpItem->IsItem() ) return -1; ItemIsBufExOption(ExOption, lpItem); LogAddTD("[CashItem][LotteryItem] Get Item Category:%d,Index:%d (Name:%s,Type:%d,Index:%d,Level:%d) Skill:%d,Luck:%d,AddOption:%d,ExOption(%d,%d,%d,%d,%d,%d)", iItemCategory, iItemSelectNumber, ItemAttribute[iItemNumber].Name, iItemType, iItemIndex, iItemLevel, btSkillOption, btLuckOption, btAddOption, ExOption[0], ExOption[1], ExOption[2], ExOption[3], ExOption[4], ExOption[5]); return iItemCategory; }
BOOL CMonsterSetBase::GetPosition(int TableNum, short MapNumber, short & x, short & y) { int count = 100; BYTE attr; int tx; int ty; int w; int h; if ( TableNum < 0 || TableNum > OBJ_MAXMONSTER-1 ) { LogAdd("ERROR : %s %d", __FILE__, __LINE__ ); return false; } if ( this->m_Mp[TableNum].m_ArrangeType == 1 || this->m_Mp[TableNum].m_ArrangeType == 3 ) { while ( count-- != 0 ) { w = this->m_Mp[TableNum].m_W - this->m_Mp[TableNum].m_X; h = this->m_Mp[TableNum].m_H - this->m_Mp[TableNum].m_Y; if ( w < 1 ) { w = 1; } if ( h < 1 ) { h = 1; } int iRX = GetLargeRand()%w; int iRY = GetLargeRand()%h; tx = this->m_Mp[TableNum].m_X + iRX; ty = this->m_Mp[TableNum].m_Y + iRY; attr = MapC[MapNumber].GetAttr(tx, ty); if ( ((attr&1) != 1) && ((attr &4) != 4) && ((attr&8) != 8) ) { x = tx; y = ty; return TRUE; } } } else if ( this->m_Mp[TableNum].m_ArrangeType == 0 ) { x = this->m_Mp[TableNum].m_X; y = this->m_Mp[TableNum].m_Y; return true; } else if ( this->m_Mp[TableNum].m_ArrangeType == 2 ) { while ( count-- != 0 ) { int Orx = this->m_Mp[TableNum].m_X -3; int Ory = this->m_Mp[TableNum].m_Y -3; Orx += Random(0,6); Ory += Random(0,6); attr = MapC[MapNumber].GetAttr(Orx, Ory); if ( ((attr&1) != 1) && ((attr &4) != 4) && ((attr&8) != 8) ) { x = Orx; y = Ory; return TRUE; } } } else if ( this->m_Mp[TableNum].m_ArrangeType == 3 ) { return TRUE; } else if ( this->m_Mp[TableNum].m_ArrangeType == 4 ) { x = this->m_Mp[TableNum].m_X; y = this->m_Mp[TableNum].m_Y; return TRUE; } return false; }
//004309b0 -> 100% (Identical) void CMonsterItemMng::MagicBookGiveItemSearch(int monsterlevel, int maxlevel) { int result = 0; int incount = 0; int type, index; int BallTable[22]; // ---- if( monsterlevel > MAX_MONSTER_LEVEL - 1 ) { LogAdd("error-L3 : Monster Level Overflow~ %s %d", __FILE__, __LINE__); //Line: 8 return; } // ---- BallTable[0] = 7; BallTable[1] = 8; BallTable[2] = 9; BallTable[3] = 10; BallTable[4] = 11; BallTable[5] = 12; BallTable[6] = 13; BallTable[7] = 14; BallTable[8] = 16; BallTable[9] = 17; BallTable[10] = 18; BallTable[11] = 19; BallTable[12] = 21; BallTable[13] = 22; BallTable[14] = 23; BallTable[15] = 24; BallTable[16] = 35; BallTable[17] = 44; BallTable[18] = 45; BallTable[19] = 46; BallTable[20] = 47; BallTable[21] = 48; // ---- while(true) { if( rand() % 2 ) { type = MAX_TYPE_ITEMS - 1; index = GetLargeRand() % (g_MaxItemIndexOfEachItemType[type] + 1); } else { type = 12; index = BallTable[GetLargeRand() % 22]; } // ---- if( type == 12 && index == 11 ) { CItem * item = &this->m_MonsterInvenExItems[monsterlevel][incount]; result = GetLevelItem(type, index, monsterlevel); // ---- if( result >= 0 ) { int item_type = ITEMGET(type, index); item->Convert(item_type, 0, 0, 0, 0, 0, 0, 0, -1, 0, 3); item->m_Level = result; item->m_Durability = item->m_BaseDurability; // ---- incount++; // ---- if( incount > MAX_MONSTER_EXITEM - 1 ) { break; } } continue; } else { result = GetLevelItem(type, index, monsterlevel); // ---- if( result != 0 ) { continue; } // ---- CItem * item = &this->m_MonsterInvenExItems[monsterlevel][incount]; int item_type = ITEMGET(type, index); // ---- item->Convert(item_type, 0, 0, 0, 0, 0, 0, 0, -1, 0, 3); item->m_Level = 0; item->m_Durability = item->m_BaseDurability; // ---- incount++; // ---- if( incount > MAX_MONSTER_EXITEM - 1 ) { break; } } } // ---- this->m_iMonsterInvenExItemCount[monsterlevel] = incount; }
//004314c0 -> 100% (Identical) CItem * CMonsterItemMng::GetItemEx(int monsterlevel) { if( m_bScriptLoaded == false ) { return 0; } // ---- if( monsterlevel > MAX_MONSTER_LEVEL || monsterlevel < 0 ) { return 0; } // ---- int sum = 0; int nRandValue = GetLargeRand() % 10000000; sum += this->RateData[monsterlevel].m_MagicBookRate; // ---- if( nRandValue < sum ) { int itemcount = this->m_iMonsterInvenExItemCount[monsterlevel]; // ---- if( itemcount <= 0 ) { return 0; } else { int itemindex = GetLargeRand() % itemcount; return &this->m_MonsterInvenExItems[monsterlevel][itemindex]; } } // ---- sum += this->RateData[monsterlevel].m_JewelOfBlessRate; // ---- if( nRandValue < sum ) { return this->m_MonsterJewelItem1; } // ---- sum += this->RateData[monsterlevel].m_JewelOfSoulRate; // ---- if( nRandValue < sum ) { return this->m_MonsterJewelItem2; } // ---- sum += this->RateData[monsterlevel].m_JewelOfLifeRate; // ---- if( nRandValue < sum ) { return this->m_MonsterJewelItem3; } // ---- sum += this->RateData[monsterlevel].m_JewelOfCreationRate; // ---- if( nRandValue < sum ) { return this->m_MonsterJewelItem4; } // ---- sum += this->RateData[monsterlevel].m_JewelOfChaosRate; // ---- if( nRandValue < sum ) { return this->m_MonsterJewelItem5; } // ---- int itemcount = this->m_iMonsterInvenItemCount[monsterlevel]; // ---- if( itemcount <= 0 ) { return 0; } else { int itemindex = GetLargeRand() % itemcount; return &this->m_MonsterInvenItems[monsterlevel][itemindex]; } // ---- return 0; }