Example #1
0
bool ChatHandler::HandleRangeCheckCommand( const char *args , WorldSession *m_session )
{
	WorldPacket data;
	uint64 guid = m_session->GetPlayer()->GetSelection();
	m_session->SystemMessage( "=== RANGE CHECK ===" );
	if (guid == 0)
	{
		m_session->SystemMessage("No selection imo.");
		return true;
	}

	Unit* unit = m_session->GetPlayer()->GetMapMgr()->GetUnit( guid );
	if(!unit)
	{
		m_session->SystemMessage("Invalid selection imo.");
		return true;
	}
	float DistSq = unit->GetDistanceSq( TO_OBJECT(m_session->GetPlayer()) );
	m_session->SystemMessage( "GetDistanceSq  :   %u" , FL2UINT( DistSq ) );
	LocationVector locvec( m_session->GetPlayer()->GetPositionX() , m_session->GetPlayer()->GetPositionY() , m_session->GetPlayer()->GetPositionZ() );
	float DistReal = unit->CalcDistance( locvec );
	m_session->SystemMessage( "CalcDistance   :   %u" , FL2UINT( DistReal ) );
	float Dist2DSq = unit->GetDistance2dSq( TO_OBJECT(m_session->GetPlayer()) );
	m_session->SystemMessage( "GetDistance2dSq:   %u" , FL2UINT( Dist2DSq ) );
	return true;
}
Example #2
0
bool ChatHandler::HandleRangeCheckCommand(const char* /*args*/, WorldSession* m_session)
{
    uint64 guid = m_session->GetPlayer()->GetSelection();
    if (!guid)
    {
        m_session->SystemMessage("No selection.");
        return false;
    }

    Unit* unit = m_session->GetPlayer()->GetMapMgr()->GetUnit(guid);
    if (!unit)
    {
        m_session->SystemMessage("Invalid selection.");
        return false;
    }

    float DistSq = unit->GetDistanceSq(m_session->GetPlayer());
    m_session->SystemMessage("GetDistanceSq  :   %u", float2int32(DistSq));
    LocationVector locvec(m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ());
    float DistReal = unit->CalcDistance(locvec);
    m_session->SystemMessage("CalcDistance   :   %u", float2int32(DistReal));
    float Dist2DSq = unit->GetDistance2dSq(m_session->GetPlayer());
    m_session->SystemMessage("GetDistance2dSq:   %u", float2int32(Dist2DSq));
    return true;
}