📄 field.cpp
字号:
}
*/
}
VOID Field::DestroyNearNPC( Object* pObject )
{
__UNUSED(pObject);
}
VOID Field::AddDeadNPCList( Object *pObject )
{
m_pDeadNPCList->Add( pObject );
}
VOID Field::Update( DWORD dwDeltaTick )
{
// 鞘靛俊 拱赴 冀磐甸 诀单捞飘
Sector *pSector; SectorGroup *pSectorGroup;
for( SECTORGROUP_ITERATOR it = m_pSectorGroupList->Begin(); it != m_pSectorGroupList->End(); ++it )
{
pSectorGroup = *it;
if( !pSectorGroup->IsReferenced() ) continue;
for( SECTOR_ITERATOR itr = pSectorGroup->Begin(); itr != pSectorGroup->End(); ++itr )
{
pSector = *itr;
pSector->Update( dwDeltaTick );
}
}
m_pRegenManager->Update();
m_pTriggerManager->Update();
// Effect甸 诀单捞飘
DWORD curTick = GetTickCount();
m_pEffectManager->Update( curTick );
// 磷篮 NPC 鞘靛俊辑 力芭
M_OBJECT_LIST_ITR it_object;
for( it_object = m_pDeadNPCList->begin(); it_object != m_pDeadNPCList->end(); ++it_object )
{
LeaveField( it_object->second );
ObjectFactory::Instance()->FreeObject( it_object->second );
}
m_pDeadNPCList->clear();
}
VOID Field::SendAIMessageAroundExceptMe( Object *pObject, AI_MSG *pMsg, WORD wSize, DWORD dwDelay )
{
if( !pObject ) return;
Sector *pSector = GetSector( pObject->GetSectorIndex() );
if( pSector )
{
pSector->SendAIMessageToSectorExceptMe( pObject, pMsg, wSize );
}
/// 坷宏璃飘啊 加茄 冀磐狼 牢立 冀磐甸俊霸 AIMessage 傈价
SectorInfo * pInfo = m_pFieldInfo->GetSectorInfo( pObject->GetSectorIndex() );
ASSERT( pInfo );
POS pos = pInfo->GetNeighborSectorInfoList().GetFirstPos();
SectorInfo * pNextInfo = NULL;
while( (pNextInfo = pInfo->GetNeighborSectorInfoList().GetNextPos( pos )) != NULL )
{
pSector = GetSector( pNextInfo->GetSectorIndex() );
if( !pSector ) continue;
pSector->SendAIMessageToSectorExceptMe( pObject, pMsg, wSize );
}
}
Character* Field::SearchTarget( NPC* pNPC, eTARGET_SEARCH_TYPE eSearchType, eSKILL_TARGET_TYPE eTargetType )
{
switch( eSearchType )
{
case eRARGET_SEARCH_LOW_HPRATIO:
{
LowHPRatioTargetFinder finder;
finder.SetOwner( pNPC );
finder.SetTargetType( eTargetType );
return SearchTarget( &finder );
}
break;
case eRARGET_SEARCH_LOW_HP:
{
LowHPTargetFinder finder;
finder.SetOwner( pNPC );
finder.SetTargetType( eTargetType );
return SearchTarget( &finder );
}
break;
case eRARGET_SEARCH_LOW_LEVEL:
{
LowLevelTargetFinder finder;
finder.SetOwner( pNPC );
finder.SetTargetType( eTargetType );
return SearchTarget( &finder );
}
break;
case eRARGET_SEARCH_HIGH_MP:
{
HighMPTargetFinder finder;
finder.SetOwner( pNPC );
finder.SetTargetType( eTargetType );
return SearchTarget( &finder );
}
break;
case eRARGET_SEARCH_CORPSE:
{
DeadTargetFinder finder;
finder.SetOwner( pNPC );
finder.SetTargetType( eTargetType );
return SearchTarget( &finder );
}
break;
default:
{
NearestTargetFinder finder;
finder.SetOwner( pNPC );
finder.SetTargetType( eTargetType );
return SearchTarget( &finder );
}
}
}
Character* Field::SearchTarget( TargetFinder *pFinder )
{
Character *pTarget;
if( rand() % 3 )
{
pTarget = SearchPlayer( *pFinder );
if( !pTarget ) pTarget = SearchNPC( *pFinder );
}
else
{
pTarget = SearchNPC( *pFinder );
if( !pTarget ) pTarget = SearchPlayer( *pFinder );
}
return pTarget;
}
VOID Field::KillAllNPC( Player* pPlayer, BOOL bIsDrop )
{
NPC *pNPC;
for( M_OBJECT_LIST_ITR it = m_pNPCList->begin(); it != m_pNPCList->end(); ++it )
{
pNPC = (NPC*)(it->second);
KillNPC( pPlayer, pNPC, bIsDrop );
}
}
// 1疙狼 NPC甫 力芭茄促.
// pPlayer 磷捞绰 USER
// pNPC 磷捞妨绰 NPC
BOOL Field::KillNPC( Player* pPlayer, NPC* pNPC, BOOL bIsDrop )
{
if( !pPlayer || !pNPC ) return FALSE;
if( !pNPC->IsAlive() ) return FALSE;
DAMAGETYPE wDamage = (DAMAGETYPE)pNPC->GetMaxHP();
// 沥惑利栏肺 版氰摹, 酒捞袍盒硅甫 贸府茄促搁,
if( bIsDrop )
{
pNPC->Damaged( pPlayer, eATTACK_TYPE_MELEE, wDamage );
pNPC->OnDead();
}
// 窜鉴洒 NPC甫 磷捞妨绊 茄促搁,
else
{
pNPC->SetHP( 0 );
pNPC->StopMoving();
// pNPC->DecreaseHP( wDamage );
AddDeadNPCList(pNPC);
}
// 磊脚阑 器窃茄 牢立 敲饭捞绢俊霸 宏肺靛 某胶飘
MSG_CG_BATTLE_PLAYER_ATTACK_BRD sendMsg;
sendMsg.dwClientSerial = 0;
pPlayer->GetPos( &sendMsg.wvCurPos );
pPlayer->GetPos( &sendMsg.wvDestPos );
sendMsg.dwAttackerKey = pPlayer->GetObjectKey();
sendMsg.byAttackType = eATTACK_SEQUENCE_FIRST;
sendMsg.dwTargetKey = pNPC->GetObjectKey();
sendMsg.wDamage = wDamage;
sendMsg.dwTargetHP = pNPC->GetHP();
sendMsg.byEffect = 0; // GM疙飞绢肺 磷捞绰 巴捞瘤父 捞 蔼俊 措茄 技泼阑 秦林绢具 窃!!(20060115)
pPlayer->SendPacketAround( (MSG_BASE_FORWARD*)&sendMsg, sizeof(sendMsg) );
return TRUE;
}
BYTE Field::FindTargetsByAttacker( eSKILL_TARGET_TYPE eTargetType, Character* pAttacker, Character** pTargetArray,
WzVector &vMainTargetPos, float fRange, unsigned int uiRangeForm,
float fArea, BYTE byCountLimit, DWORD dwExceptTargetKey )
{
BYTE byCount = 0;
if( !pAttacker )
{
SUNLOG( eCRITICAL_LOG, "[Field::FindTargetsByAttacker] pAttacker is NULL!" );
return 0;
}
// pTargetArray俊绰 MainTarget档 器窃等促.
Sector *pSector = GetSector( pAttacker->GetSectorIndex() );
if( !pSector )
{
SUNLOG( eCRITICAL_LOG, "[Field::FindTargetsByAttacker] Invalid SectorIndex[%d/%d]", pAttacker->GetSectorIndex(), m_vecTotalSector.size() );
return 0;
}
byCount = pSector->FindTargetsByAttacker( eTargetType, pAttacker, pTargetArray, vMainTargetPos,
fRange, uiRangeForm, fArea, byCountLimit, dwExceptTargetKey );
/// 坷宏璃飘啊 加茄 冀磐狼 牢立 冀磐甸俊霸 菩哦 傈价
SectorInfo * pInfo = m_pFieldInfo->GetSectorInfo( pAttacker->GetSectorIndex() );
if( !pInfo ) return byCount;
POS pos = pInfo->GetNeighborSectorInfoList().GetFirstPos();
SectorInfo * pNextInfo = NULL;
while( (pNextInfo = pInfo->GetNeighborSectorInfoList().GetNextPos( pos )) != NULL )
{
pSector = GetSector( pNextInfo->GetSectorIndex() );
if( !pSector ) continue;
byCount += pSector->FindTargetsByAttacker( eTargetType, pAttacker, &pTargetArray[byCount],
vMainTargetPos, fRange, uiRangeForm, fArea, byCountLimit-byCount, dwExceptTargetKey );
if( byCount >= MAX_TARGET_NUM )
{
return byCount;
}
}
return byCount;
}
BYTE Field::FindTargetsByPosition( Character** pTargetArray, DWORD dwSectorIndex, WzVector &vMainPos, float fRange, BYTE byCountLimit )
{
BYTE byCount = 0;
Sector *pSector = GetSector( dwSectorIndex );
if( !pSector )
{
SUNLOG( eCRITICAL_LOG, "[Field::FindTargetsByPosition] Invalid SectorIndex[%d/%d]", dwSectorIndex, m_vecTotalSector.size() );
return 0;
}
byCount = pSector->FindTargetsByPosition( pTargetArray, vMainPos, fRange, byCountLimit );
/// 坷宏璃飘啊 加茄 冀磐狼 牢立 冀磐甸俊霸 菩哦 傈价
SectorInfo * pInfo = m_pFieldInfo->GetSectorInfo( dwSectorIndex );
if( !pInfo ) return byCount;
POS pos = pInfo->GetNeighborSectorInfoList().GetFirstPos();
SectorInfo * pNextInfo = NULL;
while( (pNextInfo = pInfo->GetNeighborSectorInfoList().GetNextPos( pos )) != NULL )
{
pSector = GetSector( pNextInfo->GetSectorIndex() );
if( !pSector ) continue;
byCount += pSector->FindTargetsByPosition( &pTargetArray[byCount], vMainPos, fRange, byCountLimit-byCount );
if( byCount >= MAX_TARGET_NUM )
{
return byCount;
}
}
return byCount;
}
ObjectGroup* Field::AllocGroup( DWORD dwAreaID, DWORD dwGroupID )
{
return m_pObjectGroupManager->AllocGroup( dwAreaID, dwGroupID );
}
BOOL Field::RemoveGroup( ObjectGroup *pGroup )
{
return m_pObjectGroupManager->RemoveGroup( pGroup );
}
ObjectGroup* Field::FindGroup( DWORD dwAreaID, DWORD dwGroupID )
{
return m_pObjectGroupManager->FindGroup( dwAreaID, dwGroupID );
}
ObjectGroup* Field::FindGroup( DWORD64 dwGroupKey )
{
return m_pObjectGroupManager->FindGroup( dwGroupKey );
}
BaseEffect* Field::AllocEffect( eFIELDEFFECT_TYPE eEffectType )
{
return m_pEffectManager->AllocEffect( eEffectType );
}
VOID Field::SetActiveRoom()
{
if( !m_pFieldInfo )
{
SUNLOG( eCRITICAL_LOG, "[SetActiveRoom] m_pFieldInfo is NULL" );
return;
}
if( !m_pFieldInfo->GetWorldBase() )
{
SUNLOG( eCRITICAL_LOG, "[SetActiveRoom] GetWorldBase is NULL" );
return;
}
if( !m_pFieldInfo->GetWorldBase()->x_pRoomManager )
{
SUNLOG( eCRITICAL_LOG, "[SetActiveRoom] x_pRoomManager is NULL" );
return;
}
m_pFieldInfo->GetWorldBase()->x_pRoomManager->SetActiveRoom( GetRIndex() );
}
DWORD Field::GetPlayerNum()
{
DWORD TotalNum = 0;
Sector *pSector; SectorGroup *pSectorGroup;
for( SECTORGROUP_ITERATOR it = m_pSectorGroupList->Begin(); it != m_pSectorGroupList->End(); ++it )
{
pSectorGroup = *it;
if( !pSectorGroup->GetReferenceCount() ) continue;
for( SECTOR_ITERATOR itr = pSectorGroup->Begin(); itr != pSectorGroup->End(); ++itr )
{
pSector = *itr;
TotalNum += pSector->GetPlayerNum();
}
}
return TotalNum;
}
VOID Field::IncreasePlayerReferenceCount( DWORD dwSectorIndex, Object *pObject )
{
if( ( pObject->GetObjectType() & PLAYER_OBJECT ) != PLAYER_OBJECT ) return;
Sector *pSector = GetSector( dwSectorIndex );
if( !pSector ) return;
// 冀磐狼 ReferenceCount甫 疵赴促.
pSector->IncreaseReferencePlayer( pObject );
// 冀磐啊 加茄 弊缝狼 ReferenceCount甫 疵赴促.
SectorGroup *pSectorGroup = m_pSectorGroupList->GetGroup( pSector->GetGroupIndex() );
if( !pSectorGroup ) return;
pSectorGroup->SetReferenceCount( pSectorGroup->GetReferenceCount() + 1 );
}
VOID Field::DecreasePlayerReferenceCount( DWORD dwSectorIndex, Object *pObject )
{
if( ( pObject->GetObjectType() & PLAYER_OBJECT ) != PLAYER_OBJECT ) return;
Sector *pSector = GetSector( dwSectorIndex );
if( !pSector ) return;
// 冀磐狼 ReferenceCount甫 临牢促.
pSector->DecreaseReferencePlayer( pObject );
// 冀磐啊 加茄 弊缝狼 ReferenceCount甫 临牢促.
SectorGroup *pSectorGroup = m_pSectorGroupList->GetGroup( pSector->GetGroupIndex() );
if( !pSectorGroup ) return;
pSectorGroup->SetReferenceCount( pSectorGroup->GetReferenceCount() - 1 );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -