bool CASW_Hud_Squad_Hotbar::ShouldDraw( void )
{
	if ( !ASWGameResource() )
		return false;

	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return false;

	if ( asw_hotbar_self.GetBool() )
	{
		return asw_draw_hud.GetBool() && CASW_HudElement::ShouldDraw();
	}

	m_iNumMarines = 0;
	for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource* pMR = ASWGameResource()->GetMarineResource( i );
		if ( !pMR )
			continue;

		if ( pMR->GetCommander() != pPlayer )
			continue;

		C_ASW_Marine *pMarine = pMR->GetMarineEntity();
		if ( !pMarine )
			continue;

		m_iNumMarines++;
	}

	return m_iNumMarines > 1 && asw_draw_hud.GetBool() && CASW_HudElement::ShouldDraw();
}
void MissionCompleteStatsLine::UpdateLabels()
{
	C_ASW_Game_Resource* pGameResource = ASWGameResource();
	if (!pGameResource)
		return;

	if (m_iMarineIndex <0 || m_iMarineIndex>=pGameResource->GetMaxMarineResources())
	{
		m_pNameLabel->SetText("");
		m_pMedalArea->SetMarineResource(NULL);
		Q_snprintf(m_szCurrentName, sizeof(m_szCurrentName), "");
		return;	
	}
	
	C_ASW_Marine_Resource* pMR = pGameResource->GetMarineResource(m_iMarineIndex);
	if (m_pMedalArea)
		m_pMedalArea->SetMarineResource(pMR);
	if (pMR)
	{
		if ( pMR->GetProfile() && Q_strcmp( pMR->GetProfile()->m_ShortName, m_szCurrentName ) )
		{
			m_pNameLabel->SetText(pMR->GetProfile()->m_ShortName);
			Q_snprintf(m_szCurrentName, sizeof(m_szCurrentName), "%s", pMR->GetProfile()->m_ShortName);
		}
		SetBgColor(m_pBGColor);
	}
	else
	{
		m_pNameLabel->SetText("");
	}

	// todo: reset stats bars
}
Esempio n. 3
0
void C_ASW_Alien::GetShadowFromFlashlight(Vector &vecDir, float &fContribution) const
{
	if (gpGlobals->framecount == m_iLastCustomFrame)
	{
		return;
	}
	
	if ( ASWGameResource() )
	{
		// go through all marines
		int iMaxMarines = ASWGameResource()->GetMaxMarineResources();
		for (int i=0;i<iMaxMarines;i++)
		{
			C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource(i);
			C_ASW_Marine *pMarine = pMR ? pMR->GetMarineEntity() : NULL;
			if (pMarine && pMarine->m_pFlashlight)	// if this is a marine with a flashlight
			{
				Vector diff = WorldSpaceCenter() - pMarine->EyePosition();
				if (diff.Length() < 700.0f)
				{
					diff.NormalizeInPlace();
					Vector vecMarineFacing(0,0,0);
					AngleVectors(pMarine->GetAbsAngles(), &vecMarineFacing);
					float dot = vecMarineFacing.Dot(diff);
					if (dot > 0.2)	// if the flashlight is facing us
					{
						vecDir += dot * diff;
						fContribution += (dot - 0.2f) * 1.25f;
					}
				}
			}
		}
	}
}
void CASWHud3DMarineNames::PaintMarineNameLabels()
{
	C_ASW_Player *local = C_ASW_Player::GetLocalASWPlayer();
	if ( !local )
		return;

	C_ASW_Game_Resource *pGameResource = ASWGameResource();
	if ( !pGameResource )
		return;

	int count = 0;
	int my_count = 0;
	for ( int i = 0; i < pGameResource->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource *pMR = pGameResource->GetMarineResource( i );
		if ( pMR && pMR->GetHealthPercent() > 0 )
		{
			C_ASW_Marine *pMarine = pMR->GetMarineEntity();
			if ( pMarine )
			{
				if ( pMarine->GetCommander() == local )
				{
					PaintMarineLabel( my_count, pMarine, pMR, local->GetMarine() == pMarine );
					my_count++;
				}
				else
				{
					PaintMarineLabel( -1, pMarine, pMR, false );
				}

				count++;
			}
		}		
	}
}
Esempio n. 5
0
//-----------------------------------------------------------------------------
// Purpose: Return the player who will predict this entity
//-----------------------------------------------------------------------------
C_BasePlayer* C_ASW_Hack::GetPredictionOwner()
{
	C_ASW_Marine_Resource *pMR = m_hHackerMarineResource.Get();
	if ( !pMR )
		return NULL;

	return pMR->GetCommander();
}
Esempio n. 6
0
ASW_Marine_Class CASW_Briefing::GetMarineClass( int nLobbySlot )
{	
	int nMarineResourceIndex = LobbySlotToMarineResourceIndex( nLobbySlot );
	C_ASW_Marine_Resource *pMR = ASWGameResource() ? ASWGameResource()->GetMarineResource( nMarineResourceIndex ) : NULL;
	if ( !pMR || !pMR->GetProfile() )
		return MARINE_CLASS_UNDEFINED;

	return pMR->GetProfile()->GetMarineClass();
}
Esempio n. 7
0
CASW_Marine_Profile *CASW_Briefing::GetMarineProfile( int nLobbySlot )
{
	int nMarineResourceIndex = LobbySlotToMarineResourceIndex( nLobbySlot );
	C_ASW_Marine_Resource *pMR = ASWGameResource() ? ASWGameResource()->GetMarineResource( nMarineResourceIndex ) : NULL;
	if ( !pMR )
		return NULL;

	return pMR->GetProfile();
}
Esempio n. 8
0
bool CASW_Briefing::IsLobbySlotLocal( int nLobbySlot )
{
	if ( nLobbySlot == 0 || IsOfflineGame() )		// first slot is always the local player
		return true;

	int nMarineResourceIndex = LobbySlotToMarineResourceIndex( nLobbySlot );
	C_ASW_Marine_Resource *pMR = ASWGameResource() ? ASWGameResource()->GetMarineResource( nMarineResourceIndex ) : NULL;
	if ( !pMR )
		return false;

	return pMR->GetCommander() && ( pMR->GetCommander() == C_ASW_Player::GetLocalASWPlayer() );
}
Esempio n. 9
0
void CASWHudPortraits::OnThink()
{
    VPROF_BUDGET( "CASWHudPortraits::OnThink", VPROF_BUDGETGROUP_ASW_CLIENT );

    int iNumMyMarines = 0;
    int iNumOtherMarines = 0;
    C_ASW_Player *local = C_ASW_Player::GetLocalASWPlayer();
    if ( local )
    {
        C_ASW_Game_Resource* pGameResource = ASWGameResource();
        if (pGameResource)
        {
            for (int i=0; i<pGameResource->GetMaxMarineResources(); i++)
            {
                C_ASW_Marine_Resource* pMR = pGameResource->GetMarineResource(i);
                if (pMR)
                {
                    if (pMR->GetCommander() == local)
                    {
                        m_hMyMarine[iNumMyMarines] = pMR;

                        iNumMyMarines++;
                        if (pMR->GetMarineEntity() == local->GetMarine())
                            m_hCurrentlySelectedMarineResource = pMR;
                    }
                    else if (!(ASWGameRules() && ASWGameRules()->IsTutorialMap()))	// in tutorial, don't show marines not under your command
                    {
                        m_hOtherMarine[iNumOtherMarines] = pMR;
                        iNumOtherMarines++;
                    }
                }
            }
            // clear out future slots
            for (int i=iNumMyMarines; i<ASW_MAX_MARINE_RESOURCES; i++)
            {
                m_hMyMarine[i] == NULL;
            }
            for (int i=iNumOtherMarines; i<ASW_MAX_MARINE_RESOURCES; i++)
            {
                m_hOtherMarine[i] == NULL;
            }
        }
    }
    // JOYPAD REMOVED
    //bool bJoypadModeChanged = (m_bLastJoypadMode != engine->ASW_IsJoypadMode());
    //m_bLastJoypadMode = engine->ASW_IsJoypadMode();
    bool bJoypadModeChanged = m_bLastJoypadMode = false;
    bool bResize = ((m_iNumMyMarines != iNumMyMarines) || (m_iNumOtherMarines != iNumOtherMarines) || bJoypadModeChanged);
    m_iNumMyMarines = iNumMyMarines;
    m_iNumOtherMarines = iNumOtherMarines;

    UpdatePortraits(bResize);
}
Esempio n. 10
0
int CASW_Briefing::GetMarineSkillPoints( int nLobbySlot, int nSkillSlot )
{
	if ( nLobbySlot < 0 || nLobbySlot >= NUM_BRIEFING_LOBBY_SLOTS || !ASWGameResource() )
		return -1;

	int nMarineResourceIndex = LobbySlotToMarineResourceIndex( nLobbySlot );
	C_ASW_Marine_Resource *pMR = ASWGameResource() ? ASWGameResource()->GetMarineResource( nMarineResourceIndex ) : NULL;
	if ( !pMR )
		return -1;

	return GetProfileSkillPoints( pMR->GetProfileIndex(), nSkillSlot );
	
}
Esempio n. 11
0
wchar_t* CASW_Briefing::GetMarineName( int nLobbySlot )
{
	if ( nLobbySlot < 0 || nLobbySlot >= NUM_BRIEFING_LOBBY_SLOTS || !IsLobbySlotOccupied( nLobbySlot ) )
		return L"";

	int nMarineResourceIndex = LobbySlotToMarineResourceIndex( nLobbySlot );
	C_ASW_Marine_Resource *pMR = ASWGameResource() ? ASWGameResource()->GetMarineResource( nMarineResourceIndex ) : NULL;
	if ( !pMR )
		return L"";

	static wchar_t wszMarineNameResult[ 32 ];	

	pMR->GetDisplayName( wszMarineNameResult, sizeof( wszMarineNameResult ) );
	return wszMarineNameResult;
}
Esempio n. 12
0
int CASW_Briefing::GetProfileSelectedWeapon( int nProfileIndex, int nWeaponSlot )
{
	for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource( i );
		if ( !pMR )
			continue;

		if ( pMR->GetProfileIndex() == nProfileIndex )
		{
			return pMR->m_iWeaponsInSlots[ nWeaponSlot ];
		}
	}
	return -1;
}
Esempio n. 13
0
wchar_t* CASW_Briefing::GetMarineOrPlayerName( int nLobbySlot )
{
	if ( nLobbySlot < 0 || nLobbySlot >= NUM_BRIEFING_LOBBY_SLOTS || !IsLobbySlotOccupied( nLobbySlot ) )
		return L"";

	int nMarineResourceIndex = LobbySlotToMarineResourceIndex( nLobbySlot );
	C_ASW_Marine_Resource *pMR = ASWGameResource() ? ASWGameResource()->GetMarineResource( nMarineResourceIndex ) : NULL;

	bool bUsePlayerName = ( pMR == NULL );

	if ( pMR )
	{
		C_ASW_Player *pPlayer = m_LobbySlotMapping[ nLobbySlot ].m_hPlayer.Get();
		C_ASW_Marine_Resource *pFirstMR = pPlayer ? ASWGameResource()->GetFirstMarineResourceForPlayer( pPlayer ) : NULL;

		if ( pFirstMR == pMR )
		{
			bUsePlayerName = true;
		}
	}
	else if ( !bUsePlayerName )
	{
		// no marine and no player name to use, return blank
		return L"";
	}

	
	static wchar_t wszMarineNameResult[ 32 ];

	// if it's their first marine, show the commander name instead
	if ( bUsePlayerName )
	{		
		C_ASW_Player *pPlayer = m_LobbySlotMapping[ nLobbySlot ].m_hPlayer.Get();
		if ( !pPlayer )
			return L"";

		const char *pszPlayerName = pPlayer->GetPlayerName();
		g_pVGuiLocalize->ConvertANSIToUnicode( pszPlayerName ? pszPlayerName : "", wszMarineNameResult, sizeof( wszMarineNameResult ) );
		return wszMarineNameResult;
	}
	
	pMR->GetDisplayName( wszMarineNameResult, sizeof( wszMarineNameResult ) );
	return wszMarineNameResult;
}
Esempio n. 14
0
void CASWHudEmotes::PaintEmotes()
{
    C_ASW_Game_Resource *pGameResource = ASWGameResource();
    if (!pGameResource)
        return;

    for (int i=0; i<pGameResource->GetMaxMarineResources(); i++)
    {
        C_ASW_Marine_Resource *pMR = pGameResource->GetMarineResource(i);
        if (!pMR)
            continue;

        C_ASW_Marine *marine = pMR->GetMarineEntity();
        if ( !marine )
            continue;

        PaintEmotesFor(marine);
    }
}
Esempio n. 15
0
void CASW_Briefing::SelectWeapon( int nProfileIndex, int nInventorySlot, int nEquipIndex )
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

	for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource( i );
		if ( !pMR )
			continue;

		if ( pMR->GetProfileIndex() == nProfileIndex )
		{
			int nMarineResourceIndex = ASWGameResource()->GetIndexFor( pMR );
			pPlayer->LoadoutSelectEquip( nMarineResourceIndex, nInventorySlot, nEquipIndex );
			return;
		}
	}
}
Esempio n. 16
0
const char* CASW_Briefing::GetPlayerNameForMarineProfile( int nProfileIndex )
{
	for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource( i );
		if ( !pMR )
			continue;

		if ( pMR->GetProfileIndex() == nProfileIndex )
		{
			C_ASW_Player *pPlayer = pMR->GetCommander();
			if ( pPlayer )
			{
				return pPlayer->GetPlayerName();
			}
			break;
		}
	}
	return "";
}
Esempio n. 17
0
bool CASW_Briefing::IsProfileSelected( int nProfileIndex )
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return false;

	for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource( i );
		if ( !pMR )
			continue;

		if ( pMR->GetProfileIndex() == nProfileIndex )
		{
			return true;
		}
	}

	return false;
}
Esempio n. 18
0
void ExperienceStatLine::UpdateVisibility( C_ASW_Player *pPlayer )
{
	if ( !pPlayer )
	{
		pPlayer = ToASW_Player( m_hPlayer.Get() );
	}

	if ( !pPlayer || !ASWGameResource() )
		return;

	C_ASW_Marine_Resource *pMR = ASWGameResource()->GetFirstMarineResourceForPlayer( pPlayer );
	if ( !pMR )
		return;

	bool bMedic = pMR->GetProfile() && pMR->GetProfile()->GetMarineClass() == MARINE_CLASS_MEDIC;
	bool bTech = pMR->GetProfile() && pMR->GetProfile()->GetMarineClass() == MARINE_CLASS_TECH;

	if ( !Briefing()->IsOfflineGame() )
	{
		if ( ( m_XPType == ASW_XP_HEALING && !bMedic ) || ( m_XPType == ASW_XP_HACKING && !bTech ) )
		{
			SetVisible( false );
			return;
		}
	}

	if ( pPlayer->GetStatNumXP( ASW_XP_MISSION ) < 100 )
	{
		// Don't do these if we failed
		if ( m_XPType == ASW_XP_DAMAGE_TAKEN || m_XPType == ASW_XP_FRIENDLY_FIRE || m_XPType == ASW_XP_TIME )
		{
			SetVisible( false );
			return;
		}
	}

	SetVisible( true );
}
void MissionCompleteStatsLine::ShowStats()
{
	m_pStats[0]->SetStartCountingTime(gpGlobals->curtime);
	m_pStats[1]->SetStartCountingTime(gpGlobals->curtime + 1);
	m_pStats[2]->SetStartCountingTime(gpGlobals->curtime + 2);
	m_pStats[3]->SetStartCountingTime(gpGlobals->curtime + 3);
	m_pStats[4]->SetStartCountingTime(gpGlobals->curtime);

	if (ASWGameRules() && ASWGameRules()->GetMissionSuccess())
		m_pStats[6]->SetStartCountingTime(gpGlobals->curtime + 3);
	
	if (m_iMarineIndex >= 0 && m_iMarineIndex < ASW_MAX_MARINE_RESOURCES
		&& ASWGameRules() && ASWGameResource())
	{
		C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource(m_iMarineIndex);
		if (pMR && pMR->GetProfile() && pMR->GetProfile()->GetMarineClass() != MARINE_CLASS_SPECIAL_WEAPONS)
			m_pStats[5]->SetStartCountingTime(gpGlobals->curtime + 1);
	}

	int x, y;
	GetPos(x, y);
	float fProp = y / ScreenHeight();
	m_pMedalArea->StartShowingMedals(gpGlobals->curtime + fProp * 0.9f + 5.0f);
}
Esempio n. 20
0
/// @TODO can use a more optimal sorting strategy
void C_ASW_Game_Resource::CMarineToCrosshairInfo::RecomputeCache()
{
	VPROF("C_ASW_Game_Resource::CMarineToCrosshairInfo::RecomputeCache()");
	C_ASW_Game_Resource * RESTRICT  pGameResource = ASWGameResource();
	// purge the array.
	m_tMarines.RemoveAll();

	const Vector vecCrosshairAimingPos = ASWInput()->GetCrosshairAimingPos();

	for ( int i=0; i<pGameResource->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource *pMR = pGameResource->GetMarineResource(i);
		C_ASW_Marine *pMarine;
		if ( pMR && (pMarine = pMR->GetMarineEntity()) )
		{
			float dist = (vecCrosshairAimingPos - pMR->GetMarineEntity()->GetAbsOrigin()).Length2D();
			m_tMarines.AddToTail( tuple_t(pMarine, dist) );
		}
	}

	m_tMarines.Sort( &MarineTupleComparator );

	m_iLastFrameCached = gpGlobals->framecount;
}
void MissionCompleteStatsLine::InitFrom(C_ASW_Debrief_Stats *pDebriefStats)
{
	if (!pDebriefStats)
		return;

	if (m_iMarineIndex < 0 || m_iMarineIndex >= ASW_MAX_MARINE_RESOURCES)
		return;

	if (!ASWGameRules() || !ASWGameResource())
		return;

	C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource(m_iMarineIndex);
	if (!pMR)
		return;

	m_bInitStats = true;

	// find marine with highest kills, highest acc, lowest FF and lowest damage taken
	int iHighestKills = pDebriefStats->GetHighestKills();
	float fHighestAccuracy = pDebriefStats->GetHighestAccuracy();
	int iHighestFF = pDebriefStats->GetHighestFriendlyFire();
	int iHighestDamage = pDebriefStats->GetHighestDamageTaken();
	int iHighestShotsFired = pDebriefStats->GetHighestShotsFired();

	float fDelay = 1.0f;	// roughly how many seconds we want it to take for the bars to fill
	float fKillRate = float(iHighestKills) / fDelay;
	float fAccRate = fHighestAccuracy / fDelay;
	float fFFRate = float(iHighestFF) / fDelay;
	float fDamageRate = float(iHighestDamage) / fDelay;
	float fShotsFiredRate = float(iHighestShotsFired) / fDelay;

	// kills
	m_pStats[0]->Init(0, pDebriefStats->GetKills(m_iMarineIndex), fKillRate, true, false);
	m_pStats[0]->AddMinMax( 0, iHighestKills );
	m_pStats[1]->Init(0, pDebriefStats->GetAccuracy(m_iMarineIndex), fAccRate, true, true);
	m_pStats[1]->AddMinMax( 0, fHighestAccuracy );
	m_pStats[2]->Init(0, pDebriefStats->GetFriendlyFire(m_iMarineIndex), fFFRate, true, false);
	m_pStats[2]->AddMinMax( 0, iHighestFF );
	m_pStats[3]->Init(0, pDebriefStats->GetDamageTaken(m_iMarineIndex), fDamageRate, true, false);
	m_pStats[3]->AddMinMax( 0, iHighestDamage );
	m_pStats[4]->Init(0, pDebriefStats->GetShotsFired(m_iMarineIndex), fShotsFiredRate, true, false);
	m_pStats[4]->AddMinMax( 0, iHighestShotsFired );

	// wounded
	m_pWoundedLabel->SetFgColor(Color(255,0,0,255));
	
	if (pMR->GetHealthPercent() <= 0)
	{
		m_pWoundedLabel->SetText("#asw_kia");
		m_pWoundedLabel->SetVisible(true);
	}
	else if (pDebriefStats->IsWounded(m_iMarineIndex))
	{
		m_pWoundedLabel->SetText("#asw_wounded");
		m_pWoundedLabel->SetVisible(true);
	}
	else
	{
		m_pWoundedLabel->SetVisible(false);
	}
	
	// update our class specific bar
	if (pMR->GetProfile()->GetMarineClass() == MARINE_CLASS_SPECIAL_WEAPONS)
	{
		m_pStats[5]->SetVisible(false);
		m_pBarIcons[5]->SetVisible(false);
	}
	else
	{
		m_pStats[5]->SetVisible(true);
		m_pBarIcons[5]->SetVisible(true);

		if (pMR->GetProfile()->GetMarineClass() == MARINE_CLASS_NCO)
		{
			int iHighest = pDebriefStats->GetHighestAliensBurned();
			float fRate = float(iHighest) / fDelay;
			m_pStats[5]->Init(0, pDebriefStats->GetAliensBurned(m_iMarineIndex), fRate, true, false);
			m_pStats[5]->AddMinMax( 0, iHighest );
			m_pBarIcons[5]->SetImage("swarm/Briefing/statburned");
		}
		else if (pMR->GetProfile()->GetMarineClass() == MARINE_CLASS_MEDIC)
		{
			int iHighest = pDebriefStats->GetHighestHealthHealed();
			float fRate = float(iHighest) / fDelay;
			Msg( "Medic healed %d highest %d\n", pDebriefStats->GetHealthHealed(m_iMarineIndex), iHighest );
			m_pStats[5]->Init(0, pDebriefStats->GetHealthHealed(m_iMarineIndex), fRate, true, false);
			m_pStats[5]->AddMinMax( 0, iHighest );
			m_pBarIcons[5]->SetImage("swarm/Briefing/statheal");
		}
		else if (pMR->GetProfile()->GetMarineClass() == MARINE_CLASS_TECH)
		{
			int iHighest = pDebriefStats->GetHighestFastHacks();
			float fRate = float(iHighest) / fDelay;
			m_pStats[5]->Init(0, pDebriefStats->GetFastHacks(m_iMarineIndex), fRate, true, false);
			m_pStats[5]->AddMinMax( 0, iHighest );
			m_pBarIcons[5]->SetImage("swarm/Briefing/stathack");
		}
	}

	if (ASWGameRules() && ASWGameRules()->GetMissionSuccess() && ASWGameRules()->IsCampaignGame())
	{
		m_pStats[6]->SetVisible(true);
		m_pBarIcons[6]->SetVisible(true);

		int iHighestSkillPointsAwarded = pDebriefStats->GetHighestSkillPointsAwarded();
		float fDelay = 1.0f;	// roughly how many seconds we want it to take for the bars to fill
		float fSkillPointsRate = float(iHighestSkillPointsAwarded) / fDelay;
		m_pStats[6]->Init(0, pDebriefStats->GetSkillPointsAwarded(m_iMarineIndex), fSkillPointsRate, true, false);
		m_pStats[6]->AddMinMax( 0, iHighestSkillPointsAwarded );
	}
	else
	{
		m_pStats[6]->SetVisible(false);
		m_pBarIcons[6]->SetVisible(false);
	}
}
void MissionCompleteStatsLine::OnThink()
{	
	UpdateLabels();
	// check tooltips
	if (!g_hBriefingTooltip.Get())
		return;

	const char *szName = "";
	const char *szDescription = "";
	for (int i=0;i<ASW_NUM_STATS_BARS;i++)
	{
		vgui::Panel *pPanel = NULL;
		if (m_pStats[i]->IsCursorOver() && m_pStats[i]->IsFullyVisible())
			pPanel = m_pStats[i];
		
		if (pPanel)
		{
			switch (i)
			{
			case 0: szName = "#asw_stats_kills"; szDescription = "#asw_stats_kills_desc"; break;
			case 1: szName = "#asw_stats_accuracy"; szDescription = "#asw_stats_accuracy_desc"; break;
			case 2: szName = "#asw_stats_ff"; szDescription = "#asw_stats_ff_desc"; break;
			case 3: szName = "#asw_stats_damage"; szDescription = "#asw_stats_damage_desc"; break;			
			case 6: szName = "#asw_stats_skillpoints"; szDescription = "#asw_stats_skillpoints_desc"; break;
			case 4: default:  szName = "#asw_stats_shots"; szDescription = "#asw_stats_shots_desc"; break;				
			}
			if (i == 5)	// class specific
			{
				szName = ""; szDescription = "";
				if (m_iMarineIndex >= 0 && m_iMarineIndex < ASW_MAX_MARINE_RESOURCES
					&& ASWGameResource())
				{
					C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource(m_iMarineIndex);
					if (pMR && pMR->GetProfile())
					{
						if (pMR->GetProfile()->GetMarineClass() == MARINE_CLASS_MEDIC)
						{
							szName= "#asw_stats_healed"; szDescription = "#asw_stats_healed_desc";
						}
						else if (pMR->GetProfile()->GetMarineClass() == MARINE_CLASS_SPECIAL_WEAPONS)
						{
							szName= "#asw_stats_burned"; szDescription = "#asw_stats_burned_desc";
						}
						else if (pMR->GetProfile()->GetMarineClass() == MARINE_CLASS_TECH)
						{
							szName = "#asw_stats_fasth"; szDescription = "#asw_stats_fasth";
						}
					}
				}
			}
			if (g_hBriefingTooltip->GetTooltipPanel() != pPanel)
			{	
				int tx, ty, w, h;
				tx = ty = 0;
				pPanel->LocalToScreen(tx, ty);
				pPanel->GetSize(w, h);
				tx += w * 0.5f;
				ty -= h * 0.01f;
				
				g_hBriefingTooltip->SetTooltip(pPanel, szName, szDescription,
					tx, ty);
			}
			return;
		}
	}
}
void CASW_Hud_Squad_Hotbar::UpdateList()
{
	if ( !ASWGameResource() )
		return;

	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();

	int iEntry = 0;
	bool bHasItem = false;
	if ( asw_hotbar_self.GetBool() )
	{
		if ( iEntry >= m_pEntries.Count() )
		{
			CASW_Hotbar_Entry *pPanel = new CASW_Hotbar_Entry( this, "SquadInventoryPanelEntry" );
			m_pEntries.AddToTail( pPanel );
			InvalidateLayout();
		}

		// add your offhand item to the hotbar first
		CASW_Marine *pPlayerMarine = pPlayer->GetMarine();
		if ( pPlayerMarine )
		{
			C_ASW_Weapon *pWeapon = pPlayerMarine->GetASWWeapon( ASW_INVENTORY_SLOT_EXTRA );
			if ( pWeapon )
			{
				m_pEntries[ iEntry ]->m_iHotKeyIndex = -1;
				m_pEntries[ iEntry ]->SetVisible( true );
				m_pEntries[ iEntry ]->SetDetails( pPlayerMarine, ASW_INVENTORY_SLOT_EXTRA );
				bHasItem = true;
			}
		}

		if ( !bHasItem )	// blank it out if there's no item in that slot
		{
			m_pEntries[ iEntry ]->m_iHotKeyIndex = iEntry;
			m_pEntries[ iEntry ]->SetDetails( NULL, -1 );
			m_pEntries[ iEntry ]->SetVisible( false );
		}

		iEntry++;
	}

	for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource* pMR = ASWGameResource()->GetMarineResource( i );
		if ( !pMR )
			continue;

		if ( pMR->GetCommander() != pPlayer )
			continue;

		C_ASW_Marine *pMarine = pMR->GetMarineEntity();
		if ( !pMarine )
			continue;

		if ( pMarine->IsInhabited() )
			continue;

		if ( iEntry >= m_pEntries.Count() )
		{
			CASW_Hotbar_Entry *pPanel = new CASW_Hotbar_Entry( this, "SquadInventoryPanelEntry" );
			m_pEntries.AddToTail( pPanel );
			InvalidateLayout();
		}

		bHasItem = false;
		for ( int k = 0; k < ASW_NUM_INVENTORY_SLOTS; k++ )
		{
			C_ASW_Weapon *pWeapon = pMarine->GetASWWeapon( k );
			if ( !pWeapon )
				continue;

			const CASW_WeaponInfo* pInfo = pWeapon->GetWeaponInfo();
			if ( !pInfo || !pInfo->m_bOffhandActivate )		// TODO: Fix for sentry guns
				continue;

			m_pEntries[ iEntry ]->m_iHotKeyIndex = iEntry;
			m_pEntries[ iEntry ]->SetVisible( true );
			m_pEntries[ iEntry ]->SetDetails( pMarine, k );
			bHasItem = true;

			if ( asw_hotbar_simple.GetBool() )		// only 1 item per marine
				break;
		}

		if ( !bHasItem )	// blank it out if there's no item in that slot
		{
			m_pEntries[ iEntry ]->m_iHotKeyIndex = iEntry;
			m_pEntries[ iEntry ]->SetDetails( NULL, -1 );
			m_pEntries[ iEntry ]->SetVisible( false );
		}

		iEntry++;
	}

	for ( int i = iEntry; i < m_pEntries.Count(); i++ )
	{
		m_pEntries[ i ]->SetVisible( false );
	}
}
Esempio n. 24
0
bool CASW_Briefing::CheckMissionRequirements()
{
	if ( ASWGameRules() && ASWGameRules()->GetGameState() < ASW_GS_DEBRIEF && ASWGameResource() )
	{	
		if ( ASWGameRules()->m_bMissionRequiresTech )
		{
			bool bTech = false;
			for (int i=0;i<ASWGameResource()->GetMaxMarineResources();i++)
			{
				C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource(i);
				if (pMR && pMR->GetProfile() && pMR->GetProfile()->CanHack())
					bTech = true;
			}
			if (!bTech)
			{
				// have the server print a message about needing a tech, so all can see
				engine->ClientCmd("cl_needtech");
				return false;
			}
		}
		C_ASW_Equip_Req* pReq = C_ASW_Equip_Req::FindEquipReq();
		if (pReq)
		{
			if (pReq && !pReq->AreRequirementsMet())
			{
				// have the server print a message about needing equip, so all can see
				engine->ClientCmd("cl_needequip");
				return false;
			}
		}
		if ( !ASWGameResource()->AtLeastOneMarine() )
		{
			return false;
		}

		if ( ASWGameResource() && !asw_ignore_need_two_player_requirement.GetBool() )
		{
			CASW_Campaign_Info *pCampaign = ASWGameRules()->GetCampaignInfo();

			char mapname[64];
			V_FileBase( engine->GetLevelName(), mapname, sizeof( mapname ) );

			if ( pCampaign && pCampaign->GetMissionByMapName( mapname ) )
			{
				bool bNeedsMoreThanOneMarine = pCampaign->GetMissionByMapName( mapname )->m_bNeedsMoreThanOneMarine;
				if ( bNeedsMoreThanOneMarine )
				{
					// how many marines do we have?
					int numMarines = 0;
					for (int i=0;i<ASWGameResource()->GetMaxMarineResources();i++)
					{
						C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource(i);
						if ( pMR && pMR->GetProfileIndex() >= 0 )
							numMarines++;
					}

					if ( numMarines < 2 )
					{
						engine->ClientCmd("cl_needtwoplayers");
						return false;
					}
				}
			}
		}
	}
	return true;
}
Esempio n. 25
0
void CASW_Briefing::UpdateLobbySlotMapping()
{
	if ( m_nLastLobbySlotMappingFrame == gpGlobals->framecount )		// don't update twice in one frame
		return;

	m_nLastLobbySlotMappingFrame = gpGlobals->framecount;

	if ( !ASWGameResource() )
		return;

	C_ASW_Player *pLocalPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pLocalPlayer )
		return;

	if ( IsOfflineGame() )
	{
		// just map marine resources to slots directly		
		for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources() && i < NUM_BRIEFING_LOBBY_SLOTS; i++ )
		{
			C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource( i );
			if ( !pMR )
			{
				if ( i == 0 )
				{
					m_LobbySlotMapping[ i ].m_nPlayerEntIndex = pLocalPlayer->entindex();
					m_LobbySlotMapping[ i ].m_hPlayer = pLocalPlayer;
				}
				else
				{
					m_LobbySlotMapping[ i ].m_nPlayerEntIndex = -1;
					m_LobbySlotMapping[ i ].m_hPlayer = NULL;
				}
				m_LobbySlotMapping[ i ].m_nMarineResourceIndex = -1;
				m_LobbySlotMapping[ i ].m_hMR = NULL;
			}
			else
			{
				m_LobbySlotMapping[ i ].m_nPlayerEntIndex = pLocalPlayer->entindex();
				m_LobbySlotMapping[ i ].m_hPlayer = pLocalPlayer;
				m_LobbySlotMapping[ i ].m_nMarineResourceIndex = i;
				m_LobbySlotMapping[ i ].m_hMR = pMR;
			}
		}
		return;
	}

	// lobby slot 0 is always reserved for the local player
	m_LobbySlotMapping[ 0 ].m_nPlayerEntIndex = pLocalPlayer->entindex();
	m_LobbySlotMapping[ 0 ].m_hPlayer = pLocalPlayer;
	m_LobbySlotMapping[ 0 ].m_nMarineResourceIndex = -1;
	m_LobbySlotMapping[ 0 ].m_hMR = NULL;

	for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource( i );
		if ( !pMR || pMR->GetCommander() != pLocalPlayer )
			continue;

		m_LobbySlotMapping[ 0 ].m_nMarineResourceIndex = i;
		m_LobbySlotMapping[ 0 ].m_hMR = pMR;
		break;
	}

	int nSlot = 1;
	
	// if the player has any other marines selected, they come first
	for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
	{
		C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource( i );
		if ( !pMR || pMR->GetCommander() != pLocalPlayer )
			continue;
		
		bool bAlreadyInList = false;
		for ( int k = 0; k < nSlot; k++ )
		{
			if ( pMR == m_LobbySlotMapping[ k ].m_hMR.Get() )
			{
				bAlreadyInList = true;
				break;
			}
		}

		if ( bAlreadyInList )
			continue;

		m_LobbySlotMapping[ nSlot ].m_nPlayerEntIndex = pLocalPlayer->entindex();
		m_LobbySlotMapping[ nSlot ].m_hPlayer = pLocalPlayer;
		m_LobbySlotMapping[ nSlot ].m_hMR = pMR;
		m_LobbySlotMapping[ nSlot ].m_nMarineResourceIndex = i;

		nSlot++;
		if ( nSlot >= NUM_BRIEFING_LOBBY_SLOTS )
			break;
	}

	if ( nSlot >= NUM_BRIEFING_LOBBY_SLOTS )
		return;

	// now add marines for other players in order
	for( int iClient = 1; iClient < MAX_PLAYERS; iClient++ )
	{
		if ( !g_PR->IsConnected( iClient ) )
			continue;

		if ( iClient == pLocalPlayer->entindex() )
			continue;

		for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
		{
			C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource( i );
			if ( !pMR || pMR->m_iCommanderIndex != iClient )
				continue;

			bool bAlreadyInList = false;
			for ( int k = 0; k < nSlot; k++ )
			{
				if ( pMR == m_LobbySlotMapping[ k ].m_hMR.Get() )
				{
					bAlreadyInList = true;
					break;
				}
			}

			if ( bAlreadyInList )
				continue;

			m_LobbySlotMapping[ nSlot ].m_nPlayerEntIndex = iClient;
			m_LobbySlotMapping[ nSlot ].m_hPlayer = static_cast<C_ASW_Player*>( UTIL_PlayerByIndex( iClient ) );
			m_LobbySlotMapping[ nSlot ].m_hMR = pMR;
			m_LobbySlotMapping[ nSlot ].m_nMarineResourceIndex = i;

			nSlot++;
			if ( nSlot >= NUM_BRIEFING_LOBBY_SLOTS )
				break;
		}
	}

	if ( nSlot >= NUM_BRIEFING_LOBBY_SLOTS )
		return;

	// now add any players who don't have any marines
	for( int iClient = 1; iClient < MAX_PLAYERS; iClient++ )
	{
		if ( !g_PR->IsConnected( iClient ) )
			continue;

		if ( iClient == pLocalPlayer->entindex() )
			continue;

		int nMarines = 0;
		for ( int i = 0; i < ASWGameResource()->GetMaxMarineResources(); i++ )
		{
			C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource( i );
			if ( !pMR || pMR->m_iCommanderIndex != iClient )
				continue;

			nMarines++;
		}

		if ( nMarines == 0)
		{
			m_LobbySlotMapping[ nSlot ].m_nPlayerEntIndex = iClient;
			m_LobbySlotMapping[ nSlot ].m_hPlayer = static_cast<C_ASW_Player*>( UTIL_PlayerByIndex( iClient ) );
			m_LobbySlotMapping[ nSlot ].m_hMR = NULL;
			m_LobbySlotMapping[ nSlot ].m_nMarineResourceIndex = -1;

			nSlot++;
			if ( nSlot >= NUM_BRIEFING_LOBBY_SLOTS )
				break;
		}
	}

	for ( int k = nSlot; k < NUM_BRIEFING_LOBBY_SLOTS; k++ )
	{
		m_LobbySlotMapping[ k ].m_nPlayerEntIndex = -1;
		m_LobbySlotMapping[ k ].m_hPlayer = NULL;
		m_LobbySlotMapping[ k ].m_hMR = NULL;
		m_LobbySlotMapping[ k ].m_nMarineResourceIndex = -1;
	}
}