1 #using scripts\codescripts\struct;
2 #using scripts\shared\system_shared;
3 #using scripts\shared\callbacks_shared;
4 #using scripts\mp\killstreaks\_killstreaks;
5 #using scripts\mp\gametypes\_globallogic_utils;
6 #using scripts\mp\gametypes\_globallogic_audio;
7 #using scripts\shared\util_shared;
8 #using scripts\shared\sound_shared;
10 #insert scripts\shared\shared.gsh;
12 #using scripts\mp\_util;
13 #insert scripts\mp\_teamops.gsh;
19 teamopsInfoTableLoaded =
false;
22 if ( isdefined( teamopsInfoTableID ) )
24 teamopsInfoTableLoaded =
true;
27 return teamopsInfoTableID;
32 game[
"teamops"] = SpawnStruct();
34 game[
"teamops"].data = [];
35 game[
"teamops"].teamProgress = [];
36 game[
"teamops"].teamopsName = undefined;
38 foreach( team
in level.teams )
40 game[
"teamops"].teamProgress[team] = 0;
47 assert( isdefined( tableID ) );
48 if( !isdefined( tableID ) )
50 game[
"teamops"].teamopsInitialed =
false;
59 game[
"teamops"].data[
name] = SpawnStruct();
64 game[
"teamops"].data[
name].count = int( tableLookupColumnForRow( tableID, row,
GAMEOPS_COUNT ) );
65 game[
"teamops"].data[
name].time = int( tableLookupColumnForRow( tableID, row,
GAMEOPS_TIME ) );
66 game[
"teamops"].data[
name].modes = StrTok( tableLookupColumnForRow( tableID, row,
GAMEOPS_MODE ),
"," );
67 game[
"teamops"].data[
name].rewards = StrTok( tableLookupColumnForRow( tableID, row,
GAMEOPS_REWARD ),
"," );
71 game[
"teamops"].teamopsInitialized =
true;
79 _name = tableLookupColumnForRow( tableID, row,
GAMEOPS_NAME );
88 teamops = game[
"teamops"].data[
name];
90 if( teamops.modes.size == 0 )
93 for( mi = 0; mi < teamops.modes.size; mi++ )
95 if( teamops.modes[mi] == level.gameType )
103 level notify(
"teamops_starting" );
104 level.teamopsOnPlayerKilled = undefined;
110 preAnounceTime = GetDvarInt(
"teamOpsPreanounceTime", 5 );
112 foreach( team
in level.teams )
117 wait ( preAnounceTime );
119 for( i = 0; i < level.players.size; i++ )
121 player = level.players[i];
122 if( isdefined( player ) )
123 player playlocalsound(
"uin_objective_updated" );
126 teamops = game[
"teamops"].data[
name];
128 game[
"teamops"].teamopsName =
name;
130 game[
"teamops"].teamopsRewardIndex = RandomIntRange( 0, teamops.rewards.size );
131 game[
"teamops"].teamopsReward = teamops.rewards[game[
"teamops"].teamopsRewardIndex];
132 game[
"teamops"].teamopsStartTime = GetTime();
134 foreach( team
in level.teams )
136 game[
"teamops"].teamProgress[team] = 0;
141 TeamOpsStart( game[
"teamops"].teamOpsID, game[
"teamops"].teamopsRewardIndex, game[
"teamops"].teamopsStartTime, teamops.time );
146 TeamOpsUpdateProgress(
"axis", 0 );
147 TeamOpsUpdateProgress(
"allies", 0 );
154 while( isdefined( game[
"teamops"].teamopsName ) )
156 time = game[
"teamops"].data[game[
"teamops"].teamopsName].time;
157 if( isdefined( time ) && ( time > 0 ) )
159 elapsed = GetTime() - game[
"teamops"].teamopsStartTime;
160 if( elapsed > time * 1000 )
163 foreach( team
in level.teams )
176 game[
"teamops"].teamopsName = undefined;
177 game[
"teamops"].teamopsReward = undefined;
178 game[
"teamops"].teamopsStartTime = undefined;
180 foreach( team
in level.teams )
182 game[
"teamops"].teamProgress[team] = 0;
188 teamopsName = game[
"teamops"].teamopsName;
190 if( isplayer( player ) && isdefined( teamopsName ) )
198 teamopsName = game[
"teamops"].teamopsName;
199 teamops = game[
"teamops"].data[teamopsName];
201 if( isdefined( teamops.pushevent ) && ( event == teamops.pushevent ) )
203 game[
"teamops"].teamProgress[team] += 1;
207 if( isdefined( teamops.popevent ) && ( event == teamops.popevent ) )
209 game[
"teamops"].teamProgress[team] -= 1;
210 if( game[
"teamops"].teamProgress[team] < 0 )
211 game[
"teamops"].teamProgress[team]= 0;
215 if( isdefined( teamops.resetevent ) && ( event == teamops.resetevent ) )
217 game[
"teamops"].teamProgress[team] = 0;
225 teamopsName = game[
"teamops"].teamopsName;
226 teamops = game[
"teamops"].data[teamopsName];
228 count_target = teamops.count;
229 progress = int( ( 100 * game[
"teamops"].teamProgress[team] ) / count_target );
231 TeamOpsUpdateProgress( team, progress );
233 if( game[
"teamops"].teamProgress[team] >= teamops.count )
235 if( isdefined( player ) )
244 game[
"teamops"].teamopsName = undefined;
260 level.teamopsTargetKills = GetDvarInt(
"teamOpsKillsCountTrigger_" + level.gameType, 37 );
261 if ( level.teamopsTargetKills > 0 )
269 operations = StrTok( GetDvarString(
"teamOpsName" ),
"," );
272 for( i = 0; i < 20; i++ )
274 operation = operations[RandomIntRange( 0, operations.size )];
280 for( i = 0; i < operations.size; i++ )
282 operation = operations[i];
292 level endon(
"teamops_starting" );
294 if (
IS_TRUE( level.inPrematchPeriod ) )
295 level waittill(
"prematch_over");
298 if( !isdefined( activeTeamOps ) )
301 startDelay = GetDvarInt(
"teamOpsStartDelay_" + level.gameType, 300 );
305 if( isdefined( game[
"teamops"].teamopsName ) )
307 if ( GetDvarInt(
"scr_stop_teamops" ) == 1 )
310 SetDvar(
"scr_stop_teamops", 0 );
317 if( timePassed > startDelay )
328 function onPlayerKilled( eInflictor, attacker, iDamage, sMeansOfDeath, weapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration )
330 level endon(
"teamops_starting" );
332 if ( isPlayer( attacker ) ==
false || attacker.team ==
self.team )
335 if ( !isdefined( level.teamopsKillTracker ) )
337 level.teamopsKillTracker = [];
340 if ( !isdefined( level.teamopsKillTracker[attacker.team] ) )
342 level.teamopsKillTracker[attacker.team] = 0;
345 level.teamopsKillTracker[attacker.team]++;
347 if ( level.teamopsKillTracker[attacker.team] >= level.teamopsTargetKills )
350 if( !isdefined( activeTeamOps ) )