Example #1
0
void CNpc::NpcInOut(BYTE Type, float fx, float fz, float fy)
{
	int send_index = 0;
	char buff[1024];
	memset( buff, 0x00, 1024 );

	C3DMap *pMap = m_pMain->GetZoneByID(getZoneID());
	if (pMap == NULL)
		return;

	m_pMap = pMap;

	if( Type == NPC_OUT )
	{
		pMap->RegionNpcRemove( m_sRegion_X, m_sRegion_Z, m_sNid );
	}
	else	
	{
		pMap->RegionNpcAdd( m_sRegion_X, m_sRegion_Z, m_sNid );
		m_fCurX = fx;	m_fCurZ = fz;	m_fCurY = fy;
	}

	SetByte( buff, WIZ_NPC_INOUT, send_index );
	SetByte( buff, Type, send_index );
	SetShort( buff, m_sNid, send_index );
	if( Type == NPC_OUT ) {
		m_pMain->Send_Region(buff, send_index, GetMap(), m_sRegion_X, m_sRegion_Z);
		return;
	}

	GetNpcInfo(buff, send_index);
	m_pMain->Send_Region(buff, send_index, GetMap(), m_sRegion_X, m_sRegion_Z);
}
Example #2
0
void CNpc::RegisterRegion()
{
	int iRegX = 0, iRegZ = 0, old_region_x = 0, old_region_z = 0;
	iRegX = (int)(m_fCurX / VIEW_DISTANCE);
	iRegZ = (int)(m_fCurZ / VIEW_DISTANCE);

	if (m_sRegion_X != iRegX || m_sRegion_Z != iRegZ)
	{
		C3DMap* pMap = GetMap();
		if (pMap == NULL)
			return;
		
		old_region_x = m_sRegion_X;	old_region_z = m_sRegion_Z;
		pMap->RegionNpcRemove(m_sRegion_X, m_sRegion_Z, m_sNid);
		m_sRegion_X = iRegX;		m_sRegion_Z = iRegZ;
		pMap->RegionNpcAdd(m_sRegion_X, m_sRegion_Z, m_sNid);

		RemoveRegion( old_region_x - m_sRegion_X, old_region_z - m_sRegion_Z );	// delete npc 는 계산 방향이 진행방향의 반대...
		InsertRegion( m_sRegion_X - old_region_x, m_sRegion_Z - old_region_z );	// add npc 는 계산 방향이 진행방향...
	}
}