Random Stat Scroll Question

04/19/2016 19:38 .HeyEyay.#1
Hello Epvp, anyone who can tell me how can I change the Stats of Random Scroll (Scroll of STR, Scroll of DEX, Scroll of INT, Scroll of STA) I want to change it to random stats by 150 randomized by 10, 20, 30, 40 up to 150

and Here's the Code


Code:

void CDPSrvr::OnRandomScroll( CAr & ar, DPID dpidCache, DPID dpidUser, LPBYTE lpbuf, u_long uBufSize )
{
#ifdef __SYSSECURITY
try{
#endif
	DWORD dwId1, dwId2;
	
	ar >> dwId1;
	ar >> dwId2;
	
	CUser* pUser	= g_UserMng.GetUser( dpidCache, dpidUser );
	if( IsValidObj( pUser ) )
	{
		// Àκ¥Å丮¿¡ ÀÖ´ÂÁö ÀåÂøµÇ¾î ÀÖ´ÂÁö È®ÀÎÀ» ÇØ¾ß ÇÔ
		CItemElem* pItemElem0	= pUser->m_Inventory.GetAtId( dwId1 );
		CItemElem* pItemElem1	= pUser->m_Inventory.GetAtId( dwId2 );
		if( IsUsableItem( pItemElem0 ) == FALSE || IsUsableItem( pItemElem1 ) == FALSE )
		{
			return;
		}


		if( pUser->m_Inventory.IsEquip( dwId1 ) )
		{
			pUser->AddDefinedText( TID_GAME_EQUIPPUT , "" );
			return;
		}			


		if( pItemElem1->GetProp()->dwItemKind3 != IK3_RANDOM_SCROLL )
		{
			return;					
		}


		if( !(pItemElem0->GetProp()->dwItemKind1 == IK1_WEAPON || pItemElem0->GetProp()->dwItemKind2 == IK2_ARMOR || pItemElem0->GetProp()->dwItemKind2 == IK2_ARMORETC ) )
		{
			pUser->AddDefinedText(  TID_GAME_RANDOMSCROLL_ERROR, "" );
			return;
		}


		int nSTR[4] = { 1,  9, 21, 37 };
		int nDEX[4] = { 2, 10, 22, 38 };
		int nINT[4] = { 3, 11, 23, 39 };
		int nSTA[4] = { 4, 12, 24, 40 };


		int nValue = 0;
		int nRandom = xRandom( 100 );
		if( nRandom < 64 )
			nValue = 1;
		else if( nRandom < 94 )
			nValue = 2;
		else if( nRandom < 99 )
			nValue = 3;
		else if( nRandom < 100 )
			nValue = 4;



		if( 0 < nValue )
		{
			int nKind = 0;
			int nToolKind = 0;
			if( pItemElem1->GetProp()->dwID == II_SYS_SYS_SCR_RANDOMSTR )
			{
				nKind = nSTR[nValue-1];
				nToolKind = DST_STR;
			}
			else if( pItemElem1->GetProp()->dwID == II_SYS_SYS_SCR_RANDOMDEX )
			{
				nKind = nDEX[nValue-1];
				nToolKind = DST_DEX;
			}
			else if( pItemElem1->GetProp()->dwID == II_SYS_SYS_SCR_RANDOMINT )
			{
				nKind = nINT[nValue-1];
				nToolKind = DST_INT;
			}
			else if( pItemElem1->GetProp()->dwID == II_SYS_SYS_SCR_RANDOMSTA )
			{
				nKind = nSTA[nValue-1];
				nToolKind = DST_STA;
			}


			pUser->UpdateItem( (BYTE)pItemElem0->m_dwObjId, UI_RANDOMOPTITEMID, nKind );


			LogItemInfo aLogItem;
			aLogItem.SendName = pUser->GetName();
			aLogItem.RecvName = "RANDOMSCROLL";
			aLogItem.WorldId = pUser->GetWorld()->GetID();
			aLogItem.Gold = aLogItem.Gold2 = pUser->GetGold();
			aLogItem.Action = "(";
			OnLogItem( aLogItem, pItemElem0, pItemElem0->m_nItemNum );
			aLogItem.Action = ")";
			OnLogItem( aLogItem, pItemElem1, pItemElem1->m_nItemNum );


			pUser->RemoveItem( (BYTE)( dwId2 ), (short)1 );		


			// ¾ÆÀÌÅÛ ¹Ú±â ¼º°ø~
			pUser->AddPlaySound( SND_INF_UPGRADESUCCESS );			
			g_UserMng.AddCreateSfxObj((CMover *)pUser, XI_INT_SUCCESS, pUser->GetPos().x, pUser->GetPos().y, pUser->GetPos().z);			


			DWORD dwStringNum = 0;
			switch( nToolKind )
			{
			case DST_STR:
				dwStringNum = TID_TOOLTIP_STR;
				break;
			case DST_DEX:
				dwStringNum = TID_TOOLTIP_DEX;
				break;
			case DST_STA:
				dwStringNum = TID_TOOLTIP_STA;
				break;
			default: //case DST_INT:
				dwStringNum = TID_TOOLTIP_INT;
				break;
			}
			CString strMessage;
			strMessage.Format( prj.GetText( TID_GAME_RANDOMSCROLL_SUCCESS ), pItemElem0->GetProp()->szName, prj.GetText( dwStringNum ), nValue );
			pUser->AddText( strMessage );
		}
	}
#ifdef __SYSSECURITY
}
catch(...)
{
	Error("Error on Line %d in %s",__LINE__,__FILE__);
}
#endif
}
04/19/2016 20:23 FlyCraft.TobiLap#2
No need for Source changes.
Open the propItemEtc.inc and at the and of the file you'll find the stated items properties.
Defines the Randomoption id: int nSTR[4] = { 1, 9, 21, 37 };
Quote:
RandomOptItem 21 IDS_PROPITEMETC_INC_000103 37 90000000
{
DST_STR 3
}
04/20/2016 03:39 .HeyEyay.#3
Im Gonna Test It Thank You :)

btw i gonna make it by 10 like this

10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150 so im gonna change it too on propItemEtc.inc? or I Gonna edit it here

Code:
   		int nSTR[4] = { 1,  9, 21, 37, 50, 54 };		int nDEX[4] = { 2, 10, 22, 38, 51, 55 };
		int nINT[4] = { 3, 11, 23, 39, 52, 56 };
		int nSTA[4] = { 4, 12, 24, 40, 53, 57 };

PropItemEtc


Code:
	RandomOptItem	50	IDS_PROPITEMETC_INC_000119	52	90000000
	{
		DST_STR	40
	}
	RandomOptItem	51	IDS_PROPITEMETC_INC_000120	52	90000000
	{
		DST_DEX	40
	}
	RandomOptItem	52	IDS_PROPITEMETC_INC_000121	52	90000000
	{
		DST_INT	40
	}
	RandomOptItem	53	IDS_PROPITEMETC_INC_000122	52	90000000
	{
		DST_STA	40
	}