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() ); }
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(); }
//----------------------------------------------------------------------------- // 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(); }
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); }
bool CASW_Briefing::IsProfileSelectedBySomeoneElse( 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 ( pMR->GetCommander() != pPlayer ); } } return false; }
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 ""; }
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 ); } }
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; } }