1 #using scripts\codescripts\struct;
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\util_shared;
5 #using scripts\shared\system_shared;
6 #using scripts\shared\filter_shared;
8 #insert scripts\shared\shared.gsh;
12 #define BLOOD_STAGE_1_THRESHOLD .99
13 #define BLOOD_STAGE_2_THRESHOLD .80
14 #define BLOOD_STAGE_3_THRESHOLD .5
16 #define BLOOD_SPRITE_LIGHT_PASS 0
17 #define BLOOD_SPRITE_HEAVY_PASS 1
18 #define BLOOD_FRAME_PASS 2
20 #define BLOOD_FADE_RATE 1000 // per ms
29 level.use_digital_blood_enabled = GetDvarFloat(
"scr_use_digital_blood_enabled",
true );
36 if(
self != GetLocalPlayer( localClientNum ) )
40 level.use_digital_blood_enabled = GetDvarFloat(
"scr_use_digital_blood_enabled", level.use_digital_blood_enabled );
42 self.use_digital_blood =
false;
43 bodyType =
self GetCharacterBodyType();
44 if ( ( level.use_digital_blood_enabled ) && ( bodyType >= 0 ) )
46 bodyTypeFields = GetCharacterFields( bodyType, CurrentSessionMode() );
47 self.use_digital_blood =
VAL( bodyTypeFields.digitalBlood,
false );
62 self.blood_enabled =
true;
74 if( isdefined(
self ) )
76 self.blood_enabled =
false;
82 if(!
IS_TRUE(
self.noBloodLightBarChange))
84 SetControllerLightbarColor( localClientNum );
90 if( playerHealth < level.bloodStage3 )
92 self.stage3Amount = ( level.bloodStage3 - playerHealth ) / ( level.bloodStage3 );
96 self.stage3Amount = 0;
99 if( playerHealth < level.bloodStage2 )
101 self.stage2Amount = ( level.bloodStage2 - playerHealth ) / level.bloodStage2;
105 self.stage2Amount = 0;
111 if( playerHealth < level.bloodStage1 )
113 minStage1Health = 0.55;
115 assert( level.bloodStage1 > minStage1Health );
117 stageHealth = playerHealth - minStage1Health;
118 if( stagehealth < 0 )
120 self.stage1Amount = 1.0 - ( stageHealth / ( level.bloodStage1 - minStage1Health ) );
124 self.stage1Amount = 0;
133 currentTime = GetServerTime( localClientNum );
134 elapsedTime = currentTime -
self.lastBloodUpdate;
135 self.lastBloodUpdate = currentTime;
138 if(
self.stage3Amount > 0 )
140 self.stage3Amount -= subTract;
143 if(
self.stage3Amount < 0 )
145 self.stage3Amount = 0;
148 if(
self.stage2Amount > 0 )
150 self.stage2Amount -= subTract;
153 if(
self.stage2Amount < 0 )
155 self.stage2Amount = 0;
161 if(
self.stage1Amount > 0 )
163 self.stage1Amount -= subTract;
166 if(
self.stage1Amount < 0 )
168 self.stage1Amount = 0;
177 self endon(
"disconnect" );
178 self endon(
"entityshutdown" );
179 self endon(
"death" );
180 self endon(
"killBloodOverlay");
182 self.stage2Amount = 0;
183 self.stage3Amount = 0;
184 self.lastBloodUpdate = 0;
185 priorPlayerHealth = renderhealthoverlayhealth( localClientNum );
186 self blood_in( localClientNum, priorPlayerHealth );
189 if( renderHealthOverlay( localClientNum ) && !
IS_TRUE(
self.noBloodOverlay) )
191 shouldEnabledOverlay =
false;
192 playerHealth = renderhealthoverlayhealth( localClientNum );
193 if( playerHealth < priorPlayerHealth )
195 shouldEnabledOverlay =
true;
196 self blood_in( localClientNum, playerHealth );
198 else if( ( playerHealth == priorplayerhealth ) && ( playerhealth != 1.0 ) )
200 shouldEnabledOverlay =
true;
201 self.lastBloodUpdate = GetServerTime( localClientNum );
203 else if( (
self.stage2Amount > 0 ) || (
self.stage3Amount > 0 ) )
205 shouldEnabledOverlay =
true;
208 else if(
IS_TRUE(
self.blood_enabled ) )
212 priorPlayerHealth = playerHealth;
214 if( !
IS_TRUE(
self.blood_enabled ) && shouldEnabledOverlay )
218 if(!
IS_TRUE(
self.noBloodLightBarChange))
220 if(
self.stage3Amount > 0 )
224 else if(
self.stage2Amount == 1 )
230 if( GetGadgetPower( localClientNum ) == 1.0 && ( !SessionModeIsCampaignGame() || CodeGetUIModelClientField(
self,
"playerAbilities.inRange" ) ) )
236 if( isdefined(
self.controllerColor ) )
238 SetControllerLightbarColor( localClientNum,
self.controllerColor );
242 SetControllerLightbarColor( localClientNum );
248 else if(
IS_TRUE(
self.blood_enabled ) )
260 curColor = color * 0.2;
261 scale = ( ( GetTime() % pulseRate ) / (pulseRate * 0.5) );
264 scale = (scale - 2.0) * -1.0;
266 curColor += color * 0.8 * scale;
268 SetControllerLightbarColor( localClientNum, curColor );