aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/mod/scripts/vscripts/sh_mp_utility.gnut
blob: 2e6e04f42535980af4ba362bd8956420f44f582d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
untyped

globalize_all_functions

struct
{
	table<string,table<string,int> > mapModeScoreLimits
} file

int function GetRoundScoreLimit_FromPlaylist()
{
	if ( !GameMode_IsDefined( GAMETYPE ) )
		return GetCurrentPlaylistVarInt( "roundscorelimit", 10 )

	return GameMode_GetRoundScoreLimit( GAMETYPE )
}

int function GetScoreLimit_FromPlaylist()
{
	if ( GameMode_HasMapSpecificScoreLimits( GAMETYPE ) )
		return GameMode_GetMapSpecificScoreLimit( GAMETYPE )

	if ( !GameMode_IsDefined( GAMETYPE ) )
		return GetCurrentPlaylistVarInt( "scorelimit", 10 )

	return GameMode_GetScoreLimit( GAMETYPE )
}

bool function GameMode_HasMapSpecificScoreLimits( string gameType )
{
	if ( gameType in file.mapModeScoreLimits )
	{
		if ( GetMapName() in file.mapModeScoreLimits[gameType] )
			return true
	}
	return false
}

int function GameMode_GetMapSpecificScoreLimit( string gameType )
{
	return file.mapModeScoreLimits[gameType][GetMapName()]
}

void function GameMode_SetMapSpecificScoreLimit( table<string,int> mapModeScoreTable, string gameType )
{
	Assert( !( gameType in file.mapModeScoreLimits ), "GAMETYPE has already been added to mapModeScoreLimits" )
	file.mapModeScoreLimits[gameType] <- mapModeScoreTable
}

bool function IsSuddenDeathGameMode()
{
	return GameMode_GetSuddenDeathEnabled( GameRules_GetGameMode() )
}

bool function IsCaptureMode()
{
	return GameRules_GetGameMode() == CAPTURE_POINT
}

bool function GameModeWantsToSkipBoostsAndTitanEarning()
{
	if ( Riff_TitanAvailability() == eTitanAvailability.Never )
		return true
	if ( Riff_BoostAvailability() == eBoostAvailability.Disabled )
		return true

	return false
}

IntFromEntityCompare function GetScoreboardCompareFunc()
{
	return ScoreboardCompareFuncForGamemode( GameRules_GetGameMode() )
}

IntFromEntityCompare function ScoreboardCompareFuncForGamemode( string gamemode )
{
	IntFromEntityCompare func = GameMode_GetScoreCompareFunc( gamemode )
	if ( func != null )
		return func

	return CompareScore
}


bool function IsRoundWinningKillReplayEnabled()
{
	return expect bool ( level.nv.roundWinningKillReplayEnabled )
}

bool function IsRoundWinningKillReplayPlaying()
{
	return expect bool ( level.nv.roundWinningKillReplayPlaying )
}

bool function HasRoundScoreLimitBeenReached() //Different from RoundScoreLimit_Complete in that it only checks to see if the score required has been reached. Allows us to use it on the client to cover 90% of the cases we want
{
	if ( !IsRoundBased() )
		return false

	int roundLimit = GetRoundScoreLimit_FromPlaylist()

	if ( !roundLimit )
		return false

	int militiaScore = GameRules_GetTeamScore2( TEAM_MILITIA )
	int imcScore = GameRules_GetTeamScore2( TEAM_IMC )

	if ( ( militiaScore >= roundLimit ) || ( imcScore >= roundLimit ) )
		return true

	return false
}


bool function IsTitanAvailable( entity player )
{
	var shiftIndex = player.GetEntIndex() - 1
	var elimMask = (1 << shiftIndex)

	return (level.nv.titanAvailableBits & elimMask) != 0
}



bool function IsRespawnAvailable( entity player )
{
	var shiftIndex = player.GetEntIndex() - 1
	var elimMask = (1 << shiftIndex)

	return (level.nv.respawnAvailableBits & elimMask) != 0
}

bool function IsPrivateMatchSpectator( entity player )
{
	// JFS
	#if SERVER
	if ( !player.p.clientScriptInitialized )
		return false
	#endif
	
	// NS: allow spectators on non-private_match playlists
	if ( ( IsPrivateMatch() || GetConVarBool( "ns_allow_spectators" ) ) && player.GetPersistentVarAsInt( "privateMatchState" ) == 1 )
		return true

	return false
}