1 #using scripts\codescripts\struct;
3 #using scripts\shared\system_shared;
5 #insert scripts\shared\shared.gsh;
7 #namespace rewindobjects;
13 level.rewindWatcherArray = [];
19 level.rewindWatcherArray[localClientNum] = [];
29 if ( isdefined( level.rewindWatcherArray[localClientNum] ) )
31 rewindWatcherKeys = getArrayKeys( level.rewindWatcherArray[localClientNum] );
32 for ( i = 0; i < rewindWatcherKeys.size; i++ )
34 rewindWatcher = level.rewindWatcherArray[localClientNum][rewindWatcherKeys[i]];
36 if ( !isdefined( rewindWatcher ) )
39 if ( !isdefined( rewindWatcher.event ) )
42 timeKeys = getArrayKeys( rewindWatcher.event );
43 for ( j = 0; j < timeKeys.size; j++ )
45 timeKey = timeKeys[j];
46 if ( rewindWatcher.event[timeKey].inProgress ==
true )
49 if ( level.serverTime >= timeKey )
62 player = getlocalplayer( localClientNum );
63 level endon(
"demo_jump" + localClientNum );
64 self.event[timeKey].inProgress =
true;
65 allFunctionsStarted =
false;
66 while( allFunctionsStarted ==
false )
68 allFunctionsStarted =
true;
69 assert(isdefined(
self.timedFunctions ) );
70 timedFunctionKeys = getArrayKeys(
self.timedFunctions );
72 for ( i = 0; i < timedFunctionKeys.size; i++ )
74 timedFunction =
self.timedFunctions[timedFunctionKeys[i]];
75 timedFunctionKey = timedFunctionKeys[i];
76 if (
self.event[timeKey].timedFunction[timedFunctionKey] ==
true )
78 startTime = timeKey + ( timedFunction.startTimeSec * 1000 );
81 allFunctionsStarted =
false;
84 self.event[timeKey].timedFunction[timedFunctionKey] =
true;
86 level thread [[timedFunction.func]]( localClientNum,
startTime, timedFunction.startTimeSec,
self.event[timeKey].data );
96 timeIncreaseBetweenPlanes = 0;
110 player = getlocalplayer( localClientNum );
111 if ( !isdefined(level.rewindWatcherArray[localClientNum]) )
113 level.rewindWatcherArray[localClientNum] = [];
118 if ( !isdefined( rewindWatcher ) )
120 rewindWatcher = SpawnStruct();
121 level.rewindWatcherArray[localClientNum][level.rewindWatcherArray[localClientNum].size] = rewindWatcher;
124 rewindWatcher.name =
name;
125 rewindWatcher.event = [];
129 return rewindWatcher;
136 level waittill(
"demo_jump" + localClientNum );
138 self.inProgress =
false;
140 timedFunctionKeys = getArrayKeys(
self.timedFunctions );
142 for ( i = 0; i < timedFunctionKeys.size; i++ )
144 self.timedFunctions[timedFunctionKeys[i]].inProgress =
false;
147 eventKeys = getArrayKeys(
self.event );
148 for ( i = 0; i < eventKeys.size; i++ )
150 self.event[eventKeys[i]].inProgress =
false;
151 timedFunctionKeys = getArrayKeys(
self.event[eventKeys[i]].timedFunction );
152 for ( index = 0; index < timedFunctionKeys.size; index++ )
154 self.event[eventKeys[i]].timedFunction[timedFunctionKeys[index]] =
false;
162 if ( !isdefined(
self.timedFunctions) )
164 self.timedFunctions = [];
167 assert( !isdefined(
self.timedFunctions[
name] ) );
169 self.timedFunctions[
name] = spawnStruct();
170 self.timedFunctions[
name].inProgress =
false;
171 self.timedFunctions[
name].func = func;
172 self.timedFunctions[
name].startTimeSec = relativeStartTimeInSecs;
177 if ( !isdefined( level.rewindWatcherArray[localClientNum] ) )
182 for ( watcher = 0; watcher < level.rewindWatcherArray[localClientNum].size; watcher++ )
184 if (level.rewindWatcherArray[localClientNum][watcher].name ==
name )
186 return level.rewindWatcherArray[localClientNum][watcher];
205 if ( isdefined(
self.timedFunctions ) )
207 timedFunctionKeys = getArrayKeys(
self.timedFunctions );
209 for ( i = 0; i < timedFunctionKeys.size; i++ )
211 timedFunctionKey = timedFunctionKeys[i];
212 self.event[
startTime].timedFunction[timedFunctionKey] =
false;
219 level endon(
"demo_jump" + localClientNum );
220 timeElapsed = ( level.serverTime -
startTime ) * 0.001;
221 assert( duration > 0 );
223 if ( timeElapsed < 0.02 )
225 if ( timeElapsed < duration )
227 moveTime = duration - timeElapsed;
230 jumpPoint =
getPointOnLine( startPoint, endPoint, ( timeElapsed / duration ) );
231 self.origin = jumpPoint;
233 self moveTo( endPoint, moveTime, 0, 0 );
238 self.origin = endPoint;
245 level endon(
"demo_jump" + localClientNum );
246 timeElapsed = ( level.serverTime -
startTime ) * 0.001;
247 if ( !isdefined ( timeIn ) )
256 assert( duration > 0 );
257 if ( timeElapsed < duration )
259 rotateTime = duration - timeElapsed;
260 self RotateTo(angles, rotateTime, timeIn, timeOut );
265 self.angles = angles;
272 while( timeFromStart > level.serverTime )
280 clientEnt endon(
"complete" );
281 player = GetLocalPlayer( localClientNum );
282 level waittill(
"demo_jump" + localClientNum );
284 clientEnt notify(
"delete" );
285 clientEnt forcedelete();
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 ) );