Release __BS_EFFECT_LUA FIXXED

12/01/2011 20:12 Pixelfehler#1
So da es einige noch nicht geschafft haben die __BS_EFFECT_LUA zu Fixxen dachte ich mir das ich alle benötigten Snippes einmal hier releasen tue :D

Wenn man alles genau so macht klappt es :D

Neuz-VersionCommon.h
Code:
 
#define	__BS_EFFECT_LUA
Sucht in der Mover.cpp nach
Code:
BOOL CMover::IsCommBank( void )
{
	return	( IsSMMode( SM_BANK15 ) || IsSMMode( SM_BANK30 ) || IsSMMode( SM_BANK001 ) );
}
und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
const char* CMover::GetNameO3D( )
{
	CObject3D* pObj = ((CModelObject*)m_pModel)->GetObject3D( );
	if( !pObj )
	{
		Error( "CMover::GetNameO3D, pObj == NULL" );
		return NULL;
	}

	return pObj->m_szFileName;
}

BOOL CMover::SetDataMTE( const char* alphaTex, const char* eff2ndTex )
{
	// ÁøÂ¥ ½á¾ßÇÒ¶§ È£ÃâµÈ´Ù.
	// À̶§ ºñ·Î¼Ò m_pMteData°¡ ÇÒ´çµÈ´Ù.

	CObject3D* pObj = ((CModelObject*)m_pModel)->GetObject3D( );
	if( !pObj )
	{
		Error( "CMover::GetNameO3D, pObj == NULL" );
		return FALSE;
	}

	if( NULL == pObj->m_pMteData )
		pObj->m_pMteData = new CObject3D::MTE_DATA;

	CObject3D::MTE_DATA* pData = pObj->m_pMteData;

	char	szAlphaTexture[MAX_PATH];
	GetFileTitle( alphaTex, szAlphaTexture );
	strcat( szAlphaTexture, "-ef01.tga" );
	
	pData->_pTex[ 0 ] = TexturePool::Get()->GetTexture( DIR_SFXTEX, std::string(szAlphaTexture) );
	pData->_pTex[ 1 ] = TexturePool::Get()->GetTexture( DIR_SFXTEX, std::string(eff2ndTex) );

	if( NULL == pData->_pTex[ 0 ] || NULL == pData->_pTex[ 1 ] )
	{
		Error( "Failed loading MTE texture %s or %s", szAlphaTexture, eff2ndTex );
		return FALSE;
	}
	
	//ok... now you can use this data
	return TRUE;
}

#endif //__BS_EFFECT_LUA
Sucht nach
Code:
#if __VER >= 15 // __PETVIS
	m_pSfxBuffPet = NULL;
#endif
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
	CSfxModelMng::GetThis()->SubData( GetId() );
#endif //__BS_EFFECT_LUA
Öffnet die Datei StdAfx.h und sucht nach
Code:
#ifdef __BS_CONSOLE
#include "Console.h"
#endif
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
#include "BsCommon.h"
#endif
Geht zu der Datei Mover.h und sucht nach
Code:
#if __VER >= 14 // __WING_ITEM
	void			WingMotionSetting( const CModelObject* pModel );
	float			GetRideFrameSpeed( void );
#endif // __WING_ITEM
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
	const char*		GetNameO3D( );
	BOOL			SetDataMTE( const char* fname1, const char* fname2 );
#endif
Geht zu der Datei sfxbase.cpp und sucht nach
Code:
CSfxMng::~CSfxMng()
{
	for(int i=0;i<m_apSfxBase.GetSize();i++)
		safe_delete( (CSfxBase*)m_apSfxBase.GetAt(i) );
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
	close_lua_sfx( );
#endif	//__BS_EFFECT_LUA
Sucht nach
Code:
if( pMesh ) pMesh->DeleteDeviceObjects();
	}
	return S_OK;
}
Und genau darunter fügt ihr das ein
Code:
#ifdef __BS_EFFECT_LUA

//gmpbigsun: ¿ÜºÎ(·ç¾Æ)¿¡¼* sfx¸¦ µ¹¸®±â À§ÇÔ ( 20100201 )

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//SfxModelSet
SfxModelSet::SfxModelSet( const OBJID idMaster, const char* szSfxName, const char* szBoneName, BOOL bLoop, int nState )
{
	_idMaster = idMaster;

	_pModel = new CSfxModel;
	_pModel->SetSfx( szSfxName );

	// ÃÖ´ë ÇÁ·¹ÀÓÀ» ã´Â´Ù 
	for(int i = 0; i < _pModel->m_pSfxBase->m_apParts.GetSize(); i++)
	{	
		for(int j = 0; j < _pModel->m_pSfxBase->Part( i )->m_apKeyFrames.GetSize(); j++)
		{
			// °¢ ÆÄÆ®ÀÇ ÇÁ·¹ÀÓ ¼ö¿Í ºñ±³Çؼ* ÃÖ´ë ÇÁ·¹ÀÓÀ» ãÀ½
			if(_nMaxFrame < _pModel->m_pSfxBase->Part( i )->Key(j)->nFrame)
				_nMaxFrame = _pModel->m_pSfxBase->Part( i )->Key(j)->nFrame;
		}
		
	}

	strcpy( _szFileName, szSfxName );
	strcpy( _szBone, szBoneName );
	_bLoop = bLoop;

	_nState = nState;
}

SfxModelSet::~SfxModelSet( )
{
	SAFE_DELETE( _pModel );
}

BOOL SfxModelSet::Update( )
{
	CMover* pMaster = prj.GetMover( _idMaster );
	if( !pMaster )
		return FALSE;

	CModelObject* pMasterModel = (CModelObject*)pMaster->GetModel( );
	if( !pMasterModel )
		return FALSE;

	D3DXVECTOR3 kPos( 0.0f, 0.0f, 0.0f );

	BOOL bOK = pMasterModel->GetPosBone( &kPos, _szBone );
	if( !bOK )
		return FALSE;

	D3DXMATRIX* pMat = &pMaster->GetMatrixWorld( );
	D3DXVec3TransformCoord( &kPos, &kPos, pMat );
	_pModel->m_vPos = kPos;
	
	//looping
	if( _nMaxFrame < _pModel->m_nCurFrame )
	{
		if( _bLoop )
			_pModel->m_nCurFrame = 0;
		else 
			return FALSE;
	}

	_pModel->Process( );

	return TRUE;
}

BOOL SfxModelSet::Render( LPDIRECT3DDEVICE9 pd3dDevice )
{
	if( _pModel )
		_pModel->Render( pd3dDevice );

	return TRUE;
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//CSfxModelMng

CSfxModelMng* CSfxModelMng::_pThis = NULL;

CSfxModelMng* CSfxModelMng::GetThis()
{
	if( !_pThis )
		_pThis = new CSfxModelMng;

	return _pThis;
}

void CSfxModelMng::Free()
{
	SAFE_DELETE( _pThis );
}

CSfxModelMng::CSfxModelMng( )
{
}

CSfxModelMng::~CSfxModelMng( )
{
	for( SfxModelSetIter iter = _cDatas.begin(); iter != _cDatas.end(); ++iter )
	{
		SMSVector& cSMS = iter->second;
		SeqDeleter< SMSVector >() ( cSMS );
	}

	_cDatas.clear();
}

BOOL CSfxModelMng::IsFull( OBJID objID, const char* szSfx, const char* szBone )
{
	// ²Ë á´Â°¡?
	static const int MAX_PLAY = 5;

	SfxModelSetIter iter = _cDatas.find( objID );
	if( iter != _cDatas.end() )
	{
		SMSVector& cSMS = iter->second;

		// ÃÖ´ë µ¿½Ã °¡´ÉÇÑ ÀÌÆåÆ® °Ë»ç
		if( cSMS.size() > MAX_PLAY )
			return TRUE;

		// À̸§ÀÌ °°Àº sfx´Â ÀÏ´Ü Áߺ¹ ¾È´ï
		for( SMSVector::iterator iter2 = cSMS.begin(); iter2 != cSMS.end(); ++iter2 )
		{
			SfxModelSet* pData = *iter2;
			if( !pData->_bLoop )		//clamp Áߺ¹Çã¿ë 
				continue;

			// loopingÀε¥ bone ÀÌ °°°í , sfx °¡ °°À¸¸é ÀÌ°Ç ¹«½ÃÇÒ µ¥ÀÌÅÍ·Î ÆÇ´Ü.
			// Áï °°Àº°÷¿¡ °°Àº ÀÌÆåÆ®¸¦ ·çÇνÃŰÀÚ°í Çß´Ù¸é ¹«½ÃÇÑ´Ù. ( ÀÌ¹Ì °°Àº ÀÌÆåÆ®°¡ Ãâ·ÂµÇ°í ÀÖÀ¸¹Ç·Î )
			if( strcmp( pData->_szBone, szBone ) == 0 )
			{
				if( strcmp( pData->_szFileName, szSfx ) == 0 )
					return TRUE;
			}
		}
	}

	return FALSE;

}

BOOL CSfxModelMng::AddData( SfxModelSet* pData, BOOL bChecked )
{
	// IsFull·Î °Ë»çÇÑ¿ì AddData°¡ ºÒ·Á¾ß ÇÔ, ÃÖ¼ÒÇÑÀÇ ¾ÈÁ¯´ëÃ¥ 
	if( !bChecked )
		return FALSE;

	//! IsFullÇÔ¼ö·Î ÀÌ¹Ì °Ë»ç°¡ µÇÀÖ´Ù°í ÆÇ´ÜÇÏ¿© Àç °Ë»ç´Â ÇÏÁö ¾ÊÀ½.

	SfxModelSetIter iter = _cDatas.find( pData->_idMaster );
	if( iter != _cDatas.end() )
	{
		//Bone nameÀÌ °°Àº°æ¿ì looping ¼Ó¼º¿¡ ´ëÇØ¼* ±âÁ¸ ÀÌÆåÆ® »èÁ¦ ÈÄ Ãß°¡ 
		SMSVector& rSMS = iter->second;

		for( SMSVector::iterator iter2 = rSMS.begin(); iter2 != rSMS.end();  )
		{
			SfxModelSet* pSet = *iter2;
			
			if( !pSet->_bLoop )		//clampÀ̸é Áߺ¹Çã¿ë 
			{
				++iter2;
				continue;
			}

			if( strcmp( pSet->_szBone, pData->_szBone ) == 0 )
			{
				//À§Ä¡°¡ °°´Ù. ±âÁ¸ sfx»èÁ¦ 
				SAFE_DELETE( pSet );
				iter2 = rSMS.erase( iter2 );
			}
			else ++iter2;
		}

		rSMS.push_back( pData );

		return TRUE;
	}
	else
	{
		// new data
		SMSVector cSMS;
		cSMS.push_back( pData );

		pair< SfxModelSetIter, bool > rst =  _cDatas.insert( SfxModelSetContainer::value_type( pData->_idMaster, cSMS ) );

		assert( rst.second );
		return (BOOL)rst.second;
	}
	 
	 return TRUE;
}

BOOL CSfxModelMng::SubData( OBJID objID )
{
	SfxModelSetIter iter = _cDatas.find( objID );
	if( iter != _cDatas.end() )
	{
		SeqDeleter< SMSVector >() ( iter->second );

		_cDatas.erase( iter++ );
		return TRUE;
	}

	return FALSE;
}

BOOL CSfxModelMng::SubData( OBJID objID, const int nState )
{
	// ÇØ´ç »óÅ¿¡ ÇØ´çÇÏ´Â ¸ðµç sfx¸¦ »èÁ¦ÇÑ´Ù.

	BOOL bOK = FALSE;
	SfxModelSetIter finder = _cDatas.find( objID );
	if( finder != _cDatas.end() )
	{
		SMSVector& kSubData = finder->second;

		for( SMSVector::iterator iter = kSubData.begin(); iter != kSubData.end(); /*none*/ )
		{
			SfxModelSet* pSfx = *iter;

			if( pSfx->_idMaster == objID )
			{
				if( nState == pSfx->_nState )
				{
					SAFE_DELETE( pSfx );
					iter = kSubData.erase( iter );

					bOK = TRUE;		//ok ã¾Æ¼* Áö¿üÀ½.
				}
				else ++iter;
			}
		}
	}

	return bOK;

}


BOOL CSfxModelMng::SubData( OBJID objID, const char* szBone )
{
	//ÇØ´ç º»¿¡ ¸µÅ©µÇ¾î ÀÖ´Â ¸ðµç sfx¸¦ »èÁ¦ÇÑ´Ù.
	BOOL bOK = FALSE;
	SfxModelSetIter finder = _cDatas.find( objID );
	if( finder != _cDatas.end() )
	{
		SMSVector& kSubData = finder->second;

		for( SMSVector::iterator iter = kSubData.begin(); iter != kSubData.end(); /*none*/ )
		{
			SfxModelSet* pSfx = *iter;

			if( pSfx->_idMaster == objID )
			{
				if( 0 == strcmp( pSfx->_szBone, szBone ) )
				{
					SAFE_DELETE( pSfx );
					iter = kSubData.erase( iter );

					bOK = TRUE;		//ok ã¾Æ¼* Áö¿üÀ½.
				}
				else ++iter;
			}
		}
	}

	return bOK;
}

void CSfxModelMng::Update( )
{
	if( !_cWaitingObj.empty() )
	{
		for( map<DWORD,int>::iterator iter = _cWaitingObj.begin(); iter != _cWaitingObj.end(); ++iter )
		{
			CMover* pMover = prj.GetMover( iter->first );
			if( pMover )
			{
				int nState = iter->second;
				pMover->m_pActMover->RemoveStateFlag( nState );		//»©°í
				pMover->m_pActMover->AddStateFlag( nState );		//³ÖÀ¸¸é lua°¡ ¹ßµ¿
			}
		}

		_cWaitingObj.clear();
	}

	for( SfxModelSetIter iter = _cDatas.begin(); iter != _cDatas.end();  )
	{
		SMSVector& cSMS = iter->second;

		//sub loop
		for( SMSVector::iterator iter2 = cSMS.begin(); iter2 != cSMS.end();  )
		{
			SfxModelSet* pData = *iter2;
			if( !pData->Update() )
			{
				SAFE_DELETE( pData );
				iter2 = cSMS.erase( iter2 );
			}
			else 
				++iter2;
		}

		// main loop
		if( cSMS.empty() )
			_cDatas.erase( iter++ );
		else ++iter;
	}
}

void CSfxModelMng::Render( LPDIRECT3DDEVICE9 pd3dDevice )
{
	for( SfxModelSetIter iter = _cDatas.begin(); iter != _cDatas.end(); ++iter )
	{
		SMSVector& cSMS = iter->second;
	//	for_each( cSMS.begin(), cSMS.end(), bind2nd( mem_fun( &SfxModelSet::Render ), pd3dDevice ) );

		for( SMSVector::iterator iter2 = cSMS.begin(); iter2 != cSMS.end(); ++iter2 )
		{
			SfxModelSet* pData = *iter2;
			pData->Render( pd3dDevice );
		}
	}
}


///////////////////////////////////////////////////////////////////////////////////////////
// lua for sfx

lua_State* g_SfxLua = NULL;

int call_sfx( lua_State* L )
{
	// ·ç¾Æ¿¡¼* call ( lua glue )
	int n = lua_gettop( L ); 

	int who = lua_tointeger( L, 1 );				// master id
	int nKind = lua_tointeger( L, 2 );				// kind of the effect
	const char* szSfx = lua_tostring( L, 3 );		// sfx
	const char* szBone = lua_tostring( L, 4 );		// bone
	BOOL bLoop = lua_tointeger( L, 5 );				// is loop ?
	int nState = lua_tointeger( L, 6 );				// state ( create, battle ... )

	CMover* pMover = prj.GetMover( who );
	if( !pMover )
	{
		assert( 0 );
		return 0;
	}

	//! »ý¼ºÇϱâ Àü¿¡ ÇÊÈ÷ °Ë»çÇØ¾ßÇÔ.
	BOOL bFull = CSfxModelMng::GetThis()->IsFull( who, szSfx, szBone );
	if( bFull )
		return 0;

	SfxModelSet* pSfxSet = new SfxModelSet( who, szSfx, szBone, bLoop, nState );
	BOOL bOK = CSfxModelMng::GetThis()->AddData( pSfxSet, TRUE );

	if( !bOK )
		SAFE_DELETE( pSfxSet );

	return 0;
}

int call_mte( lua_State* L )
{
	// ·ç¾Æ¿¡¼* call ( lua glue )
	// multitexture effect
	int n = lua_gettop( L ); 

	int who = lua_tointeger( L, 1 );				// master id
	int nKind = lua_tointeger( L, 2 );				// kind of the effect
	const char* sz2ndDDS = lua_tostring( L, 3 );	// 2nd dds

	CMover* pMover = prj.GetMover( who );
	if( !pMover )
	{
		assert( 0 );
		return 0;
	}

	if( !pMover->IsNPC( ) )
		return 0;

	CModelObject* pModel = (CModelObject*)pMover->GetModel();
	if( !pModel )
		return 0;

	CObject3D* pObj = pModel->GetObject3D( );
	if( !pObj )
		return 0;

	pObj->m_dwEffect_EX |= XE_MTE;

	char szDDS[ 64 ];
	strcpy( szDDS, sz2ndDDS );
	strcat( szDDS, ".dds" );
	BOOL bOK = pMover->SetDataMTE( pMover->GetNameO3D(), szDDS );

	if( !bOK )
		Error( "please check the mte texture %s", pMover->GetNameO3D() );

	return 0;
}

int stop_sfx_bybone( lua_State* L )
{
	//2010_05_10 gmpbigsun : ÀÏ´Ü ¸¸µé¾î³ùµû.. Ȥ½Ã³ª ¾î¶²»óŰ¡ ³¡³ª¸é ¾î¶²º»¿¡ ¸µÅ©µÈ sfx¸¸ Áö¿ì°í½ÍÀ»¶§¸¦ ´ëºñÇØ¼*..
	int n = lua_gettop( L );

	int who = lua_tointeger( L, 1 );
	const char* szBone = lua_tostring( L, 2 );

	CMover* pMover = prj.GetMover( who );
	if( !pMover )
	{
		assert( 0 );
		return 0;
	}

	BOOL bOK = CSfxModelMng::GetThis()->SubData( who, szBone );

	return bOK;
}

void open_lua_sfx()
{
	if( !g_SfxLua )
 	{
		g_SfxLua = lua_open();
//		luaL_openlibs(g_SfxLua);

		// push function
		lua_register( g_SfxLua, "call_sfx", call_sfx );
		lua_register( g_SfxLua, "call_mte", call_mte );
	}
}

void close_lua_sfx()
{
	if( g_SfxLua )
		lua_close( g_SfxLua );
}


void run_lua_sfx( int nState, OBJID caller, const char* szMoverName )
{
	static const CString strPATH( "SFX\\Scripts\\" );
	static const CString strFORMAT(".lua");

	// setup 
	if( !g_SfxLua )
		open_lua_sfx( );

	// caller´Â ¹«¹ö¸¸ Áö¿øÇÑ´Ù. ÇöÀç 2010_0204
	CMover* pWho = prj.GetMover( caller );
	if( !pWho )
	{
		// Èì »ý¼ºÀÌ µÇ´ÂµµÁß ºÒ¸±¼ö°¡ ÀÖ´Ù. ÀÌ·±°æ¿ì´Â prj¿¡¼* ¸øÃ¡À»²¯À̹ǷΠµî·Ï»óÅ·ΠµÎ°í ´ÙÀ½ ÇÁ·¹ÀÓ¿¡ ½ÃµµÇÑ´Ù.
		CSfxModelMng::GetThis()->_cWaitingObj.insert( map< DWORD, int >::value_type( caller, nState ) );
		return;
	}

	char szFunc[ 64 ];
	GetFileTitle( szMoverName, szFunc );
	CString strFileName = CString( szFunc ) + strFORMAT;
	CString strFullPath = strPATH + strFileName;
	
	// res¸¦ Ãë±ÞÇÏ´Â Å×¼· ¹× Á¤¼·Àº buffer¸¦ ¾ò¾î¿Í¼* ·ç¾Æ¸¦ µ¹¸®ÀÚ 
#ifdef __BS_EFFECT_LUA
	if( 0 != luaL_dofile( g_SfxLua, strFullPath.GetBuffer(0) ) )
	{
	//	Error( "run_lua_sfx : %s", (char*)lua_tostring( g_SfxLua, -1 ) );
		return;
	}
#else
	// res·Î mergeµÈ ÆÄÀÏÀº CResFileÀ» ÀÌ¿ëÇØ ¹öÆÛ¸¦ ¾ò°í ·ç¾Æ¸¦ È£Ãâ 
	CResFile file;
	BOOL bRet = file.Open( strFullPath.GetBuffer(0), "rt" );
	if( bRet == FALSE )	
	{
		Error( "run_lua_sfx : %s ÀÐ±â ½ÇÆÐ", strFullPath.GetBuffer(0) );
		return;
	}

	static char pBuff[ 2048 ];
	int nLength = file.GetLength();
	if( nLength > 2047 )
	{
		Error( "error!! overflowed size of lua file %s", strFullPath.GetBuffer(0) );
		return;
	}

	if( nLength < 2 )		// Á¸ÀçÀÌÀ¯°¡ ¾ø´Â ±æÀÌ ÀÌ´Ù .
		return;

	pBuff[ 0 ] = 0;
	file.Read( pBuff, nLength );
	pBuff[ nLength ] = 0;
	
	// TODO : buffer¸¦ ¾ò¾î¿Í¼* call lua
	int a = luaL_loadbuffer( g_SfxLua, pBuff, nLength, NULL );
	int b = lua_pcall(g_SfxLua, 0, LUA_MULTRET, 0);

	if( (a | b) != 0 )
	{
		Error( "error run_lua_sfx : %s", (char*)lua_tostring( g_SfxLua, -1 ) );
		return;
	}
#endif// __BS_EFFECT_LUA

	//¸¸¾à ¸ó½ºÅÍ¿¡ ´ëÇØ¼* ÀϹÝÀûÀÎ lua¸¦ Àû¿ëÇϰí, Ưº°ÇÑ °æ¿ì¸¸ ¸ó½ºÅͰ³°³Àο¡ ´ëÇØ¼* lua¸¦ ÁöÁ¤ÇÑ´Ù¸é 
	// ¿ì¼±¼øÀ§´Â Ưº°È÷ ÁöÁ¤µÈ°æ¿ì´Ù ,

	if( OBJSTAF_COMBAT == nState )
		strcat( szFunc, "_battle" );
	else
	if( OBJSTA_NONE == nState ) 
	{
		//»ý¼º»óÅ·Π°£ÁÖÇÑ´Ù.. Áï »ý¼ºµÇ°í ¾Æ¹«°Íµµ ¾Æ´Ñ»óŶõ °É·Î ÇØ¼®Çϱ⠹ٶ÷.
		strcat( szFunc, "_create" );
	}
	else
	{
		Error( "SFXLUA is not supported the state : %d ", nState );
		return;
	}

	lua_getglobal( g_SfxLua, szFunc );
	lua_pushnumber( g_SfxLua, caller );

//	lua_call( g_SfxLua, 1, 0 ) ;

//_DEBUG
	if( lua_pcall( g_SfxLua, 1, 0, 0 ) != 0 ) 
	{
		char* szError = (char*)lua_tostring( g_SfxLua, -1 );
		Error( "run_lua_sfx : %s", szError );
	}
}

BOOL stop_sfx( OBJID caller )
{
	return CSfxModelMng::GetThis()->SubData( caller );
}

#endif //__BS_EFFECT_LUA
Geht zu der Datei sfxbase.h und sucht nach
Code:
HRESULT DeleteDeviceObjects();
};
Und fügt genau darunter das ein
Code:
#ifdef __BS_EFFECT_LUA

void open_lua_sfx();
void close_lua_sfx();

void run_lua_sfx( int nState, OBJID caller, const char* szMoverName );

//for lua glue
struct lua_State;
static int call_sfx( lua_State* L );
static BOOL stop_sfx( OBJID caller );

// ÀÚü update 
struct SfxModelSet
{
	SfxModelSet( ) : _idMaster(0), _pModel(NULL), _bLoop(FALSE), _nMaxFrame(0), _nState(0) { }
	SfxModelSet( const OBJID idMaster, const char* szSfxName, const char* szBoneName, BOOL bLoop, int _nState );
	
	~SfxModelSet( );

	BOOL Update( );
	BOOL Render( LPDIRECT3DDEVICE9 pd3dDevice );
	
	OBJID _idMaster;
	char _szBone[ 64 ];
	char _szFileName[ 64 ];
	int _nMaxFrame;
	BOOL _bLoop;
	CSfxModel* _pModel;

	int _nState;		//»óÅ : ¾î¶²»óÅÂÀ϶§ ¹ßµ¿µÇ´Â È¿°úÀÎÁö

};

typedef vector< SfxModelSet* >					SMSVector;				//SMS : SfxModelSet
typedef map< OBJID, SMSVector >					SfxModelSetContainer;
typedef SfxModelSetContainer::iterator			SfxModelSetIter;

//gmpbigsun(100128 ) : Lua¿¡¼* È£ÃâÇÑ sfx( ¸ðµç ¼Ó¼ºÀÌ data·Î Á¸ÀçÇÏ´Â ) °ü¸®ÀÚ
// bone ¿¡ ¸µÅ©µÇ¾î loopµÇ´Â ÀÌÆå¸¸ Áö¿øÇÑ´Ù. 
class CSfxModelMng 
{
public:
	CSfxModelMng( );
	~CSfxModelMng( );

	BOOL AddData( SfxModelSet* pData, BOOL bChecked );				
	BOOL SubData( OBJID objID );						//ÇØ´ç ¿ÀºêÁ§Æ®ÀÇ ¸ðµç lua°ü·Ã sfx»èÁ¦ 
	BOOL SubData( OBJID objID, const int nState );		//ÇØ´ç ¿ÀºêÁ§Æ®ÀÇ ¸ðµç »óÅ¿¡ ÇØ´çÇÏ´Â sfx»èÁ¦
	BOOL SubData( OBJID objID, const char* szBone );	//ÇØ´ç ¿ÀºêÁ§Æ®ÀÇ ÇØ´ç º»¿¡ ¸µÅ©µÈ ¸ðµç sfx»èÁ¦
	
	void Update( );
	void Render( LPDIRECT3DDEVICE9 pd3dDevice );

	BOOL IsFull( OBJID objID, const char* szSfx, const char* szBone );	//optimized 

	static CSfxModelMng* GetThis();
	static void Free();

public:
	map< DWORD, int > _cWaitingObj;

private:
	static CSfxModelMng* _pThis;

	SfxModelSetContainer	_cDatas;
};


#endif //__BS_EFFECT_LUA
Geht zu der Datei ModelGlobal.h und sucht nach
Code:
#define XE_ITEM_GEN_AL		(0x00100000)		// Ultimate¿ë
#endif //__Y_ADV_ENCHANT_EFFECT
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
#define XE_MTE				(0x00200000)		// multi texturing effect
#endif //__BS_EFFECT_LUA
Geht zu der Datei ModelObject.cpp und sucht nach
Code:
D3DXVec3TransformCoord( &v1, &v1, &mWorld );
	*vOut = v1;
	
}
Und fügt genau darunter
Code:
#ifdef __BS_EFFECT_LUA
BOOL CModelObject::GetPosBone( D3DXVECTOR3* pOut, const char* bonename )
{
	//gmpbigsun : º»À̸§À¸·Î º»ÁÂÇ¥ ÃßÃâ 
	for( int i =0; i < m_pBone->m_nMaxBone; ++i )
	{
		BONE* pUnitBone = m_pBone->GetBone( i );
		if( !pUnitBone )
		{
			assert( 0 );
			continue;
		}

		if( strcmp( bonename, pUnitBone->m_szName ) == 0 )
		{
			D3DXMATRIX matTemp;
			if( pUnitBone->m_pParent )
				D3DXMatrixMultiply( &matTemp, &pUnitBone->m_mLocalTM, &m_mUpdateBone[ pUnitBone->m_nParentIdx ] );
			else 
				D3DXMatrixMultiply( &matTemp, &pUnitBone->m_mLocalTM, &m_mUpdateBone[ i ] );

			pOut->x = matTemp._41;
			pOut->y = matTemp._42;
			pOut->z = matTemp._43;

			return TRUE;
		}
	}

	return FALSE;
	
}

#endif //__BS_EFFECT_LUA
Geht zu der Datei ModelObject.h und sucht nach
Code:
// virtual
	int LoadModel( LPCTSTR szFileName ) { return LoadElement( szFileName, 0 ); }
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
	BOOL CModelObject::GetPosBone( D3DXVECTOR3* pOut, const char* bonename );
#endif
Geht zu der Datei Object3D.cpp und sucht nach
Code:
#ifdef __YENV
	m_pNormalDecl	= NULL;
#endif //__YENV
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
	m_dwEffect_EX = 0;

	m_pMteData = NULL;
#endif;
Sucht nach
Code:
SAFE_DELETE_ARRAY( m_pBaseBone );
SAFE_DELETE( m_pMotion );
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
	m_dwEffect_EX = 0;

	SAFE_DELETE( m_pMteData );
#endif;
Sucht nach
Code:
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR  );
		}
		
	}
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
	if( nEffect & XE_MTE )
	{
		//animated texcoord ( alpha map - subtract )
   
		//check data
		if( !m_pMteData )
			return;

		m_pd3dDevice->SetSamplerState( 1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
        m_pd3dDevice->SetSamplerState( 1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
		
		//D3DRS_ALPHATESTENABLE²¨Áà¾ß ºí·»µù È¿°ú¸¦ ±â´ëÇÒ¼öÀÖ´Ù.
		m_pd3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, FALSE );
		m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
	    
		m_pd3dDevice->SetTexture( 0, m_pMteData->_pTex[0] );

//		m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_MODULATE );
//		m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
//		m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR  );

		m_pd3dDevice->SetTexture( 1, m_pMteData->_pTex[1] );

		m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
		m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP,   D3DTOP_ADDSIGNED2X );
		m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );
		m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
		m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP,   D3DTOP_SUBTRACT );

		// 20sec : 1.0f
		// ¾Æ·¡´Â tool¿¡¼* ±¸ÇöµÈ °Í°ú ´Ù¸¥µ¥, ½ÇÁ¦°ÔÀÓ¿¡¼*´Â ½Ã°£À¸·Î ±× ¼öÄ¡¸¦ Á¤Çϰí Àֱ⠶§¹®ÀÌ´Ù. 
		// tool¿¡¼*´Â ¿©·¯ °³Ã¼¼ö¸¦ ¶ç¿ïÇʿ䰡 ¾ø±â¿¡ ½Ã°£´ë½Å »ó¼ö¸¦ »ç¿ëÇÏ¿´´Ù.
		
		extern DWORD g_timeMTE;	// 20ÃÊ °»½Å¿ë ŸÀ̸Ó
		float fUV = (float)(g_timeMTE * 0.00005f);
		m_pMteData->_kUV[0].x = fUV;
		m_pMteData->_kUV[0].y = fUV;

		if( m_pMteData->_kUV[0].x > 1.0f )
			m_pMteData->_kUV[0] = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
		m_pd3dDevice->SetVertexShaderConstantF( 91, (float*)&m_pMteData->_kUV[0], 1 );		//texture uv ( skinning2.vsh )


		if( g_timeMTE < 11000 ) // ¼*¼*È÷ ¹à¾ÆÁö°Ô ÇÏÀÚ
		{
			float v = (float)(g_timeMTE * 0.0001f);
			m_pMteData->_kUV[1] = D3DXVECTOR3( v, v, v );
		}
		else 
		{
			float v = (float)( ( 22000 - g_timeMTE ) * 0.0001f );
			m_pMteData->_kUV[1] = D3DXVECTOR3( v, v, v );
		}
	
		////light
		m_pd3dDevice->SetVertexShaderConstantF( 93, (float*)&m_pMteData->_kUV[1], 1 );
		m_pd3dDevice->SetVertexShaderConstantF( 94, (float*)&m_pMteData->_kUV[1], 1 );
	}
	else 
	
#endif //__BS_EFFECT_LUA
Sucht nach
Code:
if( (pBlock->m_dwEffect & XE_BUMP) || (nEffect & XE_BUMP) )
	{
		if( m_nNoEffect )	return;
		int a = 0;
	}
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
	if( nEffect & XE_MTE )
	{
		if( m_nNoEffect ) 
			return;

		m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
		m_pd3dDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1 );	
		m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
		m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
	}
#endif //__BS_EFFECT_LUA
Sucht nach
Code:
SetState( pBlock, nEffect, dwBlendFactor );
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
		if( XE_MTE != nEffect)
#endif //__BS_EFFECT_LUA
Sucht nach
Code:
if( pObj->m_Type == GMT_SKIN )
		{
			if( ppd3d_VB == NULL )
				Error( "CObject3D::Render : %s ½ºÅ²¿ÀºêÁ§Æ®Àε¥ ppd3d_VB°¡ ¾ø´Ù.", m_szFileName );

			RenderSkin( pd3dDevice, ppd3d_VB[i], pObj, mWorld, nEffect, dwBlendFactor );
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
			if( m_dwEffect_EX & XE_MTE )
				RenderSkin( pd3dDevice, ppd3d_VB[i], pObj, mWorld, XE_MTE, dwBlendFactor );
#endif //__BS_EFFECT_LUA
Geht zu der Datei Object3D.h und sucht nach
Code:
int		m_nUseCnt;		// ¸î¹ø °øÀ¯µÇ¾î »ç¿ëµÇ¾ú´Â°¡.	

	FLOAT	m_fAmbient[3];
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
	DWORD m_dwEffect_EX;	// Render effect È®Àå

	struct MTE_DATA	// Multi Texturing Effect
	{
		MTE_DATA() { _pTex[ 0 ] = NULL; _pTex[ 1 ] = NULL; _kUV[0] = D3DXVECTOR3( 0.f, 0.f, 0.f ); _kUV[1] = D3DXVECTOR3( 0.f, 0.f, 0.f ); }
		LPDIRECT3DTEXTURE9 _pTex[2];
		D3DXVECTOR3 _kUV[2];
	};
	MTE_DATA* m_pMteData;
#endif //__BS_EFFECT_LUA
Geht zu der Datei World.cpp und sucht nach
Code:
#if __VER >= 15 // __BS_CHANGING_ENVIR
	m_strCurContName = "";
#endif
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
	CSfxModelMng::Free( );
#endif	//__BS_EFFECT_LUA
Sucht nach
Code:
if( ((CMover *)pObj)->GetId() == m_idObjFocusOld )
			{
				SetObjFocus( pObj );
			}
		}
	}
Und fügt genau darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
	
	// »ý¼º½ÃÁ¡¿¡¼* »ý¼º°ü·Ã Effect ó¸®( NPC only!! )
	if( OT_MOVER == pObj->GetType() )
	{
		CMover* pMover = static_cast< CMover* > ( pObj );
		
		if( pMover->IsNPC() )
			run_lua_sfx( OBJSTA_NONE, pMover->GetId(), pMover->GetNameO3D() );
	}

#endif //__BS_EFFECT_LUA
Sucht nach
Code:
#else //__WATER_EXT
	CLandscape::m_fWaterFrame += 0.15f;
	
	if( CLandscape::m_fWaterFrame >= 54.0f )
		CLandscape::m_fWaterFrame = 0.0f;	
#endif //__WATER_EXT
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
	CSfxModelMng::GetThis()->Update();
#endif	//__BS_EFFECT_LUA
Geht zu der Datei World3D.cpp und sucht nach
Code:
RenderGrid();
		
		// ¿ÀºêÁ§Æ® ·£´õ¸µ 
		RenderObject( pFont );
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
		CSfxModelMng::GetThis()->Render( m_pd3dDevice );
#endif //__BS_EFFECT_LUA
Geht zu der Datei path.h und sucht nach
Code:
#define DIR_LOGO         _T( "Model\\Logo\\"   )
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
#define DIR_SFXLUA		 _T( "Sfx\\Scripts\\" )
#endif //__BS_EFFECT_LUA
Geht zu der Datei timer.cpp und sucht nach
Code:
///////////////////////////////////////////////
DWORD	m_lTime, m_dwOldTime;
Und fügt darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
DWORD g_timeMTE = 0;
#endif;


static BOOL	s_bFrameSkip = TRUE;

void InitFST( void )
{
	m_lTime = 0;
	m_dwOldTime = timeGetTime();
	s_bFrameSkip = TRUE;
}

// ÇÁ·¹ÀÓ ½ºÅ°ÇÎÀ» ÄѰí/²ö´Ù
void	SetFrameSkip( BOOL bFlag )
{
	s_bFrameSkip = bFlag;
	if( bFlag == TRUE )		InitFST();
}

// ÇöÀç Ç÷¡±× µ¹·ÁÁÜ
BOOL	GetFrameSkip( void )
{
	return s_bFrameSkip;
}

static void UpdateTime( void )
{
	DWORD	dwTime = timeGetTime();

	m_lTime += (dwTime - m_dwOldTime);	// °æ°úµÈ ½Ã°£À» ´õÇÔ
	if( m_lTime > 1000 )	m_lTime = 1000;

#ifdef __BS_EFFECT_LUA
	g_timeMTE += ( dwTime - m_dwOldTime );
	if( g_timeMTE > 20000 )	//20Ãʸ¶´Ù °»½Å
		g_timeMTE = 0;
#endif //__BS_EFFECT_LUA
Geht zu der Datei Action.cpp und sucht nach
Code:
void	CAction::AddStateFlag( DWORD dwFlag ) 
{
Und fügt genau darunter das ein
Code:
#ifdef __BS_EFFECT_LUA
	//»óŰ¡ Ãß°¡µÉ °æ¿ì ÃÖÃÊÀΰæ¿ì¿¡ È¿°ú¸¦ ¹ß»ý½ÃŲ´Ù.
	if( dwFlag & OBJSTAF_COMBAT && !IsStateFlag( OBJSTAF_COMBAT ) )	
	{
		// ¸¸¾à ÀüÅõ»óÅ·ΠóÀ½ µ¹ÀÔÇϴ°Ŷó¸é »óź° È¿°ú¸¦ È£ÃâÇÑ´Ù. ÀÏ´Ü npc·ù¸¸ 
		if( m_pMover->IsNPC( ) )
			run_lua_sfx( OBJSTAF_COMBAT, m_pMover->GetId(), m_pMover->GetNameO3D() );
	}
#endif //__BS_EFFECT_LUA
Sucht nach
Code:
void	CAction::RemoveStateFlag( DWORD dwFlag )
{
Und fügt genau das darunter
Code:
#ifdef __BS_EFFECT_LUA
	// »óŰ¡ ÇØÁ¦µÉ°æ¿ì lua¿¡¼* È£ÃâÇÑ ¸ðµç »óÅÂÈ¿°ú¸¦ ÇØÁ¦ÇÑ´Ù.
	if( dwFlag & OBJSTAF_COMBAT )
	{
		//ÀüÅõ »óÅÂÈ¿°ú ÇØÁ¦
		CSfxModelMng::GetThis()->SubData( m_pMover->GetId(), OBJSTAF_COMBAT );
	}
#endif //__BS_EFFECT_LUA
Die Lua´s sind im Anhang.
Das ist mein erster release also seid nicht so streng zu mir :p
12/01/2011 20:14 Jopsi332#2
benutz mal spoiler ;D
12/01/2011 20:15 N8Schatten#3
Und was Fixxed man damit? (Denn Source is ja errorfrei soweit ich weiß)
12/01/2011 20:15 .Crasy#4
Was ist denn das für ne Scheiße rofl.

Ich musste nur eine Zeile ändern und es Funktionierte auf einmal, wups, was denn da Falsch?
12/01/2011 20:19 Pixelfehler#5
Quote:
Originally Posted by .Crasy View Post
Was ist denn das für ne Scheiße rofl.
Ich musste nur eine Zeile ändern und es Funktionierte auf einmal, wups, was denn da Falsch?
Dumm in Kopf?? Er fragte ob jemand seine fertigen Snippets gibt.
Hier nochmal für blinde
Quote:
Originally Posted by guardianangel View Post
Kann wer seine Gefixxten Snippets Posten ?
Wär Echt Sexieh
:D
@Jopsi332 Werde ich nachher noch tuen ;)
12/01/2011 20:22 killerooo#6
am besten erwähnst du jetzt noch von wem du es hast, sieht stark nach dem aus was ich gemacht hatte.
12/01/2011 20:24 Pixelfehler#7
Quote:
Originally Posted by killerooo View Post
am besten erwähnst du jetzt noch von wem du es hast, sieht stark nach dem aus was ich gemacht hatte.
Ich glaube nicht das es von dir kommt :handsdown:
12/01/2011 20:30 .Crasy#8
Bei dem SFX Lua shit muss man nur EINE zeile ändern, wenn du 0 Hirn hast lass es.

Ich verwett du verstehst nicht mal dne Halben code wo du oben gepostet hast weil du es von i wem C&P hast.
12/01/2011 20:35 .Tear#9
Right, das __INTERNALSERVER bei nem __BS_EFFECT_LUA ifdef oder?
12/01/2011 20:38 Pixelfehler#10
Quote:
Originally Posted by .Crasy View Post
Bei dem SFX Lua shit muss man nur EINE zeile ändern, wenn du 0 Hirn hast lass es.

Ich verwett du verstehst nicht mal dne Halben code wo du oben gepostet hast weil du es von i wem C&P hast.
Ach Crasy ich muss mich bei dir nicht rechtfertigen was ich kann bzw versteh das las mal meine Sorge sein.Der Release soll ja auch nur für die Leute sein die es überhaupt nicht hinbekommen. Und C&P ?! Zeig mir ein Source der Releast wurden ist wo es zu 100% geht?
;)
12/01/2011 20:46 Clept0#11
Quote:
Originally Posted by Pixelfehler View Post
Ach Crasy ich muss mich bei dir nicht rechtfertigen was ich kann bzw versteh das las mal meine Sorge sein.Der Release soll ja auch nur für die Leute sein die es überhaupt nicht hinbekommen. Und C&P ?! Zeig mir ein Source der Releast wurden ist wo es zu 100% geht?
;)
Trozdem ist es übermässig sinnlos soviele snippets zuposten, wo es vollkommen ausreicht EINE zeile zuändern. Ist lieb gemeint, aber einfach stroh dumm.
12/01/2011 21:20 killerooo#12
Stimmt du hast Recht es ist nicht meins es wird auch nicht funktionieren!
12/01/2011 21:21 guardianangel#13
Das Funzt aber nich

C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_AIInterface\Action.cpp(37): error C2039: 'GetNameO3D' : is not a member of 'CMover'
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_AIInterface\Action.cpp(37): error C3861: 'run_lua_sfx': identifier not found, even with argument-dependent lookup
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_AIInterface\Action.cpp(50): error C2653: 'CSfxModelMng' : is not a class or namespace name
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_AIInterface\Action.cpp(50): error C2227: left of '->SubData' must point to class/struct/union
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_AIInterface\Action.cpp(50): error C3861: 'GetThis': identifier not found, even with argument-dependent lookup
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_Common\Mover.cpp(11943): error C2039: 'GetNameO3D' : is not a member of 'CMover'
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_Common\Mover.cpp(11945): error C2065: 'm_pModel' : undeclared identifier
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_Common\Mover.cpp(11945): error C2227: left of '->GetObject3D' must point to class/struct/union
type is ''unknown-type''
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_Common\Mover.cpp(11955): error C2039: 'SetDataMTE' : is not a member of 'CMover'
..\_Common\Mover.h(464) : see declaration of 'CMover'
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_Common\Mover.cpp(11960): error C2227: left of '->GetObject3D' must point to class/struct/union
type is ''unknown-type''
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_Common\Mover.cpp(11960): error C3861: 'm_pModel': identifier not found, even with argument-dependent lookup
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_Common\Mover.cpp(11976): error C2653: 'TexturePool' : is not a class or namespace name
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_Common\Mover.cpp(11976): error C2227: left of '->GetTexture' must point to class/struct/union
type is ''unknown-type''
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_Common\Mover.cpp(11976): error C3861: 'Get': identifier not found, even with argument-dependent lookup
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_Common\Mover.cpp(11977): error C2653: 'TexturePool' : is not a class or namespace name
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_Common\Mover.cpp(11977): error C2227: left of '->GetTexture' must point to class/struct/union
type is ''unknown-type''
C:\Users\Administrator\Desktop\Flyff\BF Source\Source\_Common\Mover.cpp(11977): error C3861: 'Get': identifier not found, even with argument-dependent lookup
12/01/2011 21:42 clinkz96#14
can you post some screen shot sir? of ur release?
12/01/2011 21:45 Pixelfehler#15
[Only registered and activated users can see links. Click Here To Register...]