Welcome!

Join our community of MMORPG enthusiasts and private server developers! By registering, you'll gain access to in-depth discussions on source codes, binaries, and the latest developments in MMORPG server files. Collaborate with like-minded individuals, explore tutorials, and share insights on building and optimizing private servers. Join us today and unlock the full potential of MMORPG server development!

Join Today!

[PHP] Show Item awakes

Junior Spellweaver
Joined
Sep 16, 2009
Messages
137
Reaction score
103
Here's the script that I wrote in PHP to read the Item Awakes.

Class:
PHP:
 <?php
    define( 'MAX_RANDOM_OPTION', 3 );
    define( '_AWAKE_SAFE_FLAG', 0x2000000000000000 );
    
    class CRandomOptionProperty
    {        
        public function GetRandomOptionSize( $nRandomOptItemId )
        {
            $nSize = 0;
            
            $bCheckedSafeFlag = false;
            $bCheckedSafeFlag = CRandomOptionProperty::IsCheckedSafeFlag( $nRandomOptItemId );
            if( $bCheckedSafeFlag )
                return nSize;
            
            $i = 0x3FFFF << 8;
            for( $j = 0; $j < MAX_RANDOM_OPTION; $j++ )
            {
                if( $nRandomOptItemId & $i )
                    $nSize++;
                else
                    return $nSize;
                    
                $i = $i << 18;
            }
            
            return $nSize;
        }
        public function IsCheckedSafeFlag( $n64RandomeOption )
        {
            if( ( $n64RandomeOption & _AWAKE_SAFE_FLAG ) == _AWAKE_SAFE_FLAG )
                return true;
            return false;
        }
        public function GetParam( $nRandomOptItemId, $i, &$pnDst, &$pnAdj )
        {
            if ( $i > MAX_RANDOM_OPTION )
                return false;
                            
            $nRandomOption = ( $nRandomOptItemId >> ( 8 + $i * 18 ) );
            $pnAdj = $nRandomOption & 0x000001FF;
            if( $nRandomOption & 0x00000200 )
                $pnAdj = -$pnAdj;
            $nRandomOption = $nRandomOption >> 10;
        
            $pnDst = $nRandomOption & 0x0000007F;
                        
            return ( $pnDst > 0 );
        }
    }
?>

Function call:
PHP:
        public function GetAwakes( $nRandomOptItemId )
        {
            $nDst;
            $nAdj;
            $nStr = '';
            $str = '';
            if( CRandomOptionProperty::GetRandomOptionSize( $nRandomOptItemId ) > 1 )
                $nStr = ', ';
            for( $i = 0; $i < CRandomOptionProperty::GetRandomOptionSize( $nRandomOptItemId ); $i++ )
            {
                if( !CRandomOptionProperty::GetParam( $nRandomOptItemId, $i, &$nDst, &$nAdj ) )
                    continue;
                
                if( $nAdj >= 0 )
                    $str .= $nDst.' +'.$nAdj.$nStr;
                else
                    $str .= $nDst.' -'.$nAdj.$nStr;
            }
            return $str;
        }

You can read the Awake ID from the database.
If the Awake ID is over 2147483647 you have to use the 64-Bit version of PHP to calculate it.

$nDst is the Attribute ID
$nAdj is the Attribute Value

All credits goes to me.
 
Last edited:
I'm extremely impressed with this, though I don't have any knowledge of PHP. Although, it seems clean enough.. reading simple syntax, it seems safe. Good job, Sedrika.
 
He just converted the source part or EoCRM to PHP. Anyways good work, it could be pretty usseful...

PHP:
#define	MAX_RANDOM_OPTION	3

//	mulcom	BEGIN100405	°¢¼º º¸È£ÀÇ µÎ·ç¸¶¸®
#define _AWAKE_SAFE_FLAG	0x2000000000000000


BOOL	CRandomOptionProperty::GetParam( __int64 nRandomOptItemId, int i, int* pnDst, int* pnAdj )
{
//	ASSERT( i < MAX_RANDOM_OPTION );
	if( i >= MAX_RANDOM_OPTION )
		return FALSE;

	int nRandomOption	= static_cast<int>( nRandomOptItemId >> ( 8 + i * 18 ) );	// °ªÀ» °¡Á®¿À±â À§ÇÏ¿© ÇØ´ç À§Ä¡·Î ½ÃÇÁÆ®
	*pnAdj	= nRandomOption & 0x000001FF;	// ÇÏÀ§ 9ºñÆ® °¡Á®¿È.
	if( nRandomOption & 0x00000200 )	// ÃÖ»óÀ§ 10 ºñÆ®°¡ 1À̸é À½¼ö
		*pnAdj	= -*pnAdj;
	nRandomOption	= nRandomOption >> 10;	// 10ºñÆ® ¹Ð°í, 

	//	mulcom	BEGIN100405	°¢¼º º¸È£ÀÇ µÎ·ç¸¶¸®
	//*pnDst	= nRandomOption & 0x000000FF;	// 8ºñÆ® °¡Á®¿È
	*pnDst	= nRandomOption & 0x0000007F;	// 8ºñÆ® °¡Á®¿È
	//	mulcom	END100405	°¢¼º º¸È£ÀÇ µÎ·ç¸¶¸®

	return ( *pnDst > 0 );
}

int CRandomOptionProperty::GetRandomOptionSize( __int64 nRandomOptItemId )
{
	int nSize	= 0;

	//	mulcom	BEGIN100405	°¢¼º º¸È£ÀÇ µÎ·ç¸¶¸®
	bool	bCheckedSafeFlag = false;
	bCheckedSafeFlag	= IsCheckedSafeFlag( nRandomOptItemId );

	if( bCheckedSafeFlag == true )
	{
		return	nSize;
	}
	//	mulcom	END100405	°¢¼º º¸È£ÀÇ µÎ·ç¸¶¸®

	__int64 i	= 0x3FFFF << 8;
	for( int j = 0; j < MAX_RANDOM_OPTION; j++ )
	{
		if( nRandomOptItemId & i )
			nSize++;
		else
			return nSize;

		i	= i << 18;
	}

	return nSize;
}

bool	CRandomOptionProperty::IsCheckedSafeFlag( __int64 n64RandomeOption )
{
	if( (n64RandomeOption & _AWAKE_SAFE_FLAG) == _AWAKE_SAFE_FLAG )
	{
#ifdef __PROTECT_AWAKE
		return	true;
#endif	
	}

	return	false;
}
 
Back