‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
shaderanim_shared.csc
Go to the documentation of this file.
1 #insert scripts\shared\shared.gsh;
2 
3 #namespace shaderanim;
4 
5 #define FPS 60.0
6 
7 //-----------------------------------------------------------------------------
8 
9 // TODO: table of scriptvector and shader property names (keep up to date)
10 // scriptVector0: opacity XXX XXX XXX
11 // scriptVector1: crack1 XXX XXX XXX
12 // scriptVector2: crack2 XXX XXX XXX
13 // scriptVector3: crack3 XXX XXX XXX
14 
15 //-----------------------------------------------------------------------------
16 
17 // function shaderanim_animate_cracks
18 // entity: entity to modulate the material on.
19 // localClientNum: number of the client to update.
20 // vectorName: vector to animate (scriptVector1 for red, 2 for blue, 3 for green vertex colors)
21 // delay: time to wait (in frames) before animating the crack threshold.
22 // duration: time over which to fully reveal or fade the cracks (in frames).
23 // start: value to start the crack reveal.
24 // end: value to stop the crack reveal.
25 function ‪animate_crack( localClientNum, vectorName, ‪delay, duration, start, ‪end )
26 {
27  self endon( "entityshutdown" );
28 
29  // convert frame delay to seconds
30  delaySeconds = ‪delay / ‪FPS;
31  // wait out the delay
32  wait delaySeconds;
33 
34  // direction of loop
35  direction = 1.0;
36  if ( start > ‪end )
37  direction = -1.0;
38 
39  // convert frame durations to seconds
40  durationSeconds = duration / ‪FPS;
41 
42  // figure out the loop step
43  valStep = 0;
44  if ( durationSeconds > 0 )
45  valStep = (‪end - start) / (durationSeconds / 0.01);
46  timeStep = 0.01 * direction;
47 
48  value = start;
49  self MapShaderConstant( localClientNum, 0, vectorName, value, 0, 0, 0 );
50  for ( i = 0; i < durationSeconds; i += timeStep )
51  {
52  // update value
53  value += valStep;
54  // delay
55  wait 0.01;
56  // TODO: how to get the existing value so they don't get bashed?
57  self MapShaderConstant( localClientNum, 0, vectorName, value, 0, 0, 0 );
58  }
59 
60  self MapShaderConstant( localClientNum, 0, vectorName, ‪end, 0, 0, 0 );
61 }
62 
63 //-----------------------------------------------------------------------------
64 
65 function ‪shaderanim_update_opacity( entity, localClientNum, opacity )
66 {
67  // TODO: how to get the existing value so they don't get bashed?
68  entity MapShaderConstant( localClientNum, 0, "scriptVector0", opacity, 0, 0, 0 );
69 }
70 
71 //-----------------------------------------------------------------------------
‪shaderanim_update_opacity
‪function shaderanim_update_opacity(entity, localClientNum, opacity)
Definition: shaderanim_shared.csc:65
‪FPS
‪#define FPS
Definition: shaderanim_shared.csc:5
‪delay
‪function delay(time_or_notify, str_endon, func, arg1, arg2, arg3, arg4, arg5, arg6)
Definition: util_shared.csc:784
‪end
‪function end(final)
Definition: _killcam.gsc:511
‪animate_crack
‪function animate_crack(localClientNum, vectorName, delay, duration, start, end)
Definition: shaderanim_shared.csc:25