Skip to content

Commit c25c9f4

Browse files
committed
feat(asw_player): add client rd_pref_spectate_marine_profile???
1 parent 0521ed8 commit c25c9f4

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/game/client/swarm/c_asw_player.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ ConVar asw_turret_fog_end( "asw_turret_fog_end", "1200", 0, "Fog end distance fo
149149

150150
ConVar rd_force_spectate_marine( "rd_force_spectate_marine", "-1", FCVAR_DONTRECORD, "spectate this marine resource index if it exists", true, -1, true, ASW_MAX_MARINE_RESOURCES );
151151
ConVar rd_force_spectate_marine_profile( "rd_force_spectate_marine_profile", "-1", FCVAR_DONTRECORD, "spectate this marine profile if it exists", true, -1, true, ASW_NUM_MARINE_PROFILES );
152+
ConVar rd_pref_spectate_marine_profile( "rd_pref_spectate_marine_profile", "-1", FCVAR_NONE, "Prefer to spectate this marine profile", true, -1, true, ASW_NUM_MARINE_PROFILES );
152153

153154
extern ConVar asw_allow_detach;
154155
extern ConVar asw_stim_cam_time;
@@ -928,6 +929,24 @@ C_ASW_Inhabitable_NPC *C_ASW_Player::GetViewNPC() const
928929
return pNPC;
929930
}
930931

932+
C_ASW_Inhabitable_NPC *C_ASW_Player::GetPreferredSpectatingMarine() const
933+
{
934+
if ( ASWGameResource() && ( engine->IsPlayingDemo() || m_hSpectating.Get() ) )
935+
{
936+
const int iProfile = rd_pref_spectate_marine_profile.GetInt();
937+
if ( iProfile != -1 )
938+
{
939+
C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResourceForProfile( iProfile );
940+
if ( pMR && pMR->GetMarineEntity() )
941+
{
942+
return pMR->GetMarineEntity();
943+
}
944+
}
945+
}
946+
947+
return NULL;
948+
}
949+
931950
HSCRIPT C_ASW_Player::Script_GetMarine() const
932951
{
933952
return ToHScript( C_ASW_Marine::AsMarine( GetNPC() ) );

src/game/client/swarm/c_asw_player.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ class C_ASW_Player : public C_BasePlayer, public IASWPlayerAnimStateHelpers
156156
C_ASW_Inhabitable_NPC *GetNPC() const;
157157
C_ASW_Inhabitable_NPC *GetSpectatingNPC() const;
158158
C_ASW_Inhabitable_NPC *GetViewNPC() const;
159+
C_ASW_Inhabitable_NPC *GetPreferredSpectatingMarine() const;
159160
HSCRIPT Script_GetMarine() const;
160161
HSCRIPT Script_GetNPC() const;
161162
HSCRIPT Script_GetSpectatingNPC() const;

src/game/server/swarm/asw_player.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,13 @@ void CASW_Player::SpectateNextMarine()
21802180
return;
21812181
CASW_Marine *pFirst = NULL;
21822182
//Msg("CASW_Player::SpectateNextMarine\n");
2183+
#ifdef GAME_DLL
2184+
{
2185+
pFirst = GetPreferredSpectatingMarine();
2186+
if ( !pFirst || !pFirst->IsAlive() || pFirst->GetHealth() <= 0 )
2187+
pFirst = NULL;
2188+
}
2189+
#endif // GAME_DLL
21832190

21842191
// loop through all marines
21852192
for (int i=0;i<pGameResource->GetMaxMarineResources();i++)

0 commit comments

Comments
 (0)