Exemplo n.º 1
0
void CHUDRadar::AddPlayer(HOBJECT hObj, uint32 nId)
{
	if (!hObj) return;
	CClientInfoMgr* pCIMgr = g_pInterfaceMgr->GetClientInfoMgr();
	CLIENT_INFO* pCI = pCIMgr->GetClientByID(nId);
	HOBJECT hLocalObj = g_pLTClient->GetClientObject();


	uint8 nTeamID = INVALID_TEAM;

	// Check for teams and only display players of the same team...
	if( IsTeamGameType() && hLocalObj != hObj)
	{
		CLIENT_INFO *pLocalCI = pCIMgr->GetLocalClient();
		if( !pLocalCI || !pCI )
			return;
	
		if( pLocalCI->nTeamID != pCI->nTeamID )
			return;

		nTeamID = pCI->nTeamID;

	}
	

	bool bDead = false;

	if (hLocalObj != hObj)
	{

		AddObject( hObj, RADAR_PLAYER_ALIVE_TYPE, nTeamID );
		
	}

	CCharacterFX *pCharacter = g_pGameClientShell->GetSFXMgr()->GetCharacterFX(hObj);
	if (pCharacter && pCharacter->IsPlayerDead())
	{
		bDead = true;
	}


	RadarPlayerList::iterator iter = m_Players.begin();
	while (iter != m_Players.end() &&  ( (*iter)->hObj != hObj ) )
	{
		iter++;
	}

	RADAR_PLAYER_OBJ* pPlayer = NULL;

	//new player...
	if (iter == m_Players.end())
	{
		pPlayer = debug_new(RADAR_PLAYER_OBJ);
		m_Players.push_back(pPlayer);
	}
	else
	{
		pPlayer = (*iter);
	}

	pPlayer->nID = nId;
	pPlayer->hObj = hObj;
	
	if (!pPlayer->pName)
	{
		uint8 nFont = 0;
		CUIFont* pFont = g_pInterfaceResMgr->GetFont(nFont);
		pPlayer->pName = g_pFontManager->CreateFormattedPolyString(pFont,"",0.0f,0.0f);
		pPlayer->pName->SetAlignmentH(CUI_HALIGN_RIGHT);
	}

	if (pCI)
	{
		pPlayer->pName->SetText(pCI->sName.c_str());
	}

	SetPlayerDead(hObj,bDead);
	
	UpdateNamePositions();
}
Exemplo n.º 2
0
// ----------------------------------------------------------------------- //
//
//	ROUTINE:	CAutoTargetMgr::GenerateCharArray()
//
//	PURPOSE:	Fill array with list of chars sorted by distance
//
// ----------------------------------------------------------------------- //
void CAutoTargetMgr::GenerateCharArray()
{
	//clear our target array
	m_Targets.resize(0);

	CSFXMgr* psfxMgr = g_pGameClientShell->GetSFXMgr();

	//step through the chars
	CSpecialFXList* const pCharList = psfxMgr->GetFXList(SFX_CHARACTER_ID);	
	int nNumSFX  = pCharList->GetSize();
	
	for (int nChar=0; nChar < nNumSFX; nChar++)
	{
		CCharacterFX* pChar = (CCharacterFX*)(*pCharList)[nChar];
		if (pChar)
		{
			if (pChar->m_cs.bIsPlayer)
			{
				//filter out local player
			    HLOCALOBJ hPlayerObj = g_pLTClient->GetClientObject();
			    if (hPlayerObj == pChar->GetServerObj())
					continue;
				if(pChar->IsPlayerDead())
					continue;

				//if this is a team game filter out our teammates
				if (GameModeMgr::Instance( ).m_grbUseTeams )
				{
					// Get the client information of the body and us.
					uint32 nId = pChar->m_cs.nClientID;
					CClientInfoMgr* pCIMgr = g_pInterfaceMgr->GetClientInfoMgr();
					CLIENT_INFO* pCI = pCIMgr->GetClientByID(nId);
					CLIENT_INFO *pLocalCI = g_pInterfaceMgr->GetClientInfoMgr()->GetLocalClient();

					// Only allow us to auto-target people on the other team.
					if( pCI && pLocalCI )
					{
						if (pCI->nTeamID == pLocalCI->nTeamID)
							continue;
					}

				}
			}
			else
			{
				// Check alignment of non-players
				if(pChar->m_cs.eCrosshairPlayerStance != kCharStance_Hate)
					continue;
			}

			//filter out anyone outside the cone
			LTVector vTargetPos;
			g_pLTClient->GetObjectPos(pChar->GetServerObj(), &vTargetPos);
			LTVector vOffset(0.0f,32.0f,0.0f);

			// we check both upper and lower parts of the body and if either is in the cone, we're good
			if (IsPointInCone( vTargetPos - vOffset) || IsPointInCone( vTargetPos + vOffset) )
			{
				// we only care about the n closest characters, so...
				// if the new one farther away than the n-th one, drop it, 
				//	otherwise drop the n-th one and insert the new one
			
				//step through the chars we already know about...
				CharFXArray::iterator iter = m_Targets.begin();
				bool bInserted = false;
				while (iter != m_Targets.end() && !bInserted)
				{
					//figure out how far away this one is
					CCharacterFX* pTestChar = (CCharacterFX*)(*iter);
					LTVector vTestPos;
					g_pLTClient->GetObjectPos(pTestChar->GetServerObj(), &vTestPos);
					float fTestDistSqr = m_vFirePos.DistSqr(vTestPos);

					//if this char is farther away than the one we're inserting
					if (fTestDistSqr > m_fRangeSqr)
					{
						//if our list is full, pop off the last one...
						if (m_Targets.size() >= MAX_AUTOTARGET_CHARACTERS)
							m_Targets.pop_back();

						m_Targets.insert(iter,pChar);
						bInserted = true;
					}

					iter++;
				}

				//if we haven't inseted it yet, and we have room, add it to the back
				if (!bInserted && m_Targets.size() < MAX_AUTOTARGET_CHARACTERS)
					m_Targets.push_back(pChar);
			}
		}

	}

}
Exemplo n.º 3
0
void CTriggerFX::CheckPlayersWithinTrigger()
{
	if( m_cs.bLocked )
		return;

	// Get a list of all the characters...

	CSpecialFXList *pList = g_pGameClientShell->GetSFXMgr()->GetFXList( SFX_CHARACTER_ID );
	if( !pList )
		return;

	int nListSize = pList->GetSize();
	int nNumChars = pList->GetNumItems();
	int nNumFoundChars = 0;
	int nNumPlayersFound = 0;
	uint32 dwLocalId = 0;

	g_pLTClient->GetLocalClientID( &dwLocalId );

	LTVector vTrigPos, vPlayerPos, vPlayerDims, vPlayerMin, vPlayerMax;
	g_pLTClient->GetObjectPos( m_hServerObject, &vTrigPos );

	// Setup the triggers box...
	
	LTVector vTrigMin = vTrigPos - m_cs.vDims;
	LTVector vTrigMax = vTrigPos + m_cs.vDims;

	bool bLocalPlayerIn = false;
	
	// Initialize our containers to zero.  Don't call clear, since we'll be using
	// these vectors every frame and most likely they will have the same
	// number of elements across multiple frames.
	m_lstPlayersNotInTrigger.resize( 0 );
	m_lstNewPlayersInTrigger.resize( 0 );

	for( int i = 0; i < nListSize; ++i )
	{
		// Try not to go through the entire list...

		if( nNumFoundChars == nNumChars )
			break;

		if( (*pList)[i] )
		{
			CCharacterFX *pChar = (CCharacterFX*)(*pList)[i];
			if( !pChar )
				continue;

			// Found another char..
			++nNumFoundChars;

			if( pChar->m_cs.bIsPlayer && pChar->m_cs.nClientID != ( uint8 )-1 )
			{
				++nNumPlayersFound;
				
				HOBJECT hPlayer = pChar->GetServerObj();

				g_pLTClient->GetObjectPos( hPlayer, &vPlayerPos );
				g_pPhysicsLT->GetObjectDims( hPlayer, &vPlayerDims );

				vPlayerMin = vPlayerPos - vPlayerDims;
				vPlayerMax = vPlayerPos + vPlayerDims;

				// Check the current list of players in the trigger for this player...
					
				CharFXList::iterator iter;
				for( iter = m_lstCurPlayersInTrigger.begin(); iter != m_lstCurPlayersInTrigger.end(); ++iter )
				{
					if( pChar == (*iter) )
						break;
				}

				// Check if we are within the height of the trigger...

				bool bWithinHeight = false;
				if( vPlayerMax.y > vTrigMin.y && vPlayerMin.y < vTrigMax.y )
					bWithinHeight = true;

				if( bWithinHeight && BoxesIntersect( vTrigMin, vTrigMax, vPlayerMin, vPlayerMax ) && !pChar->IsPlayerDead())
				{
					if( dwLocalId == pChar->m_cs.nClientID )
						bLocalPlayerIn = true;

					// If it wasn't in the list add it...

					if( iter == m_lstCurPlayersInTrigger.end() )
					{
						m_lstCurPlayersInTrigger.push_back( pChar );
						m_lstNewPlayersInTrigger.push_back( pChar );
					}

				}
				else
				{
					if( iter != m_lstCurPlayersInTrigger.end() )
						m_lstCurPlayersInTrigger.erase( iter );

					m_lstPlayersNotInTrigger.push_back( pChar );
				}
			}
		}
	}

	wchar_t wszBuffer[256];

	if( (m_lstNewPlayersInTrigger.size() > 0) && (nNumPlayersFound > 1) )
	{
		CClientInfoMgr *pInfoMgr = g_pInterfaceMgr->GetClientInfoMgr();
		if( !pInfoMgr )
			return;

		if( bLocalPlayerIn )
		{
			// Display a general transmission and messages for each player you are waiting for...

			int nPlayersNotInTrig = m_lstPlayersNotInTrigger.size();

			if( m_cs.nPlayerInsideID != (uint32)-1 )
			{
				g_pTransmission->Show( StringIDFromIndex(m_cs.nPlayerInsideID) );
			}
			else if( nPlayersNotInTrig > 1 )
			{
				//sTransmission.Format( "You are waiting for %i players.", nPlayersNotInTrig );
				FormatString( "IDS_EXIT_PLAYER_WAITING", wszBuffer, LTARRAYSIZE(wszBuffer), nPlayersNotInTrig );
				g_pTransmission->Show( wszBuffer );
			}
			else
			{
				//sTransmission.Format( "You are waiting for 1 player." );
				FormatString( "IDS_EXIT_PLAYER_WAITING_1", wszBuffer, LTARRAYSIZE(wszBuffer) );
				g_pTransmission->Show( wszBuffer );
			}		
			
			
			CharFXList::iterator iter;
			for( iter = m_lstPlayersNotInTrigger.begin(); iter != m_lstPlayersNotInTrigger.end(); ++iter )
			{
				//sMessage.Format( "You are waiting for %s.", pInfoMgr->GetPlayerName( (*iter)->m_cs.nClientID ));
				FormatString( "IDS_EXIT_PLAYER_WAITING_NAME", wszBuffer, LTARRAYSIZE(wszBuffer), pInfoMgr->GetPlayerName( (*iter)->m_cs.nClientID) );
				g_pGameMsgs->AddMessage( wszBuffer );
			}
		}
		else
		{
			// Display a general transmission and messages for each player waiting for you...

			int nPlayersInTrig = m_lstCurPlayersInTrigger.size();
			
			if( m_cs.nPlayerOutsideID != (uint32)-1 )
			{
				g_pTransmission->Show( LoadString(m_cs.nPlayerOutsideID) );
			}
			else if( nPlayersInTrig > 1 )
			{
//				sTransmission.Format( "%i players are waiting for you",nPlayersInTrig  );
				FormatString( "IDS_EXIT_WAITING", wszBuffer, LTARRAYSIZE(wszBuffer), nPlayersInTrig );
				g_pTransmission->Show( wszBuffer );
			}
			else
			{
//				sTransmission.Format( "1 player is waiting for you." );
				FormatString( "IDS_EXIT_WAITING_1", wszBuffer, LTARRAYSIZE(wszBuffer) );
				g_pTransmission->Show( wszBuffer );
			}
			

			CharFXList::iterator iter;
			for( iter = m_lstCurPlayersInTrigger.begin(); iter != m_lstCurPlayersInTrigger.end(); ++iter )
			{
				FormatString( "IDS_EXIT_WAITING_NAME", wszBuffer, LTARRAYSIZE(wszBuffer), pInfoMgr->GetPlayerName( (*iter)->m_cs.nClientID) );
				g_pGameMsgs->AddMessage( wszBuffer );	
			}
		}
	}
}
Exemplo n.º 4
0
void CHUDScoreDiff::Update()
{
	if (!IsMultiplayerGameClient()) return;

	if (GameModeMgr::Instance( ).m_grbEliminationWin)
	{
		CClientInfoMgr *pCIMgr = g_pGameClientShell->GetInterfaceMgr( )->GetClientInfoMgr();
		if (!pCIMgr) return;

		CLIENT_INFO* pCI = pCIMgr->GetFirstClient();

		int32 nEnemiesLeft = 0;
		while (pCI)
		{
			if (pCI && pCI != g_pInterfaceMgr->GetClientInfoMgr()->GetLocalClient())
			{
				CCharacterFX* pCharacter = g_pGameClientShell->GetSFXMgr()->GetCharacterFromClientID(pCI->nID);
				if (pCharacter &&  !pCharacter->IsPlayerDead() && !pCharacter->m_cs.bIsSpectating )
				{
					if (GameModeMgr::Instance( ).m_grbUseTeams)
					{
						if (!pCIMgr->IsLocalTeam(pCI->nTeamID)) 
						{
							++nEnemiesLeft;
						}
					}
					else
					{
						++nEnemiesLeft;
					}
				}
			}
			pCI = pCI->pNext;
		}
		wchar_t wsScore[16] = L"";
		FormatString("HUD_Score_Format",wsScore,LTARRAYSIZE(wsScore),nEnemiesLeft);
		m_Text.SetText(wsScore);
		m_Text.SetColor(m_cTextColor);
	}
	else
	{
		int32 nLocalScore = 0;
		int32 nOtherScore = 0;
		if (GameModeMgr::Instance( ).m_grbUseTeams)
		{
			uint8 nTeam = g_pInterfaceMgr->GetClientInfoMgr()->GetLocalTeam();
			CTeam* pTeam = CTeamMgr::Instance().GetTeam(nTeam);
			if (pTeam)
			{
				nLocalScore = pTeam->GetScore();
			}

			nTeam = 1-nTeam;
			pTeam = CTeamMgr::Instance().GetTeam(nTeam);
			if (pTeam)
			{
				nOtherScore = pTeam->GetScore();
			}
		}
		else
		{
			CLIENT_INFO* pCI = g_pInterfaceMgr->GetClientInfoMgr()->GetLocalClient();
			if (pCI)
			{
				nLocalScore = pCI->sScore.GetScore();
			}

			pCI = g_pInterfaceMgr->GetClientInfoMgr()->GetFirstClient();
			if (pCI && pCI == g_pInterfaceMgr->GetClientInfoMgr()->GetLocalClient())
			{
				pCI = pCI->pNext;
			}
			if (pCI)
			{
				nOtherScore = pCI->sScore.GetScore();
			}
		}
		wchar_t wsScore[16] = L"";
		int32 nDiff = (nLocalScore-nOtherScore);

		FormatString("HUD_Score_Format",wsScore,LTARRAYSIZE(wsScore),nDiff);
		if (nDiff > 0)
		{
			m_Text.SetColor(m_cWinningTextColor);
			FormatString("HUD_Score_Format_Advantage",wsScore,LTARRAYSIZE(wsScore),nDiff);
		}
		else if (nDiff == 0)
		{
			m_Text.SetColor(m_cTextColor);
		}
		else
		{
			m_Text.SetColor(m_cLosingTextColor);
		}

		m_Text.SetText(wsScore);

	}

}
Exemplo n.º 5
0
void CHUDScores::Update()
{
    if( !m_bInitialized )
        return;

    if( !m_bDraw )
        return;

//	uint32 textCol = (m_bScreen ? m_cScreenTextColor : m_cTextColor);
//	uint32 playerTextCol = (m_bScreen ? m_cScreenPlayerTextColor : m_cPlayerTextColor);

    //for the screen mode scoreboard, don't update the text once we've drawn it
    if (m_bScreen && !m_bFirstScreenUpdate)
        return;

    m_bFirstScreenUpdate = false;

    if (GameModeMgr::Instance( ).m_grbUseTeams)
    {
        for( uint8 nTeamNum = 0; nTeamNum < kNumTeams; ++nTeamNum )
        {
            uint8 team;
            if (g_pInterfaceMgr->GetClientInfoMgr()->IsLocalTeam(nTeamNum))
                team = 0;
            else
                team = 1;

            CTeam* pTeam = CTeamMgr::Instance().GetTeam(nTeamNum);
            if (!pTeam) continue;

            wchar_t wszTmp[128];
            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%s : %d",pTeam->GetName(),pTeam->GetScore());
            m_Team[team].SetString(wszTmp);

            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%s : %d", LoadString("IDS_ROUNDS"), pTeam->GetRoundScore( ));
            m_Rounds[team].SetString(wszTmp);

            m_Header[team].Show(true);
        }

    }
    else
    {
        m_Team[0].SetString(L"");
        m_Rounds[0].SetString(L"");
        m_Header[1].Show(false);
    }


    m_Server.SetColor(m_cTextColor);

    if ( !GameModeMgr::Instance( ).m_grwsSessionName.GetValue().empty())
    {
        std::wstring wstr = GameModeMgr::Instance( ).m_grwsSessionName;
        if ( g_pClientConnectionMgr->IsConnectedToRemoteServer( ))
        {
            wstr += L" : ";
            wstr += MPA2W(g_pClientConnectionMgr->GetStartGameRequest( ).m_TCPAddress).c_str();
        }

        m_Server.SetString(wstr.c_str());
    }
    else
    {
        m_Server.SetString(L"");
    }

    // Update the round counter.
    m_RoundInfo.SetColor(m_cTextColor);
    wchar_t wszRound[32];
    uint8 nCurrentRound = g_pClientConnectionMgr ? g_pClientConnectionMgr->GetCurrentRound() : 0;
    uint8 nNumRounds = GameModeMgr::Instance( ).m_grnNumRounds;
    FormatString( "HUD_SCORES_ROUNDINFO", wszRound, LTARRAYSIZE( wszRound ), nCurrentRound + 1, nNumRounds );
    m_RoundInfo.SetString( wszRound );

    CClientInfoMgr *pCIMgr = g_pGameClientShell->GetInterfaceMgr( )->GetClientInfoMgr();
    if (!pCIMgr) return;

    CLIENT_INFO* pCI = pCIMgr->GetFirstClient();
    int nTotal = 0;
    int count[kNumTeams] = {0,0};
    wchar_t wszTmp[64] = L"";
    uint32 nHeight[kNumTeams];
    nHeight[0] = m_Server.GetBaseHeight() + m_Header[0].GetBaseHeight() + m_Team[0].GetBaseHeight() + 24;
    nHeight[1] = m_Team[1].GetBaseHeight() + m_Header[1].GetBaseHeight() + 16;
    uint32 nLocalID = 0;
    g_pLTClient->GetLocalClientID (&nLocalID);


    while (pCI && (nTotal < kMaxPlayers))
    {
        uint8 nTeam = 0;
        CCharacterFX* pCharacter = g_pGameClientShell->GetSFXMgr()->GetCharacterFromClientID(pCI->nID);

        if (GameModeMgr::Instance( ).m_grbUseTeams)
        {
            if (g_pInterfaceMgr->GetClientInfoMgr()->IsLocalTeam(pCI->nTeamID))
                nTeam = 0;
            else
                nTeam = 1;
        }


        int ndx = count[nTeam];



        if (nTeam < kNumTeams)
        {
            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%s%s",pCI->sName.c_str( ), pCI->bIsAdmin ? L"[*]" : L"" );
            m_Columns[nTeam][ndx].SetString( eColumnName, wszTmp );

            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetScore());
            m_Columns[nTeam][ndx].SetString( eColumnScore, wszTmp );

            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eKill));
            m_Columns[nTeam][ndx].SetString( eColumnKill, wszTmp );

            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eDeath));
            m_Columns[nTeam][ndx].SetString( eColumnDeath, wszTmp );

            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eObjective));
            m_Columns[nTeam][ndx].SetString( eColumnObjective, wszTmp );

            if (GameModeMgr::Instance( ).m_grbUseTeams)
            {
                LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eTeamKill));
                m_Columns[nTeam][ndx].SetString( eColumnTK, wszTmp );
                m_Columns[nTeam][ndx].ShowColumn(eColumnTK, true);
            }
            else
            {
                m_Columns[nTeam][ndx].ShowColumn(eColumnTK, false);
            }


            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eSuicide));
            m_Columns[nTeam][ndx].SetString( eColumnSuicide, wszTmp );

            LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->nPing);
            m_Columns[nTeam][ndx].SetString( eColumnPing, wszTmp );

            if (nLocalID == pCI->nID)
            {
                if (!pCharacter || pCharacter->IsPlayerDead() || pCharacter->m_cs.bIsSpectating )
                    m_Columns[nTeam][ndx].SetColor(m_cPlayerDeadColor);
                else
                    m_Columns[nTeam][ndx].SetColor(m_cPlayerTextColor);
            }
            else
            {
                if (!pCharacter || pCharacter->IsPlayerDead() || pCharacter->m_cs.bIsSpectating )
                    m_Columns[nTeam][ndx].SetColor(m_cDeadColor);
                else
                    m_Columns[nTeam][ndx].SetColor(m_cTextColor);
            }

            m_Columns[nTeam][ndx].Show(true);

            nHeight[nTeam] += m_Columns[nTeam][ndx].GetBaseHeight();
        }

        pCI = pCI->pNext;
        ++count[nTeam];
    }



    for (uint8 team = 0; team < kNumTeams; team++)
    {

        m_Team[team].SetColor(m_cTextColor);
        m_Rounds[team].SetColor(m_cTextColor);
        m_Header[team].SetColor(m_cTextColor);

        nHeight[team] += 16;
        m_Frame[team].SetSize(LTVector2n(m_nFrameWidth,nHeight[team]));

        while (count[team] < kMaxPlayers)
        {
            m_Columns[team][count[team]].Show(false);
            ++count[team];
        }

        LTVector2n pos = m_vBasePos;
        g_pInterfaceResMgr->ScaleScreenPos(pos);
        if (GameModeMgr::Instance( ).m_grbUseTeams && team > 0)
        {
            pos.y += nHeight[team-1] + 8;
        }
        UpdateTeamPos(team,pos);

    }
    m_SingleFrame.SetSize(LTVector2n(m_nFrameWidth,nHeight[0]+8));
}