‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
_rewindobjects.csc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\system_shared;
4 
5 #insert scripts\shared\shared.gsh;
6 
7 #namespace rewindobjects;
8 
9 ‪REGISTER_SYSTEM( "rewindobjects", &‪__init__, undefined )
10 
11 function ‪__init__()
12 {
13  level.rewindWatcherArray = [];
14 
15 }
16 
17 function ‪initRewindObjectWatchers( localClientNum )
18 {
19  level.rewindWatcherArray[localClientNum] = [];
20  ‪createNapalmRewindWatcher( localClientNum );
21  ‪createAirstrikeRewindWatcher( localClientNum );
22  level thread ‪watchRewindableEvents( localClientNum );
23 }
24 
25 function ‪watchRewindableEvents( localClientNum )
26 {
27  for (;;)
28  {
29  if ( isdefined( level.rewindWatcherArray[localClientNum] ) )
30  {
31  rewindWatcherKeys = getArrayKeys( level.rewindWatcherArray[localClientNum] );
32  for ( i = 0; i < rewindWatcherKeys.size; i++ )
33  {
34  rewindWatcher = level.rewindWatcherArray[localClientNum][rewindWatcherKeys[i]];
35 
36  if ( !isdefined( rewindWatcher ) )
37  continue;
38 
39  if ( !isdefined( rewindWatcher.event ) )
40  continue;
41 
42  timeKeys = getArrayKeys( rewindWatcher.event );
43  for ( j = 0; j < timeKeys.size; j++ )
44  {
45  timeKey = timeKeys[j];
46  if ( rewindWatcher.event[timeKey].inProgress == true )
47  continue;
48 
49  if ( level.serverTime >= timeKey )
50  {
51  rewindWatcher thread ‪startRewindableEvent( localClientNum, timeKey );
52  }
53  }
54  }
55  }
56  wait( 0.1 );
57  }
58 }
59 
60 function ‪startRewindableEvent( localClientNum, timeKey )
61 {
62  player = getlocalplayer( localClientNum );
63  level endon( "demo_jump" + localClientNum );
64  self.event[timeKey].inProgress = true;
65  allFunctionsStarted = false;
66  while( allFunctionsStarted == false )
67  {
68  allFunctionsStarted = true;
69  assert(isdefined( self.timedFunctions ) );
70  timedFunctionKeys = getArrayKeys( self.timedFunctions );
71 
72  for ( i = 0; i < timedFunctionKeys.size; i++ )
73  {
74  timedFunction = self.timedFunctions[timedFunctionKeys[i]];
75  timedFunctionKey = timedFunctionKeys[i];
76  if ( self.event[timeKey].timedFunction[timedFunctionKey] == true )
77  continue;
78  ‪startTime = timeKey + ( timedFunction.startTimeSec * 1000 );
79  if ( ‪startTime > level.serverTime )
80  {
81  allFunctionsStarted = false;
82  continue;
83  }
84  self.event[timeKey].timedFunction[timedFunctionKey] = true;
85 
86  level thread [[timedFunction.func]]( localClientNum, ‪startTime, timedFunction.startTimeSec, self.event[timeKey].data );
87  }
88  wait( 0.1 );
89  }
90 }
91 
92 function ‪createNapalmRewindWatcher( localClientNum )
93 {
94  napalmRewindWatcher = ‪createRewindWatcher( localClientNum, "napalm" );
95 
96  timeIncreaseBetweenPlanes = 0;
97 
98  //napalmRewindWatcher addTimedFunction( "napalmPlane", _plane::flyPlane, timeIncreaseBetweenPlanes );
99 }
100 
101 function ‪createAirstrikeRewindWatcher( localClientNum )
102 {
103  airstrikeRewindWatcher = ‪createRewindWatcher( localClientNum, "airstrike" );
104 // airstrikeRewindWatcher addTimedFunction( "aistrikePlane", _airstrike::flyAirstrikePlane, 0 );
105 }
106 
107 
108 function ‪createRewindWatcher( localClientNum, ‪name )
109 {
110  player = getlocalplayer( localClientNum );
111  if ( !isdefined(level.rewindWatcherArray[localClientNum]) )
112  {
113  level.rewindWatcherArray[localClientNum] = [];
114  }
115 
116  rewindWatcher = ‪getRewindWatcher( localClientNum, ‪name );
117 
118  if ( !isdefined( rewindWatcher ) )
119  {
120  rewindWatcher = SpawnStruct();
121  level.rewindWatcherArray[localClientNum][level.rewindWatcherArray[localClientNum].size] = rewindWatcher;
122  }
123 
124  rewindWatcher.name = ‪name;
125  rewindWatcher.event = [];
126 
127  rewindWatcher thread ‪resetOnDemoJump( localClientNum );
128 
129  return rewindWatcher;
130 }
131 
132 function ‪resetOnDemoJump( localClientNum )
133 {
134  for (;;)
135  {
136  level waittill( "demo_jump" + localClientNum );
137 
138  self.inProgress = false;
139 
140  timedFunctionKeys = getArrayKeys( self.timedFunctions );
141 
142  for ( i = 0; i < timedFunctionKeys.size; i++ )
143  {
144  self.timedFunctions[timedFunctionKeys[i]].inProgress = false;
145  }
146 
147  eventKeys = getArrayKeys( self.event );
148  for ( i = 0; i < eventKeys.size; i++ )
149  {
150  self.event[eventKeys[i]].inProgress = false;
151  timedFunctionKeys = getArrayKeys( self.event[eventKeys[i]].timedFunction );
152  for ( index = 0; index < timedFunctionKeys.size; index++ )
153  {
154  self.event[eventKeys[i]].timedFunction[timedFunctionKeys[index]] = false;
155  }
156  }
157  }
158 }
159 
160 function ‪addTimedFunction( ‪name, func, relativeStartTimeInSecs )
161 {
162  if ( !isdefined(self.timedFunctions) )
163  {
164  self.timedFunctions = [];
165  }
166 
167  assert( !isdefined(self.timedFunctions[‪name] ) );
168 
169  self.timedFunctions[‪name] = spawnStruct();
170  self.timedFunctions[‪name].inProgress = false;
171  self.timedFunctions[‪name].func = func;
172  self.timedFunctions[‪name].startTimeSec = relativeStartTimeInSecs;
173 }
174 
175 function ‪getRewindWatcher( localClientNum, ‪name )
176 {
177  if ( !isdefined( level.rewindWatcherArray[localClientNum] ) )
178  {
179  return undefined;
180  }
181 
182  for ( watcher = 0; watcher < level.rewindWatcherArray[localClientNum].size; watcher++ )
183  {
184  if (level.rewindWatcherArray[localClientNum][watcher].name == ‪name )
185  {
186  return level.rewindWatcherArray[localClientNum][watcher];
187  }
188  }
189 
190  return undefined;
191 }
192 
194 {
195  // duplicate message
196  if ( isdefined( self.event[‪startTime] ) )
197  {
198  return;
199  }
200 
201  self.event[‪startTime] = spawnStruct();
202  self.event[‪startTime].data = data;
203  self.event[‪startTime].inprogress = false;
204 
205  if ( isdefined( self.timedFunctions ) )
206  {
207  timedFunctionKeys = getArrayKeys( self.timedFunctions );
208  self.event[‪startTime].timedFunction = [];
209  for ( i = 0; i < timedFunctionKeys.size; i++ )
210  {
211  timedFunctionKey = timedFunctionKeys[i];
212  self.event[‪startTime].timedFunction[timedFunctionKey] = false;
213  }
214  }
215 }
216 
217 function ‪serverTimedMoveTo( localClientNum, startPoint, endPoint, ‪startTime, duration )
218 {
219  level endon( "demo_jump" + localClientNum );
220  timeElapsed = ( level.serverTime - ‪startTime ) * 0.001;
221  assert( duration > 0 );
222  doJump = true;
223  if ( timeElapsed < 0.02 )
224  doJump = false;
225  if ( timeElapsed < duration )
226  {
227  moveTime = duration - timeElapsed;
228  if ( doJump )
229  {
230  jumpPoint = ‪getPointOnLine( startPoint, endPoint, ( timeElapsed / duration ) );
231  self.origin = jumpPoint;
232  }
233  self moveTo( endPoint, moveTime, 0, 0 );
234  return true;
235  }
236  else
237  {
238  self.origin = endPoint;
239  return false;
240  }
241 }
242 
243 function ‪serverTimedRotateTo( localClientNum, angles, ‪startTime, duration, timeIn, ‪timeout )
244 {
245  level endon( "demo_jump" + localClientNum );
246  timeElapsed = ( level.serverTime - ‪startTime ) * 0.001;
247  if ( !isdefined ( timeIn ) )
248  {
249  timeIn = 0;
250  }
251  if ( !isdefined( ‪timeout ) )
252  {
253  timeOut = 0;
254  }
255 
256  assert( duration > 0 );
257  if ( timeElapsed < duration )
258  {
259  rotateTime = duration - timeElapsed;
260  self RotateTo(angles, rotateTime, timeIn, timeOut );
261  return true;
262  }
263  else
264  {
265  self.angles = angles;
266  return false;
267  }
268 }
269 
270 function ‪waitForServerTime( localClientNum, timeFromStart )
271 {
272  while( timeFromStart > level.serverTime )
273  {
275  }
276 }
277 
278 function ‪removeClientEntOnJump( clientEnt, localClientNum )
279 {
280  clientEnt endon( "complete" );
281  player = GetLocalPlayer( localClientNum );
282  level waittill( "demo_jump" + localClientNum );
283 
284  clientEnt notify( "delete" );
285  clientEnt forcedelete();
286 }
287 
288 function ‪getPointOnLine( startPoint, endPoint, ratio )
289 {
290  nextPoint = ( startPoint[0] + ( ( endPoint[0] - startPoint[0] ) * ratio ) ,
291  startPoint[1] + ( ( endPoint[1] - startPoint[1] ) * ratio ) ,
292  startPoint[2] + ( ( endPoint[2] - startPoint[2] ) * ratio ) );
293 
294  return nextPoint;
295 }
296 
‪timeout
‪function timeout(n_time, func, arg1, arg2, arg3, arg4, arg5, arg6)
Definition: util_shared.csc:762
‪createRewindWatcher
‪function createRewindWatcher(localClientNum, name)
Definition: _rewindobjects.csc:108
‪startTime
‪class AnimationAdjustmentInfoZ startTime
‪createNapalmRewindWatcher
‪function createNapalmRewindWatcher(localClientNum)
Definition: _rewindobjects.csc:92
‪createAirstrikeRewindWatcher
‪function createAirstrikeRewindWatcher(localClientNum)
Definition: _rewindobjects.csc:101
‪addRewindableEventToWatcher
‪function addRewindableEventToWatcher(startTime, data)
Definition: _rewindobjects.csc:193
‪serverTimedRotateTo
‪function serverTimedRotateTo(localClientNum, angles, startTime, duration, timeIn, timeout)
Definition: _rewindobjects.csc:243
‪serverTimedMoveTo
‪function serverTimedMoveTo(localClientNum, startPoint, endPoint, startTime, duration)
Definition: _rewindobjects.csc:217
‪startRewindableEvent
‪function startRewindableEvent(localClientNum, timeKey)
Definition: _rewindobjects.csc:60
‪initRewindObjectWatchers
‪function initRewindObjectWatchers(localClientNum)
Definition: _rewindobjects.csc:17
‪removeClientEntOnJump
‪function removeClientEntOnJump(clientEnt, localClientNum)
Definition: _rewindobjects.csc:278
‪waitForServerTime
‪function waitForServerTime(localClientNum, timeFromStart)
Definition: _rewindobjects.csc:270
‪addTimedFunction
‪function addTimedFunction(name, func, relativeStartTimeInSecs)
Definition: _rewindobjects.csc:160
‪REGISTER_SYSTEM
‪#define REGISTER_SYSTEM(__sys, __func_init_preload, __reqs)
Definition: shared.gsh:204
‪resetOnDemoJump
‪function resetOnDemoJump(localClientNum)
Definition: _rewindobjects.csc:132
‪__init__
‪function __init__()
Definition: _rewindobjects.csc:11
‪watchRewindableEvents
‪function watchRewindableEvents(localClientNum)
Definition: _rewindobjects.csc:25
‪name
‪class GroundFx name
‪WAIT_CLIENT_FRAME
‪#define WAIT_CLIENT_FRAME
Definition: shared.gsh:266
‪getRewindWatcher
‪function getRewindWatcher(localClientNum, name)
Definition: _rewindobjects.csc:175
‪getPointOnLine
‪function getPointOnLine(startPoint, endPoint, ratio)
Definition: _rewindobjects.csc:288