本文整理汇总了C++中CMonster::GetAIReferrence方法的典型用法代码示例。如果您正苦于以下问题:C++ CMonster::GetAIReferrence方法的具体用法?C++ CMonster::GetAIReferrence怎么用?C++ CMonster::GetAIReferrence使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMonster
的用法示例。
在下文中一共展示了CMonster::GetAIReferrence方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
void GuardSearch::Execute( BaseType::EntityType *entity )
{
CMonster *pSelf = dynamic_cast<CMonster*>( entity->GetOwner() );
ShapeListType player_list;
ShapeListType monster_list;
CServerRegion *pRegion = static_cast<CServerRegion*>( pSelf->GetFather() );
CMoveShape *pTarget = NULL;
if( CanAttackCurrent( pSelf, entity ) )
{
return;
}
// find the around players
pRegion->FindAroundObject( pSelf, TYPE_PLAYER, player_list );
// find the around monsters including the guards.
pRegion->FindAroundObject( pSelf, TYPE_MONSTER, monster_list );
// filter the result
Filter filter( static_cast<CMonster*>( pSelf ) );
filter_shape( player_list, filter );
filter_shape( monster_list, filter );
// retrieve the ai reference
DWORD ai_ref = pSelf->GetAIReferrence( 0 );
if( ai_ref >= 0 )
{
pTarget = SearchByAIRef1( pSelf, player_list, ai_ref );
}
if( pTarget == NULL && ( ai_ref = pSelf->GetAIReferrence( 1 ) ) > 0 )
{
pTarget = SearchByAIRef2( pSelf, player_list, ai_ref );
}
if( pTarget == NULL && ( ai_ref = pSelf->GetAIReferrence( 2 ) ) > 0 )
{
pTarget = SearchByAIRef3( pSelf, monster_list, ai_ref );
}
if( pTarget == NULL && ( ai_ref = pSelf->GetAIReferrence( 3 ) ) > 0 )
{
pTarget = SearchByAIRef4( pSelf, monster_list, ai_ref );
}
if( pTarget != NULL )
{
// search successfully
entity->SetTarget( pTarget->GetExID(), pTarget->GetType() );
}
else if( entity->HasTarget() )
{
AI_EVENT_SENDER( entity ).ReturnPeace();
}
}
示例2: CanAttackCurrent
BOOL Guard::CanAttackCurrent()
{
if( !HasTarget() )
{
return FALSE;
}
CMoveShape *pTarget = GetTarget();
long dis = m_pOwner->Distance( pTarget );
long attack_range = static_cast<CMonster*>( m_pOwner )->GetAttribute( string( "C_GuardRange" ) );
if( dis > attack_range )
{
return FALSE;
}
CMonster *pSelf = static_cast<CMonster*>( m_pOwner );
DWORD ai_ref = 0;
if( pTarget->GetType() == TYPE_PLAYER )
{
CPlayer *pPlayer = static_cast<CPlayer*>( pTarget );
// ai reference 1
ai_ref = pSelf->GetAIReferrence( 0 );
if( ai_ref >= 0 )
{
if( pPlayer->GetPVPValue() >= ai_ref && !IsSameCamp( pPlayer, pSelf ) )
{
return TRUE;
}
}
// ai reference 2
ai_ref = pSelf->GetAIReferrence( 1 );
if( ai_ref > 0 )
{
if( pPlayer->GetPkValue() >= ai_ref )
{
return TRUE;
}
}
}
// actually, it's not necessary to judge monsters, that because the property for the monsters will
// not changed .So ignored here.
// ...
return FALSE;
}
示例3: SearchEnemy
BOOL Guard::SearchEnemy()
{
if( !CanSearchEnemy() )
{
return FALSE;
}
if( CanAttackCurrent() )
{
return FALSE;
}
ShapeListType player_list;
ShapeListType monster_list;
CServerRegion *pRegion = static_cast<CServerRegion*>( m_pOwner->GetFather() );
CMonster *pSelf = static_cast<CMonster*>( m_pOwner );
CMoveShape *pTarget = NULL;
// find the around players
pRegion->FindAroundObject( m_pOwner, TYPE_PLAYER, player_list );
// find the around monsters including the guards.
pRegion->FindAroundObject( m_pOwner, TYPE_MONSTER, monster_list );
// filter the result
Filter filter( static_cast<CMonster*>( m_pOwner ) );
filter_shape( player_list, filter );
filter_shape( monster_list, filter );
// retrieve the ai reference
DWORD ai_ref = pSelf->GetAIReferrence( 0 );
if( ai_ref >= 0 )
{
pTarget = SearchByAIRef1( player_list, ai_ref );
}
if( pTarget == NULL && ( ai_ref = pSelf->GetAIReferrence( 1 ) ) > 0 )
{
pTarget = SearchByAIRef2( player_list, ai_ref );
}
if( pTarget == NULL && ( ai_ref = pSelf->GetAIReferrence( 2 ) ) > 0 )
{
pTarget = SearchByAIRef3( monster_list, ai_ref );
}
if( pTarget == NULL && ( ai_ref = pSelf->GetAIReferrence( 3 ) ) > 0 )
{
pTarget = SearchByAIRef4( monster_list, ai_ref );
}
if( pTarget != NULL )
{
// search successfully
SetTarget( pTarget->GetType(), pTarget->GetExID() );
return TRUE;
}
else if( HasTarget() )
{
WhenLoseTarget();
}
return FALSE;
}