@@ -138,6 +138,7 @@ ConVar viewmodel_offset_z("viewmodel_offset_z", "0", FCVAR_CLIENTDLL | FCVAR_ARC
138
138
ConVar viewmodel_offset_pitch (" viewmodel_offset_pitch" , " 0" , FCVAR_CLIENTDLL | FCVAR_ARCHIVE);
139
139
ConVar viewmodel_offset_yaw (" viewmodel_offset_yaw" , " 0" , FCVAR_CLIENTDLL | FCVAR_ARCHIVE);
140
140
ConVar viewmodel_offset_roll (" viewmodel_offset_roll" , " 0" , FCVAR_CLIENTDLL | FCVAR_ARCHIVE);
141
+ ConVar tf_viewmodel_cloak_tint (" tf_viewmodel_cloak_tint" , " 0" , FCVAR_ARCHIVE, " Allow viewmodels to be tinted while cloaked." );
141
142
#else
142
143
ConVar tf_viewmodels_offset_override (" tf_viewmodels_offset_override" , " " , FCVAR_CHEAT, " If set, this will override the position of all viewmodels. Usage 'x y z'" );
143
144
#endif
@@ -636,9 +637,42 @@ EXPOSE_INTERFACE( CViewModelInvisProxy, IMaterialProxy, "vm_invis" IMATERIAL_PRO
636
637
class CInvisProxy : public CBaseInvisMaterialProxy
637
638
{
638
639
public:
640
+ #ifdef BDSBASE
641
+ CInvisProxy (void );
642
+ virtual bool Init (IMaterial* pMaterial, KeyValues* pKeyValues) OVERRIDE;
643
+ #endif
639
644
virtual void OnBind ( C_BaseEntity *pC_BaseEntity ) OVERRIDE;
645
+ #ifdef BDSBASE
646
+ private:
647
+ IMaterialVar* m_pCloakColorTint;
648
+ #endif
640
649
};
641
650
651
+ #ifdef BDSBASE
652
+ // -----------------------------------------------------------------------------
653
+ // Purpose:
654
+ // -----------------------------------------------------------------------------
655
+ CInvisProxy::CInvisProxy (void )
656
+ {
657
+ m_pCloakColorTint = NULL ;
658
+ }
659
+
660
+ // -----------------------------------------------------------------------------
661
+ // Purpose: Get pointer to the color value
662
+ // Input : *pMaterial -
663
+ // -----------------------------------------------------------------------------
664
+ bool CInvisProxy::Init (IMaterial* pMaterial, KeyValues* pKeyValues)
665
+ {
666
+ // Need to get the material var
667
+ bool bInvis = CBaseInvisMaterialProxy::Init (pMaterial, pKeyValues);
668
+
669
+ bool bTint;
670
+ m_pCloakColorTint = pMaterial->FindVar (" $cloakColorTint" , &bTint);
671
+
672
+ return (bInvis && bTint);
673
+ }
674
+ #endif
675
+
642
676
// -----------------------------------------------------------------------------
643
677
// Purpose:
644
678
// -----------------------------------------------------------------------------
@@ -651,11 +685,30 @@ void CInvisProxy::OnBind( C_BaseEntity *pC_BaseEntity )
651
685
652
686
CTFPlayer *pPlayer = NULL ;
653
687
688
+ #ifdef BDSBASE
689
+ static Vector cloakTintRed = Vector (1 .0f , 0 .5f , 0 .4f );
690
+ static Vector cloakTintBlue = Vector (0 .4f , 0 .5f , 1 .0f );
691
+ #endif
692
+
654
693
// Check if we have a move parent and if it's a player
655
694
C_BaseEntity *pMoveParent = pEnt->GetMoveParent ();
656
695
if ( pMoveParent && pMoveParent->IsPlayer () )
657
696
{
658
697
pPlayer = ToTFPlayer ( pMoveParent );
698
+ #ifdef BDSBASE
699
+ // Anything relating to players always tint
700
+ switch (pPlayer->GetTeamNumber ())
701
+ {
702
+ case TF_TEAM_RED:
703
+ m_pCloakColorTint->SetVecValue (cloakTintRed.Base (), 3 );
704
+ break ;
705
+
706
+ case TF_TEAM_BLUE:
707
+ default :
708
+ m_pCloakColorTint->SetVecValue (cloakTintBlue.Base (), 3 );
709
+ break ;
710
+ }
711
+ #endif
659
712
}
660
713
661
714
// If it's not a player then check for viewmodel.
@@ -667,6 +720,29 @@ void CInvisProxy::OnBind( C_BaseEntity *pC_BaseEntity )
667
720
if ( pVM )
668
721
{
669
722
pPlayer = ToTFPlayer ( pVM->GetOwner () );
723
+ #ifdef BDSBASE
724
+ // Viewmodels do not tint unless otherwise specified
725
+ bool bViewmodelTint = tf_viewmodel_cloak_tint.GetBool ();
726
+
727
+ if (!bViewmodelTint)
728
+ {
729
+ m_pCloakColorTint->SetVecValue (1 .0f , 1 .0f , 1 .0f );
730
+ }
731
+ else
732
+ {
733
+ switch (pPlayer->GetTeamNumber ())
734
+ {
735
+ case TF_TEAM_RED:
736
+ m_pCloakColorTint->SetVecValue (cloakTintRed.Base (), 3 );
737
+ break ;
738
+
739
+ case TF_TEAM_BLUE:
740
+ default :
741
+ m_pCloakColorTint->SetVecValue (cloakTintBlue.Base (), 3 );
742
+ break ;
743
+ }
744
+ }
745
+ #endif
670
746
}
671
747
}
672
748
0 commit comments