1 #using scripts\codescripts\struct;
3 #using scripts\shared\util_shared;
5 #insert scripts\shared\shared.gsh;
7 #using scripts\mp\gametypes\_dev;
8 #using scripts\mp\gametypes\_globallogic_utils;
10 #using scripts\mp\_util;
12 #namespace gameadvertisement;
16 level.gameAdvertisementRuleScorePercent = GetGametypeSetting(
"gameAdvertisementRuleScorePercent" );
17 level.gameAdvertisementRuleTimeLeft = ( 1000 * 60 ) * GetGametypeSetting(
"gameAdvertisementRuleTimeLeft" );
18 level.gameAdvertisementRuleRound = GetGametypeSetting(
"gameAdvertisementRuleRound" );
19 level.gameAdvertisementRuleRoundsWon = GetGametypeSetting(
"gameAdvertisementRuleRoundsWon" );
27 changeAdvertisedStatus( onOff );
32 if( SessionModeIsPrivate() )
37 if( !isdefined( runRules ) )
40 level endon(
"game_end" );
42 level waittill(
"prematch_over" );
44 currentAdvertisedStatus = undefined;
47 sessionAdvertCheckwait = GetDvarInt(
"sessionAdvertCheckwait", 1 );
49 wait( sessionAdvertCheckwait );
51 advertise = [[runRules]]();
52 if ( !isdefined( currentAdvertisedStatus ) || ( isdefined( advertise ) && ( currentAdvertisedStatus != advertise ) ) )
56 currentAdvertisedStatus = advertise;
62 gametype = level.gametype;
82 if ( level.roundScoreLimit )
86 else if ( level.scoreLimit )
88 scoreLimit = level.scoreLimit;
93 minScorePercentageLeft = 100;
95 foreach ( team
in level.teams )
97 scorePercentageLeft = 100 - ( ( game[
"teamScores" ][ team ] / scoreLimit ) * 100 );
99 if( minScorePercentageLeft > scorePercentageLeft )
100 minScorePercentageLeft = scorePercentageLeft;
102 if( ruleScorePercent >= scorePercentageLeft )
115 maxTime = level.timeLimit;
121 if( ruleTimeLeft >= timeLeft )
139 currentRound = game[
"roundsplayed" ] + 1;
144 if( level.gameAdvertisementRuleScorePercent )
146 if ( level.teambased )
148 if ( (currentRound >= (level.gameAdvertisementRuleRound - 1)) )
156 if ( level.scoreLimit )
159 players = GetPlayers();
161 for( i = 0; i < players.size; i++)
163 if( players[i].pointstowin > highestScore )
164 highestScore = players[i].pointstowin;
167 scorePercentageLeft = 100 - ( ( highestScore / level.scoreLimit ) * 100 );
169 if( level.gameAdvertisementRuleScorePercent >= scorePercentageLeft )
180 if( level.gameAdvertisementRuleTimeLeft && (currentRound >= (level.gameAdvertisementRuleRound - 1)) )
189 if( level.gameAdvertisementRuleRound )
191 if ( level.gameAdvertisementRuleRound <= currentRound )
198 if ( level.gameAdvertisementRuleRoundsWon )
201 foreach ( team
in level.teams )
203 roundsWon = game[
"teamScores" ][ team ];
205 if( maxRoundsWon < roundsWon )
206 maxRoundsWon = roundsWon;
208 if( level.gameAdvertisementRuleRoundsWon <= roundsWon )
230 minWeaponsLeft = level.gunProgression.size;
232 foreach ( player
in level.activePlayers )
234 if ( !isdefined( player ) )
237 if ( !isdefined( player.gunProgress ) )
240 weaponsLeft = level.gunProgression.size - player.gunProgress;
242 if( minWeaponsLeft > weaponsLeft )
243 minWeaponsLeft = weaponsLeft;
245 if( ruleWeaponsLeft >= minWeaponsLeft )