123 lines
3.9 KiB
C++
123 lines
3.9 KiB
C++
|
|
#include "StdAfx.h"
|
|||
|
|
#include "DnBuffProp.h"
|
|||
|
|
#include "DnPropStateScanActor.h"
|
|||
|
|
#include "DnPropActionCondition.h"
|
|||
|
|
#include "SMScanActor.h"
|
|||
|
|
#include "boost/shared_ptr.hpp"
|
|||
|
|
|
|||
|
|
|
|||
|
|
CDnBuffProp::CDnBuffProp( CMultiRoom* pRoom ) : CDnWorldActProp( pRoom ),
|
|||
|
|
CDnDamageBase( DamageObjectTypeEnum::Prop )
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CDnBuffProp::~CDnBuffProp(void)
|
|||
|
|
{
|
|||
|
|
ReleasePostCustomParam();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
bool CDnBuffProp::Initialize( CEtWorldSector *pParentSector, const char *szPropName, EtVector3 &vPos, EtVector3 &vRotate, EtVector3 &vScale )
|
|||
|
|
{
|
|||
|
|
if( CDnWorldActProp::Initialize( pParentSector, szPropName, vPos, vRotate, vScale ) == false ) return false;
|
|||
|
|
if( m_hMonster ) *m_hMonster->GetMatEx() = *GetMatEx();
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool CDnBuffProp::InitializeTable( int nTableID )
|
|||
|
|
{
|
|||
|
|
if( CDnWorldActProp::InitializeTable( nTableID ) == false )
|
|||
|
|
return false;
|
|||
|
|
|
|||
|
|
bool bResult = false;
|
|||
|
|
|
|||
|
|
// TODO: BuffProp Ÿ<><C5B8> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߰<EFBFBD><DFB0>ؾ<EFBFBD><D8BE><EFBFBD>.
|
|||
|
|
if( GetData() )
|
|||
|
|
{
|
|||
|
|
BuffStruct* pStruct = (BuffStruct*)(GetData());
|
|||
|
|
int nSkillTableID = pStruct->nSkillTableID;
|
|||
|
|
int nSkillLevel = pStruct->nSkillLevel;
|
|||
|
|
float fCheckRange = pStruct->fCheckRange; // <20><><EFBFBD>͵<EFBFBD> üũ <20><><EFBFBD><EFBFBD>
|
|||
|
|
bResult = InitializeMonsterActorProp( pStruct->nMonsterTableID );
|
|||
|
|
|
|||
|
|
// <20>߸<EFBFBD><DFB8><EFBFBD> <20><>ų <20><><EFBFBD><EFBFBD>
|
|||
|
|
_ASSERT( nSkillTableID != 0 && nSkillLevel != 0 );
|
|||
|
|
if( nSkillTableID == 0 || nSkillLevel == 0 )
|
|||
|
|
return false;
|
|||
|
|
|
|||
|
|
set<int>* pSetTargetActorIDs = NULL;
|
|||
|
|
set<int> setTargetActorIDs;
|
|||
|
|
if( bResult )
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE>ִٸ<D6B4> <20><> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
if( 3 == pStruct->nTeam )
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>.
|
|||
|
|
pSetTargetActorIDs = &setTargetActorIDs;
|
|||
|
|
|
|||
|
|
string strTargetActorIDs = pStruct->TargetActorID;
|
|||
|
|
if( strTargetActorIDs.at( strTargetActorIDs.length()-1 ) != ';' )
|
|||
|
|
strTargetActorIDs.push_back( ';' );
|
|||
|
|
|
|||
|
|
int iFoundPos = -1;
|
|||
|
|
while( true )
|
|||
|
|
{
|
|||
|
|
int iStartPos = iFoundPos + 1;
|
|||
|
|
iFoundPos = static_cast<int>(strTargetActorIDs.find_first_of( ';', iStartPos ));
|
|||
|
|
if( string::npos != iFoundPos )
|
|||
|
|
{
|
|||
|
|
string strTargetID = strTargetActorIDs.substr( iStartPos, iFoundPos -iStartPos );
|
|||
|
|
int iTargetID = atoi( strTargetID.c_str() );
|
|||
|
|
setTargetActorIDs.insert( iTargetID );
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_BuffPropComponent.Initialize( GetRoom(), pStruct->nTeam, nSkillTableID, nSkillLevel, pSetTargetActorIDs );
|
|||
|
|
|
|||
|
|
// state <20><> <20>ʱ<EFBFBD>ȭ.
|
|||
|
|
// Idle <20>ǿ<D7BC><C7BF><EFBFBD><EFBFBD><EFBFBD> <20>ƹ<EFBFBD><C6B9>͵<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ʰ<EFBFBD>, Activate <20><EFBFBD><D7BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD> <20>ֺ<EFBFBD><D6BA><EFBFBD> <20>˻<EFBFBD><CBBB>ؼ<EFBFBD> <20>ɸ<EFBFBD><C9B8><EFBFBD> <20><><EFBFBD>鿡<EFBFBD><E9BFA1> <20><>ų<EFBFBD><C5B3> <20>پ<EFBFBD><D9BE>ִ<EFBFBD> <20><><EFBFBD><EFBFBD>ȿ<EFBFBD><C8BF> <20>ο<EFBFBD>.
|
|||
|
|
CDnPropState* pNormalState = CDnPropState::Create( GetMySmartPtr(), CDnPropState::NORMAL );
|
|||
|
|
CDnPropState* pScanState = CDnPropState::Create( GetMySmartPtr(), CDnPropState::SCAN_ACTOR );
|
|||
|
|
|
|||
|
|
CDnPropCondition* pNormalToScan = CDnPropCondition::Create( GetMySmartPtr(), CDnPropCondition::ACTION_CHECK );
|
|||
|
|
CDnPropCondition* pScanToNormal = CDnPropCondition::Create( GetMySmartPtr(), CDnPropCondition::ACTION_CHECK );
|
|||
|
|
|
|||
|
|
static_cast<CDnPropStateScanActor*>(pScanState)->SetRange( fCheckRange );
|
|||
|
|
|
|||
|
|
static_cast<CDnPropActionCondition*>(pNormalToScan)->SetActionName( "Activate" );
|
|||
|
|
static_cast<CDnPropActionCondition*>(pScanToNormal)->SetActionName( "Idle" );
|
|||
|
|
|
|||
|
|
m_pFSM->AddCondition( pNormalToScan );
|
|||
|
|
m_pFSM->AddCondition( pScanToNormal );
|
|||
|
|
|
|||
|
|
m_pFSM->AddState( pNormalState );
|
|||
|
|
m_pFSM->AddState( pScanState );
|
|||
|
|
|
|||
|
|
pNormalState->AddTransitState( pScanState, pNormalToScan );
|
|||
|
|
pScanState->AddTransitState( pNormalState, pScanToNormal );
|
|||
|
|
|
|||
|
|
m_pFSM->SetEntryState( pNormalState );
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return bResult;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
void CDnBuffProp::OnMessage( const boost::shared_ptr<IStateMessage>& pMessage )
|
|||
|
|
{
|
|||
|
|
m_BuffPropComponent.OnMessage( pMessage );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CDnBuffProp::OnChangeAction( const char *szPrevAction )
|
|||
|
|
{
|
|||
|
|
if( (0 == strcmp( szPrevAction, "Activate" ) && 0 == strcmp( GetCurrentAction(), "Idle" )) ||
|
|||
|
|
(0 == strcmp( szPrevAction, "Off" ) && 0 == strcmp(GetCurrentAction(), "Idle")) ) // off <20><EFBFBD> <20>Ŀ<EFBFBD> idle <20><> <20>Ѿ<D1BE><EEB0A1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> ȿ<><C8BF> <20><><EFBFBD><EFBFBD>.
|
|||
|
|
m_BuffPropComponent.RemoveAffectedStateEffects();
|
|||
|
|
}
|
|||
|
|
}
|