aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/mod/scripts/vscripts/mp/_classic_mp.nut
blob: 2baf119c45688cafd64b248c16138c2fb3bce4e6 (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
untyped
global function ClassicMp_Init
global function ClassicMP_TryDefaultIntroSetup 

// intro setups
global function	ClassicMP_SetLevelIntro
global function ClassicMP_SetCustomIntro
global function ClassicMP_SetupIntro

// intro funcs
global function ClassicMP_OnIntroStarted
global function ClassicMP_OnIntroFinished
global function ClassicMP_GetIntroLength

// epilogue setups
global function ClassicMP_ForceDisableEpilogue
global function ClassicMP_SetEpilogue
global function ClassicMP_SetupEpilogue
global function ClassicMP_ShouldRunEpilogue

global function GetClassicMPMode

struct {
	// level intros have a lower priority than custom intros
	// level intros are used only if a custom intro was not specified
	void functionref() levelIntroSetupFunc
	float levelIntroLength

	void functionref() customIntroSetupFunc
	float customIntroLength
	
	bool epilogueForceDisabled = false
	bool shouldRunEpilogueInRoundBasedMode = false
	void functionref() epilogueSetupFunc
} file

void function ClassicMp_Init()
{
	// default level intros
	if ( IsFFAGame() )
		ClassicMP_SetLevelIntro( ClassicMP_DefaultNoIntro_Setup, ClassicMP_DefaultNoIntro_GetLength() )
	else
		ClassicMP_SetLevelIntro( ClassicMP_DefaultDropshipIntro_Setup, DROPSHIP_INTRO_LENGTH )
}

// stub func, called in mp_sh_init
void function ClassicMP_TryDefaultIntroSetup()
{

}

void function ClassicMP_SetLevelIntro( void functionref() setupFunc, float introLength )
{
	file.levelIntroSetupFunc = setupFunc
	file.levelIntroLength = introLength
}

void function ClassicMP_SetCustomIntro( void functionref() setupFunc, float introLength )
{
	file.customIntroSetupFunc = setupFunc
	file.customIntroLength = introLength
}

void function ClassicMP_SetupIntro()
{
	if ( file.customIntroSetupFunc != null )
		file.customIntroSetupFunc()
	else 
		file.levelIntroSetupFunc()
}

void function ClassicMP_OnIntroStarted()
{
	print( "started intro!" )
	
	float introLength = ClassicMP_GetIntroLength()
	SetServerVar( "gameStartTime", Time() + introLength )
	SetServerVar( "roundStartTime", Time() + introLength )
}

void function ClassicMP_OnIntroFinished()
{
	print( "intro finished!" )
	SetGameState( eGameState.Playing )
}

float function ClassicMP_GetIntroLength() 
{
	if ( file.customIntroSetupFunc != null )
		return file.customIntroLength

	return file.levelIntroLength
}

void function ClassicMP_ForceDisableEpilogue( bool disabled )
{
	file.epilogueForceDisabled = disabled
}

void function ClassicMP_SetEpilogue( void functionref() setupFunc )
{
	file.epilogueSetupFunc = setupFunc
}

void function ClassicMP_SetupEpilogue()
{
	if ( file.epilogueSetupFunc == null ) // default is evac
		ClassicMP_SetEpilogue( EvacEpilogueSetup )
	
	file.epilogueSetupFunc()
}

bool function GetClassicMPMode()
{
	return GetCurrentPlaylistVarInt( "classic_mp", 1 ) == 1
}

bool function ClassicMP_ShouldRunEpilogue()
{
	// note: there is a run_evac playlist var, but it's unused, and default 0, so use a new one
	return !file.epilogueForceDisabled && GetClassicMPMode() && GetCurrentPlaylistVarInt( "run_epilogue", 1 ) == 1
}