‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
blood.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\callbacks_shared;
4 #using scripts\shared\util_shared;
5 #using scripts\shared\system_shared;
6 #using scripts\shared\filter_shared;
7 
8 #insert scripts\shared\shared.gsh;
9 
10 #namespace blood;
11 
12 #define BLOOD_STAGE_1_THRESHOLD .99
13 #define BLOOD_STAGE_2_THRESHOLD .80
14 #define BLOOD_STAGE_3_THRESHOLD .5
15 
16 #define BLOOD_SPRITE_LIGHT_PASS 0
17 #define BLOOD_SPRITE_HEAVY_PASS 1
18 #define BLOOD_FRAME_PASS 2
19 
20 #define BLOOD_FADE_RATE 1000 // per ms
21 
22 ‪REGISTER_SYSTEM( "blood", &‪__init__, undefined )
23 
24 function ‪__init__()
25 {
26  level.bloodStage3 = GetDvarFloat( "cg_t7HealthOverlay_Threshold3", ‪BLOOD_STAGE_3_THRESHOLD );
27  level.bloodStage2 = GetDvarFloat( "cg_t7HealthOverlay_Threshold2", ‪BLOOD_STAGE_2_THRESHOLD );
28  level.bloodStage1 = GetDvarFloat( "cg_t7HealthOverlay_Threshold1", ‪BLOOD_STAGE_1_THRESHOLD );
29  level.use_digital_blood_enabled = GetDvarFloat( "scr_use_digital_blood_enabled", true );
30 
32 }
33 
34 function ‪localplayer_spawned( localClientNum )
35 {
36  if( self != GetLocalPlayer( localClientNum ) )
37  return;
38 
39 /#
40  level.use_digital_blood_enabled = GetDvarFloat( "scr_use_digital_blood_enabled", level.use_digital_blood_enabled );
41 #/
42  self.use_digital_blood = false;
43  bodyType = self GetCharacterBodyType();
44  if ( ( level.use_digital_blood_enabled ) && ( bodyType >= 0 ) )
45  {
46  bodyTypeFields = GetCharacterFields( bodyType, CurrentSessionMode() );
47  self.use_digital_blood = ‪VAL( bodyTypeFields.digitalBlood, false );
48  }
49 
50  self thread ‪player_watch_blood( localClientNum );
51  self thread ‪player_watch_blood_shutdown( localClientNum );
52 }
53 
54 function ‪player_watch_blood_shutdown( localClientNum )
55 {
56  self ‪util::waittill_any ( "entityshutdown", "death" );
57  self ‪disable_blood( localClientNum );
58 }
59 
60 function ‪enable_blood( localClientNum )
61 {
62  self.blood_enabled = true;
63  ‪filter::init_filter_feedback_blood( localClientNum, self.use_digital_blood );
64  ‪filter::enable_filter_feedback_blood( localClientNum, ‪FILTER_INDEX_BLOOD, ‪BLOOD_FRAME_PASS, self.use_digital_blood );
66 
67  ‪filter::init_filter_sprite_blood_heavy( localClientNum, self.use_digital_blood );
70 }
71 
72 function ‪disable_blood( localClientNum )
73 {
74  if( isdefined( self ) )
75  {
76  self.blood_enabled = false;
77  }
78 
81 
82  if(!‪IS_TRUE(self.noBloodLightBarChange))
83  {
84  SetControllerLightbarColor( localClientNum );
85  }
86 }
87 
88 function ‪blood_in( localClientNum, playerHealth )
89 {
90  if( playerHealth < level.bloodStage3 )
91  {
92  self.stage3Amount = ( level.bloodStage3 - playerHealth ) / ( level.bloodStage3 );
93  }
94  else
95  {
96  self.stage3Amount = 0;
97  }
98 
99  if( playerHealth < level.bloodStage2 )
100  {
101  self.stage2Amount = ( level.bloodStage2 - playerHealth ) / level.bloodStage2;
102  }
103  else
104  {
105  self.stage2Amount = 0;
106  }
107 
110 
111  if( playerHealth < level.bloodStage1 )
112  {
113  minStage1Health = 0.55;
114 
115  assert( level.bloodStage1 > minStage1Health );
116 
117  stageHealth = playerHealth - minStage1Health;
118  if( stagehealth < 0 )
119  stagehealth = 0;
120  self.stage1Amount = 1.0 - ( stageHealth / ( level.bloodStage1 - minStage1Health ) );
121  }
122  else
123  {
124  self.stage1Amount = 0;
125  }
126 
128  ‪filter::set_filter_sprite_blood_elapsed( localClientNum, ‪FILTER_INDEX_BLOOD, ‪BLOOD_SPRITE_HEAVY_PASS, GetServerTime( localClientNum ) );
129 }
130 
131 function ‪blood_out( localClientNum )
132 {
133  currentTime = GetServerTime( localClientNum );
134  elapsedTime = currentTime - self.lastBloodUpdate;
135  self.lastBloodUpdate = currentTime;
136  subTract = elapsedTime / ‪BLOOD_FADE_RATE;
137 
138  if( self.stage3Amount > 0 )
139  {
140  self.stage3Amount -= subTract;
141  }
142 
143  if( self.stage3Amount < 0 )
144  {
145  self.stage3Amount = 0;
146  }
147 
148  if( self.stage2Amount > 0 )
149  {
150  self.stage2Amount -= subTract;
151  }
152 
153  if( self.stage2Amount < 0 )
154  {
155  self.stage2Amount = 0;
156  }
157 
160 
161  if( self.stage1Amount > 0 )
162  {
163  self.stage1Amount -= subTract;
164  }
165 
166  if( self.stage1Amount < 0 )
167  {
168  self.stage1Amount = 0;
169  }
170 
172  ‪filter::set_filter_sprite_blood_elapsed( localClientNum, ‪FILTER_INDEX_BLOOD, ‪BLOOD_SPRITE_HEAVY_PASS, GetServerTime( localClientNum ) );
173 }
174 
175 function ‪player_watch_blood( localClientNum )
176 {
177  self endon( "disconnect" );
178  self endon( "entityshutdown" );
179  self endon( "death" );
180  self endon("killBloodOverlay");
181 
182  self.stage2Amount = 0;
183  self.stage3Amount = 0;
184  self.lastBloodUpdate = 0;
185  priorPlayerHealth = renderhealthoverlayhealth( localClientNum );
186  self ‪blood_in( localClientNum, priorPlayerHealth );
187  while( true )
188  {
189  if( renderHealthOverlay( localClientNum ) && !‪IS_TRUE(self.noBloodOverlay) )
190  {
191  shouldEnabledOverlay = false;
192  playerHealth = renderhealthoverlayhealth( localClientNum );
193  if( playerHealth < priorPlayerHealth )
194  {
195  shouldEnabledOverlay = true;
196  self ‪blood_in( localClientNum, playerHealth );
197  }
198  else if( ( playerHealth == priorplayerhealth ) && ( playerhealth != 1.0 ) )
199  {
200  shouldEnabledOverlay = true;
201  self.lastBloodUpdate = GetServerTime( localClientNum );
202  }
203  else if( ( self.stage2Amount > 0 ) || ( self.stage3Amount > 0 ) ) // while we're recovering till we're done fading out
204  {
205  shouldEnabledOverlay = true;
206  self ‪blood_out( localClientNum );
207  }
208  else if( ‪IS_TRUE( self.blood_enabled ) )
209  {
210  self ‪disable_blood( localClientNum );
211  }
212  priorPlayerHealth = playerHealth;
213 
214  if( !‪IS_TRUE( self.blood_enabled ) && shouldEnabledOverlay )
215  {
216  self ‪enable_blood( localClientNum );
217  }
218  if(!‪IS_TRUE(self.noBloodLightBarChange))
219  {
220  if( self.stage3Amount > 0 )
221  {
222  ‪SetControllerLightBarColorPulsing( localClientNum, (1,0,0), 600 );
223  }
224  else if( self.stage2Amount == 1 )
225  {
226  ‪SetControllerLightBarColorPulsing( localClientNum, (0.8,0,0), 1200 );
227  }
228  else
229  {
230  if( GetGadgetPower( localClientNum ) == 1.0 && ( !SessionModeIsCampaignGame() || CodeGetUIModelClientField( self, "playerAbilities.inRange" ) ) )
231  {
232  ‪SetControllerLightBarColorPulsing( localClientNum, (1,1,0), 2000 );
233  }
234  else
235  {
236  if( isdefined( self.controllerColor ) )
237  {
238  SetControllerLightbarColor( localClientNum, self.controllerColor );
239  }
240  else
241  {
242  SetControllerLightbarColor( localClientNum );
243  }
244  }
245  }
246  }
247  }
248  else if( ‪IS_TRUE( self.blood_enabled ) )
249  {
250  self ‪disable_blood( localClientNum );
251  }
252 
254  }
255 }
256 
257 // This function needs to be called every frame to keep the pulse going
258 function ‪SetControllerLightBarColorPulsing( localClientNum, color, pulseRate )
259 {
260  curColor = color * 0.2;
261  scale = ( ( GetTime() % pulseRate ) / (pulseRate * 0.5) );
262  if( scale > 1.0 )
263  {
264  scale = (scale - 2.0) * -1.0;
265  }
266  curColor += color * 0.8 * scale;
267 
268  SetControllerLightbarColor( localClientNum, curColor );
269 }
‪blood_out
‪function blood_out(localClientNum)
Definition: blood.csc:131
‪player_watch_blood_shutdown
‪function player_watch_blood_shutdown(localClientNum)
Definition: blood.csc:54
‪on_localplayer_spawned
‪function on_localplayer_spawned(local_client_num)
Definition: _perks.csc:109
‪init_filter_sprite_blood_heavy
‪function init_filter_sprite_blood_heavy(localClientNum, digitalBlood)
Definition: filter_shared.csc:1041
‪BLOOD_FADE_RATE
‪#define BLOOD_FADE_RATE
Definition: blood.csc:20
‪enable_blood
‪function enable_blood(localClientNum)
Definition: blood.csc:60
‪set_filter_sprite_blood_opacity
‪function set_filter_sprite_blood_opacity(localClientNum, filterid, passid, opacity)
Definition: filter_shared.csc:1067
‪SetControllerLightBarColorPulsing
‪function SetControllerLightBarColorPulsing(localClientNum, color, pulseRate)
Definition: blood.csc:258
‪VAL
‪#define VAL(__var, __default)
Definition: shared.gsh:272
‪BLOOD_FRAME_PASS
‪#define BLOOD_FRAME_PASS
Definition: blood.csc:18
‪disable_filter_feedback_blood
‪function disable_filter_feedback_blood(localClientNum, filterid, passid)
Definition: filter_shared.csc:1141
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪set_filter_sprite_blood_elapsed
‪function set_filter_sprite_blood_elapsed(localClientNum, filterid, passid, time)
Definition: filter_shared.csc:1077
‪enable_filter_feedback_blood
‪function enable_filter_feedback_blood(localClientNum, filterid, passid, digitalBlood)
Definition: filter_shared.csc:1106
‪blood_in
‪function blood_in(localClientNum, playerHealth)
Definition: blood.csc:88
‪set_filter_feedback_blood_opacity
‪function set_filter_feedback_blood_opacity(localClientNum, filterid, passid, opacity)
Definition: filter_shared.csc:1119
‪set_filter_feedback_blood_sundir
‪function set_filter_feedback_blood_sundir(localClientNum, filterid, passid, pitch, yaw)
Definition: filter_shared.csc:1124
‪enable_filter_sprite_blood_heavy
‪function enable_filter_sprite_blood_heavy(localClientNum, filterid, passid, digitalBlood)
Definition: filter_shared.csc:1053
‪BLOOD_SPRITE_HEAVY_PASS
‪#define BLOOD_SPRITE_HEAVY_PASS
Definition: blood.csc:17
‪__init__
‪function __init__()
Definition: blood.csc:24
‪waittill_any
‪function waittill_any(str_notify1, str_notify2, str_notify3, str_notify4, str_notify5)
Definition: util_shared.csc:375
‪BLOOD_STAGE_2_THRESHOLD
‪#define BLOOD_STAGE_2_THRESHOLD
Definition: blood.csc:13
‪set_filter_sprite_blood_seed_offset
‪function set_filter_sprite_blood_seed_offset(localClientNum, filterid, passid, offset)
Definition: filter_shared.csc:1072
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪FILTER_INDEX_BLOOD
‪#define FILTER_INDEX_BLOOD
Definition: shared.gsh:488
‪disable_filter_sprite_blood
‪function disable_filter_sprite_blood(localClientNum, filterid, passid)
Definition: filter_shared.csc:1082
‪init_filter_feedback_blood
‪function init_filter_feedback_blood(localClientNum, digitalBlood)
Definition: filter_shared.csc:1093
‪BLOOD_STAGE_1_THRESHOLD
‪#define BLOOD_STAGE_1_THRESHOLD
Definition: blood.csc:12
‪localplayer_spawned
‪function localplayer_spawned(localClientNum)
Definition: blood.csc:34
‪player_watch_blood
‪function player_watch_blood(localClientNum)
Definition: blood.csc:175
‪WAIT_CLIENT_FRAME
‪#define WAIT_CLIENT_FRAME
Definition: shared.gsh:266
‪BLOOD_STAGE_3_THRESHOLD
‪#define BLOOD_STAGE_3_THRESHOLD
Definition: blood.csc:14
‪disable_blood
‪function disable_blood(localClientNum)
Definition: blood.csc:72
‪set_filter_feedback_blood_vignette
‪function set_filter_feedback_blood_vignette(localClientNum, filterid, passid, amount)
Definition: filter_shared.csc:1130