Esempio n. 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);
}
Esempio n. 2
0
/**
* @brief	Constructs an in/out packet for the NPC.
*
* @param	result	The packet buffer the constructed packet will be stored in.
* @param	bType 	The type (in or out).
*/
void CNpc::GetInOut(Packet & result, uint8 bType)
{
	result.Initialize(WIZ_NPC_INOUT);
	result << bType << GetID();
	if (bType != INOUT_OUT)
		GetNpcInfo(result);
}
Esempio n. 3
0
void CNpc::InsertRegion(int del_x, int del_z)
{
	int send_index = 0, buff_index = 0, i=0;
	int region_x = -1, region_z = -1;
	char buff[128];
	memset( buff, NULL, 128 );
	C3DMap* pMap = GetMap();
	if (pMap == NULL)
		return;

	SetByte( buff, WIZ_NPC_INOUT, send_index );
	SetByte( buff, NPC_IN, send_index );

	GetNpcInfo(buff, send_index);

	if( del_x != 0 ) {
		m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+del_x, m_sRegion_Z-1 );
		m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+del_x, m_sRegion_Z );
		m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+del_x, m_sRegion_Z+1 );
	}
	if( del_z != 0 ) {
		m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X, m_sRegion_Z+del_z );
		
		if( del_x < 0 )	{
			m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+1, m_sRegion_Z+del_z );
		}
		else if( del_x > 0 ) {
			m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X-1, m_sRegion_Z+del_z );
		}
		else {
			m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X-1, m_sRegion_Z+del_z );
			m_pMain->Send_UnitRegion( buff, send_index, GetMap(), m_sRegion_X+1, m_sRegion_Z+del_z );
		}
	}
}