aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/scripts/vscripts/mp/_classic_mp_no_intro.gnut
blob: 106f867b157b6ed291762f8c63309bc7834c6c47 (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
untyped

global function ClassicMP_DefaultNoIntro_Setup
global function ClassicMP_DefaultNoIntro_GetLength

global const float NOINTRO_INTRO_PILOT_LENGTH = 10.0
global const float TITAN_DROP_SPAWN_INTRO_LENGTH = 0.0 // this intro shouldn't have a countdown visually, so we have to set the length of this intro to 0
global const float TITAN_DROP_SPAWN_INTRO_REAL_LENGTH = 2.0 // we wait roughly this long during the intro, even when it's technically over

void function ClassicMP_DefaultNoIntro_Setup()
{
	AddCallback_OnClientConnected( ClassicMP_DefaultNoIntro_SpawnPlayer )
	AddCallback_GameStateEnter( eGameState.Prematch, ClassicMP_DefaultNoIntro_Start )
}

float function ClassicMP_DefaultNoIntro_GetLength()
{
	if ( ShouldIntroSpawnAsTitan() )
		return TITAN_DROP_SPAWN_INTRO_LENGTH
	else
		return NOINTRO_INTRO_PILOT_LENGTH
		
	unreachable
}

void function ClassicMP_DefaultNoIntro_Start()
{
	ClassicMP_OnIntroStarted()

	foreach ( entity player in GetPlayerArray() )
		ClassicMP_DefaultNoIntro_SpawnPlayer( player )
		
	if ( ShouldIntroSpawnAsTitan() )
		wait TITAN_DROP_SPAWN_INTRO_REAL_LENGTH
	else
	{
		wait NOINTRO_INTRO_PILOT_LENGTH
		
		foreach ( entity player in GetPlayerArray() )
		{
			player.UnfreezeControlsOnServer()
			RemoveCinematicFlag( player, CE_FLAG_CLASSIC_MP_SPAWNING )
			TryGameModeAnnouncement( player )
		}
	}
	
	ClassicMP_OnIntroFinished()
}

void function ClassicMP_DefaultNoIntro_SpawnPlayer( entity player )
{
	if ( GetGameState() != eGameState.Prematch )
		return
	
	if ( IsAlive( player ) )
		player.Die()
	
	if ( ShouldIntroSpawnAsTitan() )
		thread ClassicMP_DefaultNoIntro_TitanSpawnPlayer( player )
	else
		thread ClassicMP_DefaultNoIntro_PilotSpawnPlayer( player )
}


// spawn as pilot for intro
void function ClassicMP_DefaultNoIntro_PilotSpawnPlayer( entity player )
{
	RespawnAsPilot( player )
	player.FreezeControlsOnServer()
	AddCinematicFlag( player, CE_FLAG_CLASSIC_MP_SPAWNING )
	ScreenFadeFromBlack( player, 0.5, 0.5 )
}

// spawn as titan for intro
void function ClassicMP_DefaultNoIntro_TitanSpawnPlayer( entity player )
{
	// blocking call
	RespawnAsTitan( player, false )
	TryGameModeAnnouncement( player )
}