@@ -36,13 +36,34 @@ public static HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo in
3636 if ( player ! . Team < CsTeam . Terrorist ) return HookResult . Continue ; // if player isnt on a team
3737 // var gameRules = Utilities.FindAllEntitiesByDesignerName<CCSGameRulesProxy>("cs_gamerules").First();
3838 // if (gameRules.GameRules!.WarmupPeriod) return HookResult.Continue;
39-
4039
4140 CreateWallhackData ( player ! ) ;
4241
4342 return HookResult . Continue ;
4443 }
4544
45+ public static HookResult OnPlayerTakeDamage ( EventPlayerHurt @event , GameEventInfo info )
46+ {
47+ if ( Globals . Config . WallHackConfig . dynamicColor )
48+ {
49+ Globals . WallhackData . TryGetValue ( @event . Userid , out var wallhackData ) ;
50+
51+ var health = @event . Health ;
52+
53+ health = Math . Clamp ( health , 1 , 100 ) ;
54+
55+ float t = ( health - 1 ) / 99f ;
56+
57+ int r = ( int ) ( 255 * ( 1f - t ) ) ;
58+ int g = ( int ) ( 255 * t ) ;
59+
60+ wallhackData . GlowEnt . Glow . GlowColorOverride = Color . FromArgb ( 255 , r , g , 0 ) ;
61+ Utilities . SetStateChanged ( wallhackData . GlowEnt , "CBaseModelEntity" , "m_Glow" ) ;
62+ }
63+
64+ return HookResult . Continue ;
65+ }
66+
4667 public static HookResult OnPlayerDisconnect ( EventPlayerDisconnect @event , GameEventInfo info )
4768 {
4869 var player = @event . Userid ;
@@ -102,10 +123,18 @@ private static void CreateWallhackData(CCSPlayerController player)
102123
103124 glowEntity . DispatchSpawn ( ) ;
104125 modelRelay . DispatchSpawn ( ) ;
126+
127+ Color color = Color . FromArgb ( 255 , Globals . Config . WallHackConfig . R , Globals . Config . WallHackConfig . G , Globals . Config . WallHackConfig . B ) ;
128+
129+ if ( Globals . Config . WallHackConfig . dynamicColor )
130+ {
131+ color = Color . FromArgb ( 255 , 0 , 255 , 0 ) ;
132+ }
133+
105134
106135 glowEntity . Glow . GlowRange = 5000 ;
107136 glowEntity . Glow . GlowRangeMin = 0 ;
108- glowEntity . Glow . GlowColorOverride = Color . FromArgb ( 255 , Globals . Config . WallHackConfig . R , Globals . Config . WallHackConfig . G , Globals . Config . WallHackConfig . B ) ;
137+ glowEntity . Glow . GlowColorOverride = color ;
109138 glowEntity . Glow . GlowTeam = - 1 ;
110139 glowEntity . Glow . GlowType = 3 ;
111140
@@ -133,6 +162,7 @@ public static void Setup()
133162 Globals . Plugin . RegisterEventHandler < EventPlayerDisconnect > ( OnPlayerDisconnect ) ;
134163 Globals . Plugin . RegisterEventHandler < EventPlayerSpawn > ( OnPlayerSpawn , HookMode . Post ) ;
135164 Globals . Plugin . RegisterEventHandler < EventPlayerTeam > ( OnPlayerChangeTeam , HookMode . Post ) ;
165+ Globals . Plugin . RegisterEventHandler < EventPlayerHurt > ( OnPlayerTakeDamage ) ;
136166
137167 Globals . Plugin . AddCommand ( "css_wh" , "Gives a player walls" , CommandWallhack . OnWallhackCommand ) ;
138168 Globals . Plugin . AddCommand ( "css_wallhack" , "Gives a player walls" , CommandWallhack . OnWallhackCommand ) ;
0 commit comments