aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Custom/mod/scripts/vscripts/gamemodes/cl_gamemode_fastball.gnut
blob: a8ce6a404f49ba85cacec9bc7678e632d4eedc29 (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
global function ClGamemodeFastball_Init
global function ServerCallback_FastballUpdatePanelRui
global function ServerCallback_FastballPanelHacked
global function ServerCallback_FastballRespawnPlayer

struct {
	var panelARui
	var panelBRui
	var panelCRui
} file

void function ClGamemodeFastball_Init()
{
	ClGameState_RegisterGameStateAsset( $"ui/gamestate_info_lts.rpak" )

	RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_INTRO, "Music_Beacon_14_BTThrowThruFirstCrane", TEAM_MILITIA )
	RegisterLevelMusicForTeam( eMusicPieceID.LEVEL_INTRO, "Music_Beacon_14_BTThrowThruFirstCrane", TEAM_MILITIA )
	
	AddCallback_OnClientScriptInit( FastballCreateRui )
	AddCallback_GameStateEnter( eGameState.Postmatch, DisplayPostMatchTop3 )
}

void function FastballCreateRui( entity player )
{
	file.panelARui = CreateCockpitRui( $"ui/cp_hardpoint_marker.rpak", 200 )
	file.panelBRui = CreateCockpitRui( $"ui/cp_hardpoint_marker.rpak", 200 )
	file.panelCRui = CreateCockpitRui( $"ui/cp_hardpoint_marker.rpak", 200 )

}

void function ServerCallback_FastballUpdatePanelRui( int panelHandle, int id )
{
	entity panel = GetEntityFromEncodedEHandle( panelHandle )
	if (!IsValid(panel))
		return
	var rui
	if ( id == 0 )
		rui = file.panelARui
	else if ( id == 1 )
		rui = file.panelBRui
	else if ( id == 2 )
		rui = file.panelCRui

	RuiSetInt( rui, "hardpointId", id )
	RuiTrackFloat3( rui, "pos", panel, RUI_TRACK_OVERHEAD_FOLLOW )
	RuiSetInt( rui, "viewerTeam", GetLocalClientPlayer().GetTeam() )
	////RuiTrackInt( rui, "cappingTeam", null, RUI_TRACK_SCRIPT_NETWORK_VAR_GLOBAL_INT, GetNetworkedVariableIndex( "panel" + id + "progress" ) )
	RuiTrackInt( rui, "hardpointTeamRelation", panel, RUI_TRACK_TEAM_RELATION_VIEWPLAYER )
	
	RuiSetBool( rui, "isVisible", true )
}

void function ServerCallback_FastballPanelHacked( int panelHandle, int id, int capturingPlayerHandle )
{
	ServerCallback_FastballUpdatePanelRui( panelHandle, id ) // may not be necessary, just wanna ensure this is always right

	entity panel = GetEntityFromEncodedEHandle( panelHandle )
	entity capturingPlayer = GetEntityFromEncodedEHandle( capturingPlayerHandle )
	
	if ( capturingPlayer == GetLocalViewPlayer() )
		return
		
	string panelIdString
	if ( id == 0 )
		panelIdString = "A"
	if ( id == 1 )
		panelIdString = "B"
	else if ( id == 2 )
		panelIdString = "C"
		
	AnnouncementData announcement = Announcement_Create( Localize( "#FASTBALL_PANEL_CAPTURED", capturingPlayer.GetPlayerName(), panelIdString ) )
	
	if ( capturingPlayer.GetTeam() == GetLocalClientPlayer().GetTeam() )
		Announcement_SetTitleColor( announcement, < 0, 0, 1 > )
	else
		Announcement_SetTitleColor( announcement, < 1, 0, 0 > )
		
	Announcement_SetPurge( announcement, true )
	Announcement_SetPriority( announcement, 200 ) //Be higher priority than Titanfall ready indicator etc
	Announcement_SetSoundAlias( announcement, SFX_HUD_ANNOUNCE_QUICK )
	Announcement_SetStyle( announcement, ANNOUNCEMENT_STYLE_QUICK )
	AnnouncementFromClass( GetLocalClientPlayer(), announcement )
}

void function ServerCallback_FastballRespawnPlayer()
{
	thread FastballRespawnPlayerEffects_Threaded()
}

void function FastballRespawnPlayerEffects_Threaded()
{
	// sometimes this seems to get called before the player has respawned clientside, so we just wait until the client thinks they're alive
	entity player = GetLocalClientPlayer()
	
	while ( !IsAlive( player ) || !IsValid( player.GetCockpit() ) )
		WaitFrame()
		
	StartParticleEffectOnEntity( player.GetCockpit(), GetParticleSystemIndex( $"P_pod_screen_lasers_OUT" ), FX_PATTACH_ABSORIGIN_FOLLOW, -1 )
}