int CASW_Steamstats::GetFavoriteMarineClass( void ) { // Find the marine's class CASW_Marine_Profile *pProfile = MarineProfileList()->GetProfile( GetFavoriteMarine() ); Assert( pProfile ); return pProfile ? pProfile->GetMarineClass() : 0; }
// lists a few basic details about a marine's profile void ASW_InspectProfile( const CCommand &args ) { int i = atoi( args[1] ); Msg("Marine profile %d\n", i); CASW_Marine_Profile *profile = MarineProfileList()->m_Profiles[i]; if (profile != NULL) { Msg("Name: %s\n", profile->m_ShortName); Msg("Age: %d\n", profile->m_Age); if (profile->GetMarineClass() == MARINE_CLASS_TECH) Msg("Tech\n"); if (profile->GetMarineClass() == MARINE_CLASS_MEDIC) Msg("First Aid\n"); if (profile->GetMarineClass() == MARINE_CLASS_SPECIAL_WEAPONS) Msg("Special Weapons\n"); if (profile->GetMarineClass() == MARINE_CLASS_NCO) Msg("Sapper\n"); } }
void CASW_Briefing::AutoSelectFullSquadForSingleplayer( int nFirstSelectedProfileIndex ) { if ( !MarineProfileList() ) return; CASW_Marine_Profile* pFirstSelectedProfile = MarineProfileList()->GetProfile( nFirstSelectedProfileIndex ); if ( !pFirstSelectedProfile ) return; ASW_Marine_Class nMarineClasses[]= { MARINE_CLASS_NCO, MARINE_CLASS_SPECIAL_WEAPONS, MARINE_CLASS_MEDIC, MARINE_CLASS_TECH }; // select one of each class for ( int i = 0; i < NELEMS( nMarineClasses ); i++ ) { if ( nMarineClasses[ i ] == pFirstSelectedProfile->GetMarineClass() ) continue; CASW_Marine_Profile* pProfile = NULL; for ( int p = 0; p < MarineProfileList()->m_NumProfiles; p++ ) { pProfile = MarineProfileList()->GetProfile( p ); if ( pProfile && pProfile->GetMarineClass() == nMarineClasses[i] ) { break; } } if ( !pProfile ) continue; SelectMarine( 0, pProfile->m_ProfileIndex, -1 ); } }
float CASW_Steamstats::GetFavoriteMarineClassPercent( void ) { int iFav = 0; float fTotal = 0; int iClassCounts[NUM_MARINE_CLASSES] = {0}; for( int i=0; i<m_MarineSelectionCounts.Count(); ++i ) { // Find the marine's class CASW_Marine_Profile *pProfile = MarineProfileList()->GetProfile( i ); Assert( pProfile ); if( !pProfile ) continue; int iProfileClass = pProfile->GetMarineClass(); iClassCounts[iProfileClass] += m_MarineSelectionCounts[i]; fTotal += m_MarineSelectionCounts[i]; if( iClassCounts[iFav] < iClassCounts[iProfileClass] ) iFav = iProfileClass; } return ( fTotal > 0.0f ) ? ( iClassCounts[iFav] / fTotal * 100.0f ) : 0.0f; }
void CNB_Select_Marine_Panel::OnCommand( const char *command ) { if ( !Q_stricmp( command, "BackButton" ) ) { Briefing()->SetChangingWeaponSlot( 0 ); MarkForDeletion(); CLocalPlayerFilter filter; C_BaseEntity::EmitSound( filter, -1, "ASWComputer.MenuBack" ); return; } else if ( !Q_stricmp( command, "AcceptButton" ) ) { CNB_Select_Marine_Entry *pHighlighted = dynamic_cast<CNB_Select_Marine_Entry*>( GetHighlightedEntry() ); if ( pHighlighted ) { int nProfileIndex = pHighlighted->GetProfileIndex(); if ( !Briefing()->IsProfileSelectedBySomeoneElse( nProfileIndex ) ) { Briefing()->SelectMarine( 0, nProfileIndex, m_nPreferredLobbySlot ); // is this the first marine we've selected? if ( Briefing()->IsOfflineGame() && ASWGameResource() && ASWGameResource()->GetNumMarines( NULL ) <= 0 ) { //Briefing()->AutoSelectFullSquadForSingleplayer( nProfileIndex ); } bool bHasPointsToSpend = Briefing()->IsCampaignGame() && !Briefing()->UsingFixedSkillPoints() && ( Briefing()->GetProfileSkillPoints( nProfileIndex, ASW_SKILL_SLOT_SPARE ) > 0 ); if ( bHasPointsToSpend ) { CNB_Main_Panel *pPanel = dynamic_cast<CNB_Main_Panel*>( GetParent() ); if ( pPanel ) { pPanel->SpendSkillPointsOnMarine( nProfileIndex ); } } else { MarkForDeletion(); Briefing()->SetChangingWeaponSlot( 0 ); } CASW_Marine_Profile* pProfile = Briefing()->GetMarineProfileByProfileIndex( nProfileIndex ); if ( pProfile ) { engine->ClientCmd_Unrestricted(VarArgs("exec configloader/chars/%s\n", pProfile->m_PortraitName)); switch (pProfile->GetMarineClass()) { case MARINE_CLASS_NCO: engine->ClientCmd_Unrestricted("exec configloader/chars/Officer\n"); break; case MARINE_CLASS_SPECIAL_WEAPONS: engine->ClientCmd_Unrestricted("exec configloader/chars/SpecialWeapons\n"); break; case MARINE_CLASS_MEDIC: engine->ClientCmd_Unrestricted("exec configloader/chars/Medic\n"); break; case MARINE_CLASS_TECH: engine->ClientCmd_Unrestricted("exec configloader/chars/Tech\n"); break; default: Assert(0); } } } else { CLocalPlayerFilter filter; C_BaseEntity::EmitSound( filter, -1, "ASWComputer.TimeOut" ); } } return; } BaseClass::OnCommand( command ); }