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
}
Exemplo n.º 2
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();
}
Exemplo n.º 3
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();
}
Exemplo n.º 4
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);
}
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;
		}
	}
}
Exemplo n.º 8
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;
}